Skip to content

Commit 2b1b9b6

Browse files
authoredAug 20, 2024··
fix: ignore case when checking for repo rename (#903)
fix #901
1 parent f9e5774 commit 2b1b9b6

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed
 

‎lib/verify.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,10 @@ export default async function verify(pluginConfig, context, { Octokit }) {
109109
} = await octokit.request("GET /repos/{owner}/{repo}", { repo, owner });
110110
// Verify if Repository Name wasn't changed
111111
const parsedCloneUrl = parseGithubUrl(clone_url);
112-
if (owner !== parsedCloneUrl.owner || repo !== parsedCloneUrl.repo) {
112+
if (
113+
`${owner}/${repo}`.toLowerCase() !==
114+
`${parsedCloneUrl.owner}/${parsedCloneUrl.repo}`.toLowerCase()
115+
) {
113116
errors.push(
114117
getError("EMISMATCHGITHUBURL", { repositoryUrl, clone_url }),
115118
);

‎test/verify.test.js

+34
Original file line numberDiff line numberDiff line change
@@ -1269,6 +1269,40 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) =>
12691269
t.true(fetch.done());
12701270
});
12711271

1272+
test(`Don't throw an error if owner/repo only differs in case`, async (t) => {
1273+
const env = { GH_TOKEN: "github_token" };
1274+
1275+
const fetch = fetchMock.sandbox().getOnce(
1276+
`https://api.github.local/repos/org/foo`,
1277+
{
1278+
permissions: { push: true },
1279+
clone_url: `https://github.com/ORG/FOO.git`,
1280+
},
1281+
{ repeat: 2 },
1282+
);
1283+
1284+
await t.notThrowsAsync(
1285+
verify(
1286+
{},
1287+
{
1288+
env,
1289+
options: {
1290+
repositoryUrl: `https://github.com/org/foo.git`,
1291+
},
1292+
logger: t.context.logger,
1293+
},
1294+
{
1295+
Octokit: TestOctokit.defaults((options) => ({
1296+
...options,
1297+
request: { ...options.request, fetch },
1298+
})),
1299+
},
1300+
),
1301+
);
1302+
1303+
t.true(fetch.done());
1304+
});
1305+
12721306
const urlFormats = [
12731307
(owner, repo) => `https://github.com/${owner}/${repo}.git`,
12741308
(owner, repo) => `git+https://github.com/${owner}/${repo}.git`,

0 commit comments

Comments
 (0)
Please sign in to comment.