Skip to content

Commit 35cd252

Browse files
authored
Merge pull request #124 from git-for-windows/fix-snapshot-uploading-of-full-releases
Fix the snapshot uploading of official Git for Windows versions
2 parents adc1a0e + c2b466e commit 35cd252

File tree

3 files changed

+28
-9
lines changed

3 files changed

+28
-9
lines changed

GitForWindowsHelper/cascading-runs.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,15 @@ 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, behind_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-
return `Ignoring ${name} check-run because its corresponding commit ${commit} is not on the main branch`
176+
if (ahead_by > 0) {
177+
return `Ignoring ${name} check-run because its corresponding commit ${commit} is not on the main branch (ahead by ${ahead_by}, behind by ${behind_by})`
177178
}
178179

179180
const workFlowRunIDs = {}
@@ -245,7 +246,7 @@ const cascadingRuns = async (context, req) => {
245246
}
246247
)
247248

248-
return `The 'upload-snapshot' workflow run was started at ${answer.html_url}`
249+
return `The 'upload-snapshot' workflow run was started at ${answer.html_url} (ahead by ${ahead_by}, behind by ${behind_by})`
249250
}
250251
return `Not a cascading run: ${name}; Doing nothing.`
251252
}

GitForWindowsHelper/finalize-g4w-release.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,20 @@ module.exports = async (context, req) => {
5858
force: false // require fast-forward
5959
})
6060

61-
return `Took care of pushing the \`main\` branch to close PR ${prNumber}`
61+
// trigger "upload artifacts" workflow
62+
const { handlePush } = require('./cascading-runs')
63+
const uploadSnapshotAnswer = await handlePush(context, {
64+
body: {
65+
repository: {
66+
owner: {
67+
login: owner,
68+
},
69+
name: repo,
70+
},
71+
ref: 'refs/heads/main',
72+
after: sha,
73+
}
74+
})
75+
76+
return `Took care of pushing the \`main\` branch to close PR ${prNumber}\n${uploadSnapshotAnswer}`
6277
}

__tests__/index.test.js

Lines changed: 7 additions & 4 deletions
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, behind_by: 99 }
179179
}
180180
throw new Error(`Unhandled ${method}-${requestPath}-${JSON.stringify(payload)}`)
181181
})
@@ -943,11 +943,14 @@ test('a completed `release-git` run updates the `main` branch in git-for-windows
943943
try {
944944
expect(await index(context, context.req)).toBeUndefined()
945945
expect(context.res).toEqual({
946-
body: `Took care of pushing the \`main\` branch to close PR 765`,
946+
body: [
947+
'Took care of pushing the `main` branch to close PR 765',
948+
`The 'tag-git' workflow run was started at dispatched-workflow-tag-git.yml`,
949+
].join('\n'),
947950
headers: undefined,
948951
status: undefined
949952
})
950-
expect(mockGitHubApiRequest).toHaveBeenCalledTimes(4)
953+
expect(mockGitHubApiRequest).toHaveBeenCalledTimes(7)
951954
expect(mockGitHubApiRequest.mock.calls[3].slice(1)).toEqual([
952955
'installation-access-token',
953956
'PATCH',
@@ -994,7 +997,7 @@ test('the third completed `git-artifacts-<arch>` check-run triggers an `upload-s
994997
try {
995998
expect(await index(context, context.req)).toBeUndefined()
996999
expect(context.res).toEqual({
997-
body: `The 'upload-snapshot' workflow run was started at dispatched-workflow-upload-snapshot.yml`,
1000+
body: `The 'upload-snapshot' workflow run was started at dispatched-workflow-upload-snapshot.yml (ahead by 0, behind by 99)`,
9981001
headers: undefined,
9991002
status: undefined
10001003
})

0 commit comments

Comments
 (0)