mirror of
https://github.com/martinvonz/jj.git
synced 2025-01-15 08:53:16 +00:00
templater: take non-tracking remote branches as unrelated to local branch
This corresponds to the change I've made for "jj branch list". Non-tracking remote branches have no relation to local branches.
This commit is contained in:
parent
eb78ae9758
commit
bcf159c545
2 changed files with 14 additions and 10 deletions
|
@ -360,22 +360,26 @@ fn build_branches_index(repo: &dyn Repo) -> RefNamesIndex {
|
|||
let mut index = RefNamesIndex::default();
|
||||
for (branch_name, branch_target) in repo.view().branches() {
|
||||
let local_target = branch_target.local_target;
|
||||
let mut unsynced_remote_targets = branch_target
|
||||
.remote_refs
|
||||
.iter()
|
||||
.filter(|&&(_, remote_ref)| remote_ref.target != *local_target)
|
||||
.peekable();
|
||||
let remote_refs = branch_target.remote_refs;
|
||||
let unsynced_remote_refs = remote_refs.iter().copied().filter(|&(_, remote_ref)| {
|
||||
!remote_ref.is_tracking() || remote_ref.target != *local_target
|
||||
});
|
||||
let has_unsynced_tracking_refs = || {
|
||||
remote_refs.iter().any(|&(_, remote_ref)| {
|
||||
remote_ref.is_tracking() && remote_ref.target != *local_target
|
||||
})
|
||||
};
|
||||
if local_target.is_present() {
|
||||
let decorated_name = if local_target.has_conflict() {
|
||||
format!("{branch_name}??")
|
||||
} else if unsynced_remote_targets.peek().is_some() {
|
||||
} else if has_unsynced_tracking_refs() {
|
||||
format!("{branch_name}*")
|
||||
} else {
|
||||
branch_name.to_owned()
|
||||
};
|
||||
index.insert(local_target.added_ids(), decorated_name);
|
||||
}
|
||||
for &(remote_name, remote_ref) in unsynced_remote_targets {
|
||||
for (remote_name, remote_ref) in unsynced_remote_refs {
|
||||
let decorated_name = if remote_ref.target.has_conflict() {
|
||||
format!("{branch_name}@{remote_name}?")
|
||||
} else {
|
||||
|
|
|
@ -560,7 +560,7 @@ fn test_branch_track_untrack() {
|
|||
main: sptzoqmo 7b33f629 commit 1
|
||||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ feature1 feature2@origin main 7b33f6295eda
|
||||
◉ feature1 feature1@origin feature2@origin main 7b33f6295eda
|
||||
│ @ 230dd059e1b0
|
||||
├─╯
|
||||
◉ 000000000000
|
||||
|
@ -586,7 +586,7 @@ fn test_branch_track_untrack() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ feature1@origin feature2@origin main 40dabdaf4abe
|
||||
│ ◉ feature1* 7b33f6295eda
|
||||
│ ◉ feature1 7b33f6295eda
|
||||
├─╯
|
||||
│ @ 230dd059e1b0
|
||||
├─╯
|
||||
|
@ -619,7 +619,7 @@ fn test_branch_track_untrack() {
|
|||
"###);
|
||||
insta::assert_snapshot!(get_log_output(&test_env, &repo_path), @r###"
|
||||
◉ feature1@origin feature2@origin feature3 main 3f0f86fa0e57
|
||||
│ ◉ feature1* 7b33f6295eda
|
||||
│ ◉ feature1 7b33f6295eda
|
||||
├─╯
|
||||
│ @ 230dd059e1b0
|
||||
├─╯
|
||||
|
|
Loading…
Reference in a new issue