Skip to content

Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows

fix: delegate tea login discovery and preserve settings key order (#4420)

Maximilian Roos074a92561223
diff --git a/Cargo.toml b/Cargo.toml
index 64abafe67..950227a66 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -207,7 +207,7 @@ minijinja = { version = "2.24", default-features = false, features = [
] }
rayon = "1.12"
serde = { version = "1.0.228", features = ["derive"] }
-serde_json = "1.0.150"
+serde_json = { version = "1.0.150", features = ["preserve_order"] }
shell-escape = "0.1"
shellexpand = "3.1"
strsim = "0.11.1"
diff --git a/src/commands/config/show.rs b/src/commands/config/show.rs
index 859352ef5..b593e1dba 100644
--- a/src/commands/config/show.rs
+++ b/src/commands/config/show.rs
@@ -583,7 +583,7 @@ fn render_diagnostics(out: &mut String, repo: Option<&Repository>) -> anyhow::Re
// falls through to the hint and the remaining checks still run.
match repo.and_then(|repo| Some((repo, repo.ci_platform(None)?))) {
Some((_, ForgeKind::GitHub)) => {
- let ci_tools = CiToolsStatus::detect(None);
+ let ci_tools = CiToolsStatus::detect(None)?;
render_ci_tool_status(
out,
"gh",
@@ -593,7 +593,7 @@ fn render_diagnostics(out: &mut String, repo: Option<&Repository>) -> anyhow::Re
);
}
Some((_, ForgeKind::GitLab)) => {
- let ci_tools = CiToolsStatus::detect(None);
+ let ci_tools = CiToolsStatus::detect(None)?;
render_ci_tool_status(
out,
"glab",
@@ -603,7 +603,7 @@ fn render_diagnostics(out: &mut String, repo: Option<&Repository>) -> anyhow::Re
);
}
Some((_, ForgeKind::Gitea)) => {
- let ci_tools = CiToolsStatus::detect(None);
+ let ci_tools = CiToolsStatus::detect(None)?;
render_ci_tool_status(
out,
"tea",
@@ -613,7 +613,7 @@ fn render_diagnostics(out: &mut String, repo: Option<&Repository>) -> anyhow::Re
);
}
Some((repo, ForgeKind::AzureDevOps)) => {
- let ci_tools = CiToolsStatus::detect(None);
+ let ci_tools = CiToolsStatus::detect(None)?;
render_ci_tool_status(
out,
"az",
diff --git a/src/commands/list/ci_status/mod.rs b/src/commands/list/ci_status/mod.rs
index 44ed5eb5f..c0b5e7002 100644
--- a/src/commands/list/ci_status/mod.rs
+++ b/src/commands/list/ci_status/mod.rs
@@ -238,7 +238,7 @@ impl CiToolsStatus {
/// If `gitlab_host` is provided, checks glab auth status against that specific
/// host instead of the default. This is important for self-hosted GitLab instances
/// where the default host (gitlab.com) may be unreachable.
- pub fn detect(gitlab_host: Option<&str>) -> Self {
+ pub fn detect(gitlab_host: Option<&str>) -> anyhow::Result<Self> {
let gh_installed = tool_available("gh", &["--version"]);
let gh_authenticated = gh_installed && tool_available("gh", &["auth", "status"]);
let glab_installed = tool_available("glab", &["--version"]);
@@ -249,15 +249,14 @@ impl CiToolsStatus {
tool_available("glab", &["auth", "status"])
};
let tea_installed = tool_available("tea", &["--version"]);
- // `tea` stores logins in its config file; reading it (rather than
- // invoking `tea`) avoids the OAuth-refresh side effect a `tea` lookup
- // can trigger. See `git::remote_ref::gitea`.
- let tea_authenticated = tea_installed && worktrunk::git::remote_ref::gitea::has_any_login();
+ // The shared tea login probe reads local config through `logins list`.
+ let tea_authenticated =
+ tea_installed && worktrunk::git::remote_ref::gitea::has_any_login()?;
let az_installed = tool_available("az", &["--version"]);
// `az account show` exits non-zero when logged out — works whether or not
// the azure-devops extension is installed.
let az_authenticated = az_installed && tool_available("az", &["account", "show"]);
- Self {
+ Ok(Self {
gh_installed,
gh_authenticated,
glab_installed,
@@ -266,7 +265,7 @@ impl CiToolsStatus {
tea_authenticated,
az_installed,
az_authenticated,
- }
+ })
}
}
diff --git a/src/commands/list/json_v2.rs b/src/commands/list/json_v2.rs
index 02a37a82c..2150a0006 100644
--- a/src/commands/list/json_v2.rs
+++ b/src/commands/list/json_v2.rs
@@ -126,6 +126,8 @@ pub fn schema_document() -> serde_json::Value {
"title".to_string(),
"wt list --format=json (schema 2)".into(),
);
+ // Keep the published schema stable regardless of JSON map storage order.
+ value.sort_all_objects();
value
}
diff --git a/src/commands/worktree/switch.rs b/src/commands/worktree/switch.rs
index f4930df8b..679fc9f24 100644
--- a/src/commands/worktree/switch.rs
+++ b/src/commands/worktree/switch.rs
@@ -172,7 +172,7 @@ fn choose_pr_forge(repo: &Repository) -> anyhow::Result<ForgeKind> {
return Ok(ForgeKind::GitHub);
};
- if remote_ref::gitea::is_authed_for(&host) && !remote_ref::github::is_authed_for(&host) {
+ if remote_ref::gitea::is_authed_for(&host)? && !remote_ref::github::is_authed_for(&host) {
Ok(ForgeKind::Gitea)
} else {
Ok(ForgeKind::GitHub)
diff --git a/src/git/remote_ref/gitea.rs b/src/git/remote_ref/gitea.rs
index f43c4c7fb..c7b18f6ed 100644
--- a/src/git/remote_ref/gitea.rs
+++ b/src/git/remote_ref/gitea.rs
@@ -32,14 +32,14 @@
//! resolves its own context.
use anyhow::{Context, bail};
-use etcetera::base_strategy::{BaseStrategy, Xdg};
use serde::Deserialize;
use super::{
CliApiRequest, PlatformData, RemoteRefInfo, cli_api_error, extract_host_from_html_url,
run_cli_api,
};
-use crate::git::{ForgeKind, Repository};
+use crate::git::{CommandError, ErrorExt, ForgeKind, Repository, WorktrunkError};
+use crate::shell_exec::Cmd;
/// Raw JSON response from `tea api repos/{owner}/{repo}/pulls/{number}`.
#[derive(Debug, Deserialize)]
@@ -315,83 +315,60 @@ pub fn fork_remote_url(host: &str, owner: &str, repo: &str) -> String {
/// Whether `tea` has a login configured for `host`.
///
-/// Used by the switch dispatcher to decide which forge CLI to try when the
-/// remote URL doesn't unambiguously identify the forge. Reads tea's config
-/// file directly — `$XDG_CONFIG_HOME/tea/config.yml` (default
-/// `~/.config/tea/config.yml`) with legacy fallback `~/.tea/tea.yml` — and
-/// returns true if any `logins[].url` parses to the same host. Pure local
-/// I/O; never invokes `tea` (which can trigger an OAuth refresh on lookup).
-pub fn is_authed_for(host: &str) -> bool {
- read_tea_config().is_some_and(|content| config_has_login_for(&content, host))
+/// Used by the switch dispatcher for ambiguous forge hosts. Login discovery is
+/// local-only; the shared login probe below owns that contract.
+pub fn is_authed_for(host: &str) -> anyhow::Result<bool> {
+ Ok(load_logins()?.iter().any(|login| {
+ login.ssh_host.eq_ignore_ascii_case(host)
+ || extract_host_from_html_url(&login.url)
+ .is_ok_and(|login_host| login_host.eq_ignore_ascii_case(host))
+ }))
}
-/// Pure parser: scan tea's `config.yml` content for a `logins[].url` whose
-/// host matches `target`. Extracted from `is_authed_for` so the YAML-shaped
-/// matching can be unit-tested without touching the filesystem or env vars.
-fn config_has_login_for(content: &str, target: &str) -> bool {
- content.lines().any(|line| {
- let trimmed = line.trim_start();
- let Some(rest) = trimmed.strip_prefix("url:") else {
- return false;
- };
- let value = rest.trim().trim_matches(|c: char| c == '"' || c == '\'');
- let Some(without_scheme) = value
- .strip_prefix("https://")
- .or_else(|| value.strip_prefix("http://"))
- else {
- return false;
- };
- let host = without_scheme.split(['/', '?', '#']).next().unwrap_or("");
- host.eq_ignore_ascii_case(target)
- })
-}
-
-/// Whether `tea` has *any* login configured (host-agnostic).
-///
-/// Used by `wt config show` diagnostics to report Gitea auth status when the
-/// caller has no specific host in hand. Like [`is_authed_for`], reads tea's
-/// config file directly rather than invoking `tea` (which can trigger an OAuth
-/// refresh on lookup).
-pub fn has_any_login() -> bool {
- read_tea_config().is_some_and(|content| content_has_any_login(&content))
+/// Whether `tea` has any login configured, for host-agnostic diagnostics.
+pub fn has_any_login() -> anyhow::Result<bool> {
+ Ok(!load_logins()?.is_empty())
}
-/// Pure parser: true if any line is a `url:` entry carrying an http(s) URL.
-/// Mirrors the line shape `config_has_login_for` matches, minus the host check.
-fn content_has_any_login(content: &str) -> bool {
- content.lines().any(|line| {
- let Some(rest) = line.trim_start().strip_prefix("url:") else {
- return false;
- };
- let value = rest.trim().trim_matches(|c: char| c == '"' || c == '\'');
- value.starts_with("https://") || value.starts_with("http://")
- })
+/// The login-list JSON carries display fields, with no authentication tokens.
+#[derive(Debug, Deserialize)]
+struct TeaLogin {
+ url: String,
+ ssh_host: String,
}
-/// Read tea's config.yml, honoring `$XDG_CONFIG_HOME` and the legacy
-/// `~/.tea/tea.yml` fallback. Returns None if neither file is readable.
+/// Ask tea to read its own local config, including its platform-specific paths
+/// and legacy fallback. Unlike API login lookup, `logins list` does not
+/// refresh OAuth tokens or contact the server. Both auth consumers use this
+/// command so config discovery and YAML parsing remain tea's responsibility.
///
-/// The base directory comes from etcetera's XDG strategy — the crate worktrunk
-/// already resolves its own config with — so the spec's exclusions apply: an
-/// exported-but-empty or relative value falls back to `~/.config` instead of
-/// resolving `tea/config.yml` against whatever directory `wt` was invoked
-/// from, which would leave the user's tea logins unread and silently drop the
-/// Gitea CI column from `wt list --full` and send `wt switch pr:<n>` to GitHub.
-///
-/// `Xdg` specifically, not `choose_base_strategy`: tea honors `$XDG_CONFIG_HOME`
-/// on every platform and this keeps that. Its *default* is
-/// `github.com/adrg/xdg`'s — `~/Library/Application Support` on macOS,
-/// `%LOCALAPPDATA%` on Windows, `~/.config` elsewhere — so only the Linux
-/// default is matched here; `choose_base_strategy` would pick
-/// `~/Library/Preferences` and `%APPDATA%`, matching tea on neither.
-fn read_tea_config() -> Option<String> {
- let xdg = Xdg::new().ok()?;
- [
- xdg.config_dir().join("tea").join("config.yml"),
- xdg.home_dir().join(".tea").join("tea.yml"),
- ]
- .into_iter()
- .find_map(|path| std::fs::read_to_string(path).ok())
+/// An absent or failing CLI means no known login, matching the auth probes for
+/// other forges. Debug logging distinguishes failure from an empty login list.
+/// Native SIGINT/SIGTERM must propagate so callers stop subsequent probes.
+fn load_logins() -> anyhow::Result<Vec<TeaLogin>> {
+ let args = ["logins", "list", "--output", "json"];
+ let output = match Cmd::new("tea").args(args).run() {
+ Ok(output) => output,
+ Err(error) => {
+ log::debug!("Failed to run tea logins list: {error}");
+ return Ok(Vec::new());
+ }
+ };
+ if !output.status.success() {
+ let error: anyhow::Error = CommandError::from_failed_output("tea", &args, &output).into();
+ if let Some(signal) = error.interrupt_signal() {
+ return Err(WorktrunkError::Interrupted { signal, hint: None }.into());
+ }
+ log::debug!("tea logins list failed: {}", error.display_message());
+ return Ok(Vec::new());
+ }
+ match serde_json::from_slice(&output.stdout) {
+ Ok(logins) => Ok(logins),
+ Err(error) => {
+ log::debug!("Failed to parse tea logins list JSON: {error}");
+ Ok(Vec::new())
+ }
+ }
}
#[cfg(test)]
@@ -605,48 +582,4 @@ mod tests {
None
);
}
-
- #[test]
- fn test_config_has_login_for_matches_known_hosts() {
- // tea writes one entry per `tea login add`. Match by host extracted
- // from the URL — case-insensitive, scheme-agnostic, ignores trailing
- // path/query.
- let yaml = r#"logins:
- - name: gitea-com
- url: https://gitea.com
- default: true
- - name: selfhosted
- url: "https://forge.example.com/"
- - name: with-path
- url: http://other.test/api/v1
-"#;
- assert!(config_has_login_for(yaml, "gitea.com"));
- assert!(config_has_login_for(yaml, "GITEA.COM"));
- assert!(config_has_login_for(yaml, "forge.example.com"));
- assert!(config_has_login_for(yaml, "other.test"));
- assert!(!config_has_login_for(yaml, "not-configured.test"));
- // Empty config has no logins.
- assert!(!config_has_login_for("", "gitea.com"));
- // Stray `url:` outside a logins entry must not match — but the parser
- // is line-based and intentionally permissive; document the trade-off
- // by asserting the tea-shaped scheme-prefixed form is required.
- assert!(!config_has_login_for("url: gitea.com\n", "gitea.com"));
- }
-
- #[test]
- fn test_content_has_any_login() {
- let yaml = r#"logins:
- - name: gitea-com
- url: https://gitea.com
- default: true
-"#;
- assert!(content_has_any_login(yaml));
- assert!(content_has_any_login(
- " url: \"http://forge.example.com/\"\n"
- ));
- // No logins / no scheme-prefixed url.
- assert!(!content_has_any_login(""));
- assert!(!content_has_any_login("logins: []\n"));
- assert!(!content_has_any_login("url: gitea.com\n"));
- }
}
diff --git a/src/logging.rs b/src/logging.rs
index b31f6912e..c575cbab9 100644
--- a/src/logging.rs
+++ b/src/logging.rs
@@ -373,8 +373,8 @@ impl tracing::field::Visit for JsonFieldVisitor {
/// `ts`/`tid` from the runtime *only if the event did not carry them* (a
/// `[wt-trace]` record sets its own, captured at the precise event moment; a
/// bridged `log::*` line carries neither, so it gets the emission-time values),
-/// and stamps the metadata `level`. Field order is serde_json's default
-/// (sorted) -- irrelevant to a machine reader.
+/// and stamps the metadata `level`. Fields retain insertion order, which is
+/// irrelevant to a machine reader.
fn event_json(event: &Event<'_>) -> String {
let mut visitor = JsonFieldVisitor::default();
event.record(&mut visitor);
@@ -966,7 +966,7 @@ mod tests {
/// `event_json` serializes whatever typed fields an event carries, then
/// stamps `level` and fills `ts`/`tid` only when the event omitted them.
/// Drives real events through a capture layer (the only way to obtain a
- /// `tracing::Event`). Keys land in serde_json's sorted order.
+ /// `tracing::Event`). Keys retain insertion order.
#[test]
fn event_json_serializes_structured_and_freeform_events() {
use std::sync::{Arc, Mutex};
@@ -1015,10 +1015,20 @@ mod tests {
});
let lines = lines.lock().unwrap();
- // Structured record: rich, keys sorted, `level` stamped, ts/tid kept.
+ // Structured record: rich, `level` stamped, ts/tid kept.
assert_eq!(
- lines[0],
- r#"{"cmd":"git status","context":"worktree","dur_us":12300,"kind":"cmd_completed","level":"debug","ok":true,"seq":1,"tid":3,"ts":100}"#
+ serde_json::from_str::<serde_json::Value>(&lines[0]).expect("valid JSON"),
+ serde_json::json!({
+ "cmd": "git status",
+ "context": "worktree",
+ "dur_us": 12300,
+ "kind": "cmd_completed",
+ "level": "debug",
+ "ok": true,
+ "seq": 1,
+ "tid": 3,
+ "ts": 100,
+ })
);
// Embedded quote round-trips losslessly.
diff --git a/src/testing/mod.rs b/src/testing/mod.rs
index ecc7f2aec..3487fdee4 100644
--- a/src/testing/mod.rs
+++ b/src/testing/mod.rs
@@ -2189,6 +2189,7 @@ impl TestRepo {
.expect("call setup_mock_ci_tools_unauthenticated() first");
MockConfig::new("tea")
.version("tea version development (mock)")
+ .command("logins list --output", MockResponse::output("[]"))
.write(mock_bin);
}
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index f7cf01a51..bbc1b1525 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -1648,6 +1648,152 @@ fn test_config_show_full_gitea_remote(mut repo: TestRepo, temp_home: TempDir) {
});
}
+/// tea owns login discovery; Worktrunk reads only its structured, local-only
+/// command output. The mock replaces the external tea CLI, not our process
+/// wiring or diagnostics logic.
+#[rstest]
+#[case::login(r#"[{"name":"local","url":"https://forge.example.test","ssh_host":"","user":"alice","default":"true"}]"#, 0, true)]
+#[case::empty("[]", 0, false)]
+#[case::invalid_json("not JSON", 0, false)]
+#[case::invalid_shape(r#"[{"name":"missing-url"}]"#, 0, false)]
+#[case::failed("[]", 1, false)]
+fn test_config_show_full_tea_login_discovery(
+ mut repo: TestRepo,
+ #[case] logins: &str,
+ #[case] exit_code: i32,
+ #[case] authenticated: bool,
+) {
+ use crate::common::mock_commands::MockConfig;
+
+ repo.setup_mock_ci_tools_unauthenticated();
+ MockConfig::new("tea")
+ .version("tea version development (mock)")
+ .command(
+ "logins list --output",
+ MockResponse::output(logins).with_exit_code(exit_code),
+ )
+ .command("_default", MockResponse::exit(1))
+ .write(repo.mock_bin_path().unwrap());
+ repo.run_git(&[
+ "remote",
+ "set-url",
+ "origin",
+ "https://gitea.example.com/example/repo.git",
+ ]);
+ let call_log = tempfile::tempdir().unwrap();
+ let output = repo
+ .wt_command()
+ .args(["config", "show", "--full"])
+ .env("WORKTRUNK_TEST_LATEST_VERSION", env!("CARGO_PKG_VERSION"))
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .output()
+ .unwrap();
+ assert!(output.status.success(), "{output:?}");
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ let plain = stdout.ansi_strip();
+ let status = if authenticated {
+ "tea installed & authenticated"
+ } else {
+ "tea installed but not authenticated"
+ };
+ assert!(plain.contains(status), "{plain}");
+ let calls = fs::read_to_string(call_log.path().join("tea.calls")).unwrap();
+ assert_eq!(
+ calls.lines().collect::<Vec<_>>(),
+ ["--version", "logins list --output json"]
+ );
+}
+
+/// Each forge's diagnostics use the shared probe while rendering only the
+/// CLI selected by the repository's remote.
+#[rstest]
+#[case::github("github.com", "gh", "glab")]
+#[case::gitlab("gitlab.com", "glab", "gh")]
+fn test_config_show_full_forge_diagnostics(
+ mut repo: TestRepo,
+ #[case] host: &str,
+ #[case] selected_cli: &str,
+ #[case] other_cli: &str,
+) {
+ use crate::common::mock_commands::MockConfig;
+
+ repo.setup_mock_ci_tools_unauthenticated();
+ let mock_bin = repo.mock_bin_path().unwrap();
+ MockConfig::new("tea")
+ .version("tea version development (mock)")
+ .command("logins list --output", MockResponse::output("[]"))
+ .command("_default", MockResponse::exit(1))
+ .write(mock_bin);
+ MockConfig::new("az")
+ .command("_default", MockResponse::exit(1))
+ .write(mock_bin);
+ repo.run_git(&[
+ "remote",
+ "set-url",
+ "origin",
+ &format!("https://{host}/example/repo.git"),
+ ]);
+ let output = repo
+ .wt_command()
+ .args(["config", "show", "--full"])
+ .env("WORKTRUNK_TEST_LATEST_VERSION", env!("CARGO_PKG_VERSION"))
+ .output()
+ .unwrap();
+ assert!(output.status.success(), "{output:?}");
+ let stdout = String::from_utf8_lossy(&output.stdout);
+ let plain = stdout.ansi_strip();
+ assert!(
+ plain.contains(&format!("{selected_cli} installed but not authenticated")),
+ "{plain}"
+ );
+ assert!(
+ !plain.contains(&format!("{other_cli} installed")),
+ "{plain}"
+ );
+}
+
+/// Diagnostics stop after a tea login probe is natively interrupted, before
+/// starting the next tool's probe.
+#[cfg(unix)]
+#[rstest]
+fn test_config_show_full_tea_login_native_interruption(mut repo: TestRepo) {
+ use crate::common::mock_commands::MockConfig;
+ use std::os::unix::fs::PermissionsExt;
+ use std::os::unix::process::ExitStatusExt;
+
+ repo.setup_mock_ci_tools_unauthenticated();
+ let mock_bin = repo.mock_bin_path().unwrap();
+ let tea = mock_bin.join("tea");
+ fs::write(
+ &tea,
+ r#"#!/bin/sh
+if [ "$1" = --version ]; then exit 0; fi
+kill -INT $$
+"#,
+ )
+ .unwrap();
+ fs::set_permissions(&tea, fs::Permissions::from_mode(0o755)).unwrap();
+ MockConfig::new("az")
+ .command("_default", MockResponse::exit(1))
+ .write(mock_bin);
+ repo.run_git(&[
+ "remote",
+ "set-url",
+ "origin",
+ "https://gitea.example.com/example/repo.git",
+ ]);
+ let call_log = tempfile::tempdir().unwrap();
+ let output = repo
+ .wt_command()
+ .args(["config", "show", "--full"])
+ .env("WORKTRUNK_TEST_LATEST_VERSION", env!("CARGO_PKG_VERSION"))
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .output()
+ .unwrap();
+ assert_eq!(output.status.signal(), Some(2), "{output:?}");
+ assert!(!call_log.path().join("az.calls").exists());
+}
+
/// `wt config show --full` against an Azure DevOps remote reports the `az` CLI
/// row plus the `azure-devops` extension, which the whole `az repos` command
/// group ships in: without it CI status stays blank however well `az` is
@@ -6540,12 +6686,13 @@ fn test_plugins_claude_install_statusline_foreign_command(repo: TestRepo, temp_h
#[rstest]
fn test_plugins_claude_install_statusline_preserves_existing(repo: TestRepo, temp_home: TempDir) {
- // Write existing settings with other keys
+ // Deliberately unsorted keys at both levels: installing the statusline
+ // must preserve the user's ordering as well as their values.
let claude_dir = temp_home.path().join(".claude");
fs::create_dir_all(&claude_dir).unwrap();
fs::write(
claude_dir.join("settings.json"),
- r#"{"existingKey":"existingValue"}"#,
+ r#"{"zebra":true,"existingKey":{"zulu":1,"alpha":2},"alpha":"last"}"#,
)
.unwrap();
@@ -6559,15 +6706,22 @@ fn test_plugins_claude_install_statusline_preserves_existing(repo: TestRepo, tem
assert_cmd_snapshot!(cmd);
- // Verify existing keys are preserved
let settings_path = temp_home.path().join(".claude/settings.json");
let content = fs::read_to_string(&settings_path).unwrap();
- let parsed: serde_json::Value = serde_json::from_str(&content).unwrap();
- assert_eq!(parsed["existingKey"], "existingValue");
- assert_eq!(
- parsed["statusLine"]["command"],
- "wt list statusline --format=claude-code"
- );
+ insta::assert_snapshot!(content, @r#"
+ {
+ "zebra": true,
+ "existingKey": {
+ "zulu": 1,
+ "alpha": 2
+ },
+ "alpha": "last",
+ "statusLine": {
+ "type": "command",
+ "command": "wt list statusline --format=claude-code"
+ }
+ }
+ "#);
});
}
diff --git a/tests/integration_tests/config_state.rs b/tests/integration_tests/config_state.rs
index ad07cf2f7..9414ff0fa 100644
--- a/tests/integration_tests/config_state.rs
+++ b/tests/integration_tests/config_state.rs
@@ -1654,12 +1654,12 @@ fn test_state_cache_get_json_empty(repo: TestRepo) {
assert!(output.status.success());
assert_snapshot!(String::from_utf8_lossy(&output.stdout), @r#"
{
+ "previous_branch": null,
"ci_status": [],
- "git_commands_cache": 0,
- "hints": [],
"max_pr_number": null,
- "previous_branch": null,
- "summaries": []
+ "summaries": [],
+ "git_commands_cache": 0,
+ "hints": []
}
"#);
}
@@ -1699,12 +1699,12 @@ fn test_state_cache_pr_number_ratchet(repo: TestRepo) {
assert!(output.status.success());
assert_snapshot!(String::from_utf8_lossy(&output.stdout), @r#"
{
+ "previous_branch": null,
"ci_status": [],
- "git_commands_cache": 0,
- "hints": [],
"max_pr_number": 3035,
- "previous_branch": null,
- "summaries": []
+ "summaries": [],
+ "git_commands_cache": 0,
+ "hints": []
}
"#);
@@ -2039,20 +2039,20 @@ fn test_state_get_json_empty(repo: TestRepo) {
assert!(output.status.success());
assert_snapshot!(String::from_utf8_lossy(&output.stdout), @r#"
{
- "ci_status": [],
- "command_log": [],
"default_branch": null,
- "diagnostic": [],
- "git_commands_cache": 0,
- "hints": [],
- "hook_output": [],
+ "remote_head_branch": null,
+ "previous_branch": null,
"markers": [],
+ "ci_status": [],
"max_pr_number": null,
- "previous_branch": null,
- "remote_head_branch": null,
"summaries": [],
- "trash": [],
- "vars": []
+ "git_commands_cache": 0,
+ "vars": [],
+ "command_log": [],
+ "hook_output": [],
+ "diagnostic": [],
+ "hints": [],
+ "trash": []
}
"#);
}
@@ -2122,20 +2122,9 @@ fn test_state_get_json_comprehensive(repo: TestRepo) {
settings.bind(|| {
assert_snapshot!(normalized, @r#"
{
- "ci_status": [
- {
- "branch": "feature",
- "checked_at": 1735776000,
- "head": "abc12345def67890",
- "status": "passed"
- }
- ],
- "command_log": [],
"default_branch": "main",
- "diagnostic": [],
- "git_commands_cache": 1,
- "hints": [],
- "hook_output": [],
+ "remote_head_branch": null,
+ "previous_branch": "feature",
"markers": [
{
"branch": "feature",
@@ -2143,29 +2132,40 @@ fn test_state_get_json_comprehensive(repo: TestRepo) {
"set_at": 1735776000
}
],
- "max_pr_number": null,
- "previous_branch": "feature",
- "remote_head_branch": null,
- "summaries": [
+ "ci_status": [
{
"branch": "feature",
- "generated_at": 1735776000,
- "summary": "Add constant-time token validation"
+ "status": "passed",
+ "checked_at": 1735776000,
+ "head": "abc12345def67890"
}
],
- "trash": [
+ "max_pr_number": null,
+ "summaries": [
{
- "modified_at": "<MTIME>",
- "name": "myproject.feature-1234567890",
- "path": "_REPO_/.git/wt/trash/myproject.feature-1234567890"
+ "branch": "feature",
+ "summary": "Add constant-time token validation",
+ "generated_at": 1735776000
}
],
+ "git_commands_cache": 1,
"vars": [
{
"branch": "main",
"key": "env",
"value": "staging"
}
+ ],
+ "command_log": [],
+ "hook_output": [],
+ "diagnostic": [],
+ "hints": [],
+ "trash": [
+ {
+ "name": "myproject.feature-1234567890",
+ "path": "_REPO_/.git/wt/trash/myproject.feature-1234567890",
+ "modified_at": "<MTIME>"
+ }
]
}
"#);
@@ -2212,48 +2212,48 @@ fn test_state_get_json_with_logs(repo: TestRepo) {
settings.bind(|| {
assert_snapshot!(normalized, @r#"
{
+ "default_branch": null,
+ "remote_head_branch": null,
+ "previous_branch": null,
+ "markers": [],
"ci_status": [],
+ "max_pr_number": null,
+ "summaries": [],
+ "git_commands_cache": 0,
+ "vars": [],
"command_log": [
{
"file": "commands.jsonl",
- "modified_at": "<MTIME>",
"path": "_REPO_/.git/wt/logs/commands.jsonl",
- "size": "<SIZE>"
+ "size": "<SIZE>",
+ "modified_at": "<MTIME>"
}
],
- "default_branch": null,
- "diagnostic": [],
- "git_commands_cache": 0,
- "hints": [],
"hook_output": [
{
- "branch": null,
"file": "bugfix/internal/remove.log",
- "hook_type": null,
- "modified_at": "<MTIME>",
- "name": "remove",
"path": "_REPO_/.git/wt/logs/bugfix/internal/remove.log",
"size": "<SIZE>",
- "source": "internal"
+ "modified_at": "<MTIME>",
+ "branch": null,
+ "source": "internal",
+ "hook_type": null,
+ "name": "remove"
},
{
- "branch": "feature",
"file": "feature/user/post-start/npm.log",
- "hook_type": "post-start",
- "modified_at": "<MTIME>",
- "name": "npm",
"path": "_REPO_/.git/wt/logs/feature/user/post-start/npm.log",
"size": "<SIZE>",
- "source": "user"
+ "modified_at": "<MTIME>",
+ "branch": "feature",
+ "source": "user",
+ "hook_type": "post-start",
+ "name": "npm"
}
],
- "markers": [],
- "max_pr_number": null,
- "previous_branch": null,
- "remote_head_branch": null,
- "summaries": [],
- "trash": [],
- "vars": []
+ "diagnostic": [],
+ "hints": [],
+ "trash": []
}
"#);
});
@@ -3022,8 +3022,8 @@ fn test_logs_get_json_empty(repo: TestRepo) {
assert_snapshot!(String::from_utf8_lossy(&output.stdout), @r#"
{
"command_log": [],
- "diagnostic": [],
- "hook_output": []
+ "hook_output": [],
+ "diagnostic": []
}
"#);
}
@@ -3042,8 +3042,8 @@ fn test_logs_bare_format_json(repo: TestRepo) {
assert_snapshot!(String::from_utf8_lossy(&output.stdout), @r#"
{
"command_log": [],
- "diagnostic": [],
- "hook_output": []
+ "hook_output": [],
+ "diagnostic": []
}
"#);
}
diff --git a/tests/integration_tests/merge.rs b/tests/integration_tests/merge.rs
index 7933a683d..d206571a9 100644
--- a/tests/integration_tests/merge.rs
+++ b/tests/integration_tests/merge.rs
@@ -5771,11 +5771,11 @@ fn test_merge_json(repo: TestRepo) {
assert_snapshot!(String::from_utf8_lossy(&output.stdout), @r#"
{
"branch": "feature",
+ "target": "main",
"committed": false,
- "rebased": false,
- "removed": true,
"squashed": false,
- "target": "main"
+ "rebased": false,
+ "removed": true
}
"#);
}
diff --git a/tests/integration_tests/readme_sync.rs b/tests/integration_tests/readme_sync.rs
index 5a7e5a2c1..7244adfcb 100644
--- a/tests/integration_tests/readme_sync.rs
+++ b/tests/integration_tests/readme_sync.rs
@@ -2506,16 +2506,14 @@ fn sync_terminal_style_manifest(project_root: &Path) -> (Vec<String>, Vec<String
return (errors, updated_files);
}
- let generated = format!(
- "{}\n",
- serde_json::to_string_pretty(
- &blocks
- .into_iter()
- .map(|(plain, lines)| serde_json::json!({ "plain": plain, "lines": lines }))
- .collect::<Vec<_>>()
- )
- .unwrap()
+ let mut manifest = serde_json::Value::Array(
+ blocks
+ .into_iter()
+ .map(|(plain, lines)| serde_json::json!({ "plain": plain, "lines": lines }))
+ .collect(),
);
+ manifest.sort_all_objects();
+ let generated = format!("{}\n", serde_json::to_string_pretty(&manifest).unwrap());
let rel_path = "docs/src/generated/terminal-styles.json";
let dst = project_root.join(rel_path);
if fs::read_to_string(&dst).unwrap_or_default() != generated {
diff --git a/tests/integration_tests/switch.rs b/tests/integration_tests/switch.rs
index 3aeb69f94..3a3909ea6 100644
--- a/tests/integration_tests/switch.rs
+++ b/tests/integration_tests/switch.rs
@@ -6092,7 +6092,7 @@ fn test_switch_pr_gitlab_remote_rejects_pr(#[from(repo_with_remote)] repo: TestR
/// Self-hosted forge whose hostname doesn't match any URL detection rule, but
/// `tea` has a login configured for it (via `tea login add`) — dispatch
-/// inspects tea's config file and routes to Gitea.
+/// queries tea's local login list and routes to Gitea.
#[rstest]
fn test_switch_pr_self_hosted_tea_authed_dispatches_to_gitea(
#[from(repo_with_remote)] repo: TestRepo,
@@ -6104,14 +6104,6 @@ fn test_switch_pr_self_hosted_tea_authed_dispatches_to_gitea(
"https://forge.selfhosted.test/owner/test-repo.git",
]);
- let tea_config_dir = repo.home_path().join(".config").join("tea");
- fs::create_dir_all(&tea_config_dir).unwrap();
- fs::write(
- tea_config_dir.join("config.yml"),
- "logins:\n - name: selfhosted\n url: https://forge.selfhosted.test\n default: true\n",
- )
- .unwrap();
-
let tea_response = r#"{
"title": "Routed via tea config",
"user": {"login": "alice"},
@@ -6130,13 +6122,38 @@ fn test_switch_pr_self_hosted_tea_authed_dispatches_to_gitea(
"html_url": "https://forge.selfhosted.test/owner/test-repo/pulls/101"
}"#;
let mock_bin = setup_mock_tea(&repo, "200 OK", tea_response);
+ // Model tea's JSON output boundary: tea owns reading YAML and finding its
+ // config directory; Worktrunk consumes only the structured login list.
+ MockConfig::new("tea")
+ .command(
+ "logins list --output",
+ MockResponse::output(
+ r#"[{"name":"selfhosted","url":"https://FORGE.selfhosted.test/","ssh_host":"forge-ssh.selfhosted.test","user":"alice","default":"true"}]"#,
+ ),
+ )
+ .command(
+ "api",
+ MockResponse::file("tea_pr_response.json")
+ .with_stderr(&tea_api_include_stderr("200 OK")),
+ )
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+ let call_log = tempfile::tempdir().unwrap();
let settings = setup_snapshot_settings(&repo);
settings.bind(|| {
let mut cmd = make_snapshot_cmd(&repo, "switch", &["pr:101"], None);
configure_mock_cli_env(&mut cmd, &mock_bin);
+ cmd.env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path());
assert_cmd_snapshot!("switch_pr_self_hosted_tea_authed", cmd);
});
+ let calls = fs::read_to_string(call_log.path().join("tea.calls")).unwrap();
+ assert_eq!(calls.lines().next(), Some("logins list --output json"));
+ assert!(
+ calls
+ .lines()
+ .any(|line| line == "api --include repos/owner/test-repo/pulls/101")
+ );
}
/// Self-hosted forge with a non-distinctive hostname (`forge.example.com`)
@@ -6144,7 +6161,12 @@ fn test_switch_pr_self_hosted_tea_authed_dispatches_to_gitea(
/// GitHub. The mock `gh api` succeeds, so the PR is checked out and the
/// user never sees a wrapped error.
#[rstest]
-fn test_switch_pr_self_hosted_defaults_to_github(#[from(repo_with_remote)] mut repo: TestRepo) {
+#[case::unrelated_tea_login(true)]
+#[cfg_attr(unix, case::tea_not_installed(false))]
+fn test_switch_pr_self_hosted_defaults_to_github(
+ #[from(repo_with_remote)] mut repo: TestRepo,
+ #[case] tea_installed: bool,
+) {
repo.add_worktree("feature-auth");
repo.run_git(&["push", "origin", "feature-auth"]);
@@ -6187,13 +6209,131 @@ fn test_switch_pr_self_hosted_defaults_to_github(#[from(repo_with_remote)] mut r
"html_url": "https://forge.example.com/owner/test-repo/pull/101"
}"#;
let mock_bin = setup_mock_gh_for_pr(&repo, gh_response);
+ if tea_installed {
+ // A login on another Gitea host must not claim this remote.
+ MockConfig::new("tea")
+ .command(
+ "logins list --output",
+ MockResponse::output(r#"[{"url":"https://different-forge.example.com","ssh_host":"different-ssh.example.com"}]"#),
+ )
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+ }
+ #[cfg(unix)]
+ std::os::unix::fs::symlink(which::which("git").unwrap(), mock_bin.join("git")).unwrap();
+ let call_log = tempfile::tempdir().unwrap();
let settings = setup_snapshot_settings(&repo);
settings.bind(|| {
let mut cmd = make_snapshot_cmd(&repo, "switch", &["pr:101"], None);
configure_mock_cli_env(&mut cmd, &mock_bin);
+ if !tea_installed {
+ // Exclude any real tea on the host; the mock gh and git suffice.
+ cmd.env("PATH", &mock_bin);
+ }
+ cmd.env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path());
assert_cmd_snapshot!("switch_pr_self_hosted_defaults_to_github", cmd);
});
+ if tea_installed {
+ let calls = fs::read_to_string(call_log.path().join("tea.calls")).unwrap();
+ assert_eq!(calls.trim(), "logins list --output json");
+ } else {
+ assert!(!call_log.path().join("tea.calls").exists());
+ }
+}
+
+/// A configured SSH hostname can differ from the web hostname. tea's login
+/// list supplies both, so an SSH remote must route to the same Gitea account.
+#[rstest]
+fn test_switch_pr_tea_login_matches_distinct_ssh_host(repo: TestRepo) {
+ repo.run_git(&[
+ "remote",
+ "set-url",
+ "origin",
+ "[email protected]:owner/test-repo.git",
+ ]);
+ let mock_bin = repo.home_path().join("mock-bin");
+ fs::create_dir_all(&mock_bin).unwrap();
+ MockConfig::new("tea")
+ .command(
+ "logins list --output",
+ MockResponse::output(
+ r#"[{"url":"https://forge-web.selfhosted.test","ssh_host":"FORGE-SSH.selfhosted.test"}]"#,
+ ),
+ )
+ .command("api", MockResponse::stderr("Gitea lookup reached").with_exit_code(1))
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+ MockConfig::new("gh")
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+ let call_log = tempfile::tempdir().unwrap();
+ let mut cmd = repo.wt_command();
+ configure_mock_cli_env(&mut cmd, &mock_bin);
+ let output = cmd
+ .args(["switch", "pr:101"])
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .output()
+ .unwrap();
+ assert!(!output.status.success());
+ assert!(String::from_utf8_lossy(&output.stderr).contains("Gitea lookup reached"));
+ assert_eq!(
+ fs::read_to_string(call_log.path().join("tea.calls")).unwrap(),
+ "logins list --output json\napi --include repos/owner/test-repo/pulls/101\n"
+ );
+ assert_eq!(
+ fs::read_to_string(call_log.path().join("gh.calls")).unwrap(),
+ "auth token --hostname forge-ssh.selfhosted.test\n"
+ );
+}
+
+/// Native child cancellation stops forge selection; an ordinary exit 130 still
+/// means an unavailable login and permits the GitHub fallback.
+#[cfg(unix)]
+#[rstest]
+#[case::sigint("kill -INT $$", Some(2))]
+#[case::sigterm("kill -TERM $$", Some(15))]
+#[case::exit_130("exit 130", None)]
+fn test_switch_pr_tea_login_native_interruption(
+ repo: TestRepo,
+ #[case] tea_command: &str,
+ #[case] signal: Option<i32>,
+) {
+ use std::os::unix::fs::PermissionsExt;
+ use std::os::unix::process::ExitStatusExt;
+
+ repo.run_git(&[
+ "remote",
+ "set-url",
+ "origin",
+ "https://forge.selfhosted.test/owner/test-repo.git",
+ ]);
+ let mock_bin = repo.home_path().join("mock-bin");
+ fs::create_dir_all(&mock_bin).unwrap();
+ let tea = mock_bin.join("tea");
+ fs::write(
+ &tea,
+ format!(
+ "#!/bin/sh
+{tea_command}
+"
+ ),
+ )
+ .unwrap();
+ fs::set_permissions(&tea, fs::Permissions::from_mode(0o755)).unwrap();
+ MockConfig::new("gh")
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+ let call_log = tempfile::tempdir().unwrap();
+ let mut cmd = repo.wt_command();
+ configure_mock_cli_env(&mut cmd, &mock_bin);
+ let output = cmd
+ .args(["switch", "pr:101"])
+ .env("WORKTRUNK_TEST_MOCK_CALL_LOG_DIR", call_log.path())
+ .output()
+ .unwrap();
+ assert_eq!(output.status.signal(), signal, "{output:?}");
+ assert_eq!(call_log.path().join("gh.calls").exists(), signal.is_none());
}
/// Gitea API returns malformed JSON — covers the JSON parse error path
diff --git a/tests/snapshots/integration__integration_tests__config_state__logs_get_json_with_files.snap b/tests/snapshots/integration__integration_tests__config_state__logs_get_json_with_files.snap
index 801b6c615..4424d9276 100644
--- a/tests/snapshots/integration__integration_tests__config_state__logs_get_json_with_files.snap
+++ b/tests/snapshots/integration__integration_tests__config_state__logs_get_json_with_files.snap
@@ -6,29 +6,29 @@ expression: "String::from_utf8_lossy(&output.stdout)"
"command_log": [
{
"file": "commands.jsonl",
- "modified_at": "<TIMESTAMP>",
"path": "_REPO_/.git/wt/logs/commands.jsonl",
- "size": "<SIZE>"
+ "size": "<SIZE>",
+ "modified_at": "<TIMESTAMP>"
}
],
- "diagnostic": [
+ "hook_output": [
{
- "file": "diagnostic.md",
+ "file": "main/user/post-start/server.log",
+ "path": "_REPO_/.git/wt/logs/main/user/post-start/server.log",
+ "size": "<SIZE>",
"modified_at": "<TIMESTAMP>",
- "path": "_REPO_/.git/wt/logs/diagnostic.md",
- "size": "<SIZE>"
+ "branch": "main",
+ "source": "user",
+ "hook_type": "post-start",
+ "name": "server"
}
],
- "hook_output": [
+ "diagnostic": [
{
- "branch": "main",
- "file": "main/user/post-start/server.log",
- "hook_type": "post-start",
- "modified_at": "<TIMESTAMP>",
- "name": "server",
- "path": "_REPO_/.git/wt/logs/main/user/post-start/server.log",
+ "file": "diagnostic.md",
+ "path": "_REPO_/.git/wt/logs/diagnostic.md",
"size": "<SIZE>",
- "source": "user"
+ "modified_at": "<TIMESTAMP>"
}
]
}
diff --git a/tests/snapshots/integration__integration_tests__eval__eval_format_json.snap b/tests/snapshots/integration__integration_tests__eval__eval_format_json.snap
index f51219463..9315827ad 100644
--- a/tests/snapshots/integration__integration_tests__eval__eval_format_json.snap
+++ b/tests/snapshots/integration__integration_tests__eval__eval_format_json.snap
@@ -61,8 +61,8 @@ exit_code: 0
----- stdout -----
{
"name": "eval",
- "result": "12107",
- "template": "{{ branch | hash_port }}"
+ "template": "{{ branch | hash_port }}",
+ "result": "12107"
}
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap b/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap
index 46ac9b818..f357d3f54 100644
--- a/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap
+++ b/tests/snapshots/integration__integration_tests__eval__eval_format_json_verbose.snap
@@ -62,8 +62,8 @@ exit_code: 0
----- stdout -----
{
"name": "eval",
- "result": "12107",
- "template": "{{ branch | hash_port }}"
+ "template": "{{ branch | hash_port }}",
+ "result": "12107"
}
----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_json.snap b/tests/snapshots/integration__integration_tests__remove__remove_json.snap
index 0537ba4ea..dc344d1da 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_json.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_json.snap
@@ -4,10 +4,10 @@ expression: "String::from_utf8_lossy(&output.stdout)"
---
[
{
+ "kind": "worktree",
"branch": "feature",
- "branch_checked_out_at": null,
+ "path": "<PATH>",
"branch_outcome": "deleted",
- "kind": "worktree",
- "path": "<PATH>"
+ "branch_checked_out_at": null
}
]
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_json_branch_only.snap b/tests/snapshots/integration__integration_tests__remove__remove_json_branch_only.snap
index f27483647..528504d6c 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_json_branch_only.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_json_branch_only.snap
@@ -4,11 +4,11 @@ expression: "String::from_utf8_lossy(&output.stdout)"
---
[
{
+ "kind": "branch_only",
"branch": "orphan-branch",
- "branch_checked_out_at": null,
+ "pruned": false,
"branch_outcome": "deleted",
- "detached_worktree": null,
- "kind": "branch_only",
- "pruned": false
+ "branch_checked_out_at": null,
+ "detached_worktree": null
}
]
diff --git a/tests/snapshots/integration__integration_tests__remove__remove_json_multi_with_branch_only.snap b/tests/snapshots/integration__integration_tests__remove__remove_json_multi_with_branch_only.snap
index 713f4a447..8da5cc465 100644
--- a/tests/snapshots/integration__integration_tests__remove__remove_json_multi_with_branch_only.snap
+++ b/tests/snapshots/integration__integration_tests__remove__remove_json_multi_with_branch_only.snap
@@ -4,18 +4,18 @@ expression: "String::from_utf8_lossy(&output.stdout)"
---
[
{
+ "kind": "worktree",
"branch": "wt-feature",
- "branch_checked_out_at": null,
+ "path": "<PATH>",
"branch_outcome": "deleted",
- "kind": "worktree",
- "path": "<PATH>"
+ "branch_checked_out_at": null
},
{
+ "kind": "branch_only",
"branch": "orphan-branch",
- "branch_checked_out_at": null,
+ "pruned": false,
"branch_outcome": "deleted",
- "detached_worktree": null,
- "kind": "branch_only",
- "pruned": false
+ "branch_checked_out_at": null,
+ "detached_worktree": null
}
]
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json.snap
index 28ad8dbba..d334c8b8f 100644
--- a/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json.snap
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json.snap
@@ -5,9 +5,9 @@ expression: "String::from_utf8_lossy(&output.stdout)"
[
{
"branch": "merged-a",
- "branch_deleted": true,
- "kind": "worktree",
"path": "<PATH>",
+ "kind": "worktree",
+ "branch_deleted": true,
"reason": "same commit as",
"target": "main"
}
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_current_worktree.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_current_worktree.snap
index 8964fa9e0..62851063b 100644
--- a/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_current_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_current_worktree.snap
@@ -5,9 +5,9 @@ expression: "String::from_utf8_lossy(&output.stdout)"
[
{
"branch": "current-merged",
- "branch_deleted": true,
- "kind": "current",
"path": "<PATH>",
+ "kind": "current",
+ "branch_deleted": true,
"reason": "same commit as",
"target": "main"
}
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_orphan_branch.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_orphan_branch.snap
index f30ab3239..f6039ea38 100644
--- a/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_orphan_branch.snap
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_dry_run_json_orphan_branch.snap
@@ -5,9 +5,9 @@ expression: "String::from_utf8_lossy(&output.stdout)"
[
{
"branch": "orphan-integrated",
- "branch_deleted": true,
- "kind": "branch_only",
"path": null,
+ "kind": "branch_only",
+ "branch_deleted": true,
"reason": "same commit as",
"target": "main"
}
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_json_actual_removal.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_json_actual_removal.snap
index 33de888ed..cfd5de7d0 100644
--- a/tests/snapshots/integration__integration_tests__step_prune__prune_json_actual_removal.snap
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_json_actual_removal.snap
@@ -5,8 +5,8 @@ expression: "String::from_utf8_lossy(&output.stdout)"
[
{
"branch": "merged-a",
- "branch_outcome": "deleted",
+ "path": "<PATH>",
"kind": "worktree",
- "path": "<PATH>"
+ "branch_outcome": "deleted"
}
]
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_json_current_worktree.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_json_current_worktree.snap
index 2e8b558aa..e5acb0f19 100644
--- a/tests/snapshots/integration__integration_tests__step_prune__prune_json_current_worktree.snap
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_json_current_worktree.snap
@@ -5,8 +5,8 @@ expression: "String::from_utf8_lossy(&output.stdout)"
[
{
"branch": "current-merged",
- "branch_outcome": "deleted",
+ "path": "<PATH>",
"kind": "current",
- "path": "<PATH>"
+ "branch_outcome": "deleted"
}
]
diff --git a/tests/snapshots/integration__integration_tests__step_prune__prune_json_orphan_branch.snap b/tests/snapshots/integration__integration_tests__step_prune__prune_json_orphan_branch.snap
index db2312f73..5c3b16cd5 100644
--- a/tests/snapshots/integration__integration_tests__step_prune__prune_json_orphan_branch.snap
+++ b/tests/snapshots/integration__integration_tests__step_prune__prune_json_orphan_branch.snap
@@ -5,8 +5,8 @@ expression: "String::from_utf8_lossy(&output.stdout)"
[
{
"branch": "orphan-integrated",
- "branch_outcome": "deleted",
+ "path": null,
"kind": "branch_only",
- "path": null
+ "branch_outcome": "deleted"
}
]