From b13cfef09567fe9da0a11ac539792679cd39026b Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Wed, 7 Feb 2024 19:27:51 +0900 Subject: [PATCH] cli: rename --colocated flag of "jj git init" to --colocate (verb) "jj git clone" has --colocate flag, so let's stick to it. #2747 --- cli/src/commands/git.rs | 14 +++++++------- cli/src/commands/init.rs | 4 ++-- cli/tests/cli-reference@.md.snap | 2 +- cli/tests/test_git_init.rs | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cli/src/commands/git.rs b/cli/src/commands/git.rs index d728ab4e1f..87e5d40155 100644 --- a/cli/src/commands/git.rs +++ b/cli/src/commands/git.rs @@ -134,7 +134,7 @@ pub struct GitInitArgs { /// /// This option is mutually exclusive with `--git-repo`. #[arg(long, conflicts_with = "git_repo")] - colocated: bool, + colocate: bool, /// Specifies a path to an **existing** git repository to be /// used as the backing git repo for the newly created `jj` repo. @@ -146,10 +146,10 @@ pub struct GitInitArgs { /// will not be auto-exported to the git repo. /// /// Auto-exporting from `jj` to `git` is only enabled for new repos. - /// See `--colocated` above. + /// See `--colocate` above. /// - /// This option is mutually exclusive with `--colocated`. - #[arg(long, conflicts_with = "colocated", value_hint = clap::ValueHint::DirPath)] + /// This option is mutually exclusive with `--colocate`. + #[arg(long, conflicts_with = "colocate", value_hint = clap::ValueHint::DirPath)] git_repo: Option, } @@ -374,13 +374,13 @@ pub fn git_init( ui: &mut Ui, command: &CommandHelper, workspace_root: &Path, - colocated: bool, + colocate: bool, git_repo: Option<&str>, ) -> Result<(), CommandError> { let cwd = command.cwd().canonicalize().unwrap(); let relative_wc_path = file_util::relative_path(&cwd, workspace_root); - if colocated { + if colocate { let (workspace, repo) = Workspace::init_colocated_git(command.settings(), workspace_root)?; let workspace_command = command.for_loaded_repo(ui, workspace, repo)?; maybe_add_gitignore(&workspace_command)?; @@ -481,7 +481,7 @@ fn cmd_git_init( ui, command, &wc_path, - args.colocated, + args.colocate, args.git_repo.as_deref(), )?; diff --git a/cli/src/commands/init.rs b/cli/src/commands/init.rs index 0a1b97ec1e..9230b68cb5 100644 --- a/cli/src/commands/init.rs +++ b/cli/src/commands/init.rs @@ -57,9 +57,9 @@ pub(crate) fn cmd_init( // Preserve existing behaviour where `jj init` is not able to create // a colocated repo. - let colocated = false; + let colocate = false; if args.git || args.git_repo.is_some() { - git::git_init(ui, command, &wc_path, colocated, args.git_repo.as_deref())?; + git::git_init(ui, command, &wc_path, colocate, args.git_repo.as_deref())?; writeln!( ui.warning(), "warning: `--git` and `--git-repo` are deprecated. diff --git a/cli/tests/cli-reference@.md.snap b/cli/tests/cli-reference@.md.snap index dd3eab67f4..8e893c4cf7 100644 --- a/cli/tests/cli-reference@.md.snap +++ b/cli/tests/cli-reference@.md.snap @@ -833,7 +833,7 @@ Create a new Git backed repo ###### **Options:** -* `--colocated` — Specifies that the `jj` repo should also be a valid `git` repo, allowing the use of both `jj` and `git` commands in the same directory +* `--colocate` — Specifies that the `jj` repo should also be a valid `git` repo, allowing the use of both `jj` and `git` commands in the same directory Possible values: `true`, `false` diff --git a/cli/tests/test_git_init.rs b/cli/tests/test_git_init.rs index 08e85e8b59..6b587dcaa5 100644 --- a/cli/tests/test_git_init.rs +++ b/cli/tests/test_git_init.rs @@ -542,7 +542,7 @@ fn test_git_init_colocated_via_flag_git_dir_exists() { let workspace_root = test_env.env_root().join("repo"); init_git_repo(&workspace_root, false); - let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "init", "--colocated"]); + let stderr = test_env.jj_cmd_failure(&workspace_root, &["git", "init", "--colocate"]); insta::assert_snapshot!(stderr, @r###" Error: Failed to access the repository Caused by: @@ -555,7 +555,7 @@ fn test_git_init_colocated_via_flag_git_dir_exists() { fn test_git_init_colocated_via_flag_git_dir_not_exists() { let test_env = TestEnvironment::default(); let (stdout, stderr) = - test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "--colocated", "repo"]); + test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "--colocate", "repo"]); insta::assert_snapshot!(stdout, @""); insta::assert_snapshot!(stderr, @r###" Initialized repo in "repo"