mirror of
https://github.com/actions/checkout.git
synced 2024-11-22 21:25:28 +00:00
Add costume shh port to getFetchUrl function
This commit is contained in:
parent
72f2cec99f
commit
13ef2cd8f1
@ -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'
|
||||||
|
Loading…
Reference in New Issue
Block a user