fix overview command to match both storkit and legacy story-kit commit prefixes
The .story_kit → .storkit rename updated the grep pattern but all historical merge commits still use the old "story-kit:" prefix, so overview could not find any stories. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ use super::CommandContext;
|
||||
|
||||
/// Show implementation summary for a story identified by its number.
|
||||
///
|
||||
/// Finds the `story-kit: merge {story_id}` commit on master, displays the
|
||||
/// Finds the `storkit: merge {story_id}` commit on master, displays the
|
||||
/// git diff --stat (files changed with line counts), and extracts key
|
||||
/// function/struct/type names added or modified in the implementation.
|
||||
/// Returns a friendly message when no merge commit is found.
|
||||
@@ -82,12 +82,20 @@ pub(super) fn handle_overview(ctx: &CommandContext) -> Option<String> {
|
||||
/// Find the merge commit hash for a story by its numeric ID.
|
||||
///
|
||||
/// Searches git log for a commit whose subject matches
|
||||
/// `story-kit: merge {num}_*`.
|
||||
/// `storkit: merge {num}_*` or the legacy `story-kit: merge {num}_*`.
|
||||
fn find_story_merge_commit(root: &std::path::Path, num_str: &str) -> Option<String> {
|
||||
use std::process::Command;
|
||||
let grep_pattern = format!("story-kit: merge {num_str}_");
|
||||
// Match both the current prefix and the legacy one from before the rename.
|
||||
let grep_pattern = format!("(storkit|story-kit): merge {num_str}_");
|
||||
let output = Command::new("git")
|
||||
.args(["log", "--format=%H", "--all", "--grep", &grep_pattern])
|
||||
.args([
|
||||
"log",
|
||||
"--format=%H",
|
||||
"--all",
|
||||
"--extended-regexp",
|
||||
"--grep",
|
||||
&grep_pattern,
|
||||
])
|
||||
.current_dir(root)
|
||||
.output()
|
||||
.ok()
|
||||
@@ -125,13 +133,11 @@ fn find_story_name(root: &std::path::Path, num_str: &str) -> Option<String> {
|
||||
.filter(|s| !s.is_empty() && s.chars().all(|c| c.is_ascii_digit()))
|
||||
.unwrap_or("");
|
||||
if file_num == num_str {
|
||||
return std::fs::read_to_string(&path)
|
||||
.ok()
|
||||
.and_then(|c| {
|
||||
crate::io::story_metadata::parse_front_matter(&c)
|
||||
.ok()
|
||||
.and_then(|m| m.name)
|
||||
});
|
||||
return std::fs::read_to_string(&path).ok().and_then(|c| {
|
||||
crate::io::story_metadata::parse_front_matter(&c)
|
||||
.ok()
|
||||
.and_then(|m| m.name)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -251,9 +257,16 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn overview_command_appears_in_help() {
|
||||
let result = super::super::tests::try_cmd_addressed("Timmy", "@timmy:homeserver.local", "@timmy help");
|
||||
let result = super::super::tests::try_cmd_addressed(
|
||||
"Timmy",
|
||||
"@timmy:homeserver.local",
|
||||
"@timmy help",
|
||||
);
|
||||
let output = result.unwrap();
|
||||
assert!(output.contains("overview"), "help should list overview command: {output}");
|
||||
assert!(
|
||||
output.contains("overview"),
|
||||
"help should list overview command: {output}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -316,7 +329,11 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn overview_command_case_insensitive() {
|
||||
let result = super::super::tests::try_cmd_addressed("Timmy", "@timmy:homeserver.local", "@timmy OVERVIEW 1");
|
||||
let result = super::super::tests::try_cmd_addressed(
|
||||
"Timmy",
|
||||
"@timmy:homeserver.local",
|
||||
"@timmy OVERVIEW 1",
|
||||
);
|
||||
assert!(result.is_some(), "OVERVIEW should match case-insensitively");
|
||||
}
|
||||
|
||||
@@ -324,7 +341,8 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_symbol_pub_fn() {
|
||||
let result = parse_symbol_definition("pub fn handle_foo(ctx: &Context) -> Option<String> {");
|
||||
let result =
|
||||
parse_symbol_definition("pub fn handle_foo(ctx: &Context) -> Option<String> {");
|
||||
assert_eq!(result, Some("`handle_foo` (fn)".to_string()));
|
||||
}
|
||||
|
||||
@@ -354,7 +372,9 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn parse_symbol_pub_type() {
|
||||
let result = parse_symbol_definition("pub type SlackHistory = Arc<Mutex<HashMap<String, Vec<u8>>>>;");
|
||||
let result = parse_symbol_definition(
|
||||
"pub type SlackHistory = Arc<Mutex<HashMap<String, Vec<u8>>>>;",
|
||||
);
|
||||
assert_eq!(result, Some("`SlackHistory` (type)".to_string()));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user