mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
fix empty branch list enter key still accepted and panics
This commit is contained in:
parent
b1e7b1381f
commit
f7a17fa3bb
2 changed files with 18 additions and 3 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- fetch crashed when no upstream of branch is set ([#637](https://github.com/extrawurst/gitui/issues/637))
|
- fetch crashed when no upstream of branch is set ([#637](https://github.com/extrawurst/gitui/issues/637))
|
||||||
|
- `enter` key panics in empty remote branch list ([#643](https://github.com/extrawurst/gitui/issues/643))
|
||||||
|
|
||||||
## [0.14.0] - 2020-04-11
|
## [0.14.0] - 2020-04-11
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,8 @@ impl Component for BranchListComponent {
|
||||||
strings::commands::select_branch_popup(
|
strings::commands::select_branch_popup(
|
||||||
&self.key_config,
|
&self.key_config,
|
||||||
),
|
),
|
||||||
!self.selection_is_cur_branch(),
|
!self.selection_is_cur_branch()
|
||||||
|
&& self.valid_selection(),
|
||||||
true,
|
true,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
@ -179,12 +180,16 @@ impl Component for BranchListComponent {
|
||||||
"switch branch error:",
|
"switch branch error:",
|
||||||
self.switch_to_selected_branch()
|
self.switch_to_selected_branch()
|
||||||
);
|
);
|
||||||
} else if e == self.key_config.create_branch {
|
} else if e == self.key_config.create_branch
|
||||||
|
&& self.local
|
||||||
|
{
|
||||||
self.queue
|
self.queue
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.push_back(InternalEvent::CreateBranch);
|
.push_back(InternalEvent::CreateBranch);
|
||||||
self.hide();
|
self.hide();
|
||||||
} else if e == self.key_config.rename_branch {
|
} else if e == self.key_config.rename_branch
|
||||||
|
&& self.valid_selection()
|
||||||
|
{
|
||||||
let cur_branch =
|
let cur_branch =
|
||||||
&self.branches[self.selection as usize];
|
&self.branches[self.selection as usize];
|
||||||
self.queue.borrow_mut().push_back(
|
self.queue.borrow_mut().push_back(
|
||||||
|
|
@ -197,6 +202,7 @@ impl Component for BranchListComponent {
|
||||||
self.update_branches()?;
|
self.update_branches()?;
|
||||||
} else if e == self.key_config.delete_branch
|
} else if e == self.key_config.delete_branch
|
||||||
&& !self.selection_is_cur_branch()
|
&& !self.selection_is_cur_branch()
|
||||||
|
&& self.valid_selection()
|
||||||
{
|
{
|
||||||
self.queue.borrow_mut().push_back(
|
self.queue.borrow_mut().push_back(
|
||||||
InternalEvent::ConfirmAction(
|
InternalEvent::ConfirmAction(
|
||||||
|
|
@ -276,6 +282,10 @@ impl BranchListComponent {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn valid_selection(&self) -> bool {
|
||||||
|
!self.branches.is_empty()
|
||||||
|
}
|
||||||
|
|
||||||
fn selection_is_cur_branch(&self) -> bool {
|
fn selection_is_cur_branch(&self) -> bool {
|
||||||
self.branches
|
self.branches
|
||||||
.iter()
|
.iter()
|
||||||
|
|
@ -433,6 +443,10 @@ impl BranchListComponent {
|
||||||
|
|
||||||
///
|
///
|
||||||
fn switch_to_selected_branch(&mut self) -> Result<()> {
|
fn switch_to_selected_branch(&mut self) -> Result<()> {
|
||||||
|
if !self.valid_selection() {
|
||||||
|
anyhow::bail!("no valid branch selected");
|
||||||
|
}
|
||||||
|
|
||||||
if self.local {
|
if self.local {
|
||||||
checkout_branch(
|
checkout_branch(
|
||||||
asyncgit::CWD,
|
asyncgit::CWD,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue