Skip to content

Commit 325952e

Browse files
authoredJul 26, 2024··
fix: Revert "fix: failing release due to renamed repository (#878)" (#887)
This reverts commit 76fdaa3.
1 parent 76fdaa3 commit 325952e

File tree

4 files changed

+92
-270
lines changed

4 files changed

+92
-270
lines changed
 

‎lib/definitions/errors.js

-11
Original file line numberDiff line numberDiff line change
@@ -139,17 +139,6 @@ By default the \`repositoryUrl\` option is retrieved from the \`repository\` pro
139139
};
140140
}
141141

142-
export function EMISMATCHGITHUBURL() {
143-
return {
144-
message: "The git repository URL mismatches the GitHub URL.",
145-
details: `The **semantic-release** \`repositoryUrl\` option must match your GitHub URL with the format \`<GitHub_or_GHE_URL>/<owner>/<repo>.git\`.
146-
147-
By default the \`repositoryUrl\` option is retrieved from the \`repository\` property of your \`package.json\` or the [git origin url](https://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes) of the repository cloned by your CI environment.
148-
149-
Note: If you have recently changed your GitHub repository name or owner, update the value in **semantic-release** \`repositoryUrl\` option and the \`repository\` property of your \`package.json\` respectively to match the new GitHub URL.`,
150-
};
151-
}
152-
153142
export function EINVALIDPROXY({ proxy }) {
154143
return {
155144
message: "Invalid `proxy` option.",

‎lib/verify.js

-27
Original file line numberDiff line numberDiff line change
@@ -144,33 +144,6 @@ export default async function verify(pluginConfig, context, { Octokit }) {
144144
}
145145
}
146146

147-
// Verify if Repository Name wasn't changed
148-
if (
149-
owner &&
150-
repo &&
151-
githubToken &&
152-
!errors.find(({ code }) => code === "EINVALIDPROXY") &&
153-
!errors.find(({ code }) => code === "EMISSINGREPO")
154-
) {
155-
const octokit = new Octokit(
156-
toOctokitOptions({
157-
githubToken,
158-
githubUrl,
159-
githubApiPathPrefix,
160-
githubApiUrl,
161-
proxy,
162-
}),
163-
);
164-
165-
const {
166-
status,
167-
data: { clone_url },
168-
} = await octokit.request("GET /repos/{owner}/{repo}", { owner, repo });
169-
if (status !== 200 || repositoryUrl !== clone_url) {
170-
errors.push(getError("EMISMATCHGITHUBURL"));
171-
}
172-
}
173-
174147
if (!githubToken) {
175148
errors.push(getError("ENOGHTOKEN", { owner, repo }));
176149
}

‎test/integration.test.js

+27-67
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,11 @@ test("Verify GitHub auth", async (t) => {
2424
repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`,
2525
};
2626

27-
const fetch = fetchMock.sandbox().get(
28-
`https://api.github.local/repos/${owner}/${repo}`,
29-
{
27+
const fetch = fetchMock
28+
.sandbox()
29+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
3030
permissions: { push: true },
31-
clone_url: `git+https://othertesturl.com/${owner}/${repo}.git`,
32-
},
33-
{
34-
repeat: 2,
35-
},
36-
);
31+
});
3732

3833
await t.notThrowsAsync(
3934
t.context.m.verifyConditions(
@@ -59,16 +54,11 @@ test("Verify GitHub auth with publish options", async (t) => {
5954
publish: { path: "@semantic-release/github" },
6055
repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`,
6156
};
62-
const fetch = fetchMock.sandbox().get(
63-
`https://api.github.local/repos/${owner}/${repo}`,
64-
{
57+
const fetch = fetchMock
58+
.sandbox()
59+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
6560
permissions: { push: true },
66-
clone_url: `git+https://othertesturl.com/${owner}/${repo}.git`,
67-
},
68-
{
69-
repeat: 2,
70-
},
71-
);
61+
});
7262

7363
await t.notThrowsAsync(
7464
t.context.m.verifyConditions(
@@ -101,16 +91,11 @@ test("Verify GitHub auth and assets config", async (t) => {
10191
publish: [{ path: "@semantic-release/npm" }],
10292
repositoryUrl: `git+https://othertesturl.com/${owner}/${repo}.git`,
10393
};
104-
const fetch = fetchMock.sandbox().get(
105-
`https://api.github.local/repos/${owner}/${repo}`,
106-
{
94+
const fetch = fetchMock
95+
.sandbox()
96+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
10797
permissions: { push: true },
108-
clone_url: `git+https://othertesturl.com/${owner}/${repo}.git`,
109-
},
110-
{
111-
repeat: 2,
112-
},
113-
);
98+
});
11499

115100
await t.notThrowsAsync(
116101
t.context.m.verifyConditions(
@@ -211,16 +196,9 @@ test("Publish a release with an array of assets", async (t) => {
211196

212197
const fetch = fetchMock
213198
.sandbox()
214-
.get(
215-
`https://api.github.local/repos/${owner}/${repo}`,
216-
{
217-
permissions: { push: true },
218-
clone_url: `https://github.com/${owner}/${repo}.git`,
219-
},
220-
{
221-
repeat: 2,
222-
},
223-
)
199+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
200+
permissions: { push: true },
201+
})
224202
.postOnce(
225203
`https://api.github.local/repos/${owner}/${repo}/releases`,
226204
{ upload_url: uploadUrl, html_url: releaseUrl, id: releaseId },
@@ -310,16 +288,9 @@ test("Publish a release with release information in assets", async (t) => {
310288

311289
const fetch = fetchMock
312290
.sandbox()
313-
.get(
314-
`https://api.github.local/repos/${owner}/${repo}`,
315-
{
316-
permissions: { push: true },
317-
clone_url: `https://github.com/${owner}/${repo}.git`,
318-
},
319-
{
320-
repeat: 2,
321-
},
322-
)
291+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
292+
permissions: { push: true },
293+
})
323294
.postOnce(
324295
`https://api.github.local/repos/${owner}/${repo}/releases`,
325296
{ upload_url: uploadUrl, html_url: releaseUrl, id: releaseId },
@@ -387,16 +358,9 @@ test("Update a release", async (t) => {
387358

388359
const fetch = fetchMock
389360
.sandbox()
390-
.get(
391-
`https://api.github.local/repos/${owner}/${repo}`,
392-
{
393-
permissions: { push: true },
394-
clone_url: `https://github.com/${owner}/${repo}.git`,
395-
},
396-
{
397-
repeat: 2,
398-
},
399-
)
361+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
362+
permissions: { push: true },
363+
})
400364
.getOnce(
401365
`https://api.github.local/repos/${owner}/${repo}/releases/tags/${nextRelease.gitTag}`,
402366
{ id: releaseId },
@@ -462,10 +426,10 @@ test("Comment and add labels on PR included in the releases", async (t) => {
462426
{
463427
permissions: { push: true },
464428
full_name: `${owner}/${repo}`,
465-
clone_url: `https://github.com/${owner}/${repo}.git`,
466429
},
467430
{
468-
repeat: 3,
431+
// TODO: why do we call the same endpoint twice?
432+
repeat: 2,
469433
},
470434
)
471435
.postOnce("https://api.github.local/graphql", {
@@ -565,10 +529,9 @@ test("Open a new issue with the list of errors", async (t) => {
565529
{
566530
permissions: { push: true },
567531
full_name: `${owner}/${repo}`,
568-
clone_url: `https://github.com/${owner}/${repo}.git`,
569532
},
570533
{
571-
repeat: 3,
534+
repeat: 2,
572535
},
573536
)
574537
.getOnce(
@@ -662,10 +625,9 @@ test("Verify, release and notify success", async (t) => {
662625
{
663626
permissions: { push: true },
664627
full_name: `${owner}/${repo}`,
665-
clone_url: `https://github.com/${owner}/${repo}.git`,
666628
},
667629
{
668-
repeat: 3,
630+
repeat: 2,
669631
},
670632
)
671633
.postOnce(
@@ -823,10 +785,9 @@ test("Verify, update release and notify success", async (t) => {
823785
{
824786
permissions: { push: true },
825787
full_name: `${owner}/${repo}`,
826-
clone_url: `https://github.com/${owner}/${repo}.git`,
827788
},
828789
{
829-
repeat: 3,
790+
repeat: 2,
830791
},
831792
)
832793
.getOnce(
@@ -956,10 +917,9 @@ test("Verify and notify failure", async (t) => {
956917
{
957918
permissions: { push: true },
958919
full_name: `${owner}/${repo}`,
959-
clone_url: `https://github.com/${owner}/${repo}.git`,
960920
},
961921
{
962-
repeat: 3,
922+
repeat: 2,
963923
},
964924
)
965925
.getOnce(

‎test/verify.test.js

+65-165
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@ test("Verify package, token and repository access", async (t) => {
2929

3030
const fetch = fetchMock
3131
.sandbox()
32-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
32+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
3333
permissions: { push: true },
34-
clone_url: `git+https://othertesturl.com/${owner}/${repo}.git`,
3534
});
3635

3736
await t.notThrowsAsync(
@@ -77,9 +76,8 @@ test('Verify package, token and repository access with "proxy", "asset", "discus
7776

7877
const fetch = fetchMock
7978
.sandbox()
80-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
79+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
8180
permissions: { push: true },
82-
clone_url: `git+https://othertesturl.com/${owner}/${repo}.git`,
8381
});
8482

8583
await t.notThrowsAsync(
@@ -120,9 +118,8 @@ test("Verify package, token and repository access and custom URL with prefix", a
120118

121119
const fetch = fetchMock
122120
.sandbox()
123-
.get(`https://othertesturl.com:9090/prefix/repos/${owner}/${repo}`, {
121+
.getOnce(`https://othertesturl.com:9090/prefix/repos/${owner}/${repo}`, {
124122
permissions: { push: true },
125-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
126123
});
127124

128125
await t.notThrowsAsync(
@@ -159,9 +156,8 @@ test("Verify package, token and repository access and custom URL without prefix"
159156

160157
const fetch = fetchMock
161158
.sandbox()
162-
.get(`https://othertesturl.com:9090/repos/${owner}/${repo}`, {
159+
.getOnce(`https://othertesturl.com:9090/repos/${owner}/${repo}`, {
163160
permissions: { push: true },
164-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
165161
});
166162

167163
await t.notThrowsAsync(
@@ -198,9 +194,8 @@ test("Verify package, token and repository access and shorthand repositoryUrl UR
198194

199195
const fetch = fetchMock
200196
.sandbox()
201-
.get(`https://othertesturl.com:9090/repos/${owner}/${repo}`, {
197+
.getOnce(`https://othertesturl.com:9090/repos/${owner}/${repo}`, {
202198
permissions: { push: true },
203-
clone_url: `github:${owner}/${repo}`,
204199
});
205200

206201
await t.notThrowsAsync(
@@ -238,9 +233,8 @@ test("Verify package, token and repository with environment variables", async (t
238233
};
239234
const fetch = fetchMock
240235
.sandbox()
241-
.get(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, {
236+
.getOnce(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, {
242237
permissions: { push: true },
243-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
244238
});
245239

246240
await t.notThrowsAsync(
@@ -280,9 +274,8 @@ test("Verify package, token and repository access with alternative environment v
280274

281275
const fetch = fetchMock
282276
.sandbox()
283-
.get(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, {
277+
.getOnce(`https://othertesturl.com:443/prefix/repos/${owner}/${repo}`, {
284278
permissions: { push: true },
285-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
286279
});
287280

288281
await t.notThrowsAsync(
@@ -315,9 +308,8 @@ test("Verify package, token and repository access with custom API URL", async (t
315308

316309
const fetch = fetchMock
317310
.sandbox()
318-
.get(`https://api.othertesturl.com:9090/repos/${owner}/${repo}`, {
311+
.getOnce(`https://api.othertesturl.com:9090/repos/${owner}/${repo}`, {
319312
permissions: { push: true },
320-
clone_url: `github:${owner}/${repo}`,
321313
});
322314

323315
await t.notThrowsAsync(
@@ -355,9 +347,8 @@ test("Verify package, token and repository access with API URL in environment va
355347

356348
const fetch = fetchMock
357349
.sandbox()
358-
.get(`https://api.othertesturl.com:443/repos/${owner}/${repo}`, {
350+
.getOnce(`https://api.othertesturl.com:443/repos/${owner}/${repo}`, {
359351
permissions: { push: true },
360-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
361352
});
362353

363354
await t.notThrowsAsync(
@@ -389,9 +380,8 @@ test('Verify "proxy" is a String', async (t) => {
389380

390381
const fetch = fetchMock
391382
.sandbox()
392-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
383+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
393384
permissions: { push: true },
394-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
395385
});
396386

397387
await t.notThrowsAsync(
@@ -422,9 +412,8 @@ test('Verify "proxy" is an object with "host" and "port" properties', async (t)
422412

423413
const fetch = fetchMock
424414
.sandbox()
425-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
415+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
426416
permissions: { push: true },
427-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
428417
});
429418

430419
await t.notThrowsAsync(
@@ -457,9 +446,8 @@ test('Verify "proxy" is a Boolean set to false', async (t) => {
457446

458447
const fetch = fetchMock
459448
.sandbox()
460-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
449+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
461450
permissions: { push: true },
462-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
463451
});
464452

465453
await t.notThrowsAsync(
@@ -490,9 +478,8 @@ test('Verify "assets" is a String', async (t) => {
490478

491479
const fetch = fetchMock
492480
.sandbox()
493-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
481+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
494482
permissions: { push: true },
495-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
496483
});
497484

498485
await t.notThrowsAsync(
@@ -523,9 +510,8 @@ test('Verify "assets" is an Object with a path property', async (t) => {
523510

524511
const fetch = fetchMock
525512
.sandbox()
526-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
513+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
527514
permissions: { push: true },
528-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
529515
});
530516

531517
await t.notThrowsAsync(
@@ -556,9 +542,8 @@ test('Verify "assets" is an Array of Object with a path property', async (t) =>
556542

557543
const fetch = fetchMock
558544
.sandbox()
559-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
545+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
560546
permissions: { push: true },
561-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
562547
});
563548

564549
await t.notThrowsAsync(
@@ -591,9 +576,8 @@ test('Verify "assets" is an Array of glob Arrays', async (t) => {
591576

592577
const fetch = fetchMock
593578
.sandbox()
594-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
579+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
595580
permissions: { push: true },
596-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
597581
});
598582

599583
await t.notThrowsAsync(
@@ -624,9 +608,8 @@ test('Verify "assets" is an Array of Object with a glob Arrays in path property'
624608

625609
const fetch = fetchMock
626610
.sandbox()
627-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
611+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
628612
permissions: { push: true },
629-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
630613
});
631614

632615
await t.notThrowsAsync(
@@ -659,9 +642,8 @@ test('Verify "labels" is a String', async (t) => {
659642

660643
const fetch = fetchMock
661644
.sandbox()
662-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
645+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
663646
permissions: { push: true },
664-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
665647
});
666648

667649
await t.notThrowsAsync(
@@ -692,9 +674,8 @@ test('Verify "assignees" is a String', async (t) => {
692674

693675
const fetch = fetchMock
694676
.sandbox()
695-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
677+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
696678
permissions: { push: true },
697-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
698679
});
699680

700681
await t.notThrowsAsync(
@@ -725,9 +706,8 @@ test('Verify "addReleases" is a valid string (top)', async (t) => {
725706

726707
const fetch = fetchMock
727708
.sandbox()
728-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
709+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
729710
permissions: { push: true },
730-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
731711
});
732712

733713
await t.notThrowsAsync(
@@ -758,9 +738,8 @@ test('Verify "addReleases" is a valid string (bottom)', async (t) => {
758738

759739
const fetch = fetchMock
760740
.sandbox()
761-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
741+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
762742
permissions: { push: true },
763-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
764743
});
765744

766745
await t.notThrowsAsync(
@@ -791,9 +770,8 @@ test('Verify "addReleases" is valid (false)', async (t) => {
791770

792771
const fetch = fetchMock
793772
.sandbox()
794-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
773+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
795774
permissions: { push: true },
796-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
797775
});
798776

799777
await t.notThrowsAsync(
@@ -824,9 +802,8 @@ test('Verify "draftRelease" is valid (true)', async (t) => {
824802

825803
const fetch = fetchMock
826804
.sandbox()
827-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
805+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
828806
permissions: { push: true },
829-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
830807
});
831808

832809
await t.notThrowsAsync(
@@ -857,9 +834,8 @@ test('Verify "draftRelease" is valid (false)', async (t) => {
857834

858835
const fetch = fetchMock
859836
.sandbox()
860-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
837+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
861838
permissions: { push: true },
862-
clone_url: `git@othertesturl.com:${owner}/${repo}.git`,
863839
});
864840

865841
await t.notThrowsAsync(
@@ -898,12 +874,6 @@ test("Verify if run in GitHub Action", async (t) => {
898874
const labels = ["semantic-release"];
899875
const discussionCategoryName = "Announcements";
900876

901-
const fetch = fetchMock
902-
.sandbox()
903-
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
904-
clone_url: `git+https://othertesturl.com/${owner}/${repo}.git`,
905-
});
906-
907877
await t.notThrowsAsync(
908878
verify(
909879
{ proxy, assets, successComment, failTitle, failComment, labels },
@@ -960,7 +930,9 @@ test("Throw SemanticReleaseError for invalid token", async (t) => {
960930
.sandbox()
961931
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, 401);
962932

963-
const errors = await t.throwsAsync(
933+
const {
934+
errors: [error, ...errors],
935+
} = await t.throwsAsync(
964936
verify(
965937
{},
966938
{
@@ -977,12 +949,10 @@ test("Throw SemanticReleaseError for invalid token", async (t) => {
977949
),
978950
);
979951

980-
t.log(errors);
981-
982-
// t.is(errors.length, 0);
983-
// t.is(error.name, "SemanticReleaseError");
984-
// t.is(error.code, "EINVALIDGHTOKEN");
985-
// t.true(fetch.done());
952+
t.is(errors.length, 0);
953+
t.is(error.name, "SemanticReleaseError");
954+
t.is(error.code, "EINVALIDGHTOKEN");
955+
t.true(fetch.done());
986956
});
987957

988958
test("Throw SemanticReleaseError for invalid repositoryUrl", async (t) => {
@@ -1019,9 +989,8 @@ test("Throw SemanticReleaseError if token doesn't have the push permission on th
1019989

1020990
const fetch = fetchMock
1021991
.sandbox()
1022-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
992+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
1023993
permissions: { push: false },
1024-
clone_url: `https://github.com/${owner}/${repo}.git`,
1025994
})
1026995
.headOnce(
1027996
"https://api.github.local/installation/repositories?per_page=1",
@@ -1060,9 +1029,8 @@ test("Do not throw SemanticReleaseError if token doesn't have the push permissio
10601029

10611030
const fetch = fetchMock
10621031
.sandbox()
1063-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1032+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
10641033
permissions: { push: false },
1065-
clone_url: `https://github.com/${owner}/${repo}.git`,
10661034
})
10671035
.headOnce(
10681036
"https://api.github.local/installation/repositories?per_page=1",
@@ -1096,7 +1064,7 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) =>
10961064

10971065
const fetch = fetchMock
10981066
.sandbox()
1099-
.get(`https://api.github.local/repos/${owner}/${repo}`, 404);
1067+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, 404);
11001068

11011069
const {
11021070
errors: [error, ...errors],
@@ -1123,43 +1091,6 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) =>
11231091
t.true(fetch.done());
11241092
});
11251093

1126-
test("Throw SemanticReleaseError if the repository name has been changed", async (t) => {
1127-
const owner = "test_user";
1128-
const repo = "test_repo";
1129-
const env = { GH_TOKEN: "github_token" };
1130-
1131-
const fetch = fetchMock
1132-
.sandbox()
1133-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1134-
permissions: { push: true },
1135-
clone_url: `https://github.com/${owner}/new-repo-name.git`,
1136-
});
1137-
1138-
const {
1139-
errors: [error, ...errors],
1140-
} = await t.throwsAsync(
1141-
verify(
1142-
{},
1143-
{
1144-
env,
1145-
options: { repositoryUrl: `https://github.com/${owner}/${repo}.git` },
1146-
logger: t.context.logger,
1147-
},
1148-
{
1149-
Octokit: TestOctokit.defaults((options) => ({
1150-
...options,
1151-
request: { ...options.request, fetch },
1152-
})),
1153-
},
1154-
),
1155-
);
1156-
1157-
t.is(errors.length, 0);
1158-
t.is(error.name, "SemanticReleaseError");
1159-
t.is(error.code, "EMISMATCHGITHUBURL");
1160-
t.true(fetch.done());
1161-
});
1162-
11631094
test("Throw error if github return any other errors", async (t) => {
11641095
const owner = "test_user";
11651096
const repo = "test_repo";
@@ -1258,9 +1189,8 @@ test('Throw SemanticReleaseError if "assets" option is not a String or an Array
12581189

12591190
const fetch = fetchMock
12601191
.sandbox()
1261-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1192+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
12621193
permissions: { push: true },
1263-
clone_url: `https://github.com/${owner}/${repo}.git`,
12641194
});
12651195

12661196
const {
@@ -1296,9 +1226,8 @@ test('Throw SemanticReleaseError if "assets" option is an Array with invalid ele
12961226

12971227
const fetch = fetchMock
12981228
.sandbox()
1299-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1229+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
13001230
permissions: { push: true },
1301-
clone_url: `https://github.com/${owner}/${repo}.git`,
13021231
});
13031232

13041233
const {
@@ -1334,9 +1263,8 @@ test('Throw SemanticReleaseError if "assets" option is an Object missing the "pa
13341263

13351264
const fetch = fetchMock
13361265
.sandbox()
1337-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1266+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
13381267
permissions: { push: true },
1339-
clone_url: `https://github.com/${owner}/${repo}.git`,
13401268
});
13411269

13421270
const {
@@ -1372,9 +1300,8 @@ test('Throw SemanticReleaseError if "assets" option is an Array with objects mis
13721300

13731301
const fetch = fetchMock
13741302
.sandbox()
1375-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1303+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
13761304
permissions: { push: true },
1377-
clone_url: `https://github.com/${owner}/${repo}.git`,
13781305
});
13791306

13801307
const {
@@ -1410,9 +1337,8 @@ test('Throw SemanticReleaseError if "successComment" option is not a String', as
14101337

14111338
const fetch = fetchMock
14121339
.sandbox()
1413-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1340+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
14141341
permissions: { push: true },
1415-
clone_url: `https://github.com/${owner}/${repo}.git`,
14161342
});
14171343

14181344
const {
@@ -1448,9 +1374,8 @@ test('Throw SemanticReleaseError if "successComment" option is an empty String',
14481374

14491375
const fetch = fetchMock
14501376
.sandbox()
1451-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1377+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
14521378
permissions: { push: true },
1453-
clone_url: `https://github.com/${owner}/${repo}.git`,
14541379
});
14551380

14561381
const {
@@ -1486,9 +1411,8 @@ test('Throw SemanticReleaseError if "successComment" option is a whitespace Stri
14861411

14871412
const fetch = fetchMock
14881413
.sandbox()
1489-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1414+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
14901415
permissions: { push: true },
1491-
clone_url: `https://github.com/${owner}/${repo}.git`,
14921416
});
14931417

14941418
const {
@@ -1524,9 +1448,8 @@ test('Throw SemanticReleaseError if "failTitle" option is not a String', async (
15241448

15251449
const fetch = fetchMock
15261450
.sandbox()
1527-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1451+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
15281452
permissions: { push: true },
1529-
clone_url: `https://github.com/${owner}/${repo}.git`,
15301453
});
15311454

15321455
const {
@@ -1562,9 +1485,8 @@ test('Throw SemanticReleaseError if "failTitle" option is an empty String', asyn
15621485

15631486
const fetch = fetchMock
15641487
.sandbox()
1565-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1488+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
15661489
permissions: { push: true },
1567-
clone_url: `https://github.com/${owner}/${repo}.git`,
15681490
});
15691491

15701492
const {
@@ -1600,9 +1522,8 @@ test('Throw SemanticReleaseError if "failTitle" option is a whitespace String',
16001522

16011523
const fetch = fetchMock
16021524
.sandbox()
1603-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1525+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
16041526
permissions: { push: true },
1605-
clone_url: `https://github.com/${owner}/${repo}.git`,
16061527
});
16071528

16081529
const {
@@ -1638,9 +1559,8 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is not a Str
16381559

16391560
const fetch = fetchMock
16401561
.sandbox()
1641-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1562+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
16421563
permissions: { push: true },
1643-
clone_url: `https://github.com/${owner}/${repo}.git`,
16441564
});
16451565

16461566
const {
@@ -1676,9 +1596,8 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is an empty
16761596

16771597
const fetch = fetchMock
16781598
.sandbox()
1679-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1599+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
16801600
permissions: { push: true },
1681-
clone_url: `https://github.com/${owner}/${repo}.git`,
16821601
});
16831602

16841603
const {
@@ -1714,9 +1633,8 @@ test('Throw SemanticReleaseError if "discussionCategoryName" option is a whitesp
17141633

17151634
const fetch = fetchMock
17161635
.sandbox()
1717-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1636+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
17181637
permissions: { push: true },
1719-
clone_url: `https://github.com/${owner}/${repo}.git`,
17201638
});
17211639

17221640
const {
@@ -1752,9 +1670,8 @@ test('Throw SemanticReleaseError if "failComment" option is not a String', async
17521670

17531671
const fetch = fetchMock
17541672
.sandbox()
1755-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1673+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
17561674
permissions: { push: true },
1757-
clone_url: `https://github.com/${owner}/${repo}.git`,
17581675
});
17591676

17601677
const {
@@ -1790,9 +1707,8 @@ test('Throw SemanticReleaseError if "failComment" option is an empty String', as
17901707

17911708
const fetch = fetchMock
17921709
.sandbox()
1793-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1710+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
17941711
permissions: { push: true },
1795-
clone_url: `https://github.com/${owner}/${repo}.git`,
17961712
});
17971713

17981714
const {
@@ -1828,9 +1744,8 @@ test('Throw SemanticReleaseError if "failComment" option is a whitespace String'
18281744

18291745
const fetch = fetchMock
18301746
.sandbox()
1831-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1747+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
18321748
permissions: { push: true },
1833-
clone_url: `https://github.com/${owner}/${repo}.git`,
18341749
});
18351750

18361751
const {
@@ -1866,9 +1781,8 @@ test('Throw SemanticReleaseError if "labels" option is not a String or an Array
18661781

18671782
const fetch = fetchMock
18681783
.sandbox()
1869-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1784+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
18701785
permissions: { push: true },
1871-
clone_url: `https://github.com/${owner}/${repo}.git`,
18721786
});
18731787

18741788
const {
@@ -1904,9 +1818,8 @@ test('Throw SemanticReleaseError if "labels" option is an Array with invalid ele
19041818

19051819
const fetch = fetchMock
19061820
.sandbox()
1907-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1821+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
19081822
permissions: { push: true },
1909-
clone_url: `https://github.com/${owner}/${repo}.git`,
19101823
});
19111824

19121825
const {
@@ -1942,9 +1855,8 @@ test('Throw SemanticReleaseError if "labels" option is a whitespace String', asy
19421855

19431856
const fetch = fetchMock
19441857
.sandbox()
1945-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1858+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
19461859
permissions: { push: true },
1947-
clone_url: `https://github.com/${owner}/${repo}.git`,
19481860
});
19491861

19501862
const {
@@ -1980,9 +1892,8 @@ test('Throw SemanticReleaseError if "assignees" option is not a String or an Arr
19801892

19811893
const fetch = fetchMock
19821894
.sandbox()
1983-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1895+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
19841896
permissions: { push: true },
1985-
clone_url: `https://github.com/${owner}/${repo}.git`,
19861897
});
19871898

19881899
const {
@@ -2018,9 +1929,8 @@ test('Throw SemanticReleaseError if "assignees" option is an Array with invalid
20181929

20191930
const fetch = fetchMock
20201931
.sandbox()
2021-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1932+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
20221933
permissions: { push: true },
2023-
clone_url: `https://github.com/${owner}/${repo}.git`,
20241934
});
20251935

20261936
const {
@@ -2056,9 +1966,8 @@ test('Throw SemanticReleaseError if "assignees" option is a whitespace String',
20561966

20571967
const fetch = fetchMock
20581968
.sandbox()
2059-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
1969+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
20601970
permissions: { push: true },
2061-
clone_url: `https://github.com/${owner}/${repo}.git`,
20621971
});
20631972

20641973
const {
@@ -2094,9 +2003,8 @@ test('Throw SemanticReleaseError if "releasedLabels" option is not a String or a
20942003

20952004
const fetch = fetchMock
20962005
.sandbox()
2097-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2006+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
20982007
permissions: { push: true },
2099-
clone_url: `https://github.com/${owner}/${repo}.git`,
21002008
});
21012009

21022010
const {
@@ -2132,9 +2040,8 @@ test('Throw SemanticReleaseError if "releasedLabels" option is an Array with inv
21322040

21332041
const fetch = fetchMock
21342042
.sandbox()
2135-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2043+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
21362044
permissions: { push: true },
2137-
clone_url: `https://github.com/${owner}/${repo}.git`,
21382045
});
21392046

21402047
const {
@@ -2170,9 +2077,8 @@ test('Throw SemanticReleaseError if "releasedLabels" option is a whitespace Stri
21702077

21712078
const fetch = fetchMock
21722079
.sandbox()
2173-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2080+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
21742081
permissions: { push: true },
2175-
clone_url: `https://github.com/${owner}/${repo}.git`,
21762082
});
21772083

21782084
const {
@@ -2208,9 +2114,8 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string (
22082114

22092115
const fetch = fetchMock
22102116
.sandbox()
2211-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2117+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
22122118
permissions: { push: true },
2213-
clone_url: `https://github.com/${owner}/${repo}.git`,
22142119
});
22152120

22162121
const {
@@ -2246,9 +2151,8 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string (
22462151

22472152
const fetch = fetchMock
22482153
.sandbox()
2249-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2154+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
22502155
permissions: { push: true },
2251-
clone_url: `https://github.com/${owner}/${repo}.git`,
22522156
});
22532157

22542158
const {
@@ -2284,9 +2188,8 @@ test('Throw SemanticReleaseError if "addReleases" option is not a valid string (
22842188

22852189
const fetch = fetchMock
22862190
.sandbox()
2287-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2191+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
22882192
permissions: { push: true },
2289-
clone_url: `https://github.com/${owner}/${repo}.git`,
22902193
});
22912194

22922195
const {
@@ -2322,9 +2225,8 @@ test('Throw SemanticReleaseError if "draftRelease" option is not a valid boolean
23222225

23232226
const fetch = fetchMock
23242227
.sandbox()
2325-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2228+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
23262229
permissions: { push: true },
2327-
clone_url: `https://github.com/${owner}/${repo}.git`,
23282230
});
23292231

23302232
const {
@@ -2359,9 +2261,8 @@ test('Throw SemanticReleaseError if "releaseBodyTemplate" option is an empty str
23592261

23602262
const fetch = fetchMock
23612263
.sandbox()
2362-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2264+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
23632265
permissions: { push: true },
2364-
clone_url: `https://github.com/${owner}/${repo}.git`,
23652266
});
23662267

23672268
const {
@@ -2396,9 +2297,8 @@ test('Throw SemanticReleaseError if "releaseNameTemplate" option is an empty str
23962297

23972298
const fetch = fetchMock
23982299
.sandbox()
2399-
.get(`https://api.github.local/repos/${owner}/${repo}`, {
2300+
.getOnce(`https://api.github.local/repos/${owner}/${repo}`, {
24002301
permissions: { push: true },
2401-
clone_url: `https://github.com/${owner}/${repo}.git`,
24022302
});
24032303

24042304
const {

0 commit comments

Comments
 (0)
Please sign in to comment.