@@ -137,15 +137,34 @@ jobs:
137137 console.log('Processed commits: ' + commitCount)
138138 }
139139
140+ // ------------------------------------------------------
141+ // Read existing names
142+ // ------------------------------------------------------
143+ const fs = require('fs')
144+ const acknowledgementsFile = 'website/news/${{ inputs.eclipse-version }}/acknowledgements.md'
145+ let lines = fs.readFileSync(acknowledgementsFile, {encoding: 'utf8'}).split(/\r?\n/)
146+
147+ const nameIdRegex = /\[(?<name>[^\]]+)\]\(https:\/\/github\.com\/(?<id>[^\)]+)\)/g
148+ const existingContributorNames = new Map()
149+ for (line of lines) {
150+ for (match of line.matchAll(nameIdRegex)) {
151+ existingContributorNames.set(match.groups.id, match.groups.name)
152+ }
153+ }
140154 // ------------------------------------------------------
141155 // Select name if multiple have been found for one contributor
142156 // ------------------------------------------------------
143157 const selectedContributorNames = new Map()
144158 const nameInconsistencies = []
145159 for (const [profile, names] of contributorNames) {
146160 // Select longest name, assuming that's correct
147- let selectedName = [...names].reduce((n1, n2) => n1.length > n2.length ? n1 : n2)
148- if (names.size > 1) {
161+ let selectedName = names[0]
162+ const existingName = existingContributorNames.get(profile)
163+ if (existingName && (selectedName != existingName || names.size > 1)) {
164+ selectedName = existingName
165+ console.log("Reuse existing name '" + existingName + "' for " + profile + ", instead of encountered: " + Array.from(names).join(', '))
166+ } else if (names.size > 1) {
167+ selectedName = [...names].reduce((n1, n2) => n1.length > n2.length ? n1 : n2)
149168 console.log("Multiple names encountered for " + profile + ": " + Array.from(names).join(', '))
150169 nameInconsistencies.push("@" + profile + ": " + Array.from(names).map(n => n==selectedName ? ("**`" + n + "`**") : ("`" + n + "`")).join(', '))
151170 }
@@ -155,9 +174,6 @@ jobs:
155174 // ------------------------------------------------------
156175 // Insert the list of contributors into the template file
157176 // ------------------------------------------------------
158- const fs = require('fs')
159- const acknowledgementsFile = 'website/news/${{ inputs.eclipse-version }}/acknowledgements.md'
160- let lines = fs.readFileSync(acknowledgementsFile, {encoding: 'utf8'}).split(/\r?\n/)
161177 let elementsInLine = 0
162178 for (const [organization, contributors] of orgaContributors) {
163179 console.log('Insert contributors of ' + organization)
0 commit comments