mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
6cc889803a
* fix(platform/github): use `x-access-token` for personal access tokens in clone URLs Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> Co-Authored-By: Claude Sonnet 5.5 <michael.kriese+claude-code@mend.io> * fix(platform/github): drop unreachable password fallback in clone URLs Co-Authored-By: Claude Opus 5.5 <michael.kriese+claude-code@mend.io> Co-Authored-By: Claude Sonnet 5.5 <michael.kriese+claude-code@mend.io> --------- Co-authored-by: Claude Opus 5.5 <michael.kriese+claude-code@mend.io>
63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { CONFIG_GIT_URL_UNAVAILABLE } from '../../../constants/error-messages.ts';
|
|
import { logger } from '../../../logger/index.ts';
|
|
import { parseGitAuthor } from '../../../util/git/author.ts';
|
|
import { parseUrl } from '../../../util/url.ts';
|
|
import type { GitUrlOption } from '../types.ts';
|
|
import type { GithubEnterpriseServerHost, GithubHost } from './types.ts';
|
|
|
|
export function warnIfDefaultGitAuthorEmail(
|
|
gitAuthor: string | undefined,
|
|
isGHE: boolean | undefined,
|
|
): void {
|
|
if (isGHE === true) {
|
|
return;
|
|
}
|
|
const parsed = parseGitAuthor(
|
|
gitAuthor ?? 'renovate@whitesourcesoftware.com',
|
|
);
|
|
if (parsed?.address === 'renovate@whitesourcesoftware.com') {
|
|
logger.once.warn(
|
|
{
|
|
documentationUrl:
|
|
'https://github.com/renovatebot/renovate/discussions/39309',
|
|
},
|
|
'Using the default gitAuthor email address, renovate@whitesourcesoftware.com, is not recommended on GitHub.com, as this corresponds to a user owned by Mend and used by users of the forking-renovate[bot] GitHub App. For security and authenticity reasons, Mend enables "Vigilant Mode" on this account to visibly flag unsigned commits. As an account you do not control, you will not be able to sign commits. If you are comfortable with the `Unverified` signatures on each commit, no work is needed. Otherwise, it is recommended to migrate to a user account you own',
|
|
);
|
|
}
|
|
}
|
|
|
|
export function getRepoUrl(
|
|
repository: string,
|
|
gitUrl: GitUrlOption | undefined,
|
|
sshUrl: string | null,
|
|
endpoint: URL,
|
|
authToken: string | null,
|
|
): string {
|
|
if (gitUrl === 'ssh') {
|
|
if (!sshUrl) {
|
|
throw new Error(CONFIG_GIT_URL_UNAVAILABLE);
|
|
}
|
|
logger.debug(`Using ssh URL: ${sshUrl}`);
|
|
return sshUrl;
|
|
}
|
|
|
|
// clone to avoid mutating the caller's URL; href is known-valid
|
|
const url = parseUrl(endpoint.href)!;
|
|
if (authToken) {
|
|
const [username, password] = authToken.includes(':')
|
|
? authToken.split(':')
|
|
: ['x-access-token', authToken];
|
|
url.username = username;
|
|
url.password = password;
|
|
}
|
|
url.host = url.host.replace('api.github.com', 'github.com');
|
|
url.pathname = `${repository}.git`;
|
|
return url.href;
|
|
}
|
|
|
|
export function isGithubEnterpriseServer(
|
|
host: GithubHost,
|
|
): host is GithubEnterpriseServerHost {
|
|
return host.type === 'ghes';
|
|
}
|