huskies: merge 1034
This commit is contained in:
@@ -13,17 +13,8 @@ use std::process::Command;
|
||||
/// Usage: `diff <number>`
|
||||
pub(super) fn handle_diff(ctx: &CommandContext) -> Option<String> {
|
||||
let num_str = ctx.args.trim();
|
||||
if num_str.is_empty() {
|
||||
return Some(format!(
|
||||
"Usage: `{} diff <number>`\n\nShows the git diff from the main branch to the story's worktree HEAD.",
|
||||
ctx.services.bot_name
|
||||
));
|
||||
}
|
||||
if !num_str.chars().all(|c| c.is_ascii_digit()) {
|
||||
return Some(format!(
|
||||
"Invalid story number: `{num_str}`. Usage: `{} diff <number>`",
|
||||
ctx.services.bot_name
|
||||
));
|
||||
if num_str.is_empty() || !num_str.chars().all(|c| c.is_ascii_digit()) {
|
||||
return None;
|
||||
}
|
||||
|
||||
let story_id = match find_story_id(num_str) {
|
||||
@@ -169,22 +160,33 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diff_command_no_args_returns_usage() {
|
||||
fn diff_command_no_args_routes_to_timmy() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let output = diff_cmd(tmp.path(), "").unwrap();
|
||||
let result = diff_cmd(tmp.path(), "");
|
||||
assert!(
|
||||
output.contains("Usage"),
|
||||
"no args should show usage: {output}"
|
||||
result.is_none(),
|
||||
"no args should route to LLM (None): {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diff_command_non_numeric_returns_error() {
|
||||
fn diff_command_non_numeric_routes_to_timmy() {
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let output = diff_cmd(tmp.path(), "abc").unwrap();
|
||||
let result = diff_cmd(tmp.path(), "the login feature branch");
|
||||
assert!(
|
||||
output.contains("Invalid"),
|
||||
"non-numeric arg should return error: {output}"
|
||||
result.is_none(),
|
||||
"natural-language args should route to LLM (None): {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn diff_command_well_formed_runs_handler() {
|
||||
crate::db::ensure_content_store();
|
||||
let tmp = tempfile::TempDir::new().unwrap();
|
||||
let result = diff_cmd(tmp.path(), "99994");
|
||||
assert!(
|
||||
result.is_some(),
|
||||
"well-formed numeric arg should run the command handler: {result:?}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user