Skip to content

Add commit status listing and setting to the Bitbucket backend - #222

Merged
andrew merged 1 commit into
git-pkgs:mainfrom
NopeCharon:bitbucket-commit-statuses
Nov 20, 2026
Merged

andrew merged 1 commit into
git-pkgs:mainfrom
NopeCharon:bitbucket-commit-statuses

Conversation

@NopeCharon

Copy link
Copy Markdown
Contributor

Summary

The Bitbucket Cloud backend returned ErrNotSupported for both CommitStatusService methods. That broke forge status list and forge status set on bitbucket.org, and made forge pr checks stop with "checks are not supported by this forge", because none of its sources worked there. This PR implements the service with Bitbucket's build statuses.

How it works

  • List reads /commit/{sha}/statuses and follows next links. Short SHAs work, which matters because Bitbucket pull requests only carry an abbreviated head commit hash, and that's what pr checks passes.
  • Set posts to /commit/{sha}/statuses/build. A status's key identifies it on its commit, and posting the same key replaces it, which is the role context plays on other forges. So the context is sent as the key, and also as the name the Bitbucket UI shows. On read, Context is the key. Empty descriptions and URLs are left out.

Bitbucket has four states: SUCCESSFUL, FAILED, INPROGRESS and STOPPED.

  • On write, success, failure, error, pending and cancelled map onto them. error becomes FAILED because Bitbucket has no error state. Native names are accepted in any case, and anything else (for example skipped) is sent upper-cased for Bitbucket to reject with its own validation error.
  • On read, NormalizeCommitStatusState already handled SUCCESSFUL and FAILED but returned unknown for INPROGRESS and STOPPED. They now normalize to pending and cancelled, matching how NormalizeCIStatus already treats inprogress. This also gives pr checks the right pending and failing results, and the right exit code.

Testing

  • httptest coverage for pagination, mapping all four Bitbucket states on read, timestamps, the request body (including omitted empty fields), state mapping on write, not found, a rejected state, and read-only mode.
  • TestNormalizeCommitStatusState covers the Bitbucket state names.
  • TestReplayListCommitStatuses replays a real Pipelines build status from api.bitbucket.org.
  • Ran forge status list against bitbucket.org with a full SHA and a short SHA, and forge pr checks on a merged pull request.
  • go test ./..., go test -race . ./bitbucket ./internal/cli, the js/wasm and wasip1/wasm builds, and golangci-lint run (0 issues) all pass locally.

The Bitbucket Cloud backend returned ErrNotSupported for both
CommitStatusService methods, so `forge status list`/`status set`
failed on bitbucket.org, and `forge pr checks` stopped with "checks are
not supported by this forge" because none of its sources worked there.
They now use Bitbucket's build statuses.

- List reads /commit/{sha}/statuses and follows `next` links. Short
  SHAs work, which matters because Bitbucket pull requests only carry
  an abbreviated head commit hash.
- Set posts to /commit/{sha}/statuses/build. A status's key identifies
  it on the commit and posting the same key replaces it, so the context
  is sent as the key, and also as the name the Bitbucket UI shows.
  Empty descriptions and URLs are left out.

Bitbucket has four states: SUCCESSFUL, FAILED, INPROGRESS and STOPPED.
On write, success, failure, error, pending and cancelled map onto them
(error becomes FAILED, as Bitbucket has no error state), native names
are accepted in any case, and anything else is sent upper-cased for
Bitbucket to reject. On read, NormalizeCommitStatusState already
handled SUCCESSFUL and FAILED but returned unknown for INPROGRESS and
STOPPED; they now normalize to pending and cancelled, as
NormalizeCIStatus already does for "inprogress".

Tests cover pagination, state mapping both ways, request bodies, error
responses and read-only mode, plus a replay of a real Pipelines status
from api.bitbucket.org.
@coderabbitai

coderabbitai Bot commented Nov 19, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fffb9701-82ab-4573-8a01-0b94da173e8c
Commits

Reviewing files that changed from the base of the PR and between c046578 and 2655ce9.

Files selected for processing: 6

  • bitbucket/commit_statuses.go
  • bitbucket/commit_statuses_test.go
  • bitbucket/replay_test.go
  • bitbucket/testdata/replay/TestReplayListCommitStatuses.json
  • statuses.go
  • statuses_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@andrew andrew left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this fills a real gap for pr checks on bitbucket.org. One small thing for next time: the comment on Set in bitbucket/commit_statuses.go repeats what the bbCommitStatus comment already says about the key replacing an existing status, so it could be cut to one line or dropped.

@andrew
andrew merged commit 6793179 into git-pkgs:main Nov 20, 2026
6 checks passed
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.

2 participants