@node-core/utils 7.0.1 → 7.0.2
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/pr_data.js +19 -0
- package/lib/queries/PR.gql +29 -0
- package/lib/queries/PRCommits.gql +0 -20
- package/package.json +1 -1
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
|
}
|