Skip to content

Commit

Permalink
fix: ignore case when checking for repo rename (#903)
Browse files Browse the repository at this point in the history
fix #901
  • Loading branch information
jedwards1211 authored Aug 20, 2024
1 parent f9e5774 commit 2b1b9b6
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }),
);
Expand Down
34 changes: 34 additions & 0 deletions test/verify.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`,
Expand Down

0 comments on commit 2b1b9b6

Please sign in to comment.