Skip to content

Commit

Permalink
snapshot uploading: fix the ahead/behind by logic
Browse files Browse the repository at this point in the history
The logic was _exactly_ inverted. What it _did_ want to verify was that
the commit for which the snapshot was built is reachable from `main`.
What it verified instead was that `main`'s tip commit is reachable from
said commit. 🤦

I noticed this only today, when a successful `git-artifacts` run in the
v2.48.1 PR at git-for-windows/git#5411 tried to
upload a snapshot, and the (correct) ahead/behind by logic in the
`upload-artifacts` workflow failed (but then succeeded when I re-ran the
workflow after releasing Git for Windows v2.48.1).

Let's invert the logic so that it does what it is supposed to do.

Signed-off-by: Johannes Schindelin <[email protected]>
  • Loading branch information
dscho committed Feb 13, 2025
1 parent 92e1d90 commit df801d0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions GitForWindowsHelper/cascading-runs.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,14 @@ const cascadingRuns = async (context, req) => {

// Next, check that the commit is on the `main` branch
const gitToken = await getToken(context, checkRunOwner, checkRunRepo)
const { behind_by } = await githubApiRequest(
const { ahead_by } = await githubApiRequest(
context,
gitToken,
'GET',
`/repos/${checkRunOwner}/${checkRunRepo}/compare/HEAD...${commit}`,
// `/repos/dscho/git/compare/HEAD...${commit}`,
)
if (behind_by > 0) {
if (ahead_by > 0) {
return `Ignoring ${name} check-run because its corresponding commit ${commit} is not on the main branch`
}

Expand Down
2 changes: 1 addition & 1 deletion __tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ The \`git-artifacts-aarch64\` workflow run [was started](dispatched-workflow-git
}
if (method === 'GET' && requestPath ===
'/repos/git-for-windows/git/compare/HEAD...0c796d3013a57e8cc894c152f0200107226e5dd1') {
return { behind_by: 0 }
return { ahead_by: 0 }
}
throw new Error(`Unhandled ${method}-${requestPath}-${JSON.stringify(payload)}`)
})
Expand Down

0 comments on commit df801d0

Please sign in to comment.