Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore case when checking for repo rename #903

Merged
merged 2 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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