PR-head config: extend same-repo detection to GitLab MRs + Bitbucket PRs (#223 follow-up)
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 7
- Forks
- 3
- Avg merge
- 2h 12m
- Merged PRs (30d)
- 30
Description
Follow-up to #223 (same-repo PR-head config, GitHub-only). Extend the head-config path to GitLab merge requests and Bitbucket pull requests.
Why this is smaller than it looks
Most of #223 is already provider-agnostic:
- Config fetch —
configsync.MultiFetcher.Fetchalready switches onsource.Providerand has workinggitlab.FetchGocdnextFolder/bitbucketpaths (configsync.go:158-182). No new fetch code needed. - Store barrier / resolver / binding lookup / wiring partition —
CreatePRHeadRun,resolvePRHeadPlan,FindPRHeadBindingsByURL(by normalized URL), andapplyPRHeadConfig's partition are all provider-neutral.
The only missing piece is a same-repo (same-project) predicate per provider, threaded into pullRequestEvent.SameRepo.
The gap
Today the gate is GitHub-only:
pr_head_dispatch.go:67—if ev.Provider != "github" || !ev.SameRepo.SameRepois derived + set only in the GitHub handler (handlePullRequest), via immutable repo ids (sameRepoGitHub). The GitLab and Bitbucket handlers never set it.
Work
- GitLab same-project predicate. The MR event carries
object_attributes.source_project_idandtarget_project_id, butParseMergeRequestEventdoesn't capture them yet. Add them and asameRepoGitLab(sourceProjectID, targetProjectID, projectID)mirroringsameRepoGitHub: true only when all ids are present (non-zero), consistent, andsource == target. A fork MR (source_project_id != target_project_id) → false. - Bitbucket same-repo predicate. The PR event carries
source.repository.uuidanddestination.repository.uuid; the parser captures neither today. Add them andsameRepoBitbucket(sourceUUID, destUUID)— equal (and non-empty) → true; a fork PR → false. - Thread
SameRepointopullRequestEventfrom both handlers (the field already exists; only the GitHub handler sets it). - Relax the gate. Once
SameRepois provider-uniform, drop the hard-codedev.Provider != "github"and gate on!ev.SameRepoalone — binding lookup and fetch already handle every provider. The head SHA for the fetch is already onpullRequestEvent.HeadSHAfor all three providers.
Fail-closed principle (carry over from #223)
Same-repo is decided only by immutable provider ids — never URL or name (a contributor controls both). Any missing, zero, or inconsistent id → false, so a fork or a malformed payload can never be mistaken for same-repo.
Tests
- Parser tests: id extraction for GitLab (
source/target_project_id) and Bitbucket (source/destinationrepo UUID); missing → same-repo false. - HTTP-boundary tests mirroring the GitHub matrix, per provider: same-repo + toggle-on → runs the head jobs; fork → base + zero fetch; toggle-off → base.
Notes
- GitLab already reuses
on: [pull_request]as the event name (the webhook is the provider boundary) — no schema change for users. - Bitbucket Cloud has no PR-label primitive (unchanged; unrelated to this).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in pr_head_dispatch.go at the provider gate, then trace ParseMergeRequestEvent, the Bitbucket parser, and the provider handlers alongside sameRepoGitHub. Run the parser and HTTP-boundary tests described in the issue; done means same-repository GitLab and Bitbucket events run head jobs, while forks, missing IDs, and the disabled toggle use the base path without fetching head config.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100