0
1
Fork 0
mirror of https://github.com/actions/checkout synced 2024-06-29 16:28:19 +02:00
This commit is contained in:
Jakob 2024-03-14 16:10:14 +01:00 committed by GitHub
commit 26d5791cd7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 5 deletions

6
dist/index.js vendored
View file

@ -2400,14 +2400,16 @@ function getFetchUrl(settings) {
const encodedOwner = encodeURIComponent(settings.repositoryOwner); const encodedOwner = encodeURIComponent(settings.repositoryOwner);
const encodedName = encodeURIComponent(settings.repositoryName); const encodedName = encodeURIComponent(settings.repositoryName);
if (settings.sshKey) { if (settings.sshKey) {
return `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`; return serviceUrl.port === ''
? `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`
: `ssh://git@${serviceUrl.hostname}:${serviceUrl.port}/${encodedOwner}/${encodedName}.git`;
} }
// "origin" is SCHEME://HOSTNAME[:PORT] // "origin" is SCHEME://HOSTNAME[:PORT]
return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`; return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`;
} }
exports.getFetchUrl = getFetchUrl; exports.getFetchUrl = getFetchUrl;
function getServerUrl(url) { function getServerUrl(url) {
let urlValue = url && url.trim().length > 0 const urlValue = url && url.trim().length > 0
? url ? url
: process.env['GITHUB_SERVER_URL'] || 'https://github.com'; : process.env['GITHUB_SERVER_URL'] || 'https://github.com';
return new url_1.URL(urlValue); return new url_1.URL(urlValue);

View file

@ -1,6 +1,6 @@
import * as assert from 'assert' import * as assert from 'assert'
import {URL} from 'url'
import {IGitSourceSettings} from './git-source-settings' import {IGitSourceSettings} from './git-source-settings'
import {URL} from 'url'
export function getFetchUrl(settings: IGitSourceSettings): string { export function getFetchUrl(settings: IGitSourceSettings): string {
assert.ok( assert.ok(
@ -11,8 +11,11 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
const serviceUrl = getServerUrl(settings.githubServerUrl) const serviceUrl = getServerUrl(settings.githubServerUrl)
const encodedOwner = encodeURIComponent(settings.repositoryOwner) const encodedOwner = encodeURIComponent(settings.repositoryOwner)
const encodedName = encodeURIComponent(settings.repositoryName) const encodedName = encodeURIComponent(settings.repositoryName)
if (settings.sshKey) { if (settings.sshKey) {
return `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git` return serviceUrl.port === ''
? `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git`
: `ssh://git@${serviceUrl.hostname}:${serviceUrl.port}/${encodedOwner}/${encodedName}.git`
} }
// "origin" is SCHEME://HOSTNAME[:PORT] // "origin" is SCHEME://HOSTNAME[:PORT]
@ -20,7 +23,7 @@ export function getFetchUrl(settings: IGitSourceSettings): string {
} }
export function getServerUrl(url?: string): URL { export function getServerUrl(url?: string): URL {
let urlValue = const urlValue =
url && url.trim().length > 0 url && url.trim().length > 0
? url ? url
: process.env['GITHUB_SERVER_URL'] || 'https://github.com' : process.env['GITHUB_SERVER_URL'] || 'https://github.com'