From 5f3ae46837a47e87dd92acd561054fed2133d5bf Mon Sep 17 00:00:00 2001 From: Andy Edwards Date: Mon, 19 Aug 2024 17:42:09 -0500 Subject: [PATCH] fix: ignore case when checking for repo rename fix #901 --- lib/verify.js | 5 ++++- test/verify.test.js | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/verify.js b/lib/verify.js index b6ccba95..a0987c12 100644 --- a/lib/verify.js +++ b/lib/verify.js @@ -109,7 +109,10 @@ export default async function verify(pluginConfig, context, { Octokit }) { } = await octokit.request("GET /repos/{owner}/{repo}", { repo, owner }); // Verify if Repository Name wasn't changed const parsedCloneUrl = parseGithubUrl(clone_url); - if (owner !== parsedCloneUrl.owner || repo !== parsedCloneUrl.repo) { + if ( + `${owner}/${repo}`.toLowerCase() !== + `${parsedCloneUrl.owner}/${parsedCloneUrl.repo}`.toLowerCase() + ) { errors.push( getError("EMISMATCHGITHUBURL", { repositoryUrl, clone_url }), ); diff --git a/test/verify.test.js b/test/verify.test.js index 37b3afb6..495c7b1b 100644 --- a/test/verify.test.js +++ b/test/verify.test.js @@ -1269,6 +1269,40 @@ test("Throw SemanticReleaseError if the repository doesn't exist", async (t) => t.true(fetch.done()); }); +test(`Don't throw an error if owner/repo only differs in case`, async (t) => { + const env = { GH_TOKEN: "github_token" }; + + const fetch = fetchMock.sandbox().getOnce( + `https://api.github.local/repos/org/foo`, + { + permissions: { push: true }, + clone_url: `https://github.com/ORG/FOO.git`, + }, + { repeat: 2 }, + ); + + await t.notThrowsAsync( + verify( + {}, + { + env, + options: { + repositoryUrl: `https://github.com/org/foo.git`, + }, + logger: t.context.logger, + }, + { + Octokit: TestOctokit.defaults((options) => ({ + ...options, + request: { ...options.request, fetch }, + })), + }, + ), + ); + + t.true(fetch.done()); +}); + const urlFormats = [ (owner, repo) => `https://github.com/${owner}/${repo}.git`, (owner, repo) => `git+https://github.com/${owner}/${repo}.git`,