Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions engine/crates/opensweep-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,28 @@ enum Cmd {
},
/// Never clean this folder or anything inside it; with no folder, list pins
Pin {
/// Folder to pin
folder: Option<PathBuf>,
/// Only for this many days; then the project is judged as usual
#[arg(long, value_name = "N", conflicts_with = "remote")]
/// Only for this many days (at least 1); then the project is judged
/// as usual
#[arg(
long,
value_name = "N",
conflicts_with = "remote",
requires = "folder",
value_parser = clap::value_parser!(u64).range(1..)
)]
days: Option<u64>,
/// Pin the folder's git repository (its origin remote) wherever it
/// is cloned, instead of this path
#[arg(long)]
remote: bool,
},
/// Remove a pin
Unpin { folder: PathBuf },
Unpin {
/// Folder (or clone of a pinned repository) to unpin
folder: PathBuf,
},
/// Show the settings, or change them. Changes only OpenSweep's config.
Config {
/// Projects changed within this many days are Active
Expand Down
18 changes: 18 additions & 0 deletions engine/crates/opensweep-cli/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,24 @@ fn pinned_projects_are_never_cleaned() {
assert!(e.clean(&[]).contains("Dry run: 1 folder"));
}

#[test]
fn a_pin_for_days_needs_a_folder_and_at_least_one_day() {
let e = env();
let project = e.project.to_str().unwrap();
// A pin for 0 days would end the moment it was made.
let zero = e.run(&["pin", project, "--days", "0"]);
assert!(!zero.status.success());
// Without a folder, pin only lists: --days would be dropped silently.
assert!(!e.run(&["pin", "--days", "7"]).status.success());
assert!(
!config_file(&e).exists(),
"a refused pin must not write config"
);
assert!(e
.ok(&["pin", project, "--days", "1"])
.contains("for 1 days"));
}

#[test]
fn a_broken_config_stops_cleaning() {
let e = env();
Expand Down
Loading