Merge e9130f8f55725747509e642e3b814c18f23036e8 into b4ffde65f46336ab88eb53be808477a3936bae11

This commit is contained in:
Jakob 2023-10-17 23:18:41 +02:00 committed by GitHub
commit b4bb4291eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 5 deletions

6
dist/index.js vendored
View File

@ -2381,14 +2381,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'