@@ -32816,8 +32816,8 @@ module.exports = parseParams
3281632816var __webpack_exports__ = {};
3281732817
3281832818// EXTERNAL MODULE: ./node_modules/@actions/core/lib/core.js
32819- var core = __nccwpck_require__(7484);
32820- var core_namespaceObject = /*#__PURE__*/__nccwpck_require__.t(core , 2);
32819+ var lib_core = __nccwpck_require__(7484);
32820+ var core_namespaceObject = /*#__PURE__*/__nccwpck_require__.t(lib_core , 2);
3282132821// EXTERNAL MODULE: ./node_modules/@actions/github/lib/github.js
3282232822var github = __nccwpck_require__(3228);
3282332823var github_namespaceObject = /*#__PURE__*/__nccwpck_require__.t(github, 2);
@@ -33010,7 +33010,8 @@ function prNumbersToString(prNumbers) {
3301033010}
3301133011
3301233012function authorsToString(authors) {
33013- return authors.map((author) => `@${author}`).join(', ');
33013+ const flatAuthors = [...new Set(authors.flat())];
33014+ return flatAuthors.map((author) => `@${author}`).join(', ');
3301433015}
3301533016
3301633017// GitHub API
@@ -33175,11 +33176,13 @@ async function getFilesSinceLastRelease(core, client, context) {
3317533176 );
3317633177 }
3317733178
33179+ const authors = await getFinalCommitAuthors(client, context, pr);
33180+
3317833181 for (let file of await getPrFiles(core, client, context, pr.number)) {
3317933182 core.info(`found '${file.path}' in PR #${pr.number}`);
3318033183 file.prNumber = pr.number;
33181- file.author = pr.user.login;
3318233184 file.merged_at = pr.merged_at;
33185+ file.authors = authors;
3318333186 files.push(file);
3318433187 }
3318533188 }
@@ -33193,6 +33196,83 @@ async function getFilesSinceLastRelease(core, client, context) {
3319333196 }
3319433197}
3319533198
33199+ /**
33200+ * Gets all authors from a PR, including the main author and co-authors
33201+ * from the final merge commit message.
33202+ *
33203+ * @param {Object} client - GitHub client (Octokit)
33204+ * @param {Object} context - GitHub Actions context
33205+ * @param {Object} pr - Pull Request object
33206+ * @returns {Promise<string[]>} Array of GitHub usernames of all authors
33207+ */
33208+ async function getFinalCommitAuthors(client, context, pr) {
33209+ const coAuthorExpr = /^Co-authored-by:\s*(.+?)\s*<(.+?)>\s*$/gim;
33210+
33211+ try {
33212+ if (!pr.merge_commit_sha) {
33213+ return [pr.user.login];
33214+ }
33215+
33216+ const { data: commitDetails } = await client.rest.git.getCommit({
33217+ owner: context.repo.owner,
33218+ repo: context.repo.repo,
33219+ commit_sha: pr.merge_commit_sha,
33220+ });
33221+
33222+ const authors = new Set([pr.user.login]);
33223+
33224+ if (commitDetails.author?.name) {
33225+ const authorEmail = commitDetails.author.email;
33226+ const githubUserMatch = authorEmail?.match(
33227+ /^(\d+\+)?(.+?)@users\.noreply\.github\.com$/,
33228+ );
33229+
33230+ if (githubUserMatch) {
33231+ authors.add(githubUserMatch[2]);
33232+ } else if (pr.merged_by?.login) {
33233+ authors.add(pr.merged_by.login);
33234+ }
33235+ } else if (pr.merged_by?.login) {
33236+ authors.add(pr.merged_by.login);
33237+ }
33238+
33239+ const commitMessage = commitDetails.message;
33240+ const coAuthorMatches = commitMessage.matchAll(coAuthorExpr);
33241+
33242+ for (const match of coAuthorMatches) {
33243+ const email = match[2];
33244+
33245+ const githubUserMatch = email.match(
33246+ /^(\d+\+)?(.+?)@users\.noreply\.github\.com$/,
33247+ );
33248+
33249+ if (githubUserMatch) {
33250+ authors.add(githubUserMatch[2]);
33251+ } else {
33252+ const name = match[1].trim();
33253+ try {
33254+ const { data: searchResults } = await client.rest.search.users({
33255+ q: `${email} in:email`,
33256+ });
33257+
33258+ if (searchResults.items.length > 0) {
33259+ authors.add(searchResults.items[0].login);
33260+ } else {
33261+ authors.add(name);
33262+ }
33263+ } catch (error) {
33264+ authors.add(name);
33265+ }
33266+ }
33267+ }
33268+
33269+ return Array.from(authors);
33270+ } catch (error) {
33271+ core.error(`Error getting authors for PR #${pr.number}:`, error);
33272+ return [pr.user?.login || 'unknown'];
33273+ }
33274+ }
33275+
3319633276// Logic determining changes
3319733277async function getChangesFromFile(core, file, client, context, id) {
3319833278 if (isIconFile(file.path) && file.status === STATUS_ADDED) {
@@ -33206,7 +33286,7 @@ async function getChangesFromFile(core, file, client, context, id) {
3320633286 name: he.decode(svgTitleMatch[1]),
3320733287 path: file.path,
3320833288 prNumbers: [file.prNumber],
33209- authors: [ file.author] ,
33289+ authors: file.authors ,
3321033290 },
3321133291 ];
3321233292 } else if (isIconFile(file.path) && file.status === STATUS_MODIFIED) {
@@ -33221,7 +33301,7 @@ async function getChangesFromFile(core, file, client, context, id) {
3322133301 name: he.decode(svgTitleMatch[1]),
3322233302 path: file.path,
3322333303 prNumbers: [file.prNumber],
33224- authors: [ file.author] ,
33304+ authors: file.authors ,
3322533305 },
3322633306 ];
3322733307 } else if (isIconFile(file.path) && file.status === STATUS_REMOVED) {
@@ -33235,7 +33315,7 @@ async function getChangesFromFile(core, file, client, context, id) {
3323533315 name: he.decode(svgTitleMatch[1]),
3323633316 path: file.path,
3323733317 prNumbers: [file.prNumber],
33238- authors: [ file.author] ,
33318+ authors: file.authors ,
3323933319 },
3324033320 ];
3324133321 } else if (isSimpleIconsDataFile(file.path)) {
@@ -33270,7 +33350,7 @@ async function getChangesFromFile(core, file, client, context, id) {
3327033350 changeType: CHANGE_TYPE_UPDATE,
3327133351 name: name,
3327233352 prNumbers: [file.prNumber],
33273- authors: [ file.author] ,
33353+ authors: file.authors ,
3327433354 });
3327533355 }
3327633356
0 commit comments