diff --git a/src/git.ts b/src/git.ts index f60d4293e..7c584a182 100644 --- a/src/git.ts +++ b/src/git.ts @@ -58,21 +58,6 @@ export function getServerName(repositoryUrl: string | undefined): string { return getServerUrlObj(repositoryUrl).hostname; } -function getCurrentRepoRemoteUrl(token: string | undefined): string { - const { repo, owner } = github.context.repo; - const serverName = getServerName(github.context.payload.repository?.html_url); - return getRepoRemoteUrl(token, `${serverName}/${owner}/${repo}`); -} - -function getRepoRemoteUrl(token: string | undefined, repoUrl: string): string { - if (!token) { - // Use SSH format when no token is provided - const [serverName, owner, repo] = repoUrl.split('/'); - return `git@${serverName}:${owner}/${repo}.git`; - } - return `https://x-access-token:${token}@${repoUrl}.git`; -} - async function setupSshKey(): Promise { const sshKey = core.getInput('ssh-key'); if (!sshKey) { @@ -116,6 +101,21 @@ export async function cmd(additionalGitOptions: string[], ...args: string[]): Pr return res.stdout; } +function getCurrentRepoRemoteUrl(token: string | undefined): string { + const { repo, owner } = github.context.repo; + const serverName = getServerName(github.context.payload.repository?.html_url); + return getRepoRemoteUrl(token, `${serverName}/${owner}/${repo}`); +} + +function getRepoRemoteUrl(token: string | undefined, repoUrl: string): string { + if (!token) { + // Use SSH format when no token is provided + const [serverName, owner, repo] = repoUrl.split('/'); + return `git@${serverName}:${owner}/${repo}.git`; + } + return `https://x-access-token:${token}@${repoUrl}.git`; +} + export async function push( token: string | undefined, repoUrl: string | undefined,