Skip to content

Commit 52e3fe4

Browse files
authored
Merge pull request #118 from dscho/synchronize-sdks
Add a slash command to synchronize Git for Windows' SDK repositories
2 parents 8672dce + 4b988c4 commit 52e3fe4

File tree

3 files changed

+56
-5
lines changed

3 files changed

+56
-5
lines changed

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"gnutls",
99
"Heimdal",
1010
"MSYS",
11-
"relnote"
11+
"relnote",
12+
"updpkgsums"
1213
],
1314
"cSpell.ignoreRegExpList": [
1415
"AZURE_FUNCTIONAPP_PUBLISH_PROFILE",

GitForWindowsHelper/slash-commands.js

Lines changed: 48 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ module.exports = async (context, req) => {
4949
const thumbsUp = async () => react('+1')
5050

5151
try {
52-
if (command == '/open pr') {
52+
if (command === '/open pr') {
5353
if (owner !== 'git-for-windows' || !['git', 'msys2-runtime'].includes(repo)) return `Ignoring ${command} in unexpected repo: ${commentURL}`
5454

5555
await checkPermissions()
@@ -111,7 +111,7 @@ module.exports = async (context, req) => {
111111
return `I edited the comment: ${commentURL}`
112112
}
113113

114-
if (command == '/updpkgsums') {
114+
if (command === '/updpkgsums') {
115115
if (owner !== 'git-for-windows'
116116
|| !req.body.issue.pull_request
117117
|| !['build-extra', 'MINGW-packages', 'MSYS2-packages'].includes(repo)) {
@@ -265,7 +265,7 @@ module.exports = async (context, req) => {
265265
return `I edited the comment: ${answer.html_url}`
266266
}
267267

268-
if (command == '/git-artifacts') {
268+
if (command === '/git-artifacts') {
269269
if (owner !== 'git-for-windows'
270270
|| repo !== 'git'
271271
|| !req.body.issue.pull_request
@@ -367,7 +367,7 @@ module.exports = async (context, req) => {
367367
}
368368
}
369369

370-
if (command == '/release') {
370+
if (command === '/release') {
371371
if (owner !== 'git-for-windows'
372372
|| repo !== 'git'
373373
|| !req.body.issue.pull_request
@@ -529,6 +529,50 @@ module.exports = async (context, req) => {
529529
const answer2 = await appendToIssueComment(context, await getToken(), owner, repo, commentId, `The workflow run [was started](${answer.html_url})`)
530530
return `I edited the comment: ${answer2.html_url}`
531531
}
532+
533+
if (command === '/synchronize-sdks' || command === '/sync') {
534+
if (owner !== 'git-for-windows') {
535+
return `Ignoring ${command} in unexpected repo: ${commentURL}`
536+
}
537+
538+
await checkPermissions()
539+
540+
await thumbsUp()
541+
542+
const triggerWorkflowDispatch = require('./trigger-workflow-dispatch')
543+
const triggerSync = async (sdkRepo) =>
544+
await triggerWorkflowDispatch(
545+
context,
546+
await getToken('git-for-windows', sdkRepo),
547+
'git-for-windows',
548+
sdkRepo,
549+
'sync.yml',
550+
'main'
551+
)
552+
553+
const { appendToIssueComment } = require('./issues')
554+
const appendToComment = async (text) =>
555+
await appendToIssueComment(
556+
context,
557+
await getToken(),
558+
owner,
559+
repo,
560+
commentId,
561+
text
562+
)
563+
564+
for (const architecture of ['aarch64', 'x86_64', 'i686']) {
565+
const sdkRepo = {
566+
aarch64: 'git-sdk-arm64',
567+
x86_64: 'git-sdk-64',
568+
i686: 'git-sdk-32'
569+
}[architecture]
570+
const sync = await triggerSync(sdkRepo)
571+
commentURL = (await appendToComment(`The ['sync' run for ${architecture}](${sync.html_url}) was started.`)).html_url
572+
}
573+
574+
return `I edited the comment: ${commentURL}`
575+
}
532576
} catch (e) {
533577
await react('confused')
534578
throw e

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@ For convenience, the command can be abbreviated as `/add relnote <type> <message
4545

4646
**What does it do?** This triggers one ore more [GitHub workflow runs](https://github.com/git-for-windows/git-for-windows-automation/actions/workflows/build-and-deploy.yml) to build and deploy Git for Windows' [Pacman packages](https://github.com/git-for-windows/git/wiki/Package-management).
4747

48+
### `/synchronize-sdks`
49+
50+
**Where can it be called?** In Issues and Pull Requests of Git for Windows' repositories.
51+
52+
**What does it do?** This triggers the `sync` GitHub workflow runs in Git for Windows' `git-sdk-*` repositories, i.e. updates them with the newest package versions as per the Pacman repositories.
53+
4854
### `/git-artifacts`
4955

5056
**Where can it be called?** In `git-for-windows/git`'s [Pull Requests](https://github.com/git-for-windows/git/pulls)

0 commit comments

Comments
 (0)