From 1eb8b95a6cfd1458f60d804f8d3e4515b143b256 Mon Sep 17 00:00:00 2001 From: Yuya Nishihara Date: Fri, 29 Sep 2023 16:40:41 +0900 Subject: [PATCH] cli: rephrase @git branch with no local counterpart as "deleted" Since forgotten branches are now removed at all, the only situation where @git branch persists is that the branch got removed but is not exported yet. --- cli/src/commands/branch.rs | 4 +--- cli/tests/test_branch_command.rs | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/cli/src/commands/branch.rs b/cli/src/commands/branch.rs index 2ddbf8b3f..d73e0d1da 100644 --- a/cli/src/commands/branch.rs +++ b/cli/src/commands/branch.rs @@ -403,10 +403,8 @@ fn cmd_branch_list( write!(formatter.labeled("branch"), "{name}")?; if branch_target.local_target.is_present() { print_branch_target(formatter, &branch_target.local_target)?; - } else if found_non_git_remote { - writeln!(formatter, " (deleted)")?; } else { - writeln!(formatter, " (forgotten)")?; + writeln!(formatter, " (deleted)")?; } for (remote, remote_target) in branch_target.remote_targets.iter() { diff --git a/cli/tests/test_branch_command.rs b/cli/tests/test_branch_command.rs index da939cbe8..f0e7c0b50 100644 --- a/cli/tests/test_branch_command.rs +++ b/cli/tests/test_branch_command.rs @@ -221,6 +221,30 @@ fn test_branch_delete_glob() { "###); } +#[test] +fn test_branch_delete_export() { + let test_env = TestEnvironment::default(); + test_env.jj_cmd_success(test_env.env_root(), &["init", "repo", "--git"]); + let repo_path = test_env.env_root().join("repo"); + + test_env.jj_cmd_success(&repo_path, &["new"]); + test_env.jj_cmd_success(&repo_path, &["branch", "set", "foo"]); + test_env.jj_cmd_success(&repo_path, &["git", "export"]); + + test_env.jj_cmd_success(&repo_path, &["branch", "delete", "foo"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); + insta::assert_snapshot!(stdout, @r###" + foo (deleted) + @git: rlvkpnrz 65b6b74e (empty) (no description set) + (this branch will be deleted from the underlying Git repo on the next `jj git export`) + "###); + + test_env.jj_cmd_success(&repo_path, &["git", "export"]); + let stdout = test_env.jj_cmd_success(&repo_path, &["branch", "list"]); + insta::assert_snapshot!(stdout, @r###" + "###); +} + #[test] fn test_branch_forget_export() { let test_env = TestEnvironment::default();