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
7878 }
7979
8080 impl Upstream {
81+ pub fn is_remote(&self) -> bool {
82+ self.remote_name().is_some()
83+ }
84+
8185 pub fn remote_name(&self) -> Option<&str> {
8286 self.ref_name
8387 .strip_prefix("refs/remotes/")
crates/git_ui/src/branch_picker.rs+7−4
@@ -98,15 +98,18 @@ impl BranchList { · 97 unmodified lines
9898
9999 let all_branches = cx
100100 .background_spawn(async move {
101− let upstreams: HashSet<_> = all_branches
101+ let remote_upstreams: HashSet<_> = all_branches
102102 .iter()
103103 .filter_map(|branch| {
104− let upstream = branch.upstream.as_ref()?;
105− Some(upstream.ref_name.clone())
104+ branch
105+ .upstream
106+ .as_ref()
107+ .filter(|upstream| upstream.is_remote())
108+ .map(|upstream| upstream.ref_name.clone())
106109 })
107110 .collect();
108111
109− all_branches.retain(|branch| !upstreams.contains(&branch.ref_name));
112+ all_branches.retain(|branch| !remote_upstreams.contains(&branch.ref_name));
110113
111114 all_branches.sort_by_key(|branch| {
112115 branch