From be2bbad6b837d389876fd08c3e8b36c7679abfa6 Mon Sep 17 00:00:00 2001 From: Kyosuke Fujimoto Date: Sun, 31 May 2026 13:32:20 +0900 Subject: [PATCH 1/3] Add stash user command variable --- src/app.rs | 7 ++++++- src/external.rs | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app.rs b/src/app.rs index 44f1f3c..fcb31cc 100644 --- a/src/app.rs +++ b/src/app.rs @@ -786,12 +786,16 @@ fn build_external_command_parameters<'a>( let mut branches = vec![]; let mut remote_branches = vec![]; let mut tags = vec![]; + let mut stash = None; for r in refs { match r { Ref::Tag { .. } => tags.push(r.name()), Ref::Branch { .. } => branches.push(r.name()), Ref::RemoteBranch { .. } => remote_branches.push(r.name()), - Ref::Stash { .. } => continue, // skip stashes + Ref::Stash { .. } => { + stash = Some(r.name()); + continue; // skip stashes from {{refs}} + } } all_refs.push(r.name()); } @@ -808,6 +812,7 @@ fn build_external_command_parameters<'a>( branches, remote_branches, tags, + stash, area_width, area_height, }) diff --git a/src/external.rs b/src/external.rs index 39c44e8..a23c1a8 100644 --- a/src/external.rs +++ b/src/external.rs @@ -12,6 +12,7 @@ const USER_COMMAND_REFS_MARKER: &str = "{{refs}}"; const USER_COMMAND_BRANCHES_MARKER: &str = "{{branches}}"; const USER_COMMAND_REMOTE_BRANCHES_MARKER: &str = "{{remote_branches}}"; const USER_COMMAND_TAGS_MARKER: &str = "{{tags}}"; +const USER_COMMAND_STASH_MARKER: &str = "{{stash}}"; const USER_COMMAND_AREA_WIDTH_MARKER: &str = "{{area_width}}"; const USER_COMMAND_AREA_HEIGHT_MARKER: &str = "{{area_height}}"; @@ -78,6 +79,7 @@ pub struct ExternalCommandParameters<'a> { pub branches: Vec<&'a str>, pub remote_branches: Vec<&'a str>, pub tags: Vec<&'a str>, + pub stash: Option<&'a str>, pub area_width: u16, pub area_height: u16, } @@ -152,6 +154,7 @@ fn replace_command_arg(s: &str, params: &ExternalCommandParameters) -> String { let branches = ¶ms.branches.join(sep); let remote_branches = ¶ms.remote_branches.join(sep); let tags = ¶ms.tags.join(sep); + let stash = params.stash.unwrap_or_default(); let area_width = ¶ms.area_width.to_string(); let area_height = ¶ms.area_height.to_string(); @@ -162,6 +165,7 @@ fn replace_command_arg(s: &str, params: &ExternalCommandParameters) -> String { .replace(USER_COMMAND_BRANCHES_MARKER, branches) .replace(USER_COMMAND_REMOTE_BRANCHES_MARKER, remote_branches) .replace(USER_COMMAND_TAGS_MARKER, tags) + .replace(USER_COMMAND_STASH_MARKER, stash) .replace(USER_COMMAND_AREA_WIDTH_MARKER, area_width) .replace(USER_COMMAND_AREA_HEIGHT_MARKER, area_height) } From e2dced0b3a89fbf46618052e0d3cb72ea6de7305 Mon Sep 17 00:00:00 2001 From: Kyosuke Fujimoto Date: Sun, 31 May 2026 13:32:36 +0900 Subject: [PATCH 2/3] Document stash user command variable --- docs/src/features/user-command.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/src/features/user-command.md b/docs/src/features/user-command.md index 3cc2c3f..95ab7ea 100644 --- a/docs/src/features/user-command.md +++ b/docs/src/features/user-command.md @@ -74,6 +74,9 @@ They will be replaced with their respective values command is executed. - `{{tags}}` - The names of all tags pointing to the selected commit, separated by a space. - example: `v1.0.0 v1.0.1` +- `{{stash}}` + - The name of the stash when the selected commit is a stash commit. Otherwise, this is an empty string. + - example: `stash@{0}` - `{{area_width}}` - Width of the user command display area (number of cells). - example: `80` From 5f744070991c79c859d069a3da870c7d8f5d4dec Mon Sep 17 00:00:00 2001 From: Kyosuke Fujimoto Date: Sun, 31 May 2026 13:32:50 +0900 Subject: [PATCH 3/3] Fix refs user command documentation --- docs/src/features/user-command.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/features/user-command.md b/docs/src/features/user-command.md index 95ab7ea..e36f433 100644 --- a/docs/src/features/user-command.md +++ b/docs/src/features/user-command.md @@ -63,7 +63,7 @@ They will be replaced with their respective values command is executed. - The hashes of all parents of the selected commit, separated by a space. - example: `c103d9744df8ebf100773a11345f011152ec5581 a1b2c3d4e5f67890123456789abcdef0123456789` - `{{refs}}` - - The names of all refs (branches, tags, stashes) pointing to the selected commit, separated by a space. + - The names of all refs (branches, remote branches, tags) pointing to the selected commit, separated by a space. - example: `master v1.0.0` - `{{branches}}` - The names of all branches pointing to the selected commit, separated by a space.