mirror of
https://github.com/extrawurst/gitui.git
synced 2024-11-23 03:32:30 +03:00
Status view fetch (#1483)
* adding the command to Status view * cleanup and fix warnings Co-authored-by: extrawurst <mail@rusticorn.com>
This commit is contained in:
parent
b8a436fdeb
commit
1dc097ebd8
@ -104,6 +104,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,
|
||||
@ -186,6 +187,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),
|
||||
|
@ -75,6 +75,7 @@ pub struct KeysListFile {
|
||||
pub open_file_tree: Option<GituiKeyEvent>,
|
||||
pub file_find: Option<GituiKeyEvent>,
|
||||
pub force_push: Option<GituiKeyEvent>,
|
||||
pub fetch: Option<GituiKeyEvent>,
|
||||
pub pull: Option<GituiKeyEvent>,
|
||||
pub abort_merge: Option<GituiKeyEvent>,
|
||||
pub undo_commit: Option<GituiKeyEvent>,
|
||||
@ -167,6 +168,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),
|
||||
|
@ -1456,6 +1456,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!(
|
||||
|
@ -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(),
|
||||
@ -883,6 +895,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()
|
||||
|
Loading…
Reference in New Issue
Block a user