Skip to content

Commit 7e67411

Browse files
committed
[FIXUP]
1 parent 68b0bb9 commit 7e67411

File tree

2 files changed

+13
-16
lines changed

2 files changed

+13
-16
lines changed

.github/workflows/checkAcknowledgements.yml

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ jobs:
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
15+
with:
16+
fetch-depth: 0
1517
- name: Determine changed files
1618
id: changed-files
1719
run: |
18-
changedFiles=$(git diff --name-only --diff-filter=ACMR ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep acknowledgements.md$)
20+
changedFiles=$(git diff --name-only --diff-filter=ACMR ${{ github.event.pull_request.base.sha }} ${{ github.event.pull_request.head.sha }} | grep acknowledgements.md$ | xargs)
1921
echo "Changed files: ${changedFiles}"
2022
echo "files=${changedFiles}" >> "$GITHUB_OUTPUT"
2123
- name: Check modified acknowledgements files
@@ -24,27 +26,22 @@ jobs:
2426
with:
2527
script: |
2628
const fs = require('fs')
27-
const files = '${{ steps.changed-files.outputs.files }}'.trim().split(/\r?\n/)
28-
const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)]+)\)/g
29-
const contributorNames = new Map()
29+
const files = '${{ steps.changed-files.outputs.files }}'.trim().split(/\s+/)
30+
const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)/]+)\)/g
3031
for (file of files) {
3132
let lines = fs.readFileSync(file, {encoding: 'utf8'}).split(/\r?\n/)
33+
const contributorNames = new Map()
3234
for (line of lines) {
3335
for (match of line.matchAll(nameIdRegex)) {
3436
computeIfAbsent(contributorNames, match.groups.id, () => new Set()).add(match.groups.name)
3537
}
3638
}
37-
}
38-
let boolean hasMultipleNames = false
39-
for (const [profile, names] of contributorNames) {
40-
if (names.size > 1) {
41-
core.error('Multiple names found for profile '" + profile + "': ' + Array.from(names).join(', '))
42-
hasMultipleNames = true
39+
for (const [profile, names] of contributorNames) {
40+
if (names.size > 1) {
41+
core.setFailed("Multiple names found for profile '" + profile + "': " + Array.from(names).join(', '))
42+
}
4343
}
4444
}
45-
if (hasMultipleNames) {
46-
throw new Error('No selected name for profile: ' + profile)
47-
}
4845
4946
function computeIfAbsent(map, key, valueSupplier) {
5047
let value = map.get(key)

.github/workflows/generateAcknowledgements.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ jobs:
127127
profile = committerProfile
128128
}
129129
contributors.add(profile)
130-
computeIfAbsent(contributorNames, profile, () => new Set()).add(authorName)
130+
computeIfAbsent(contributorNames, profile, () => new Set()).add(authorName.trim())
131131
} else { // author is null for directly pushed commits, which happens e.g. for I-build submodule updates
132132
console.log("Skip commit of " + authorName)
133133
}
@@ -144,11 +144,11 @@ jobs:
144144
const acknowledgementsFile = 'website/news/${{ inputs.eclipse-version }}/acknowledgements.md'
145145
let lines = fs.readFileSync(acknowledgementsFile, {encoding: 'utf8'}).split(/\r?\n/)
146146
147-
const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)]+)\)/g
147+
const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)/]+)\)/g
148148
const existingContributorNames = new Map()
149149
for (line of lines) {
150150
for (match of line.matchAll(nameIdRegex)) {
151-
existingContributorNames.set(match.groups.id, match.groups.name)
151+
existingContributorNames.set(match.groups.id.trim(), match.groups.name.trim())
152152
}
153153
}
154154
// ------------------------------------------------------

0 commit comments

Comments
 (0)