Skip to content

Commit 265711c

Browse files
committed
sync-upstream-branches: take over the job of the sync-gitster-git workflow
With a few touch-ups, the workflow can become generic enough to handle also the synchronization of `gitster/git`'s branches to `gitgitgadget/git`. The overall goal, of course, is to prepare for supporting projects other than Git, via configurations stored in repository variables. That's the task of the next commit(s). Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 6cc9af2 commit 265711c

File tree

2 files changed

+8
-140
lines changed

2 files changed

+8
-140
lines changed

.github/workflows/sync-gitster-git.yml

Lines changed: 0 additions & 140 deletions
This file was deleted.

.github/workflows/sync-upstream-branches.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ jobs:
2020
- sourceRepo: j6t/git-gui
2121
targetRepo: gitgitgadget/git
2222
targetRefNamespace: git-gui/
23+
- sourceRepo: gitster/git
24+
targetRepo: gitgitgadget/git
25+
sourceRefRegex: "^refs/heads/(maint-\\d|[a-z][a-z]/)"
2326

2427
steps:
2528
- name: check which refs need to be synchronized
@@ -28,6 +31,7 @@ jobs:
2831
with:
2932
script: |
3033
const sourceRepo = ${{ toJSON(matrix.spec.sourceRepo) }}
34+
const sourceRefRegexp = ((p) => p ? new RegExp(p) : null)(${{ toJSON(matrix.spec.sourceRefRegex) }})
3135
const targetRepo = ${{ toJSON(matrix.spec.targetRepo) }}
3236
const targetRefNamespace = ${{ toJSON(matrix.spec.targetRefNamespace) }} || ''
3337
@@ -48,10 +52,14 @@ jobs:
4852
await github.rest.git.listMatchingRefs({
4953
owner,
5054
repo,
55+
// We cannot match `source-ref-regex` as freely as we
56+
// want with GitHub's REST API, hence we do it below via
57+
// the `filter()` call.
5158
ref: 'heads/'
5259
})
5360
).data
5461
.filter((e) => {
62+
if (sourceRefRegexp && !sourceRefRegexp.test(e.ref)) return false
5563
if (!e.ref.startsWith('refs/heads/')) return false
5664
e.name = e.ref.slice(11)
5765
if (stripRefsPrefix) {

0 commit comments

Comments
 (0)