8000 fix: Revert "fix: failing release due to renamed repository (#878)" (… · semantic-release/github@325952e · GitHub
[go: up one dir, main page]

Skip to content

Commit 325952e

Browse files
authored
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

Lines changed: 0 additions & 11 deletions
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

Lines changed: 0 additions & 27 deletions
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

Lines changed: 27 additions & 67 deletions
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(

0 commit comments

Comments
 (0)
0