Skip to content

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

Show only relevant CI tool based on repository platform

Maximilian Roosdffd33a9b640
diff --git a/src/commands/config.rs b/src/commands/config.rs
index 13ccf8153..01b7d831b 100644
--- a/src/commands/config.rs
+++ b/src/commands/config.rs
@@ -428,27 +428,26 @@ fn render_shell_status(out: &mut String) -> anyhow::Result<()> {
Ok(())
}
-fn render_binaries_status(out: &mut String) -> anyhow::Result<()> {
- use super::list::ci_status::CiToolsStatus;
-
- writeln!(out, "{}", cformat!("<cyan>BINARIES</>"))?;
-
- let ci_tools = CiToolsStatus::detect();
-
- // Check gh (GitHub CLI)
- if ci_tools.gh_installed {
- if ci_tools.gh_authenticated {
+fn render_ci_tool_status(
+ out: &mut String,
+ tool: &str,
+ platform: &str,
+ installed: bool,
+ authenticated: bool,
+) -> anyhow::Result<()> {
+ if installed {
+ if authenticated {
writeln!(
out,
"{}",
- info_message(cformat!("<bold>gh</> installed & authenticated"))
+ info_message(cformat!("<bold>{tool}</> installed & authenticated"))
)?;
} else {
writeln!(
out,
"{}",
warning_message(cformat!(
- "<bold>gh</> installed but not authenticated; run <bright-black>gh auth login</>"
+ "<bold>{tool}</> installed but not authenticated; run <bright-black>{tool} auth login</>"
))
)?;
}
@@ -457,36 +456,54 @@ fn render_binaries_status(out: &mut String) -> anyhow::Result<()> {
out,
"{}",
hint_message(cformat!(
- "<bold>gh</> not found (GitHub CI status unavailable)"
+ "<bold>{tool}</> not found ({platform} CI status unavailable)"
))
)?;
}
+ Ok(())
+}
- // Check glab (GitLab CLI)
- if ci_tools.glab_installed {
- if ci_tools.glab_authenticated {
- writeln!(
+fn render_binaries_status(out: &mut String) -> anyhow::Result<()> {
+ use super::list::ci_status::{CiPlatform, CiToolsStatus, get_platform_for_repo};
+
+ writeln!(out, "{}", cformat!("<cyan>BINARIES</>"))?;
+
+ let ci_tools = CiToolsStatus::detect();
+
+ // Detect platform from repo's remote URL (if in a repo)
+ let platform = Repository::current()
+ .worktree_root()
+ .ok()
+ .and_then(|root| get_platform_for_repo(root.to_str()?));
+
+ // Only show the relevant CI tool based on detected platform
+ // If platform is unknown, don't show any warnings (user may not need CI status)
+ match platform {
+ Some(CiPlatform::GitHub) => {
+ render_ci_tool_status(
out,
- "{}",
- info_message(cformat!("<bold>glab</> installed & authenticated"))
+ "gh",
+ "GitHub",
+ ci_tools.gh_installed,
+ ci_tools.gh_authenticated,
)?;
- } else {
+ }
+ Some(CiPlatform::GitLab) => {
+ render_ci_tool_status(
+ out,
+ "glab",
+ "GitLab",
+ ci_tools.glab_installed,
+ ci_tools.glab_authenticated,
+ )?;
+ }
+ None => {
writeln!(
out,
"{}",
- warning_message(cformat!(
- "<bold>glab</> installed but not authenticated; run <bright-black>glab auth login</>"
- ))
+ hint_message("CI status requires GitHub or GitLab remote")
)?;
}
- } else {
- writeln!(
- out,
- "{}",
- hint_message(cformat!(
- "<bold>glab</> not found (GitLab CI status unavailable)"
- ))
- )?;
}
Ok(())
diff --git a/src/commands/list/ci_status.rs b/src/commands/list/ci_status.rs
index 5436ba4f2..c4e3b3e7a 100644
--- a/src/commands/list/ci_status.rs
+++ b/src/commands/list/ci_status.rs
@@ -6,7 +6,7 @@ use worktrunk::git::Repository;
// TODO: Add a `[ci] platform = "github" | "gitlab"` override in project config
// for cases where URL detection fails or users want to force a specific platform.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
-enum CiPlatform {
+pub enum CiPlatform {
GitHub,
GitLab,
}
@@ -24,7 +24,7 @@ fn detect_platform_from_url(url: &str) -> Option<CiPlatform> {
}
/// Get the CI platform for a repository by checking its origin remote URL.
-fn get_platform_for_repo(repo_root: &str) -> Option<CiPlatform> {
+pub fn get_platform_for_repo(repo_root: &str) -> Option<CiPlatform> {
let output = Command::new("git")
.args(["remote", "get-url", "origin"])
.current_dir(repo_root)
diff --git a/src/commands/list/mod.rs b/src/commands/list/mod.rs
index 198e48776..00b14b630 100644
--- a/src/commands/list/mod.rs
+++ b/src/commands/list/mod.rs
@@ -205,34 +205,51 @@ pub fn handle_list(
if show_full {
let ci_tools = ci_status::CiToolsStatus::detect();
if !ci_tools.any_available() {
+ use ci_status::{CiPlatform, get_platform_for_repo};
use color_print::cformat;
+ use worktrunk::git::Repository;
use worktrunk::styling::hint_message;
- crate::output::blank()?;
- // Provide specific guidance based on what's installed but not authenticated
- let gh_needs_auth = ci_tools.gh_installed && !ci_tools.gh_authenticated;
- let glab_needs_auth = ci_tools.glab_installed && !ci_tools.glab_authenticated;
+ // Detect platform from repo's remote URL
+ let platform = Repository::current()
+ .worktree_root()
+ .ok()
+ .and_then(|root| get_platform_for_repo(root.to_str()?));
- if gh_needs_auth && glab_needs_auth {
- // Both installed but neither authenticated
- crate::output::print(hint_message(cformat!(
- "CI status unavailable; run <bright-black>gh auth login</> or <bright-black>glab auth login</>"
- )))?;
- } else if gh_needs_auth {
- // gh installed but not authenticated
- crate::output::print(hint_message(cformat!(
- "CI status unavailable; run <bright-black>gh auth login</> to authenticate"
- )))?;
- } else if glab_needs_auth {
- // glab installed but not authenticated
- crate::output::print(hint_message(cformat!(
- "CI status unavailable; run <bright-black>glab auth login</> to authenticate"
- )))?;
- } else {
- // Neither tool is installed
- crate::output::print(hint_message(cformat!(
- "CI status unavailable; install <bright-black>gh</> or <bright-black>glab</>"
- )))?;
+ // Only show hint for the relevant platform's tool
+ let hint = match platform {
+ Some(CiPlatform::GitHub) => {
+ if ci_tools.gh_installed && !ci_tools.gh_authenticated {
+ Some(cformat!(
+ "CI status unavailable; run <bright-black>gh auth login</> to authenticate"
+ ))
+ } else if !ci_tools.gh_installed {
+ Some(cformat!(
+ "CI status unavailable; install <bright-black>gh</>"
+ ))
+ } else {
+ None
+ }
+ }
+ Some(CiPlatform::GitLab) => {
+ if ci_tools.glab_installed && !ci_tools.glab_authenticated {
+ Some(cformat!(
+ "CI status unavailable; run <bright-black>glab auth login</> to authenticate"
+ ))
+ } else if !ci_tools.glab_installed {
+ Some(cformat!(
+ "CI status unavailable; install <bright-black>glab</>"
+ ))
+ } else {
+ None
+ }
+ }
+ None => None, // Unknown platform - don't show any hint
+ };
+
+ if let Some(message) = hint {
+ crate::output::blank()?;
+ crate::output::print(hint_message(message))?;
}
}
}
diff --git a/tests/integration_tests/config_show.rs b/tests/integration_tests/config_show.rs
index 6f47e2d69..26aacbc32 100644
--- a/tests/integration_tests/config_show.rs
+++ b/tests/integration_tests/config_show.rs
@@ -352,3 +352,79 @@ args = ["-m", "test-model"]
assert_cmd_snapshot!(cmd);
});
}
+
+/// Test `wt config show` with GitHub remote shows only gh status
+#[rstest]
+fn test_config_show_github_remote(mut repo: TestRepo, temp_home: TempDir) {
+ // Setup mock gh/glab for deterministic BINARIES output
+ repo.setup_mock_ci_tools_unauthenticated();
+
+ // Add GitHub remote
+ repo.git_command(&[
+ "remote",
+ "add",
+ "origin",
+ "https://github.com/example/repo.git",
+ ])
+ .output()
+ .unwrap();
+
+ // Create fake global config
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ fs::write(
+ global_config_dir.join("config.toml"),
+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"
+"#,
+ )
+ .unwrap();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.clean_cli_env(&mut cmd);
+ repo.configure_mock_commands(&mut cmd);
+ cmd.arg("config").arg("show").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
+
+/// Test `wt config show` with GitLab remote shows only glab status
+#[rstest]
+fn test_config_show_gitlab_remote(mut repo: TestRepo, temp_home: TempDir) {
+ // Setup mock gh/glab for deterministic BINARIES output
+ repo.setup_mock_ci_tools_unauthenticated();
+
+ // Add GitLab remote
+ repo.git_command(&[
+ "remote",
+ "add",
+ "origin",
+ "https://gitlab.com/example/repo.git",
+ ])
+ .output()
+ .unwrap();
+
+ // Create fake global config
+ let global_config_dir = temp_home.path().join(".config").join("worktrunk");
+ fs::create_dir_all(&global_config_dir).unwrap();
+ fs::write(
+ global_config_dir.join("config.toml"),
+ r#"worktree-path = "../{{ main_worktree }}.{{ branch }}"
+"#,
+ )
+ .unwrap();
+
+ let settings = setup_snapshot_settings_with_home(&repo, &temp_home);
+ settings.bind(|| {
+ let mut cmd = wt_command();
+ repo.clean_cli_env(&mut cmd);
+ repo.configure_mock_commands(&mut cmd);
+ cmd.arg("config").arg("show").current_dir(repo.root_path());
+ set_temp_home_env(&mut cmd, temp_home.path());
+
+ assert_cmd_snapshot!(cmd);
+ });
+}
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
index 0fb1a6ee7..1dde1b818 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_command_not_found.snap
@@ -45,8 +45,7 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
βšͺ Running diagnostic checks...
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
index 6b5c5f838..ff321700f 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_full_not_configured.snap
@@ -41,8 +41,7 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
βšͺ Running diagnostic checks...
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
new file mode 100644
index 000000000..bc8075591
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_github_remote.snap
@@ -0,0 +1,43 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - show
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "150"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ PATH: "[PATH]"
+ SOURCE_DATE_EPOCH: "1735776000"
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+USER CONFIG ~/.config/worktrunk/config.toml
+  worktree-path = "../{{ main_worktree }}.{{ branch }}"
+
+PROJECT CONFIG [REPO]/.config/wt.toml
+πŸ’‘ Not found
+
+SHELL INTEGRATION
+βšͺ Skipped bash; ~/.bashrc not found
+βšͺ Skipped zsh; ~/.zshrc not found
+βšͺ Skipped fish; ~/.config/fish/conf.d not found
+
+BINARIES
+🟑 gh installed but not authenticated; run gh auth login
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
new file mode 100644
index 000000000..fe472ce1e
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_gitlab_remote.snap
@@ -0,0 +1,43 @@
+---
+source: tests/integration_tests/config_show.rs
+info:
+ program: wt
+ args:
+ - config
+ - show
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "150"
+ GIT_AUTHOR_DATE: "2025-01-01T00:00:00Z"
+ GIT_COMMITTER_DATE: "2025-01-01T00:00:00Z"
+ GIT_CONFIG_GLOBAL: "[TEST_GIT_CONFIG]"
+ GIT_CONFIG_SYSTEM: /dev/null
+ GIT_EDITOR: ""
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ PATH: "[PATH]"
+ SOURCE_DATE_EPOCH: "1735776000"
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+
+----- stderr -----
+USER CONFIG ~/.config/worktrunk/config.toml
+  worktree-path = "../{{ main_worktree }}.{{ branch }}"
+
+PROJECT CONFIG [REPO]/.config/wt.toml
+πŸ’‘ Not found
+
+SHELL INTEGRATION
+βšͺ Skipped bash; ~/.bashrc not found
+βšͺ Skipped zsh; ~/.zshrc not found
+βšͺ Skipped fish; ~/.config/fish/conf.d not found
+
+BINARIES
+🟑 glab installed but not authenticated; run glab auth login
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
index 871f55138..a0d60e425 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_no_project_config.snap
@@ -40,5 +40,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
index 2c492946c..b693a1be8 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_outside_git_repo.snap
@@ -33,5 +33,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
index 84c32e4aa..cedca2e79 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_partial_shell_config_shows_hint.snap
@@ -43,5 +43,4 @@ exit_code: 0
πŸ’‘ wt config shell install enables shell integration
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
index caa512b73..b5f21ca06 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_project_keys.snap
@@ -42,5 +42,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
index fd5baff49..b4c9ccd8d 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_warns_unknown_user_keys.snap
@@ -44,5 +44,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
index ac46f200d..8b18875a4 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_with_project_config.snap
@@ -46,5 +46,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
index 61dcf0c4d..d2be713f0 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_correct_order.snap
@@ -41,5 +41,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
index d0da06b9e..f8477c9b3 100644
--- a/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
+++ b/tests/snapshots/integration__integration_tests__config_show__config_show_zsh_compinit_warning.snap
@@ -43,5 +43,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote
diff --git a/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap b/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap
index 21e7081c8..67816f4b8 100644
--- a/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap
+++ b/tests/snapshots/integration__integration_tests__internal_flag__config_show_with_internal_flag.snap
@@ -41,5 +41,4 @@ exit_code: 0
βšͺ Skipped fish; ~/.config/fish/conf.d not found
BINARIES
-🟑 gh installed but not authenticated; run gh auth login
-🟑 glab installed but not authenticated; run glab auth login
+πŸ’‘ CI status requires GitHub or GitLab remote