mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 23:11:31 +00:00
9717259ffc
Enable no-else-return (with allowElseIf: false) and unicorn/no-lonely-if as errors in .oxlintrc.json and fix all 131 pre-existing violations (91 no-else-return, 40 unicorn/no-lonely-if) across 98 files. The no-else-return violations were fixed with the oxlint autofix (iterated to a fixpoint, plus two else-if chains that required --fix-dangerously) followed by Prettier formatting. One comment dropped by the autofix in lib/modules/manager/pub/artifacts.ts was restored manually. The unicorn/no-lonely-if violations were merged by hand, preserving comments and coverage-ignore hints. Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
39 lines
991 B
TypeScript
39 lines
991 B
TypeScript
import { regEx } from '../../../util/regex.ts';
|
|
import { parseUrl } from '../../../util/url.ts';
|
|
|
|
export const RE_REPOSITORY_GENERIC_GIT_SSH_FORMAT = regEx(
|
|
/^git@[^:]*:(?<repository>.+)$/,
|
|
);
|
|
|
|
export function parseGitOwnerRepo(
|
|
git: string,
|
|
githubUrl: boolean,
|
|
): string | null {
|
|
const genericGitSsh = RE_REPOSITORY_GENERIC_GIT_SSH_FORMAT.exec(git);
|
|
|
|
if (genericGitSsh?.groups) {
|
|
return genericGitSsh.groups.repository.replace(regEx(/\.git$/), '');
|
|
}
|
|
if (githubUrl) {
|
|
return git
|
|
.replace(regEx(/^github:/), '')
|
|
.replace(regEx(/^git\+/), '')
|
|
.replace(regEx(/^https:\/\/github\.com\//), '')
|
|
.replace(regEx(/\.git$/), '');
|
|
}
|
|
|
|
const url = parseUrl(git);
|
|
|
|
if (!url) {
|
|
return null;
|
|
}
|
|
|
|
return url.pathname.replace(regEx(/\.git$/), '').replace(regEx(/^\//), '');
|
|
}
|
|
|
|
export function isGithubUrl(gitUrl: string, parsedUrl: URL | null): boolean {
|
|
return (
|
|
parsedUrl?.host === 'github.com' || gitUrl.startsWith('git@github.com')
|
|
);
|
|
}
|