Skip to content

Commit df801d0

Browse files
committed
snapshot uploading: fix the ahead/behind by logic
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]>
1 parent 92e1d90 commit df801d0

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

GitForWindowsHelper/cascading-runs.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,14 @@ const cascadingRuns = async (context, req) => {
166166

167167
// Next, check that the commit is on the `main` branch
168168
const gitToken = await getToken(context, checkRunOwner, checkRunRepo)
169-
const { behind_by } = await githubApiRequest(
169+
const { ahead_by } = await githubApiRequest(
170170
context,
171171
gitToken,
172172
'GET',
173173
`/repos/${checkRunOwner}/${checkRunRepo}/compare/HEAD...${commit}`,
174+
// `/repos/dscho/git/compare/HEAD...${commit}`,
174175
)
175-
if (behind_by > 0) {
176+
if (ahead_by > 0) {
176177
return `Ignoring ${name} check-run because its corresponding commit ${commit} is not on the main branch`
177178
}
178179

__tests__/index.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ The \`git-artifacts-aarch64\` workflow run [was started](dispatched-workflow-git
175175
}
176176
if (method === 'GET' && requestPath ===
177177
'/repos/git-for-windows/git/compare/HEAD...0c796d3013a57e8cc894c152f0200107226e5dd1') {
178-
return { behind_by: 0 }
178+
return { ahead_by: 0 }
179179
}
180180
throw new Error(`Unhandled ${method}-${requestPath}-${JSON.stringify(payload)}`)
181181
})

0 commit comments

Comments
 (0)