Skip to content

Commit

Permalink
cli: drop support for jj init --{git, git_repo}
Browse files Browse the repository at this point in the history
These were deprecated early last year in favor of `jj git init`.

Signed-off-by: Austin Seipp <[email protected]>
  • Loading branch information
thoughtpolice committed Jan 3, 2025
1 parent 42d7bea commit 66151f0
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 538 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Breaking changes

* `jj init --git` and `jj init --git-repo` have been removed. They were
deprecated in early 2024. Use `jj git init` instead.

### Deprecations

### New features
Expand Down
35 changes: 6 additions & 29 deletions cli/src/commands/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@

use std::io::Write;

use clap::ArgGroup;
use jj_lib::file_util;
use jj_lib::workspace::Workspace;
use tracing::instrument;

use super::git;
use crate::cli_util::CommandHelper;
use crate::command_error::cli_error;
use crate::command_error::user_error_with_hint;
Expand All @@ -32,19 +30,10 @@ use crate::ui::Ui;
/// If the given directory does not exist, it will be created. If no directory
/// is given, the current directory is used.
#[derive(clap::Args, Clone, Debug)]
#[command(group(ArgGroup::new("backend").args(&["git", "git_repo"])))]
pub(crate) struct InitArgs {
/// The destination directory
#[arg(default_value = ".", value_hint = clap::ValueHint::DirPath)]
destination: String,
/// DEPRECATED: Use `jj git init`
/// Use the Git backend, creating a jj repo backed by a Git repo
#[arg(long, hide = true)]
git: bool,
/// DEPRECATED: Use `jj git init`
/// Path to a git repo the jj repo will be backed by
#[arg(long, hide = true, value_hint = clap::ValueHint::DirPath)]
git_repo: Option<String>,
}

#[instrument(skip_all)]
Expand All @@ -65,26 +54,14 @@ pub(crate) fn cmd_init(
.and_then(|_| dunce::canonicalize(wc_path))
.map_err(|e| user_error_with_message("Failed to create workspace", e))?;

// Preserve existing behaviour where `jj init` is not able to create
// a colocated repo.
let colocate = false;
if args.git || args.git_repo.is_some() {
git::init::do_init(ui, command, &wc_path, colocate, args.git_repo.as_deref())?;
writeln!(
ui.warning_default(),
"`--git` and `--git-repo` are deprecated.
Use `jj git init` instead"
)?;
} else {
if !command.settings().get_bool("ui.allow-init-native")? {
return Err(user_error_with_hint(
"The native backend is disallowed by default.",
"Did you mean to call `jj git init`?
if !command.settings().get_bool("ui.allow-init-native")? {
return Err(user_error_with_hint(
"The native backend is disallowed by default.",
"Did you mean to call `jj git init`?
Set `ui.allow-init-native` to allow initializing a repo with the native backend.",
));
}
Workspace::init_local(command.settings(), &wc_path)?;
));
}
Workspace::init_local(command.settings(), &wc_path)?;

let relative_wc_path = file_util::relative_path(cwd, &wc_path);
writeln!(
Expand Down
4 changes: 2 additions & 2 deletions cli/tests/test_backout_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn create_commit(
#[test]
fn test_backout() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");

create_commit(&test_env, &repo_path, "a", &[], &[("a", "a\n")]);
Expand Down Expand Up @@ -93,7 +93,7 @@ fn test_backout() {
#[test]
fn test_backout_multiple() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");

create_commit(&test_env, &repo_path, "a", &[], &[("a", "a\n")]);
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_describe_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ fn test_describe() {
#[test]
fn test_describe_editor_env() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");

// Fails if the editor doesn't exist
Expand Down
2 changes: 1 addition & 1 deletion cli/tests/test_fix_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ fn test_stderr_failure() {
#[test]
fn test_missing_command() {
let test_env = TestEnvironment::default();
test_env.jj_cmd_ok(test_env.env_root(), &["init", "repo", "--git"]);
test_env.jj_cmd_ok(test_env.env_root(), &["git", "init", "repo"]);
let repo_path = test_env.env_root().join("repo");
test_env.add_config(r#"fix.tool-command = ["this_executable_shouldnt_exist"]"#);
let (stdout, stderr) = test_env.jj_cmd_ok(&repo_path, &["fix", "-s", "@"]);
Expand Down
Loading

0 comments on commit 66151f0

Please sign in to comment.