History

git: Don't filter local upstreams from branch picker (#30557)

Release Notes: - Fixed local git branches being excluded from the branch selector when they were set as the upstream of another local branch.

Cole Miller committed 1 year ago

Commit 42dd5111 parent 571c5e72 files · +11 −4Browse files

Unified · Split

2 files
  1. crates/git/src/repository.rs +4 −0
  2. crates/git_ui/src/branch_picker.rs +7 −4
crates/git/src/repository.rs+4−0
@@ -78,6 +78,10 @@ pub struct Upstream { · 77 unmodified lines
78}78}
79 79
80impl Upstream {80impl Upstream {
81 pub fn is_remote(&self) -> bool {
82 self.remote_name().is_some()
83 }
84
81 pub fn remote_name(&self) -> Option<&str> {85 pub fn remote_name(&self) -> Option<&str> {
82 self.ref_name86 self.ref_name
83 .strip_prefix("refs/remotes/")87 .strip_prefix("refs/remotes/")
crates/git_ui/src/branch_picker.rs+7−4
@@ -98,15 +98,18 @@ impl BranchList { · 97 unmodified lines
98 98
99 let all_branches = cx99 let all_branches = cx
100 .background_spawn(async move {100 .background_spawn(async move {
101 let upstreams: HashSet<_> = all_branches101 let remote_upstreams: HashSet<_> = all_branches
102 .iter()102 .iter()
103 .filter_map(|branch| {103 .filter_map(|branch| {
104 let upstream = branch.upstream.as_ref()?;104 branch
105 Some(upstream.ref_name.clone())105 .upstream
106 .as_ref()
107 .filter(|upstream| upstream.is_remote())
108 .map(|upstream| upstream.ref_name.clone())
106 })109 })
107 .collect();110 .collect();
108 111
109 all_branches.retain(|branch| !upstreams.contains(&branch.ref_name));112 all_branches.retain(|branch| !remote_upstreams.contains(&branch.ref_name));
110 113
111 all_branches.sort_by_key(|branch| {114 all_branches.sort_by_key(|branch| {
112 branch115 branch