Skip to content

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

fix(glab): full compatibility audit and fixes (#770)

Maximilian Roosd51e04f4081f
diff --git a/src/commands/list/ci_status/gitlab.rs b/src/commands/list/ci_status/gitlab.rs
index 3fee6e20a..781354044 100644
--- a/src/commands/list/ci_status/gitlab.rs
+++ b/src/commands/list/ci_status/gitlab.rs
@@ -1,8 +1,21 @@
//! GitLab CI status detection.
//!
//! Detects CI status from GitLab MRs and pipelines using the `glab` CLI.
+//!
+//! # Two-Step MR Resolution
+//!
+//! Getting complete MR details (including pipeline status) requires two `glab` calls:
+//!
+//! 1. `glab mr list --source-branch <branch>` - Returns basic MR info including `iid`
+//! but NOT `head_pipeline` or `pipeline` fields.
+//!
+//! 2. `glab mr view <iid> --output json` - Returns complete MR details including
+//! `head_pipeline` and `pipeline` fields.
+//!
+//! See: <https://github.com/max-sixty/worktrunk/issues/764>
use serde::Deserialize;
+use std::path::Path;
use worktrunk::git::Repository;
use super::{
@@ -65,6 +78,7 @@ pub(super) fn detect_gitlab(repo: &Repository, branch: &str, local_head: &str) -
}
// Fetch MRs with matching source branch.
+ // Note: glab mr list returns open MRs by default, no --state flag needed.
// We filter client-side by source_project_id (numeric project ID comparison).
let output = match non_interactive_cmd("glab")
.args([
@@ -72,7 +86,6 @@ pub(super) fn detect_gitlab(repo: &Repository, branch: &str, local_head: &str) -
"list",
"--source-branch",
branch,
- "--state=opened",
&format!("--per-page={}", MAX_PRS_TO_FETCH),
"--output",
"json",
@@ -101,11 +114,12 @@ pub(super) fn detect_gitlab(repo: &Repository, branch: &str, local_head: &str) -
return None;
}
- // glab mr list returns an array - find the first MR from our project
- let mr_list: Vec<GitLabMrInfo> = parse_json(&output.stdout, "glab mr list", branch)?;
+ // Step 1: Parse mr list output to find matching MR.
+ // Note: glab mr list does NOT return head_pipeline/pipeline fields.
+ let mr_list: Vec<GitLabMrListEntry> = parse_json(&output.stdout, "glab mr list", branch)?;
// Filter to MRs from our project (numeric project ID comparison)
- let mr_info = if let Some(proj_id) = project_id {
+ let mr_entry = if let Some(proj_id) = project_id {
let matched = mr_list
.iter()
.find(|mr| mr.source_project_id == Some(proj_id));
@@ -128,25 +142,37 @@ pub(super) fn detect_gitlab(repo: &Repository, branch: &str, local_head: &str) -
mr_list.first()
}?;
- // Determine CI status using priority: conflicts > running > failed > passed > no_ci
- let ci_status =
- if mr_info.has_conflicts || mr_info.detailed_merge_status.as_deref() == Some("conflict") {
- CiStatus::Conflicts
- } else if mr_info.detailed_merge_status.as_deref() == Some("ci_still_running") {
- CiStatus::Running
- } else if mr_info.detailed_merge_status.as_deref() == Some("ci_must_pass") {
- CiStatus::Failed
- } else {
- mr_info.ci_status()
- };
+ // Step 2: Fetch full MR details to get pipeline status.
+ // This requires a second glab call because mr list doesn't include head_pipeline.
+ let mr_info = fetch_mr_details(mr_entry.iid, &repo_root);
+
+ // Determine CI status using priority: conflicts > running > pipeline status > no_ci
+ // Use mr_entry for basic info (available from list), mr_info for pipeline status
+ //
+ // Note: "ci_must_pass" is a policy constraint ("CI must pass to merge"), NOT a failure
+ // indicator. We let it fall through to the actual pipeline status.
+ let ci_status = if mr_entry.has_conflicts
+ || mr_entry.detailed_merge_status.as_deref() == Some("conflict")
+ {
+ CiStatus::Conflicts
+ } else if mr_entry.detailed_merge_status.as_deref() == Some("ci_still_running") {
+ CiStatus::Running
+ } else if let Some(ref info) = mr_info {
+ info.ci_status()
+ } else {
+ // Found MR but couldn't fetch details - treat as error so it surfaces
+ // (not NoCI, which would imply no MR exists)
+ log::debug!("Could not fetch MR details for !{}", mr_entry.iid);
+ return Some(PrStatus::error());
+ };
- let is_stale = mr_info.sha != local_head;
+ let is_stale = mr_entry.sha != local_head;
Some(PrStatus {
ci_status,
source: CiSource::PullRequest,
is_stale,
- url: mr_info.web_url.clone(),
+ url: mr_entry.web_url.clone(),
})
}
@@ -154,8 +180,16 @@ pub(super) fn detect_gitlab(repo: &Repository, branch: &str, local_head: &str) -
pub(super) fn detect_gitlab_pipeline(branch: &str, local_head: &str) -> Option<PrStatus> {
// Get most recent pipeline for the branch using JSON output
let output = match non_interactive_cmd("glab")
- .args(["ci", "list", "--per-page", "1", "--output", "json"])
- .env("BRANCH", branch) // glab ci list uses BRANCH env var
+ .args([
+ "ci",
+ "list",
+ "--ref",
+ branch,
+ "--per-page",
+ "1",
+ "--output",
+ "json",
+ ])
.run()
{
Ok(output) => output,
@@ -170,6 +204,12 @@ pub(super) fn detect_gitlab_pipeline(branch: &str, local_head: &str) -> Option<P
};
if !output.status.success() {
+ let stderr = String::from_utf8_lossy(&output.stderr);
+ // Return error status for retriable failures (rate limit, network) so they
+ // surface as warnings instead of being cached as "no CI"
+ if is_retriable_error(&stderr) {
+ return Some(PrStatus::error());
+ }
return None;
}
@@ -193,24 +233,37 @@ pub(super) fn detect_gitlab_pipeline(branch: &str, local_head: &str) -> Option<P
})
}
-/// GitLab MR info from `glab mr list --output json`
+/// Basic MR info from `glab mr list --output json`.
+///
+/// Note: `glab mr list` does NOT return `head_pipeline` or `pipeline` fields.
+/// Use [`fetch_mr_details`] with the `iid` to get complete MR info.
///
-/// Note: We include `source_project_id` for client-side filtering by source project.
+/// We include `source_project_id` for client-side filtering by source project.
/// See [`worktrunk::git::parse_remote_owner`] for why we filter by source, not by author.
#[derive(Debug, Deserialize)]
-pub(super) struct GitLabMrInfo {
+struct GitLabMrListEntry {
+ /// The internal MR ID (used to fetch full details via `glab mr view <iid>`)
+ pub iid: u64,
pub sha: String,
pub has_conflicts: bool,
pub detailed_merge_status: Option<String>,
- pub head_pipeline: Option<GitLabPipeline>,
- pub pipeline: Option<GitLabPipeline>,
/// The source project ID (the project the MR's branch comes from).
- /// Used to filter MRs by source project.
pub source_project_id: Option<u64>,
/// URL to the MR page for clickable links
pub web_url: Option<String>,
}
+/// Full MR info from `glab mr view <iid> --output json`.
+///
+/// This includes pipeline status that isn't available from `glab mr list`.
+/// We only need the pipeline fields here since basic MR info comes from
+/// [`GitLabMrListEntry`].
+#[derive(Debug, Deserialize)]
+pub(super) struct GitLabMrInfo {
+ pub head_pipeline: Option<GitLabPipeline>,
+ pub pipeline: Option<GitLabPipeline>,
+}
+
impl GitLabMrInfo {
pub fn ci_status(&self) -> CiStatus {
self.head_pipeline
@@ -221,6 +274,25 @@ impl GitLabMrInfo {
}
}
+/// Fetch full MR details using `glab mr view <iid>`.
+///
+/// This is the second step in the two-step MR resolution process.
+/// Returns None if the command fails or returns invalid JSON.
+fn fetch_mr_details(iid: u64, repo_root: &Path) -> Option<GitLabMrInfo> {
+ let output = non_interactive_cmd("glab")
+ .args(["mr", "view", &iid.to_string(), "--output", "json"])
+ .current_dir(repo_root)
+ .run()
+ .ok()?;
+
+ if !output.status.success() {
+ log::debug!("glab mr view {} failed", iid);
+ return None;
+ }
+
+ parse_json(&output.stdout, "glab mr view", &iid.to_string())
+}
+
#[derive(Debug, Deserialize)]
pub(super) struct GitLabPipeline {
pub status: Option<String>,
@@ -234,10 +306,17 @@ pub(super) struct GitLabPipeline {
fn parse_gitlab_status(status: Option<&str>) -> CiStatus {
match status {
+ // "manual" = pipeline waiting for user to trigger a manual job (not failed)
Some(
- "running" | "pending" | "preparing" | "waiting_for_resource" | "created" | "scheduled",
+ "running"
+ | "pending"
+ | "preparing"
+ | "waiting_for_resource"
+ | "created"
+ | "scheduled"
+ | "manual",
) => CiStatus::Running,
- Some("failed" | "canceled" | "manual") => CiStatus::Failed,
+ Some("failed" | "canceled") => CiStatus::Failed,
Some("success") => CiStatus::Passed,
Some("skipped") | None => CiStatus::NoCI,
_ => CiStatus::NoCI,
@@ -256,7 +335,7 @@ mod tests {
#[test]
fn test_parse_gitlab_status() {
- // Running states
+ // Running states (includes "manual" - waiting for user to trigger)
for status in [
"running",
"pending",
@@ -264,6 +343,7 @@ mod tests {
"waiting_for_resource",
"created",
"scheduled",
+ "manual",
] {
assert_eq!(
parse_gitlab_status(Some(status)),
@@ -273,7 +353,7 @@ mod tests {
}
// Failed states
- for status in ["failed", "canceled", "manual"] {
+ for status in ["failed", "canceled"] {
assert_eq!(
parse_gitlab_status(Some(status)),
CiStatus::Failed,
@@ -294,21 +374,13 @@ mod tests {
fn test_gitlab_mr_info_ci_status() {
// No pipeline = NoCI
let mr = GitLabMrInfo {
- sha: "abc".into(),
- has_conflicts: false,
- detailed_merge_status: None,
head_pipeline: None,
pipeline: None,
- source_project_id: None,
- web_url: None,
};
assert_eq!(mr.ci_status(), CiStatus::NoCI);
// head_pipeline takes precedence
let mr = GitLabMrInfo {
- sha: "abc".into(),
- has_conflicts: false,
- detailed_merge_status: None,
head_pipeline: Some(GitLabPipeline {
status: Some("success".into()),
sha: None,
@@ -319,24 +391,17 @@ mod tests {
sha: None,
web_url: None,
}),
- source_project_id: None,
- web_url: None,
};
assert_eq!(mr.ci_status(), CiStatus::Passed);
// Falls back to pipeline if no head_pipeline
let mr = GitLabMrInfo {
- sha: "abc".into(),
- has_conflicts: false,
- detailed_merge_status: None,
head_pipeline: None,
pipeline: Some(GitLabPipeline {
status: Some("running".into()),
sha: None,
web_url: None,
}),
- source_project_id: None,
- web_url: None,
};
assert_eq!(mr.ci_status(), CiStatus::Running);
}
diff --git a/tests/common/mod.rs b/tests/common/mod.rs
index 0e927bb7c..e84a0954a 100644
--- a/tests/common/mod.rs
+++ b/tests/common/mod.rs
@@ -1823,20 +1823,60 @@ impl TestRepo {
/// Setup mock `glab` that returns configurable MR/CI data for GitLab
///
- /// Use this for testing GitLab CI status parsing code. The mock returns JSON data
- /// for `glab mr list` and `glab repo view` commands.
+ /// Use this for testing GitLab CI status parsing code. The mock handles the
+ /// two-step MR resolution process:
+ /// - `glab mr list` returns basic MR info (iid, sha, conflicts, etc.)
+ /// - `glab mr view <iid>` returns full MR info including head_pipeline
///
/// # Arguments
- /// * `mr_json` - JSON string to return for `glab mr list --output json`
+ /// * `mr_json` - JSON string for MR data. Should include an `iid` field and
+ /// optionally `head_pipeline`. This data is used for both `mr list` and
+ /// `mr view` responses.
/// * `project_id` - Optional project ID to return from `glab repo view`
+ ///
+ /// # Note
+ /// The mock automatically handles the compound command matching:
+ /// - "mr list" → returns MR list data
+ /// - "mr view" → returns same data (works because glab mr view returns same fields)
pub fn setup_mock_glab_with_ci_data(&mut self, mr_json: &str, project_id: Option<u64>) {
use crate::common::mock_commands::{MockConfig, MockResponse};
let mock_bin = self.temp_dir.path().join("mock-bin");
std::fs::create_dir_all(&mock_bin).unwrap();
- // Write JSON data file
- std::fs::write(mock_bin.join("mr_data.json"), mr_json).unwrap();
+ // Parse the MR JSON to create separate list and view responses
+ // mr list needs: iid (for two-step lookup), sha, has_conflicts, detailed_merge_status, source_project_id, web_url
+ // mr view needs: sha, has_conflicts, detailed_merge_status, head_pipeline, pipeline, web_url
+ //
+ // Since we provide the same JSON for both, we need to ensure iid is present.
+ // The actual glab mr list doesn't return head_pipeline, but our mock can return
+ // it harmlessly - the code will ignore it and do a second lookup.
+
+ // Write JSON data files - same data for list (array) and view (single object)
+ std::fs::write(mock_bin.join("mr_list_data.json"), mr_json).unwrap();
+
+ // For mr view, create separate files for each MR by iid
+ // This allows triple-matching "mr view <iid>" to return the correct MR
+ let mut mock_config = MockConfig::new("glab")
+ .version("glab version 1.0.0 (mock)")
+ .command("auth", MockResponse::exit(0))
+ .command("mr list", MockResponse::file("mr_list_data.json"));
+
+ // Parse MR array and create iid-specific view commands
+ // Triple match: "mr view 1" matches before "mr view" (see mock-stub)
+ if let Ok(parsed) = serde_json::from_str::<serde_json::Value>(mr_json)
+ && let Some(arr) = parsed.as_array()
+ {
+ for mr in arr {
+ if let Some(iid) = mr.get("iid").and_then(|v| v.as_u64()) {
+ let filename = format!("mr_view_{}.json", iid);
+ let json = serde_json::to_string(mr).unwrap_or_default();
+ std::fs::write(mock_bin.join(&filename), json).unwrap();
+ mock_config = mock_config
+ .command(&format!("mr view {}", iid), MockResponse::file(&filename));
+ }
+ }
+ }
// Build project ID response
let project_id_response = match project_id {
@@ -1844,16 +1884,84 @@ impl TestRepo {
None => r#"{"error": "not found"}"#.to_string(),
};
- // Configure glab mock
+ // Configure glab mock with compound command matching
+ // "mr view <iid>" is matched before "mr view" (see mock-stub triple matching)
+ mock_config
+ .command("repo", MockResponse::output(&project_id_response))
+ .command("ci", MockResponse::output("[]"))
+ .write(&mock_bin);
+
+ // Configure gh mock (fails - no GitHub support)
+ MockConfig::new("gh")
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+
+ self.mock_bin_path = Some(mock_bin);
+ }
+
+ /// Setup mock glab where mr list succeeds but mr view fails.
+ ///
+ /// Use this to test the error path when `glab mr view` fails after finding an MR.
+ /// The mock returns the MR from mr list but exits with error for mr view.
+ pub fn setup_mock_glab_with_failing_mr_view(&mut self, mr_json: &str, project_id: Option<u64>) {
+ use crate::common::mock_commands::{MockConfig, MockResponse};
+
+ let mock_bin = self.temp_dir.path().join("mock-bin");
+ std::fs::create_dir_all(&mock_bin).unwrap();
+
+ std::fs::write(mock_bin.join("mr_list_data.json"), mr_json).unwrap();
+
+ let project_id_response = match project_id {
+ Some(id) => format!(r#"{{"id": {}}}"#, id),
+ None => r#"{"error": "not found"}"#.to_string(),
+ };
+
+ // glab mock: mr list succeeds, but NO mr view commands registered
+ // (falls back to exit code 1)
MockConfig::new("glab")
.version("glab version 1.0.0 (mock)")
.command("auth", MockResponse::exit(0))
- .command("mr", MockResponse::file("mr_data.json"))
+ .command("mr list", MockResponse::file("mr_list_data.json"))
+ // No "mr view" commands - will fall back to default exit code 1
.command("repo", MockResponse::output(&project_id_response))
.command("ci", MockResponse::output("[]"))
.write(&mock_bin);
- // Configure gh mock (fails - no GitHub support)
+ MockConfig::new("gh")
+ .command("_default", MockResponse::exit(1))
+ .write(&mock_bin);
+
+ self.mock_bin_path = Some(mock_bin);
+ }
+
+ /// Set up mock glab that returns a rate limit error on `ci list`.
+ ///
+ /// Used to test the `is_retriable_error` path in `detect_gitlab_pipeline`.
+ /// MR list returns empty (no MRs), so the code falls through to pipeline detection
+ /// which then hits the rate limit error.
+ pub fn setup_mock_glab_with_ci_rate_limit(&mut self, project_id: Option<u64>) {
+ use crate::common::mock_commands::{MockConfig, MockResponse};
+
+ let mock_bin = self.temp_dir.path().join("mock-bin");
+ std::fs::create_dir_all(&mock_bin).unwrap();
+
+ let project_id_response = match project_id {
+ Some(id) => format!(r#"{{"id": {}}}"#, id),
+ None => r#"{"error": "not found"}"#.to_string(),
+ };
+
+ // glab mock: mr list returns empty (no MRs), ci list fails with rate limit
+ MockConfig::new("glab")
+ .version("glab version 1.0.0 (mock)")
+ .command("auth", MockResponse::exit(0))
+ .command("mr list", MockResponse::output("[]")) // No MRs - triggers ci list fallback
+ .command("repo", MockResponse::output(&project_id_response))
+ .command(
+ "ci",
+ MockResponse::stderr("API rate limit exceeded").with_exit_code(1),
+ )
+ .write(&mock_bin);
+
MockConfig::new("gh")
.command("_default", MockResponse::exit(1))
.write(&mock_bin);
diff --git a/tests/helpers/mock-stub/src/main.rs b/tests/helpers/mock-stub/src/main.rs
index eb6e034dc..ea59a2bed 100644
--- a/tests/helpers/mock-stub/src/main.rs
+++ b/tests/helpers/mock-stub/src/main.rs
@@ -17,10 +17,14 @@
//! }
//! ```
//!
-//! Command matching:
-//! - `gh --version` → outputs version string
-//! - `gh auth ...` → matches "auth" command
-//! - `gh pr list ...` → matches "pr" command
+//! Command matching (in priority order):
+//! 1. `gh --version` → outputs version string
+//! 2. Triple: `glab mr view 123` → matches "mr view 123" (first three args)
+//! 3. Compound: `gh mr list ...` → matches "mr list" (first two args)
+//! 4. Single: `gh mr ...` → matches "mr" (first arg only)
+//! 5. `_default` → fallback if no match
+//!
+//! This allows different responses for `glab mr view 1` vs `glab mr view 2`.
//!
//! Response types:
//! - `file`: read and output contents of specified file (relative to config dir)
@@ -90,16 +94,42 @@ fn main() {
exit(0);
}
- // Match first argument against commands, fall back to _default
+ // Match against commands with priority: triple > compound > single > _default
+ // Triple: "mr view 123" matches before "mr view"
+ // Compound: "mr list" matches before "mr"
let default_response = CommandResponse {
file: None,
output: None,
stderr: None,
exit_code: 1,
};
- let response = args
- .first()
- .and_then(|cmd| config.commands.get(cmd))
+
+ // Try triple match first (e.g., "mr view 1", "mr view 2")
+ let triple_key = if args.len() >= 3 {
+ Some(format!("{} {} {}", args[0], args[1], args[2]))
+ } else {
+ None
+ };
+
+ // Try compound match (e.g., "mr list", "mr view")
+ let compound_key = if args.len() >= 2 {
+ Some(format!("{} {}", args[0], args[1]))
+ } else {
+ None
+ };
+
+ let response = triple_key
+ .as_ref()
+ .and_then(|key| config.commands.get(key))
+ // Fall back to compound match
+ .or_else(|| {
+ compound_key
+ .as_ref()
+ .and_then(|key| config.commands.get(key))
+ })
+ // Fall back to single-arg match
+ .or_else(|| args.first().and_then(|cmd| config.commands.get(cmd)))
+ // Fall back to _default
.or_else(|| config.commands.get("_default"))
.unwrap_or(&default_response);
diff --git a/tests/integration_tests/ci_status.rs b/tests/integration_tests/ci_status.rs
index 022aff5e3..379c29a16 100644
--- a/tests/integration_tests/ci_status.rs
+++ b/tests/integration_tests/ci_status.rs
@@ -459,6 +459,7 @@ fn test_list_full_with_gitlab_mr_status(
let mr_json = format!(
r#"[{{
+ "iid": 1,
"sha": "{}",
"has_conflicts": {},
"detailed_merge_status": null,
@@ -484,6 +485,7 @@ fn test_list_full_with_gitlab_stale_mr(mut repo: TestRepo) {
// MR HEAD differs from local HEAD - simulates stale MR
let mr_json = r#"[{
+ "iid": 1,
"sha": "old_sha_from_before_local_commit",
"has_conflicts": false,
"detailed_merge_status": null,
@@ -502,6 +504,7 @@ fn test_list_full_with_gitlab_no_ci(mut repo: TestRepo) {
// MR with no pipeline
let mr_json = format!(
r#"[{{
+ "iid": 1,
"sha": "{}",
"has_conflicts": false,
"detailed_merge_status": null,
@@ -529,9 +532,11 @@ fn test_list_full_with_gitlab_filters_by_project_id(mut repo: TestRepo) {
let head_sha = get_branch_sha(&repo, "feature");
// Multiple MRs - only one from our project (should filter to project 99999)
+ // The "other" MR is listed first to prove filtering works (not just taking first element)
let mr_json = format!(
r#"[
{{
+ "iid": 99,
"sha": "wrong_sha",
"has_conflicts": false,
"detailed_merge_status": null,
@@ -540,6 +545,7 @@ fn test_list_full_with_gitlab_filters_by_project_id(mut repo: TestRepo) {
"web_url": "https://gitlab.com/other-group/other-project/-/merge_requests/99"
}},
{{
+ "iid": 1,
"sha": "{}",
"has_conflicts": false,
"detailed_merge_status": null,
@@ -612,3 +618,55 @@ fn test_list_full_with_url_based_pushremote(mut repo: TestRepo) {
run_ci_status_test(&mut repo, "url_based_pushremote", &pr_json, "[]");
}
+
+// =============================================================================
+// GitLab error path tests
+// =============================================================================
+
+/// Test that when `glab mr view` fails after finding an MR, we show error status (not NoCI).
+#[rstest]
+fn test_list_full_with_gitlab_mr_view_failure(mut repo: TestRepo) {
+ let head_sha = setup_gitlab_repo_with_feature(&mut repo);
+
+ // Set up mock where mr list succeeds but mr view fails
+ let mr_list_json = format!(
+ r#"[{{
+ "iid": 1,
+ "sha": "{}",
+ "has_conflicts": false,
+ "detailed_merge_status": null,
+ "source_project_id": 12345,
+ "web_url": "https://gitlab.com/test/repo/-/merge_requests/1"
+ }}]"#,
+ head_sha
+ );
+
+ repo.setup_mock_glab_with_failing_mr_view(&mr_list_json, Some(12345));
+
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd = make_snapshot_cmd(&repo, "list", &["--full"], None);
+ repo.configure_mock_commands(&mut cmd);
+ assert_cmd_snapshot!("gitlab_mr_view_failure", cmd);
+ });
+}
+
+/// Test that rate limit errors in `glab ci list` show error status (not NoCI).
+///
+/// This exercises the `is_retriable_error` check in `detect_gitlab_pipeline`,
+/// which is the fallback path when no MR exists for a branch.
+#[rstest]
+fn test_list_full_with_gitlab_ci_rate_limit(mut repo: TestRepo) {
+ setup_gitlab_repo_with_feature(&mut repo);
+
+ // Mock returns empty MR list (no MRs), so we fall through to ci list,
+ // which returns a rate limit error
+ repo.setup_mock_glab_with_ci_rate_limit(Some(12345));
+
+ let settings = setup_snapshot_settings(&repo);
+ settings.bind(|| {
+ let mut cmd = make_snapshot_cmd(&repo, "list", &["--full"], None);
+ repo.configure_mock_commands(&mut cmd);
+ assert_cmd_snapshot!("gitlab_ci_rate_limit", cmd);
+ });
+}
diff --git a/tests/snapshots/integration__integration_tests__ci_status__gitlab_ci_rate_limit.snap b/tests/snapshots/integration__integration_tests__ci_status__gitlab_ci_rate_limit.snap
new file mode 100644
index 000000000..444549638
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__ci_status__gitlab_ci_rate_limit.snap
@@ -0,0 +1,46 @@
+---
+source: tests/integration_tests/ci_status.rs
+assertion_line: 612
+info:
+ program: wt
+ args:
+ - list
+ - "--full"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ 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: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ SOURCE_DATE_EPOCH: "1735776000"
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
+@ main ^| . | ⚠ 05a4a45d 16h Initial commit
++ feature _| ../repo.feature | ⚠ 05a4a45d 16h Initial commit
++ feature-a ↑| ↑1 +1 ../repo.feature-a | ⚠ 1b87d473 16h Add feature-a file
++ feature-b ↑| ↑1 +1 ../repo.feature-b | ⚠ f62940fc 16h Add feature-b file
++ feature-c ↑| ↑1 +1 ../repo.feature-c | ⚠ 345c7c93 16h Add feature-c file
+
+○ Showing 5 worktrees, 3 ahead
+
+----- stderr -----
diff --git a/tests/snapshots/integration__integration_tests__ci_status__gitlab_mr_view_failure.snap b/tests/snapshots/integration__integration_tests__ci_status__gitlab_mr_view_failure.snap
new file mode 100644
index 000000000..65c402fdc
--- /dev/null
+++ b/tests/snapshots/integration__integration_tests__ci_status__gitlab_mr_view_failure.snap
@@ -0,0 +1,46 @@
+---
+source: tests/integration_tests/ci_status.rs
+assertion_line: 592
+info:
+ program: wt
+ args:
+ - list
+ - "--full"
+ env:
+ APPDATA: "[TEST_CONFIG_HOME]"
+ CLICOLOR_FORCE: "1"
+ COLUMNS: "500"
+ 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: ""
+ GIT_TERMINAL_PROMPT: "0"
+ HOME: "[TEST_HOME]"
+ LANG: C
+ LC_ALL: C
+ MOCK_CONFIG_DIR: "[MOCK_CONFIG_DIR]"
+ PATH: "[PATH]"
+ RUST_LOG: warn
+ SHELL: ""
+ SOURCE_DATE_EPOCH: "1735776000"
+ TERM: alacritty
+ USERPROFILE: "[TEST_HOME]"
+ WORKTRUNK_CONFIG_PATH: "[TEST_CONFIG]"
+ WORKTRUNK_TEST_SKIP_URL_HEALTH_CHECK: "1"
+ WT_TEST_DELAYED_STREAM_MS: "-1"
+ XDG_CONFIG_HOME: "[TEST_CONFIG_HOME]"
+---
+success: true
+exit_code: 0
+----- stdout -----
+ Branch Status HEAD± main↕ main…± Path Remote⇅ CI Commit Age Message
+@ main ^| . | ⚠ 05a4a45d 16h Initial commit
++ feature _| ../repo.feature | ⚠ 05a4a45d 16h Initial commit
++ feature-a ↑| ↑1 +1 ../repo.feature-a | ⚠ 1b87d473 16h Add feature-a file
++ feature-b ↑| ↑1 +1 ../repo.feature-b | ⚠ f62940fc 16h Add feature-b file
++ feature-c ↑| ↑1 +1 ../repo.feature-c | ⚠ 345c7c93 16h Add feature-c file
+
+○ Showing 5 worktrees, 3 ahead
+
+----- stderr -----