Repository navigation
Add commit status listing and setting to the Bitbucket backend - #222
Merged
Merged
Conversation
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.
|
Warning Review limit reachedYou'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. View limit details
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. |
andrew
approved these changes
Nov 20, 2026
andrew
left a comment
Contributor
There was a problem hiding this comment.
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Bitbucket Cloud backend returned
ErrNotSupportedfor bothCommitStatusServicemethods. That brokeforge status listandforge status seton bitbucket.org, and madeforge pr checksstop 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
/commit/{sha}/statusesand followsnextlinks. Short SHAs work, which matters because Bitbucket pull requests only carry an abbreviated head commit hash, and that's whatpr checkspasses./commit/{sha}/statuses/build. A status'skeyidentifies it on its commit, and posting the same key replaces it, which is the rolecontextplays on other forges. So the context is sent as thekey, and also as thenamethe Bitbucket UI shows. On read,Contextis the key. Empty descriptions and URLs are left out.Bitbucket has four states:
SUCCESSFUL,FAILED,INPROGRESSandSTOPPED.success,failure,error,pendingandcancelledmap onto them.errorbecomesFAILEDbecause Bitbucket has no error state. Native names are accepted in any case, and anything else (for exampleskipped) is sent upper-cased for Bitbucket to reject with its own validation error.NormalizeCommitStatusStatealready handledSUCCESSFULandFAILEDbut returnedunknownforINPROGRESSandSTOPPED. They now normalize topendingandcancelled, matching howNormalizeCIStatusalready treatsinprogress. This also givespr checksthe right pending and failing results, and the right exit code.Testing
TestNormalizeCommitStatusStatecovers the Bitbucket state names.TestReplayListCommitStatusesreplays a real Pipelines build status from api.bitbucket.org.forge status listagainst bitbucket.org with a full SHA and a short SHA, andforge pr checkson a merged pull request.go test ./...,go test -race . ./bitbucket ./internal/cli, thejs/wasmandwasip1/wasmbuilds, andgolangci-lint run(0 issues) all pass locally.