diff --git a/src/keys/key_list.rs b/src/keys/key_list.rs index 24c66e959f..121056b6c6 100644 --- a/src/keys/key_list.rs +++ b/src/keys/key_list.rs @@ -103,6 +103,7 @@ pub struct KeysList { pub open_file_tree: GituiKeyEvent, pub file_find: GituiKeyEvent, pub force_push: GituiKeyEvent, + pub fetch: GituiKeyEvent, pub pull: GituiKeyEvent, pub abort_merge: GituiKeyEvent, pub undo_commit: GituiKeyEvent, @@ -184,6 +185,7 @@ impl Default for KeysList { push: GituiKeyEvent::new(KeyCode::Char('p'), KeyModifiers::empty()), force_push: GituiKeyEvent::new(KeyCode::Char('P'), KeyModifiers::SHIFT), undo_commit: GituiKeyEvent::new(KeyCode::Char('U'), KeyModifiers::SHIFT), + fetch: GituiKeyEvent::new(KeyCode::Char('F'), KeyModifiers::SHIFT), pull: GituiKeyEvent::new(KeyCode::Char('f'), KeyModifiers::empty()), abort_merge: GituiKeyEvent::new(KeyCode::Char('A'), KeyModifiers::SHIFT), open_file_tree: GituiKeyEvent::new(KeyCode::Char('F'), KeyModifiers::SHIFT), diff --git a/src/keys/key_list_file.rs b/src/keys/key_list_file.rs index 9ac19e4f3b..024ab89626 100644 --- a/src/keys/key_list_file.rs +++ b/src/keys/key_list_file.rs @@ -74,6 +74,7 @@ pub struct KeysListFile { pub open_file_tree: Option, pub file_find: Option, pub force_push: Option, + pub fetch: Option, pub pull: Option, pub abort_merge: Option, pub undo_commit: Option, @@ -165,6 +166,7 @@ impl KeysListFile { open_file_tree: self.open_file_tree.unwrap_or(default.open_file_tree), file_find: self.file_find.unwrap_or(default.file_find), force_push: self.force_push.unwrap_or(default.force_push), + fetch: self.fetch.unwrap_or(default.fetch), pull: self.pull.unwrap_or(default.pull), abort_merge: self.abort_merge.unwrap_or(default.abort_merge), undo_commit: self.undo_commit.unwrap_or(default.undo_commit), diff --git a/src/strings.rs b/src/strings.rs index c7cf5d79e5..d43a9f1346 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -1440,6 +1440,17 @@ pub mod commands { CMD_GROUP_GENERAL, ) } + + pub fn status_fetch(key_config: &SharedKeyConfig) -> CommandText { + CommandText::new( + format!( + "Fetch [{}]", + key_config.get_hint(key_config.keys.fetch), + ), + "fetch", + CMD_GROUP_GENERAL, + ) + } pub fn status_pull(key_config: &SharedKeyConfig) -> CommandText { CommandText::new( format!( diff --git a/src/tabs/status.rs b/src/tabs/status.rs index cd544b4b09..89f36fc42a 100644 --- a/src/tabs/status.rs +++ b/src/tabs/status.rs @@ -594,6 +594,12 @@ impl Status { } } + fn fetch(&self) { + if self.can_pull() { + self.queue.push(InternalEvent::FetchRemotes); + } + } + fn pull(&self) { if let Some(branch) = self.git_branch_name.last() { self.queue.push(InternalEvent::Pull(branch)); @@ -761,6 +767,12 @@ impl Component for Status { true, self.can_push() && !focus_on_diff, )); + + out.push(CommandInfo::new( + strings::commands::status_fetch(&self.key_config), + self.can_pull(), + !focus_on_diff, + )); out.push(CommandInfo::new( strings::commands::status_pull(&self.key_config), self.can_pull(), @@ -907,6 +919,12 @@ impl Component for Status { { self.push(false); Ok(EventState::Consumed) + } else if key_match(k, self.key_config.keys.fetch) + && !self.is_focus_on_diff() + && self.can_pull() + { + self.fetch(); + Ok(EventState::Consumed) } else if key_match(k, self.key_config.keys.pull) && !self.is_focus_on_diff() && self.can_pull()