@node-core/utils 7.0.1 → 7.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/auth.js +1 -1
- package/lib/pr_data.js +19 -0
- package/lib/queries/PR.gql +29 -0
- package/lib/queries/PRCommits.gql +0 -20
- package/lib/reviews.js +1 -1
- package/package.json +1 -1
package/lib/auth.js
CHANGED
|
@@ -7,7 +7,7 @@ import { clearCachedConfig, encryptValue, getMergedConfig, getNcurcPath } from '
|
|
|
7
7
|
|
|
8
8
|
export default lazy(auth);
|
|
9
9
|
|
|
10
|
-
function check(username, token, format = /^[A-Za-z0-
|
|
10
|
+
function check(username, token, format = /^[A-Za-z0-9\-_.]+$/) {
|
|
11
11
|
if (typeof username !== 'string') {
|
|
12
12
|
throw new Error(`username must be a string, received ${typeof username}`);
|
|
13
13
|
}
|
package/lib/pr_data.js
CHANGED
|
@@ -60,11 +60,30 @@ export default class PRData {
|
|
|
60
60
|
this.getThreadData(),
|
|
61
61
|
this.getCommits()
|
|
62
62
|
]).then(() => {
|
|
63
|
+
this.mergeHeadCommitChecks();
|
|
63
64
|
this.cli.stopSpinner(`Done loading data for ${prStr}`);
|
|
64
65
|
});
|
|
65
66
|
this.analyzeReviewers();
|
|
66
67
|
}
|
|
67
68
|
|
|
69
|
+
mergeHeadCommitChecks() {
|
|
70
|
+
const headCommit = this.pr.headCommit?.nodes?.[0]?.commit;
|
|
71
|
+
delete this.pr.headCommit;
|
|
72
|
+
|
|
73
|
+
const lastCommit = this.commits.at(-1)?.commit;
|
|
74
|
+
if (headCommit === undefined && lastCommit === undefined) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (headCommit?.oid !== lastCommit?.oid) {
|
|
79
|
+
throw new Error(
|
|
80
|
+
'Unable to match pull request head commit while loading data');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
lastCommit.checkSuites = headCommit.checkSuites;
|
|
84
|
+
lastCommit.status = headCommit.status;
|
|
85
|
+
}
|
|
86
|
+
|
|
68
87
|
analyzeReviewers() {
|
|
69
88
|
this.reviewers = new ReviewAnalyzer(this).getReviewers();
|
|
70
89
|
}
|
package/lib/queries/PR.gql
CHANGED
|
@@ -23,6 +23,35 @@ query PR($prid: Int!, $owner: String!, $repo: String!) {
|
|
|
23
23
|
path
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
|
+
# CI data is only consumed for the pull request's head commit. Querying
|
|
27
|
+
# it for every commit multiplies the GraphQL rate-limit cost.
|
|
28
|
+
headCommit: commits(last: 1) {
|
|
29
|
+
nodes {
|
|
30
|
+
commit {
|
|
31
|
+
oid
|
|
32
|
+
checkSuites(first: 100) {
|
|
33
|
+
nodes {
|
|
34
|
+
app {
|
|
35
|
+
slug
|
|
36
|
+
}
|
|
37
|
+
conclusion,
|
|
38
|
+
status,
|
|
39
|
+
checkRuns(first: 40) {
|
|
40
|
+
nodes {
|
|
41
|
+
name
|
|
42
|
+
status
|
|
43
|
+
conclusion
|
|
44
|
+
detailsUrl
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
status {
|
|
50
|
+
state
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
},
|
|
26
55
|
title,
|
|
27
56
|
baseRefName,
|
|
28
57
|
headRefName,
|
|
@@ -25,26 +25,6 @@ query Commits($prid: Int!, $owner: String!, $repo: String!, $after: String) {
|
|
|
25
25
|
message
|
|
26
26
|
messageHeadline
|
|
27
27
|
authoredByCommitter
|
|
28
|
-
checkSuites(first: 100) {
|
|
29
|
-
nodes {
|
|
30
|
-
app {
|
|
31
|
-
slug
|
|
32
|
-
}
|
|
33
|
-
conclusion,
|
|
34
|
-
status,
|
|
35
|
-
checkRuns(first: 40) {
|
|
36
|
-
nodes {
|
|
37
|
-
name
|
|
38
|
-
status
|
|
39
|
-
conclusion
|
|
40
|
-
detailsUrl
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
status {
|
|
46
|
-
state
|
|
47
|
-
}
|
|
48
28
|
}
|
|
49
29
|
}
|
|
50
30
|
}
|
package/lib/reviews.js
CHANGED
|
@@ -83,7 +83,7 @@ export class ReviewAnalyzer {
|
|
|
83
83
|
switch (r.state) {
|
|
84
84
|
case APPROVED:
|
|
85
85
|
case CHANGES_REQUESTED:
|
|
86
|
-
// Overwrite previous reviews, whether
|
|
86
|
+
// Overwrite previous reviews, whether initialized or not
|
|
87
87
|
map.set(
|
|
88
88
|
login,
|
|
89
89
|
new Review(r.state, r.publishedAt, r.url, FROM_REVIEW)
|