Skip to content

Commit f376378

Browse files
committed
Better users aggregation for multiple commits
show unique list of users/emails instead of just "multiple users"
1 parent 71b6746 commit f376378

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
lines changed

dist/index.js

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ function getInput(name, options) {
216216
}
217217
return val.trim();
218218
}
219+
219220
exports.getInput = getInput;
220221
/**
221222
* Gets the values of an multiline input. Each value is also trimmed.
@@ -52539,8 +52540,8 @@ function aggregateCommits(context, options, notifications) {
5253952540
commit: {
5254052541
html_url: context.compareLink,
5254152542
commit: {
52542-
author: { name: '[Multiple authors]' },
52543-
committer: { name: '[Multiple committers]' },
52543+
author: aggregateUsers(n.map(n => n.commit.commit.author)),
52544+
committer: aggregateUsers(n.map(n => n.commit.commit.committer)),
5254452545
message: `[${n.length} commits]`,
5254552546
},
5254652547
sha: '0000000000000000000000000000000000000000',
@@ -52597,6 +52598,22 @@ function stripUser(u) {
5259752598
html_url: u.html_url
5259852599
};
5259952600
}
52601+
function aggregateUsers(users) {
52602+
if (users.length === 1)
52603+
return users[0];
52604+
let uniqueNames = new Set(users.map(u => u.name));
52605+
let unique = [...uniqueNames].map(un => users.find(u => u.name === un));
52606+
if (unique.length > 1) {
52607+
return ({
52608+
name: unique.map(u => u.name).join(', '),
52609+
email: unique.map(u => u.email).join(';'),
52610+
});
52611+
}
52612+
else {
52613+
let u = { name: users[0].name, email: users[0].email };
52614+
return u;
52615+
}
52616+
}
5260052617

5260152618

5260252619
/***/ }),

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "github-codewatchers",
3-
"version": "2.1.0",
3+
"version": "2.1.1",
44
"description": "GitHub Action that triggers notifications about changed files to a list of subscribers",
55
"main": "dist/index.js",
66
"scripts": {

src/match.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ export function aggregateCommits(context: Context, options: Options, notificatio
8585
commit: {
8686
html_url: context.compareLink,
8787
commit: {
88-
author: { name: '[Multiple authors]' },
89-
committer: { name: '[Multiple committers]' },
88+
author: aggregateUsers(n.map(n => n.commit.commit.author)),
89+
committer: aggregateUsers(n.map(n => n.commit.commit.committer)),
9090
message: `[${n.length} commits]`,
9191
},
9292
sha: '0000000000000000000000000000000000000000',
@@ -143,4 +143,20 @@ function stripUser(u: Partial<GH.User>): Notif.User {
143143
gravatar_id: u.gravatar_id,
144144
html_url: u.html_url
145145
}
146+
}
147+
148+
function aggregateUsers<U extends { name?: string, email?: string }>(users: U[]): U {
149+
if (users.length === 1) return users[0];
150+
151+
let uniqueNames = new Set(users.map(u => u.name));
152+
let unique = [...uniqueNames].map(un => users.find(u => u.name === un));
153+
if (unique.length > 1) {
154+
return ({
155+
name: unique.map(u => u.name).join(', '),
156+
email: unique.map(u => u.email).join(';'),
157+
}) as U;
158+
} else {
159+
let u = { name: users[0].name, email: users[0].email };
160+
return u as U;
161+
}
146162
}

0 commit comments

Comments
 (0)