From 5244751e9e64c0b72d8deecebfdae34f7666d01c Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Tue, 23 Feb 2021 12:32:32 +0100 Subject: [PATCH] check if we `can_push` before trying (#533) closes #531 --- src/tabs/status.rs | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/tabs/status.rs b/src/tabs/status.rs index ad00a65b..df29b41e 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -376,17 +376,19 @@ impl Status { } fn push(&self, force: bool) { - if let Some(branch) = self.git_branch_name.last() { - if force { - self.queue.borrow_mut().push_back( - InternalEvent::ConfirmAction(Action::ForcePush( - branch, force, - )), - ); - } else { - self.queue - .borrow_mut() - .push_back(InternalEvent::Push(branch, force)); + if self.can_push() { + if let Some(branch) = self.git_branch_name.last() { + if force { + self.queue.borrow_mut().push_back( + InternalEvent::ConfirmAction( + Action::ForcePush(branch, force), + ), + ); + } else { + self.queue.borrow_mut().push_back( + InternalEvent::Push(branch, force), + ); + } } } }