Skip to content

Commit d4db614

Browse files
author
Stephan Dilly
committed
update branch list if a push notification arrives
1 parent 56502ad commit d4db614

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

src/app.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,7 @@ impl App {
359359
self.push_popup.update_git(ev)?;
360360
self.push_tags_popup.update_git(ev)?;
361361
self.pull_popup.update_git(ev)?;
362+
self.select_branch_popup.update_git(ev)?;
362363
}
363364

364365
self.files_tab.update_async(ev);

src/components/branchlist.rs

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use asyncgit::{
1616
self, branch::checkout_remote_branch, checkout_branch,
1717
get_branches_info, BranchInfo,
1818
},
19-
CWD,
19+
AsyncGitNotification, CWD,
2020
};
2121
use crossterm::event::Event;
2222
use std::{cell::Cell, convert::TryInto};
@@ -286,23 +286,39 @@ impl BranchListComponent {
286286

287287
///
288288
pub fn open(&mut self) -> Result<()> {
289-
self.update_branches()?;
290289
self.show()?;
290+
self.update_branches()?;
291291

292292
Ok(())
293293
}
294294

295295
/// fetch list of branches
296296
pub fn update_branches(&mut self) -> Result<()> {
297-
self.branches = get_branches_info(CWD, self.local)?;
298-
//remove remote branch called `HEAD`
299-
if !self.local {
300-
self.branches
301-
.iter()
302-
.position(|b| b.name.ends_with("/HEAD"))
303-
.map(|idx| self.branches.remove(idx));
297+
if self.is_visible() {
298+
self.branches = get_branches_info(CWD, self.local)?;
299+
//remove remote branch called `HEAD`
300+
if !self.local {
301+
self.branches
302+
.iter()
303+
.position(|b| b.name.ends_with("/HEAD"))
304+
.map(|idx| self.branches.remove(idx));
305+
}
306+
self.set_selection(self.selection)?;
304307
}
305-
self.set_selection(self.selection)?;
308+
Ok(())
309+
}
310+
311+
///
312+
pub fn update_git(
313+
&mut self,
314+
ev: AsyncGitNotification,
315+
) -> Result<()> {
316+
if self.is_visible() {
317+
if let AsyncGitNotification::Push = ev {
318+
self.update_branches()?;
319+
}
320+
}
321+
306322
Ok(())
307323
}
308324

0 commit comments

Comments
 (0)