ok/jj
1
0
Fork 0
forked from mirrors/jj

branch list: more detailed message describing deleted branches

Fixes #1537
This commit is contained in:
Ilya Grigoriev 2023-06-23 23:35:33 -07:00
parent e41d672cc0
commit d01ecc5c46
4 changed files with 17 additions and 0 deletions

View file

@ -334,10 +334,14 @@ fn cmd_branch_list(
write!(formatter.labeled("branch"), "{name}")?;
print_branch_target(formatter, branch_target.local_target.as_ref())?;
let mut found_non_git_remote = false;
for (remote, remote_target) in branch_target.remote_targets.iter() {
if Some(remote_target) == branch_target.local_target.as_ref() {
continue;
}
if remote != "git" {
found_non_git_remote = true;
}
write!(formatter, " ")?;
write!(formatter.labeled("branch"), "@{remote}")?;
if let Some(local_target) = branch_target.local_target.as_ref() {
@ -361,6 +365,13 @@ fn cmd_branch_list(
}
print_branch_target(formatter, Some(remote_target))?;
}
if found_non_git_remote && branch_target.local_target.is_none() {
writeln!(
formatter,
" (this branch will be *deleted permanently* on the remote on the\n next `jj \
git push`. Use `jj branch forget` to prevent this)"
)?;
}
}
Ok(())

View file

@ -310,6 +310,8 @@ fn test_branch_forget_deleted_or_nonexistent_branch() {
insta::assert_snapshot!(get_branch_output(&test_env, &repo_path), @r###"
feature1 (deleted)
@origin: 9f01a0e04879 message
(this branch will be *deleted permanently* on the remote on the
next `jj git push`. Use `jj branch forget` to prevent this)
"###);
// ============ End of test setup ============

View file

@ -949,5 +949,7 @@ fn test_git_fetch_remote_only_branch() {
feature1: 9f01a0e04879 message
feature2 (deleted)
@origin: 9f01a0e04879 message
(this branch will be *deleted permanently* on the remote on the
next `jj git push`. Use `jj branch forget` to prevent this)
"###);
}

View file

@ -184,6 +184,8 @@ fn test_git_push_multiple() {
insta::assert_snapshot!(stdout, @r###"
branch1 (deleted)
@origin: 45a3aa29e907 description 1
(this branch will be *deleted permanently* on the remote on the
next `jj git push`. Use `jj branch forget` to prevent this)
branch2: 15dcdaa4f12f foo
@origin (ahead by 1 commits, behind by 1 commits): 8476341eb395 description 2
my-branch: 15dcdaa4f12f foo