Skip to content

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

fix(list): set cwd when calling glab ci list (#2244)

Worktrunk Bota3ce6e721488
diff --git a/src/commands/list/ci_status/gitlab.rs b/src/commands/list/ci_status/gitlab.rs
index c90777a09..6c69a9b10 100644
--- a/src/commands/list/ci_status/gitlab.rs
+++ b/src/commands/list/ci_status/gitlab.rs
@@ -191,8 +191,16 @@ pub(super) fn detect_gitlab(
}
/// Detect GitLab pipeline status for a branch (when no MR exists).
-pub(super) fn detect_gitlab_pipeline(branch: &str, local_head: &str) -> Option<PrStatus> {
- // Get most recent pipeline for the branch using JSON output
+pub(super) fn detect_gitlab_pipeline(
+ repo: &Repository,
+ branch: &str,
+ local_head: &str,
+) -> Option<PrStatus> {
+ let repo_root = repo.current_worktree().root().ok()?;
+
+ // Get most recent pipeline for the branch using JSON output.
+ // Set cwd to the repo root so `glab` resolves the correct project from
+ // `.git/config` — matches `detect_gitlab` and `fetch_mr_details`.
let output = match non_interactive_cmd("glab")
.args([
"ci",
@@ -204,6 +212,7 @@ pub(super) fn detect_gitlab_pipeline(branch: &str, local_head: &str) -> Option<P
"--output",
"json",
])
+ .current_dir(&repo_root)
.run()
{
Ok(output) => output,
diff --git a/src/commands/list/ci_status/platform.rs b/src/commands/list/ci_status/platform.rs
index 15497f077..4844b36ba 100644
--- a/src/commands/list/ci_status/platform.rs
+++ b/src/commands/list/ci_status/platform.rs
@@ -73,7 +73,7 @@ impl CiPlatform {
match self {
Self::GitHub => github::detect_github_commit_checks(repo, branch, local_head),
// GitLab pipeline uses the bare branch name (not "origin/feature")
- Self::GitLab => gitlab::detect_gitlab_pipeline(&branch.name, local_head),
+ Self::GitLab => gitlab::detect_gitlab_pipeline(repo, &branch.name, local_head),
}
}