inspect stash commit (closes #121)

This commit is contained in:
Stephan Dilly 2020-06-13 02:11:16 +02:00
parent d550e68747
commit 5a6e67cc7e
4 changed files with 22 additions and 0 deletions

View file

@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Added ### 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)) - Commit Amend (`ctrl+a`) when in commit popup ([#89](https://github.com/extrawurst/gitui/issues/89))
![](assets/amend.gif) ![](assets/amend.gif)

View file

@ -57,6 +57,7 @@ pub const STASHING_TOGGLE_UNTRACKED: KeyEvent =
pub const STASHING_TOGGLE_INDEX: KeyEvent = pub const STASHING_TOGGLE_INDEX: KeyEvent =
no_mod(KeyCode::Char('i')); no_mod(KeyCode::Char('i'));
pub const STASH_APPLY: KeyEvent = no_mod(KeyCode::Enter); pub const STASH_APPLY: KeyEvent = no_mod(KeyCode::Enter);
pub const STASH_OPEN: KeyEvent = no_mod(KeyCode::Right);
pub const STASH_DROP: KeyEvent = pub const STASH_DROP: KeyEvent =
with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT); with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT);
pub const CMD_BAR_TOGGLE: KeyEvent = no_mod(KeyCode::Char('.')); pub const CMD_BAR_TOGGLE: KeyEvent = no_mod(KeyCode::Char('.'));

View file

@ -253,6 +253,12 @@ pub mod commands {
"drop selected stash", "drop selected stash",
CMD_GROUP_STASHES, 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( pub static LOG_DETAILS_TOGGLE: CommandText = CommandText::new(

View file

@ -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 { pub fn drop(id: CommitId) -> bool {
sync::stash_drop(CWD, id).is_ok() sync::stash_drop(CWD, id).is_ok()
@ -112,6 +120,11 @@ impl Component for StashList {
selection_valid, selection_valid,
true, true,
)); ));
out.push(CommandInfo::new(
commands::STASHLIST_INSPECT,
selection_valid,
true,
));
} }
visibility_blocking(self) visibility_blocking(self)
@ -127,6 +140,7 @@ impl Component for StashList {
match k { match k {
keys::STASH_APPLY => self.apply_stash(), keys::STASH_APPLY => self.apply_stash(),
keys::STASH_DROP => self.drop_stash(), keys::STASH_DROP => self.drop_stash(),
keys::STASH_OPEN => self.inspect(),
_ => (), _ => (),
}; };