Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
fix(list): classify non-terminal GitLab and Azure pipeline statuses as running (#3740)
Worktrunk Bot1c578cb63069
diff --git a/src/commands/list/ci_status/azure.rs b/src/commands/list/ci_status/azure.rsindex 66c81ae24..d5ae49f01 100644--- a/src/commands/list/ci_status/azure.rs+++ b/src/commands/list/ci_status/azure.rs@@ -239,15 +239,29 @@ pub(super) fn detect_azure_pipeline(}/// Map Azure Pipelines run status/result to [`CiStatus`].+///+/// `completed` is the only terminal status, so it alone consults `result`; the+/// rest of the documented [build status+/// enum](https://learn.microsoft.com/en-us/rest/api/azure/devops/build/builds/get?view=azure-devops-rest-7.1)+/// (`inProgress`, `notStarted`, `cancelling`, `postponed`) is a run still on+/// its way there and groups as `Running` — matching how+/// `parse_gitlab_status` groups GitLab's non-terminal statuses. In particular+/// `cancelling` is not the terminal cancellation: that one arrives as+/// `completed` with result `canceled`, and is already `Failed` below.+///+/// Of the `BuildResult` values a `completed` run reports, `partiallySucceeded`+/// ("completed compilation successfully but had other errors") groups with+/// `Failed`, matching how `parse_gitea_status_state` classifies Gitea's+/// equivalent `warning`. Only `none` stays `NoCI` — a finished run with no+/// result carries no verdict to show.fn parse_azure_pipeline_status(status: Option<&str>, result: Option<&str>) -> CiStatus {match status {- Some("inProgress" | "notStarted") => CiStatus::Running,+ Some("inProgress" | "notStarted" | "cancelling" | "postponed") => CiStatus::Running,Some("completed") => match result {Some("succeeded") => CiStatus::Passed,- Some("failed" | "canceled") => CiStatus::Failed,+ Some("failed" | "canceled" | "partiallySucceeded") => CiStatus::Failed,_ => CiStatus::NoCI,},- Some("cancelling") => CiStatus::Failed,_ => CiStatus::NoCI,}}@@ -373,29 +387,34 @@ mod tests {#[test]fn test_parse_azure_pipeline_status() {- assert_eq!(- parse_azure_pipeline_status(Some("inProgress"), None),- CiStatus::Running- );- assert_eq!(- parse_azure_pipeline_status(Some("notStarted"), None),- CiStatus::Running- );+ // Non-terminal statuses. "cancelling" is cancellation in flight — the+ // terminal form is "completed" with result "canceled"; "postponed" is a+ // run sitting inactive in the queue.+ for status in ["inProgress", "notStarted", "cancelling", "postponed"] {+ assert_eq!(+ parse_azure_pipeline_status(Some(status), None),+ CiStatus::Running,+ "status={status}"+ );+ }assert_eq!(parse_azure_pipeline_status(Some("completed"), Some("succeeded")),CiStatus::Passed);+ // Terminal verdicts. "partiallySucceeded" completed with errors, so it+ // reads as a failure rather than as no CI — same call gitea.rs makes+ // for "warning".+ for result in ["failed", "canceled", "partiallySucceeded"] {+ assert_eq!(+ parse_azure_pipeline_status(Some("completed"), Some(result)),+ CiStatus::Failed,+ "result={result}"+ );+ }+ // A completed run with no result carries no verdict.assert_eq!(- parse_azure_pipeline_status(Some("completed"), Some("failed")),- CiStatus::Failed- );- assert_eq!(- parse_azure_pipeline_status(Some("completed"), Some("canceled")),- CiStatus::Failed- );- assert_eq!(- parse_azure_pipeline_status(Some("cancelling"), None),- CiStatus::Failed+ parse_azure_pipeline_status(Some("completed"), Some("none")),+ CiStatus::NoCI);assert_eq!(parse_azure_pipeline_status(None, None), CiStatus::NoCI);}diff --git a/src/commands/list/ci_status/gitlab.rs b/src/commands/list/ci_status/gitlab.rsindex 34bdfff04..b3d0578f4 100644--- a/src/commands/list/ci_status/gitlab.rs+++ b/src/commands/list/ci_status/gitlab.rs@@ -413,20 +413,34 @@ pub(super) struct GitLabPipeline {pub web_url: Option<String>,}+/// Map a GitLab pipeline `status` to a [`CiStatus`].+///+/// The arms cover every value GitLab documents for the field+/// ([pipelines API](https://docs.gitlab.com/api/pipelines/)): `created`,+/// `waiting_for_resource`, `preparing`, `waiting_for_callback`, `pending`,+/// `running`, `success`, `failed`, `canceling`, `canceled`, `skipped`,+/// `manual`, `scheduled`. Every non-terminal status groups as `Running` — a+/// pipeline still moving, whatever it's waiting on — so a status GitLab adds+/// later is the only thing that reaches the `_` fallback.fn parse_gitlab_status(status: Option<&str>) -> CiStatus {match status {- // "manual" = pipeline waiting for user to trigger a manual job (not failed)+ // Non-terminal. "manual" = waiting for a user to trigger a manual job;+ // "canceling" = cancellation in flight, not yet the terminal "canceled".Some("running"| "pending"| "preparing"| "waiting_for_resource"+ | "waiting_for_callback"| "created"| "scheduled"- | "manual",+ | "manual"+ | "canceling",) => CiStatus::Running,Some("failed" | "canceled") => CiStatus::Failed,Some("success") => CiStatus::Passed,+ // "skipped" and an absent status carry no signal, as does any status+ // GitLab introduces after the list above.Some("skipped") | None => CiStatus::NoCI,_ => CiStatus::NoCI,}@@ -497,15 +511,19 @@ mod tests {#[test]fn test_parse_gitlab_status() {- // Running states (includes "manual" - waiting for user to trigger)+ // Non-terminal states. "manual" waits for a user to trigger a job;+ // "canceling" is cancellation in flight (the terminal form is+ // "canceled"); "waiting_for_callback" waits on an external system.for status in ["running","pending","preparing","waiting_for_resource",+ "waiting_for_callback","created","scheduled","manual",+ "canceling",] {assert_eq!(parse_gitlab_status(Some(status)),