From 13ef2cd8f1793be3378132e892c4c09d42f56b65 Mon Sep 17 00:00:00 2001 From: Jakob <72307968+jakob30061@users.noreply.github.com> Date: Thu, 7 Sep 2023 22:36:39 +0200 Subject: [PATCH 1/2] Add costume shh port to getFetchUrl function --- src/url-helper.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/url-helper.ts b/src/url-helper.ts index 6807b7f..94ce24a 100644 --- a/src/url-helper.ts +++ b/src/url-helper.ts @@ -1,6 +1,6 @@ import * as assert from 'assert' -import {URL} from 'url' import {IGitSourceSettings} from './git-source-settings' +import {URL} from 'url' export function getFetchUrl(settings: IGitSourceSettings): string { assert.ok( @@ -11,8 +11,11 @@ export function getFetchUrl(settings: IGitSourceSettings): string { const serviceUrl = getServerUrl(settings.githubServerUrl) const encodedOwner = encodeURIComponent(settings.repositoryOwner) const encodedName = encodeURIComponent(settings.repositoryName) + 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] @@ -20,7 +23,7 @@ export function getFetchUrl(settings: IGitSourceSettings): string { } export function getServerUrl(url?: string): URL { - let urlValue = + const urlValue = url && url.trim().length > 0 ? url : process.env['GITHUB_SERVER_URL'] || 'https://github.com' From e9130f8f55725747509e642e3b814c18f23036e8 Mon Sep 17 00:00:00 2001 From: Jakob <72307968+jakob30061@users.noreply.github.com> Date: Fri, 8 Sep 2023 00:11:37 +0200 Subject: [PATCH 2/2] Add build file --- dist/index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 67752ae..993e69a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -2371,14 +2371,16 @@ function getFetchUrl(settings) { const encodedOwner = encodeURIComponent(settings.repositoryOwner); const encodedName = encodeURIComponent(settings.repositoryName); 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] return `${serviceUrl.origin}/${encodedOwner}/${encodedName}`; } exports.getFetchUrl = getFetchUrl; function getServerUrl(url) { - let urlValue = url && url.trim().length > 0 + const urlValue = url && url.trim().length > 0 ? url : process.env['GITHUB_SERVER_URL'] || 'https://github.com'; return new url_1.URL(urlValue);