-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathpr_summary.js
62 lines (56 loc) · 1.6 KB
/
pr_summary.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
export default class PRSummary {
/**
* @param {Object} prid
* @param {Object} cli
* @param {PRData} data
*/
constructor(argv, cli, data) {
this.argv = argv;
this.cli = cli;
this.data = data;
}
display() {
const {
commits,
pr: {
author,
baseRefName,
headRefName,
labels,
title
}
} = this.data;
const {
owner,
prid
} = this.argv;
const cli = this.cli;
const branch = `${author.login}:${headRefName} -> ${owner}:${baseRefName}`;
const labelStr = labels.nodes.map(label => label.name).join(', ');
cli.table('Title', `${title} (#${prid})`);
const authorHint =
this.data.authorIsNew() ? ', first-time contributor' : '';
if (author.name && author.email) {
cli.table('Author',
`${author.name} <${author.email}> (@${author.login}${authorHint})`);
} else {
// Unable to retrive email/name of the PR Author
cli.warn('Could not retrieve the email or name ' +
"of the PR author's from user's GitHub profile!");
}
cli.table('Branch', `${branch}`);
cli.table('Labels', `${labelStr}`);
cli.table('Commits', `${commits.length}`);
const committers = new Map();
for (const commit of commits) {
const data = commit.commit;
const committer = data.committer;
committers.set(committer.email, committer);
cli.log(` - ${data.messageHeadline}`);
}
cli.table('Committers', `${committers.size}`);
for (const { name, email } of committers.values()) {
cli.log(` - ${name} <${email}>`);
}
};
}