cli: rename --colocated flag of "jj git init" to --colocate (verb)

"jj git clone" has --colocate flag, so let's stick to it.

#2747
This commit is contained in:
Yuya Nishihara 2024-02-07 19:27:51 +09:00 committed by Martin von Zweigbergk
parent 3b196d274c
commit b13cfef095
4 changed files with 12 additions and 12 deletions

View file

@ -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<String>,
}
@ -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(),
)?;

View file

@ -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.

View file

@ -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`

View file

@ -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"