Skip to content

Commit

Permalink
snapshot uploading: log both ahead/behind by numbers
Browse files Browse the repository at this point in the history
This should help with debugging in the future, should the need arise
again.

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

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

const workFlowRunIDs = {}
Expand Down Expand Up @@ -246,7 +246,7 @@ const cascadingRuns = async (context, req) => {
}
)

return `The 'upload-snapshot' workflow run was started at ${answer.html_url}`
return `The 'upload-snapshot' workflow run was started at ${answer.html_url} (ahead by ${ahead_by}, behind by ${behind_by})`
}
return `Not a cascading run: ${name}; Doing nothing.`
}
Expand Down
4 changes: 2 additions & 2 deletions __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 { ahead_by: 0 }
return { ahead_by: 0, behind_by: 99 }
}
throw new Error(`Unhandled ${method}-${requestPath}-${JSON.stringify(payload)}`)
})
Expand Down Expand Up @@ -994,7 +994,7 @@ test('the third completed `git-artifacts-<arch>` check-run triggers an `upload-s
try {
expect(await index(context, context.req)).toBeUndefined()
expect(context.res).toEqual({
body: `The 'upload-snapshot' workflow run was started at dispatched-workflow-upload-snapshot.yml`,
body: `The 'upload-snapshot' workflow run was started at dispatched-workflow-upload-snapshot.yml (ahead by 0, behind by 99)`,
headers: undefined,
status: undefined
})
Expand Down

0 comments on commit 739b2e4

Please sign in to comment.