diff --git a/.claude-plugin/skills/worktrunk/reference/README.md b/.claude-plugin/skills/worktrunk/reference/README.md index b37a94419c..b5ff4394a7 100644 --- a/.claude-plugin/skills/worktrunk/reference/README.md +++ b/.claude-plugin/skills/worktrunk/reference/README.md @@ -91,7 +91,7 @@ everything — standard `git worktree` commands continue working fine. ### LLM-Authored Commit Messages -Worktrunk can invoke an external commands during merge operations to generate +Worktrunk can invoke external commands during merge operations to generate commit messages. Simon Willison's [llm](https://llm.datasette.io/) tool reads the diff and a configurable prompt, then returns a formatted commit message. @@ -831,9 +831,7 @@ The custom emoji appears directly after the git status symbols. Claude Code can automatically set/clear emoji status when coding sessions start and end. This shows which branches have active AI sessions. -**Easy setup:** The Worktrunk repository includes a `.claude-plugin` directory with pre-configured hooks. When working in this repository, the hooks are automatically available. - -**Manual setup for other repositories:** Copy the hooks from [`.claude-plugin/hooks/hooks.json`](.claude-plugin/hooks/hooks.json) to `~/.claude/settings.json`. +**Easy setup:** The Worktrunk repository includes a `.claude-plugin` directory with pre-configured hooks. When using Claude: @@ -841,7 +839,7 @@ When using Claude: - Changes to `💬` when Claude needs input (waiting for permission or idle) - Clears the status completely when the session ends -**Status from other terminal:** +**Status from another terminal:** @@ -862,7 +860,6 @@ dirty-with-status ≡?🤖 ./dirty-with-status b8346 - Status is stored as `worktrunk.status.` in `.git/config` - Each branch can have its own status emoji - The hooks automatically detect the current branch and set/clear its status -- Status is shared across all worktrees on the same branch (by design) - Works with any git repository, no special configuration needed diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 13bda3ea55..ce672a7a6e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -5,6 +5,7 @@ on: branches: [ main ] pull_request: branches: [ main ] + workflow_dispatch: env: CARGO_TERM_COLOR: always diff --git a/.github/workflows/tier-2-integration-tests.yml b/.github/workflows/tier-2-integration-tests.yml index 4259f06277..b48e9c62a1 100644 --- a/.github/workflows/tier-2-integration-tests.yml +++ b/.github/workflows/tier-2-integration-tests.yml @@ -5,6 +5,7 @@ on: branches: [ main ] pull_request: branches: [ main ] + workflow_dispatch: env: CARGO_TERM_COLOR: always diff --git a/src/commands/list/model.rs b/src/commands/list/model.rs index ad793f9f1a..3096f77227 100644 --- a/src/commands/list/model.rs +++ b/src/commands/list/model.rs @@ -534,8 +534,10 @@ pub struct StatusSymbols { impl StatusSymbols { /// Render symbols with full alignment (all positions) /// - /// This is used for the display fields in JSON output. - /// For table rendering with selective positions, use `render_with_mask()`. + /// This is used for the display fields in JSON output. Skipped on Windows + /// to avoid an unused/dead-code warning in clippy (the interactive selector + /// that calls this exists only on Unix). + #[cfg(unix)] pub fn render(&self) -> String { self.render_with_mask(&PositionMask::FULL) } diff --git a/tests/integration_tests/e2e_shell_post_start.rs b/tests/integration_tests/e2e_shell_post_start.rs index 3c6f317802..85e0e45b36 100644 --- a/tests/integration_tests/e2e_shell_post_start.rs +++ b/tests/integration_tests/e2e_shell_post_start.rs @@ -5,7 +5,22 @@ use crate::common::{ use rstest::rstest; use std::fs; use std::thread; -use std::time::Duration; +use std::time::{Duration, Instant}; + +fn wait_for_file(path: &std::path::Path, timeout: Duration) { + let start = Instant::now(); + while start.elapsed() < timeout { + if path.exists() { + return; + } + thread::sleep(Duration::from_millis(50)); + } + panic!( + "File was not created within {:?}: {}", + timeout, + path.display() + ); +} /// Test that post-start background commands work with shell integration #[rstest] @@ -71,9 +86,6 @@ approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt" output ); - // Wait for background command to complete (command has sleep 0.05 + margin) - thread::sleep(Duration::from_millis(150)); - // Verify background command actually ran let worktree_path = repo .root_path() @@ -105,14 +117,13 @@ approved-commands = ["sleep 0.05 && echo 'Background task done' > bg_marker.txt" log_files ); - let marker_file = worktree_path.join("bg_marker.txt"); - assert!( - marker_file.exists(), - "Background command should have created bg_marker.txt in {} (logs: {:?})", - worktree_path.display(), - log_files + // Wait for background command to complete (allow plenty of margin on CI) + wait_for_file( + worktree_path.join("bg_marker.txt").as_path(), + Duration::from_secs(1), ); + let marker_file = worktree_path.join("bg_marker.txt"); let content = fs::read_to_string(&marker_file).expect("Failed to read marker file"); assert!( content.contains("Background task done"), @@ -321,8 +332,16 @@ approved-commands = ["sleep 0.05 && echo 'Fish background done' > fish_bg.txt"] output ); - // Wait for background command (command has sleep 0.05 + margin) - thread::sleep(Duration::from_millis(150)); + // Wait for background command (allow plenty of margin on CI) + wait_for_file( + repo.root_path() + .parent() + .unwrap() + .join("test-repo.fish-bg-test") + .join("fish_bg.txt") + .as_path(), + Duration::from_secs(1), + ); // Verify background command ran let worktree_path = repo diff --git a/tests/integration_tests/list.rs b/tests/integration_tests/list.rs index 049dc5bb0a..8e476a47e8 100644 --- a/tests/integration_tests/list.rs +++ b/tests/integration_tests/list.rs @@ -1611,75 +1611,61 @@ fn test_list_maximum_status_symbols() { .output() .unwrap(); - // Create a remote repo by cloning to a separate directory - let remote_dir = repo.root_path().parent().unwrap().join("remote-repo"); - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args([ - "clone", - repo.root_path().to_str().unwrap(), - remote_dir.to_str().unwrap(), - ]) - .output() - .unwrap(); + // Create a real bare remote so upstream exists, but keep all graph crafting local for determinism + repo.setup_remote("main"); - // In the remote repo, check out feature branch and make a commit - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["checkout", "feature"]) - .current_dir(&remote_dir) - .output() - .unwrap(); + // Remember the shared base (Feature work) + let base_sha = { + let output = repo + .git_command(&["rev-parse", "HEAD"]) + .current_dir(&feature) + .output() + .unwrap(); + String::from_utf8_lossy(&output.stdout).trim().to_string() + }; - std::fs::write(remote_dir.join("remote-file.txt"), "remote content").unwrap(); - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["add", "remote-file.txt"]) - .current_dir(&remote_dir) + // Remote-only commit + std::fs::write(feature.join("remote-file.txt"), "remote content").unwrap(); + repo.git_command(&["add", "remote-file.txt"]) + .current_dir(&feature) .output() .unwrap(); - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["commit", "-m", "Remote commit"]) - .current_dir(&remote_dir) + repo.git_command(&["commit", "-m", "Remote commit"]) + .current_dir(&feature) .output() .unwrap(); + let remote_sha = { + let output = repo + .git_command(&["rev-parse", "HEAD"]) + .current_dir(&feature) + .output() + .unwrap(); + String::from_utf8_lossy(&output.stdout).trim().to_string() + }; - // In the local feature worktree, make a different commit (creates divergence) - std::fs::write(feature.join("local-file.txt"), "local content").unwrap(); - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["add", "local-file.txt"]) + // Reset back to base so the remote commit is not in the local branch history + repo.git_command(&["reset", "--hard", &base_sha]) .current_dir(&feature) .output() .unwrap(); - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["commit", "-m", "Local commit"]) + + // Local-only commit (divergence on the local side) + std::fs::write(feature.join("local-file.txt"), "local content").unwrap(); + repo.git_command(&["add", "local-file.txt"]) .current_dir(&feature) .output() .unwrap(); - - // Set up the remote repo as origin for the feature worktree - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["remote", "add", "origin", remote_dir.to_str().unwrap()]) + repo.git_command(&["commit", "-m", "Local commit"]) .current_dir(&feature) .output() .unwrap(); - // Fetch from the remote to establish tracking - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["fetch", "origin"]) + // Wire up upstream tracking deterministically: point origin/feature at the remote-only commit + repo.git_command(&["update-ref", "refs/remotes/origin/feature", &remote_sha]) .current_dir(&feature) .output() .unwrap(); - - // Set up branch tracking - let mut cmd = Command::new("git"); - repo.configure_git_cmd(&mut cmd); - cmd.args(["branch", "--set-upstream-to=origin/feature", "feature"]) + repo.git_command(&["branch", "--set-upstream-to=origin/feature", "feature"]) .current_dir(&feature) .output() .unwrap(); @@ -1749,17 +1735,7 @@ fn test_list_maximum_status_symbols() { .unwrap(); // Result should show 11 chars: ?!+»✘=⊠↕⇅🤖 - // - // Note: Git's ahead/behind calculation for clone-based remotes is platform-dependent: - // - Ubuntu: reports behind=0, shows ⇡ (ahead only) - // - macOS: reports behind=1, shows ⇅ (diverged) - // We normalize the flaky upstream divergence symbol and behind count to accept either. - let mut settings = list_snapshots::standard_settings(&repo); - // Normalize upstream divergence: accept both ⇡ (ahead) and ⇅ (diverged) - // Note: Yellow ANSI code (\x1b[33m) appears before the ⊠ symbol - settings.add_filter(r"↕[⇡⇅]\x1b\[33m⊠", "↕[UPSTREAM]\x1b[33m⊠"); - // Normalize remote behind count: accept both ↓0 and ↓1 - settings.add_filter(r"↓[01]", "↓[N]"); + let settings = list_snapshots::standard_settings(&repo); settings.bind(|| { let mut cmd = list_snapshots::command(&repo, repo.root_path()); cmd.arg("--full"); diff --git a/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap b/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap index cdf328d1ba..2a80c64bca 100644 --- a/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap +++ b/tests/snapshots/integration__integration_tests__list__maximum_status_symbols.snap @@ -12,11 +12,10 @@ info: GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z" GIT_CONFIG_GLOBAL: /dev/null GIT_CONFIG_SYSTEM: /dev/null - GIT_EDITOR: "" LANG: C LC_ALL: C SOURCE_DATE_EPOCH: "1761609600" - WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpLJgbF4/test-config.toml + WORKTRUNK_CONFIG_PATH: /var/folders/wf/s6ycxvvs4ln8qsdbfx40hnc40000gn/T/.tmpoGHFYx/test-config.toml --- success: true exit_code: 0 @@ -24,7 +23,7 @@ exit_code: 0 ----- stderr ----- Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message -main ./test-repo 85ed6d3d 10 months ago Main advances -feature ?!+»✘= ↕[UPSTREAM]⊠🤖 +2 -2 ↑2 ↓[N] +3 -1 ./feature ↑1 ↓[N] 4afb2b9e 10 months ago Local commit +main ⇡ ./test-repo ↑1 ↓0 85ed6d3d 10 months ago Main advances +feature ?!+»✘= ↕⇅⊠🤖 +2 -2 ↑2 ↓1 +3 -1 ./feature ↑1 ↓1 4afb2b9e 10 months ago Local commit ⚪ Showing 2 worktrees, 1 with changes, 1 ahead