Skip to content
Merged
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
47 changes: 45 additions & 2 deletions src/commands/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,47 @@ fn is_plugin_installed() -> bool {
content.contains("\"worktrunk@worktrunk\"")
}

/// Get the git version string (e.g., "2.47.1")
fn get_git_version() -> Option<String> {
use std::process::Command;
use worktrunk::shell_exec::run;

let mut cmd = Command::new("git");
cmd.args(["--version"]);

let output = run(&mut cmd, None).ok()?;
if !output.status.success() {
return None;
}

// Parse "git version 2.47.1" -> "2.47.1"
let stdout = String::from_utf8_lossy(&output.stdout);
stdout
.trim()
.strip_prefix("git version ")
.map(|s| s.to_string())
}

/// Render OTHER section (version, Claude plugin, hyperlinks)
fn render_runtime_info(out: &mut String) -> anyhow::Result<()> {
let cmd = crate::binary_name();
let version = version_str();

// Version as suffix to heading
writeln!(out, "{}", format_heading("OTHER", None))?;

// Version info
writeln!(
out,
"{}",
format_heading("OTHER", Some(&cformat!("{cmd} {version}")))
info_message(cformat!("{cmd}: <bold>{version}</>"))
)?;
if let Some(git_version) = get_git_version() {
writeln!(
out,
"{}",
info_message(cformat!("git: <bold>{git_version}</>"))
)?;
}

// Claude Code plugin status
let plugin_installed = is_plugin_installed();
Expand Down Expand Up @@ -1754,4 +1784,17 @@ mod tests {
let path = result.unwrap();
assert!(path.ends_with("worktrunk/config.toml"));
}

// ==================== get_git_version tests ====================

#[test]
fn test_get_git_version_returns_version() {
// In a normal environment with git installed, should return a version
let version = get_git_version();
assert!(version.is_some());
let version = version.unwrap();
// Version should look like a semver (e.g., "2.47.1")
assert!(version.chars().next().unwrap().is_ascii_digit());
assert!(version.contains('.'));
}
}
14 changes: 9 additions & 5 deletions tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2110,12 +2110,16 @@ fn setup_snapshot_settings_for_paths(
// On Windows, clap shows "wt.exe" instead of "wt"
settings.add_filter(r"wt\.exe", "wt");

// Normalize version strings in `wt config show` OTHER section (formerly RUNTIME)
// Version can be: v0.8.5, v0.8.5-2-gabcdef, v0.8.5-dirty, or bare git hash (b9ffe83)
// Format: "OTHER wt v0.9.0" with cyan ANSI codes around OTHER
// Pattern: <cyan>OTHER</cyan> wt VERSION
// Normalize version strings in `wt config show` OTHER section
// wt version can be: v0.8.5, v0.8.5-2-gabcdef, v0.8.5-dirty, or bare git hash (b9ffe83)
// Format: "○ wt: <bold>VERSION</>" on its own line
settings.add_filter(
r"(OTHER\x1b\[39m wt )(?:v[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9]+-g[0-9a-f]+)?(?:-dirty)?|[0-9a-f]{7,40})",
r"(wt: \x1b\[1m)(?:v[0-9]+\.[0-9]+\.[0-9]+(?:-[0-9]+-g[0-9a-f]+)?(?:-dirty)?|[0-9a-f]{7,40})",
"${1}[VERSION]",
);
// git version format: "○ git: <bold>VERSION</>" (e.g., "2.47.1")
settings.add_filter(
r"(git: \x1b\[1m)[0-9]+\.[0-9]+\.[0-9]+[^\x1b]*",
"${1}[VERSION]",
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,7 +46,9 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed. To install, run:
  claude plugin marketplace add max-sixty/worktrunk
  claude plugin install worktrunk@worktrunk
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -59,6 +59,8 @@ exit_code: 0
  ○ Ran command:
    nonexistent-llm-command-12345 -m test-model

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -51,6 +51,8 @@ exit_code: 0
↳ CI status requires GitHub or GitLab remote
↳ Commit generation not configured

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -52,6 +52,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -52,6 +52,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_EDITOR: ""
HOME: "[TEST_HOME]"
PATH: "[PATH]"
Expand Down Expand Up @@ -38,6 +38,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -50,6 +50,8 @@ exit_code: 0

↳ To enable shell integration, run wt config shell install

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
✓ Claude Code plugin installed
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -46,6 +46,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -53,6 +53,8 @@ exit_code: 0

↳ If this is shell integration, report a false negative: https://github.com/max-sixty/worktrunk/issues/new?title=Shell%20integration%20detection%20false%20negative&body=Shell%20integration%20not%20detected%20despite%20config%20containing%20%60wt%60.%0A%0A%2A%2AUnmatched%20lines%3A%2A%2A%0A%60%60%60%0Aalias%20wt%3D%22git%20worktree%22%0A%60%60%60%0A%0A%2A%2AExpected%20behavior%3A%2A%2A%20These%20lines%20should%20be%20detected%20as%20shell%20integration.

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ info:
env:
APPDATA: "[TEST_CONFIG_HOME]"
CLICOLOR_FORCE: "1"
COLUMNS: "150"
COLUMNS: "500"
GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
Expand Down Expand Up @@ -48,6 +48,8 @@ exit_code: 0
○ Skipped zsh; ~/.zshrc not found
○ Skipped fish; ~/.config/fish/conf.d not found

OTHER wt [VERSION]
OTHER
○ wt: [VERSION]
○ git: [VERSION]
↳ Claude Code plugin not installed (claude not found)
○ Hyperlinks: inactive
Loading