Skip to content

Commit

Permalink
Re-order funcs to lessen diff
Browse files Browse the repository at this point in the history
  • Loading branch information
criccomini committed Dec 14, 2024
1 parent da52105 commit 1f79ba2
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions src/git.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
const sshKey = core.getInput('ssh-key');
if (!sshKey) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1f79ba2

Please sign in to comment.