Skip to content

Commit

Permalink
cli: rephrase @git branch with no local counterpart as "deleted"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
yuja committed Oct 7, 2023
1 parent 28e5ee3 commit 1eb8b95
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
4 changes: 1 addition & 3 deletions cli/src/commands/branch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
24 changes: 24 additions & 0 deletions cli/tests/test_branch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 1eb8b95

Please sign in to comment.