@semantic-release/github 10.1.5 → 10.1.7
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/success.js +69 -8
- package/lib/verify.js +4 -1
- package/package.json +3 -3
package/lib/success.js
CHANGED
|
@@ -67,13 +67,44 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
67
67
|
const releaseInfos = releases.filter((release) => Boolean(release.name));
|
|
68
68
|
const shas = commits.map(({ hash }) => hash);
|
|
69
69
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const
|
|
75
|
-
|
|
76
|
-
|
|
70
|
+
const associatedPRs = [];
|
|
71
|
+
|
|
72
|
+
// Split commit shas into chunks of 100 shas
|
|
73
|
+
const chunkSize = 100;
|
|
74
|
+
const shasChunks = [];
|
|
75
|
+
for (let i = 0; i < shas.length; i += chunkSize) {
|
|
76
|
+
const chunk = shas.slice(i, i + chunkSize);
|
|
77
|
+
shasChunks.push(chunk);
|
|
78
|
+
}
|
|
79
|
+
for (const chunk of shasChunks) {
|
|
80
|
+
const { repository } = await octokit.graphql(
|
|
81
|
+
buildAssociatedPRsQuery(chunk),
|
|
82
|
+
{ owner, repo },
|
|
83
|
+
);
|
|
84
|
+
const responseAssociatedPRs = Object.values(repository).map(
|
|
85
|
+
(item) => item.associatedPullRequests,
|
|
86
|
+
);
|
|
87
|
+
for (const { nodes, pageInfo } of responseAssociatedPRs) {
|
|
88
|
+
associatedPRs.push(nodes);
|
|
89
|
+
if (pageInfo.hasNextPage) {
|
|
90
|
+
let cursor = pageInfo.endCursor;
|
|
91
|
+
let hasNextPage = true;
|
|
92
|
+
while (hasNextPage) {
|
|
93
|
+
const { repository } = await octokit.graphql(
|
|
94
|
+
loadSingleCommitAssociatedPRs,
|
|
95
|
+
{ owner, repo, sha: response.commit.oid, cursor },
|
|
96
|
+
);
|
|
97
|
+
const { associatedPullRequests } = repository.commit;
|
|
98
|
+
associatedPRs.push(associatedPullRequests.nodes);
|
|
99
|
+
if (associatedPullRequests.pageInfo.hasNextPage) {
|
|
100
|
+
cursor = associatedPullRequests.pageInfo.endCursor;
|
|
101
|
+
} else {
|
|
102
|
+
hasNextPage = false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
77
108
|
|
|
78
109
|
const uniqueAssociatedPRs = uniqBy(flatten(associatedPRs), "number");
|
|
79
110
|
|
|
@@ -252,7 +283,7 @@ export default async function success(pluginConfig, context, { Octokit }) {
|
|
|
252
283
|
* @param {Array<string>} shas
|
|
253
284
|
* @returns {string}
|
|
254
285
|
*/
|
|
255
|
-
|
|
286
|
+
function buildAssociatedPRsQuery(shas) {
|
|
256
287
|
return `#graphql
|
|
257
288
|
query getAssociatedPRs($owner: String!, $repo: String!) {
|
|
258
289
|
repository(owner: $owner, name: $repo) {
|
|
@@ -260,7 +291,12 @@ export function buildAssociatedPRsQuery(shas) {
|
|
|
260
291
|
.map((sha) => {
|
|
261
292
|
return `commit${sha.slice(0, 6)}: object(oid: "${sha}") {
|
|
262
293
|
...on Commit {
|
|
294
|
+
oid
|
|
263
295
|
associatedPullRequests(first: 100) {
|
|
296
|
+
pageInfo {
|
|
297
|
+
endCursor
|
|
298
|
+
hasNextPage
|
|
299
|
+
}
|
|
264
300
|
nodes {
|
|
265
301
|
url
|
|
266
302
|
number
|
|
@@ -275,3 +311,28 @@ export function buildAssociatedPRsQuery(shas) {
|
|
|
275
311
|
}
|
|
276
312
|
`;
|
|
277
313
|
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* GraphQL Query to fetch additional associatedPR for commits that has more than 100 associatedPRs
|
|
317
|
+
*/
|
|
318
|
+
const loadSingleCommitAssociatedPRs = `#graphql
|
|
319
|
+
query getCommitAssociatedPRs($owner: String!, $repo: String!, $sha: String!, $cursor: String) {
|
|
320
|
+
repository(owner: $owner, name: $repo) {
|
|
321
|
+
commit: object(oid: $sha) {
|
|
322
|
+
...on Commit {
|
|
323
|
+
associatedPullRequests(after: $cursor, first: 100) {
|
|
324
|
+
pageInfo {
|
|
325
|
+
endCursor
|
|
326
|
+
hasNextPage
|
|
327
|
+
}
|
|
328
|
+
nodes {
|
|
329
|
+
url
|
|
330
|
+
number
|
|
331
|
+
body
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
`;
|
package/lib/verify.js
CHANGED
|
@@ -109,7 +109,10 @@ export default async function verify(pluginConfig, context, { Octokit }) {
|
|
|
109
109
|
} = await octokit.request("GET /repos/{owner}/{repo}", { repo, owner });
|
|
110
110
|
// Verify if Repository Name wasn't changed
|
|
111
111
|
const parsedCloneUrl = parseGithubUrl(clone_url);
|
|
112
|
-
if (
|
|
112
|
+
if (
|
|
113
|
+
`${owner}/${repo}`.toLowerCase() !==
|
|
114
|
+
`${parsedCloneUrl.owner}/${parsedCloneUrl.repo}`.toLowerCase()
|
|
115
|
+
) {
|
|
113
116
|
errors.push(
|
|
114
117
|
getError("EMISMATCHGITHUBURL", { repositoryUrl, clone_url }),
|
|
115
118
|
);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semantic-release/github",
|
|
3
3
|
"description": "semantic-release plugin to publish a GitHub release and comment on released Pull Requests/Issues",
|
|
4
|
-
"version": "10.1.
|
|
4
|
+
"version": "10.1.7",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "Pierre Vanduynslager (https://twitter.com/@pvdlg_)",
|
|
7
7
|
"ava": {
|
|
@@ -49,8 +49,8 @@
|
|
|
49
49
|
"ls-engines": "0.9.3",
|
|
50
50
|
"npm-run-all2": "6.2.2",
|
|
51
51
|
"prettier": "3.3.3",
|
|
52
|
-
"publint": "0.2.
|
|
53
|
-
"semantic-release": "24.
|
|
52
|
+
"publint": "0.2.10",
|
|
53
|
+
"semantic-release": "24.1.0",
|
|
54
54
|
"sinon": "18.0.0",
|
|
55
55
|
"tempy": "3.1.0"
|
|
56
56
|
},
|