@@ -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)
0 commit comments