From 9a15e323518c9b3bcc742c0f947d9753e743b480 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Sat, 9 Apr 2022 09:20:00 -0700 Subject: [PATCH] cli: require at least one path for `jj untrack` It seems very unlikely that the user would want to untrack all paths (that's still possible with `jj untrack .`, if they really want to, and have added all their current paths to the `.gitignore`). --- CHANGELOG.md | 3 +++ src/commands.rs | 1 + tests/test_untrack_command.rs | 11 +++++++++++ 3 files changed, 15 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index aec5031e4..a7150b121 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Errors are now printed to stderr (they used to be printed to stdout). +* `jj untrack` now requires at least one path (allowing no arguments was a UX + bug). + ## [0.4.0] - 2022-04-02 ### Breaking changes diff --git a/src/commands.rs b/src/commands.rs index 12bb676cb..f0544be08 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1001,6 +1001,7 @@ struct CheckoutArgs { /// Stop tracking specified paths in the working copy #[derive(clap::Args, Clone, Debug)] struct UntrackArgs { + #[clap(required = true, min_values = 1)] paths: Vec, } diff --git a/tests/test_untrack_command.rs b/tests/test_untrack_command.rs index 474312c16..9c8f26785 100644 --- a/tests/test_untrack_command.rs +++ b/tests/test_untrack_command.rs @@ -38,6 +38,17 @@ fn test_untrack() { std::fs::write(repo_path.join(".gitignore"), "*.bak\n").unwrap(); let files_before = test_env.jj_cmd_success(&repo_path, &["files"]); + // Errors out when no path is specified + let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack"]); + insta::assert_snapshot!(stderr.replace("jj.exe", "jj"), @r###" + error: The following required arguments were not provided: + ... + + USAGE: + jj untrack [OPTIONS] ... + + For more information try --help + "###); // Errors out when a specified file is not ignored let stderr = test_env.jj_cmd_failure(&repo_path, &["untrack", "file1", "file1.bak"]); insta::assert_snapshot!(stderr, @"Error: 'file1' would be added back because it's not ignored. Make sure it's ignored, \