Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Improve -vv diagnostic hint to use gist workflow (#568)
Maximilian Roos449b404dcc94
diff --git a/src/main.rs b/src/main.rsindex 275728c91..7b7fb98ad 100644--- a/src/main.rs+++ b/src/main.rs@@ -1793,8 +1793,10 @@ fn write_vv_diagnostic(verbose: u8, command_line: &str, error_msg: Option<&str>)if is_gh_installed() {// Escape single quotes for shell: 'it'\''s' -> it'slet path_str = path.to_string_lossy().replace('\'', "'\\''");+ // URL with prefilled body: ## Gist\n\n[Paste URL]\n\n## Description\n\n[Describe the issue]+ let issue_url = "https://github.com/max-sixty/worktrunk/issues/new?body=%23%23%20Gist%0A%0A%5BPaste%20gist%20URL%5D%0A%0A%23%23%20Description%0A%0A%5BDescribe%20the%20issue%5D";let _ = output::print(hint_message(cformat!(- "If this is a bug, draft an issue: <bright-black>gh issue create --web -R max-sixty/worktrunk -t 'Bug report' --body-file '{path_str}'</>"+ "To report a bug, create a secret gist with <bright-black>gh gist create --web '{path_str}'</> and reference it from an issue at <bright-black>{issue_url}</>")));}}diff --git a/tests/integration_tests/diagnostic.rs b/tests/integration_tests/diagnostic.rsindex d0906547b..fb570c93b 100644--- a/tests/integration_tests/diagnostic.rs+++ b/tests/integration_tests/diagnostic.rs@@ -13,6 +13,7 @@//! - `test_diagnostic_verbose_log_contains_git_commands`: Log has useful data//! - `test_diagnostic_saved_message_with_vv`: Output shows "Diagnostic saved" with -vv//! - `test_diagnostic_written_to_correct_location`: File in .git/wt-logs/+//! - `test_diagnostic_gh_hint_with_vv`: Hint shows gist and issue URL when gh installeduse std::fs;use std::path::PathBuf;@@ -456,6 +457,33 @@ fn test_vv_outside_repo_no_crash() {);}+/// When gh is installed, the hint should show gist creation and issue URL.+#[rstest]+fn test_diagnostic_gh_hint_with_vv(mut repo: TestRepo) {+ // Setup mock gh so it appears installed+ repo.setup_mock_gh();++ let output = repo.wt_command().args(["list", "-vv"]).output().unwrap();++ let stderr = String::from_utf8_lossy(&output.stderr);++ // Extract the hint line (starts with ↳)+ let hint_line = stderr+ .lines()+ .find(|line| line.contains("report a bug"))+ .expect("Should have hint about reporting a bug");++ // Normalize the path in the hint (handles both raw paths and _REPO_ filtered paths)+ let normalized = regex::Regex::new(r"'[^']*diagnostic\.md'")+ .unwrap()+ .replace(hint_line, "'[DIAGNOSTIC_PATH]'");++ let settings = setup_snapshot_settings(&repo);+ settings.bind(|| {+ assert_snapshot!("diagnostic_gh_hint", normalized);+ });+}+/// Normalize the report for snapshot comparison.////// Replaces variable content (versions, paths, timestamps) with placeholders.diff --git a/tests/snapshots/integration__integration_tests__diagnostic__diagnostic_gh_hint.snap b/tests/snapshots/integration__integration_tests__diagnostic__diagnostic_gh_hint.snapnew file mode 100644index 000000000..ca2212811--- /dev/null+++ b/tests/snapshots/integration__integration_tests__diagnostic__diagnostic_gh_hint.snap@@ -0,0 +1,5 @@+---+source: tests/integration_tests/diagnostic.rs+expression: normalized+---+[2m↳[22m [2mTo report a bug, create a secret gist with [90mgh gist create --web '[DIAGNOSTIC_PATH]'[39m and reference it from an issue at [90mhttps://github.com/max-sixty/worktrunk/issues/new?body=%23%23%20Gist%0A%0A%5BPaste%20gist%20URL%5D%0A%0A%23%23%20Description%0A%0A%5BDescribe%20the%20issue%5D[39m[22m