Skip to content

Commit 41dc4c3

Browse files
committed
(refactor) replace BranchListComponent::check_remotes with single condition
1 parent ed13900 commit 41dc4c3

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/components/branchlist.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ impl Component for BranchListComponent {
248248
.map(Into::into);
249249
} else if key_match(e, self.key_config.keys.tab_toggle) {
250250
self.local = !self.local;
251-
self.check_remotes();
252251
self.update_branches()?;
253252
} else if key_match(e, self.key_config.keys.enter) {
254253
try_or_popup!(
@@ -365,23 +364,16 @@ impl BranchListComponent {
365364
Ok(())
366365
}
367366

368-
fn check_remotes(&mut self) {
369-
if !self.local {
370-
self.has_remotes =
371-
get_branches_info(&self.repo.borrow(), false)
372-
.map(|branches| !branches.is_empty())
373-
.unwrap_or(false);
374-
}
375-
}
376-
377367
/// fetch list of branches
378368
pub fn update_branches(&mut self) -> Result<()> {
379369
if self.is_visible() {
380-
self.check_remotes();
381370
self.branches =
382371
get_branches_info(&self.repo.borrow(), self.local)?;
383-
//remove remote branch called `HEAD`
372+
384373
if !self.local {
374+
self.has_remotes = !self.branches.is_empty();
375+
376+
//remove remote branch called `HEAD`
385377
self.branches
386378
.iter()
387379
.position(|b| b.name.ends_with("/HEAD"))

0 commit comments

Comments
 (0)