From 5a6e67cc7e5ebbeb33bb4ef8e72f238430e74f9a Mon Sep 17 00:00:00 2001 From: Stephan Dilly Date: Sat, 13 Jun 2020 02:11:16 +0200 Subject: [PATCH] inspect stash commit (closes #121) --- CHANGELOG.md | 1 + src/keys.rs | 1 + src/strings.rs | 6 ++++++ src/tabs/stashlist.rs | 14 ++++++++++++++ 4 files changed, 22 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356b331f..a120b85a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Added +- Inspect stash commit in detail ([#121](https://github.com/extrawurst/gitui/issues/121)) - Commit Amend (`ctrl+a`) when in commit popup ([#89](https://github.com/extrawurst/gitui/issues/89)) ![](assets/amend.gif) diff --git a/src/keys.rs b/src/keys.rs index 6a1720aa..7fad8a20 100644 --- a/src/keys.rs +++ b/src/keys.rs @@ -57,6 +57,7 @@ pub const STASHING_TOGGLE_UNTRACKED: KeyEvent = pub const STASHING_TOGGLE_INDEX: KeyEvent = no_mod(KeyCode::Char('i')); pub const STASH_APPLY: KeyEvent = no_mod(KeyCode::Enter); +pub const STASH_OPEN: KeyEvent = no_mod(KeyCode::Right); pub const STASH_DROP: KeyEvent = with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT); pub const CMD_BAR_TOGGLE: KeyEvent = no_mod(KeyCode::Char('.')); diff --git a/src/strings.rs b/src/strings.rs index c75f515c..84423050 100644 --- a/src/strings.rs +++ b/src/strings.rs @@ -253,6 +253,12 @@ pub mod commands { "drop selected stash", CMD_GROUP_STASHES, ); + /// + pub static STASHLIST_INSPECT: CommandText = CommandText::new( + "Inspect [\u{2192}]", //→ + "open stash commit details (allows to diff files)", + CMD_GROUP_STASHES, + ); /// pub static LOG_DETAILS_TOGGLE: CommandText = CommandText::new( diff --git a/src/tabs/stashlist.rs b/src/tabs/stashlist.rs index 1f7ffd28..3d3c2b9d 100644 --- a/src/tabs/stashlist.rs +++ b/src/tabs/stashlist.rs @@ -73,6 +73,14 @@ impl StashList { } } + fn inspect(&mut self) { + if let Some(e) = self.list.selected_entry() { + self.queue + .borrow_mut() + .push_back(InternalEvent::InspectCommit(e.id)); + } + } + /// pub fn drop(id: CommitId) -> bool { sync::stash_drop(CWD, id).is_ok() @@ -112,6 +120,11 @@ impl Component for StashList { selection_valid, true, )); + out.push(CommandInfo::new( + commands::STASHLIST_INSPECT, + selection_valid, + true, + )); } visibility_blocking(self) @@ -127,6 +140,7 @@ impl Component for StashList { match k { keys::STASH_APPLY => self.apply_stash(), keys::STASH_DROP => self.drop_stash(), + keys::STASH_OPEN => self.inspect(), _ => (), };