Repository navigation
Conversation
This comment has been minimized.
This comment has been minimized.
|
Code Review 👍 Approved with suggestions 0 closed / 1 findings🟡 Medium risk · Targeting bookkeeping refs at the PR head or an optional SHA could make build-number allocation fail when that commit cannot be accepted. Defaults bookkeeping refs to the PR head for pull requests and adds an optional 💡 [cross-pr] Conflicts with #360's ref-target rule; one side's tests and input break📄 get-build-number/get_build_number.sh:35 📄 get-build-number/action.yml:9-11 📄 get-build-number/action.yml:66 📄 spec/get_build_number_spec.sh:24-38 Breaks when this PR is reopened and merged into master alongside #360, and both change the How
Fix
Compared 🤖 Prompt for agentsVerification Rules 2/2 met Repos 4 inspected · PRs 3 inspectedFunctional validation No results Rules 2 passed 1 not applicable
Broader impact Repos 4 inspected PRs 3 inspectedCross-repo 4 repositories inspected 0 open impacts
Cross-PR 3 PRs inspected 1 open impactAuto-approval Not enabledFor more verification details, comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
| create_ref() { | ||
| local ref="$1" | ||
| gh api --method POST -H "$GH_API_VERSION_HEADER" "$REFS_API_URL" -f "ref=refs/${ref}" -f "sha=${GITHUB_SHA}" 2>&1 | ||
| gh api --method POST -H "$GH_API_VERSION_HEADER" "$REFS_API_URL" -f "ref=refs/${ref}" -f "sha=${BUILD_NUMBER_REF_SHA:-$GITHUB_SHA}" 2>&1 |
There was a problem hiding this comment.
💡 [cross-pr] Conflicts with #360's ref-target rule; one side's tests and input break
Breaks when this PR is reopened and merged into master alongside #360, and both change the sha= argument of create_ref().
How
- This PR sends
sha=${BUILD_NUMBER_REF_SHA:-$GITHUB_SHA}(get-build-number/get_build_number.sh:35). It is fed from a newref-shainput that defaults to the PR head (get-build-number/action.yml:9-11,66). - BUILD-12998 Fix build-number ref authorization for PR merge commits #360 changes the same line to
sha=${REF_TARGET_SHA}(get-build-number/get_build_number.sh:36). That value is resolved once fromcommits/HEAD(the default-branch head). BUILD-12998 Fix build-number ref authorization for PR merge commits #360 has noref-shainput and does not passBUILD_NUMBER_REF_SHA. - If BUILD-12998 Fix build-number ref authorization for PR merge commits #360's line wins, this PR's
ref-shainput and README table describe an option that has no effect. Its new spec also fails, because the mockedghreturns 1 unlesssha=${BUILD_NUMBER_REF_SHA}is sent (spec/get_build_number_spec.sh:31). - If this PR's line wins, BUILD-12998 Fix build-number ref authorization for PR merge commits #360's default-head targeting and its specs that expect
sha=<default-head>fail. Combining both also adds acommits/HEADcall that this PR's mock doesn't expect.
Fix
- This PR: Choose one ref-target rule together with BUILD-12998 Fix build-number ref authorization for PR merge commits #360. If the
ref-shaoverride stays, make it take priority over BUILD-12998 Fix build-number ref authorization for PR merge commits #360's resolved default-branch head, and update the spec mocks to handle thecommits/HEADlookup. - BUILD-12998 Fix build-number ref authorization for PR merge commits #360: Add an optional override (for example,
BUILD_NUMBER_REF_SHA/ref-sha) that skips thecommits/HEADlookup when it is set. Otherwise, close one of the two PRs so only one strategy lands.
Compared 9ecc067 with #360 at 984ec6f
Was this helpful? React with 👍 / 👎



Build-number allocation fails with HTTP 403 on sonar-plugin-api PR #336 despite
contents: write. A diagnostic using the same job token could create a bookkeeping ref targeting the PR head, but GitHub rejected the synthetic merge commit and each older commit tested: https://github.com/SonarSource/sonar-plugin-api/actions/runs/39421989592.Default bookkeeping refs to the PR head for pull requests, retaining the workflow SHA for other events. Add an optional
ref-shainput so callers can choose the target explicitly. Ref targets are never read by the allocator, and the build checkout and commit metadata remain unchanged.Validation: all 19 focused ShellSpec tests and ShellCheck pass, including a regression that checks the supplied SHA is used for lock, number, and run-marker refs. End-to-end validation: SonarSource/sonar-plugin-api#336 allocated number 5607 against its PR head and passed its full Gradle build and SonarQube analysis while checking out the merge commit: https://github.com/SonarSource/sonar-plugin-api/actions/runs/39422587344. All checks on this PR also pass, including the full shell suite and Linux/Windows allocator integration tests.