Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/default_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -214,4 +214,5 @@ stash_menu.stash_keep_index = ["x"]
stash_menu.stash_pop = ["p"]
stash_menu.stash_apply = ["a"]
stash_menu.stash_drop = ["k"]
stash_menu.stash_clear = ["c"]
stash_menu.quit = ["q", "esc"]
2 changes: 2 additions & 0 deletions src/ops/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ pub(crate) enum Op {
StashKeepIndex,
StashPop,
StashDrop,
StashClear,
CommitFixup,
CommitInstantFixup,
LogOther,
Expand Down Expand Up @@ -165,6 +166,7 @@ impl Op {
Op::StashKeepIndex => Box::new(stash::StashKeepIndex),
Op::StashPop => Box::new(stash::StashPop),
Op::StashDrop => Box::new(stash::StashDrop),
Op::StashClear => Box::new(stash::StashClear),

Op::CommitFixup => Box::new(commit::CommitFixup),
Op::CommitInstantFixup => Box::new(commit::CommitInstantFixup),
Expand Down
23 changes: 23 additions & 0 deletions src/ops/stash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,29 @@ fn stash_drop(app: &mut App, term: &mut Term, input: &str) -> Res<()> {
Ok(())
}

pub(crate) struct StashClear;
impl OpTrait for StashClear {
fn get_action(&self, _target: &ItemData) -> Option<Action> {
Some(Rc::new(move |app: &mut App, term: &mut Term| {
stash_clear(app, term)?;
Ok(())
}))
}

fn display(&self, _state: &State) -> String {
"clear".into()
}
}

fn stash_clear(app: &mut App, term: &mut Term) -> Res<()> {
let mut cmd = Command::new("git");
cmd.args(["stash", "clear"]);

app.close_menu();
app.run_cmd(term, &[], cmd)?;
Ok(())
}

fn selected_stash(app: &App) -> Option<String> {
match app.screen().get_selected_item().data {
ItemData::Stash { id, .. } => Some(id.to_string()),
Expand Down
Loading