-
-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* parse GITHUB_SERVER_URL if present * accept proper server remotes as well
- Loading branch information
Showing
2 changed files
with
28 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1157,8 +1157,16 @@ exports.getRepoPath = getRepoPath; | |
function getRemoteDetail(remoteUrl) { | ||
// Parse the protocol and github repository from a URL | ||
// e.g. HTTPS, peter-evans/create-pull-request | ||
const httpsUrlPattern = /^https:\/\/.*@?github.com\/(.+\/.+)$/i; | ||
const sshUrlPattern = /^[email protected]:(.+\/.+).git$/i; | ||
let githubServerUrl = process.env['GITHUB_SERVER_URL']; | ||
if (!githubServerUrl) { | ||
githubServerUrl = 'https://github.com'; | ||
} | ||
const githubServerMatch = githubServerUrl.match(/^https?:\/\/(.+)$/i); | ||
if (!githubServerMatch) { | ||
throw new Error('Could not parse GitHub Server name'); | ||
} | ||
const httpsUrlPattern = new RegExp('^https?://.*@?' + githubServerMatch[1] + '/(.+/.+)$', 'i'); | ||
const sshUrlPattern = new RegExp('^git@' + githubServerMatch[1] + ':(.+/.+).git$', 'i'); | ||
const httpsMatch = remoteUrl.match(httpsUrlPattern); | ||
if (httpsMatch) { | ||
return { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,8 +39,24 @@ interface RemoteDetail { | |
export function getRemoteDetail(remoteUrl: string): RemoteDetail { | ||
// Parse the protocol and github repository from a URL | ||
// e.g. HTTPS, peter-evans/create-pull-request | ||
const httpsUrlPattern = /^https:\/\/.*@?github.com\/(.+\/.+)$/i | ||
const sshUrlPattern = /^[email protected]:(.+\/.+).git$/i | ||
let githubServerUrl = process.env['GITHUB_SERVER_URL'] | ||
if (!githubServerUrl) { | ||
githubServerUrl = 'https://github.com' | ||
} | ||
|
||
const githubServerMatch = githubServerUrl.match(/^https?:\/\/(.+)$/i) | ||
if (!githubServerMatch) { | ||
throw new Error('Could not parse GitHub Server name') | ||
} | ||
|
||
const httpsUrlPattern = new RegExp( | ||
'^https?://.*@?' + githubServerMatch[1] + '/(.+/.+)$', | ||
'i' | ||
) | ||
const sshUrlPattern = new RegExp( | ||
'^git@' + githubServerMatch[1] + ':(.+/.+).git$', | ||
'i' | ||
) | ||
|
||
const httpsMatch = remoteUrl.match(httpsUrlPattern) | ||
if (httpsMatch) { | ||
|