Skip to content

[279] feat: wire Bitbucket Pipelines into parsec ci + pr-status mapping#282

Merged
erishforG merged 1 commit intodevelopfrom
feature/279
May 4, 2026
Merged

[279] feat: wire Bitbucket Pipelines into parsec ci + pr-status mapping#282
erishforG merged 1 commit intodevelopfrom
feature/279

Conversation

@erishforG
Copy link
Copy Markdown
Owner

Summary

Closes the two gaps left after the Bitbucket Cloud forge work in #240 (PR #276):

1. `parsec ci` now dispatches on the origin remote

When the remote is Bitbucket, `ci` resolves the PR's source branch and polls the Pipelines API (`/repositories/.../pipelines/`) instead of GitHub Checks. The result is shaped into the existing `CiStatus` struct so renderers, `--watch`, and exit-code logic stay forge-agnostic.

2. `parsec pr-status` Bitbucket branch returns real CI / review

No more hardcoded `"unknown"` for `ci_status` / `review_status`:

  • `ci_status` ← latest pipeline for the PR's source branch
  • `review_status` ← PR participants list

Both fall back to `"unknown"` on network error rather than failing the whole command.

Vocabulary matches the GitHub path exactly:

  • CI: `passing` | `failing` | `pending` | `no checks` | `unknown`
  • Review: `approved` | `changes_requested` | `pending` | `no reviews`

Closes #279

Changes

  • `src/cli/commands/ci.rs` — remote-aware dispatch + Bitbucket Pipelines path with `--watch` support.
  • `src/cli/commands/pr.rs` — fill CI/review for Bitbucket pr-status.
  • `src/bitbucket/mod.rs` — new helpers: `get_latest_pipeline_for_branch`, `get_pr_source_branch`, `get_pr_participants`. Pure mapping fns `pipeline_to_ci_status` / `participants_to_review_status` are unit-tested directly.
  • `src/env.rs` — `PARSEC_BITBUCKET_API_BASE` env var so tests can point at a mock server (also useful for future Bitbucket Server / Data Center support).
  • `Cargo.toml` — `mockito` as dev-dependency. The codebase had no HTTP mocking infra and the new integration tests need it. Justified in commit message.
  • `tests/bitbucket_integration_tests.rs` (new) — 5 integration tests.

GitHub repo behaviour is unchanged — verified by the unchanged 40 existing integration tests + an explicit `expect(0)` assertion on `/repos/*` in the Bitbucket CI integration test (catches dispatch regressions).

Verification

Check Result
`cargo build --release`
`cargo test` ✅ 76 passed (31 unit + 5 new integration + 40 existing)
`cargo clippy --all-targets -- -D warnings` ✅ clean
`cargo fmt -- --check` ✅ clean

Test plan

  • CI green
  • Manual: against a real Bitbucket repo, `parsec ci ` shows live pipeline status
  • Manual: `parsec pr-status` shows CI + review state instead of `unknown`
  • Regression: GitHub repos behave unchanged (CI calls Checks API, pr-status reads gh fields)

Closes the two gaps left after the Bitbucket Cloud forge work in #240:

* `parsec ci` now dispatches on the origin remote — when it's Bitbucket,
  it resolves the PR's source branch and polls the Pipelines API
  (`/repositories/.../pipelines/`) instead of GitHub Checks. The result
  is shaped into the existing `CiStatus` struct so renderers, --watch,
  and exit-code logic stay forge-agnostic.

* `parsec pr-status`'s Bitbucket branch no longer hardcodes "unknown"
  for ci_status / review_status. ci_status comes from the latest
  pipeline for the PR's source branch; review_status comes from the
  PR participants list. Both fall back to "unknown" on network error
  rather than failing the whole command.

Vocabulary matches the GitHub path exactly: passing | failing | pending
| no checks | unknown for CI; approved | changes_requested | pending
| no reviews for review.

New `BitbucketClient` helpers: `get_latest_pipeline_for_branch`,
`get_pr_source_branch`, `get_pr_participants`. Pure mapping functions
(`pipeline_to_ci_status`, `participants_to_review_status`) are unit
tested directly.

Adds `mockito` as a dev-dependency — the codebase had no HTTP mocking
infra, and the new `tests/bitbucket_integration_tests.rs` needs it to
verify the Bitbucket dispatch path end-to-end without hitting the
real api.bitbucket.org. To make this testable, `BitbucketClient`
honors a new `PARSEC_BITBUCKET_API_BASE` env var (also useful for
future Bitbucket Server / Data Center support).

Behaviour for GitHub repositories is unchanged.

Test coverage: 20 unit tests for mappings + 5 integration tests
(`pr-status` approved/changes_requested/no-pipeline cases, `ci`
in-progress + failing-exit-code cases, plus an explicit
"never call /repos/*" assertion to catch dispatch regressions).

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@erishforG erishforG merged commit 5fc0d4a into develop May 4, 2026
11 checks passed
@erishforG erishforG deleted the feature/279 branch May 4, 2026 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant