File tree Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Expand file tree Collapse file tree 3 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -901,6 +901,7 @@ class GitHubHelper {
901
901
if ( token ) {
902
902
options . auth = `${ token } ` ;
903
903
}
904
+ options . baseUrl = process . env [ 'GITHUB_API_URL' ] || 'https://api.github.com' ;
904
905
this . octokit = new octokit_client_1 . Octokit ( options ) ;
905
906
}
906
907
parseRepository ( repository ) {
@@ -1157,8 +1158,13 @@ exports.getRepoPath = getRepoPath;
1157
1158
function getRemoteDetail ( remoteUrl ) {
1158
1159
// Parse the protocol and github repository from a URL
1159
1160
// e.g. HTTPS, peter-evans/create-pull-request
1160
- const httpsUrlPattern = / ^ h t t p s : \/ \/ .* @ ? g i t h u b .c o m \/ ( .+ \/ .+ ) $ / i;
1161
- const sshUrlPattern = / ^ g i t @ g i t h u b .c o m : ( .+ \/ .+ ) .g i t $ / i;
1161
+ const githubUrl = process . env [ 'GITHUB_SERVER_URL' ] || 'https://github.com' ;
1162
+ const githubServerMatch = githubUrl . match ( / ^ h t t p s ? : \/ \/ ( .+ ) $ / i) ;
1163
+ if ( ! githubServerMatch ) {
1164
+ throw new Error ( 'Could not parse GitHub Server name' ) ;
1165
+ }
1166
+ const httpsUrlPattern = new RegExp ( '^https?://.*@?' + githubServerMatch [ 1 ] + '/(.+/.+)$' , 'i' ) ;
1167
+ const sshUrlPattern = new RegExp ( '^git@' + githubServerMatch [ 1 ] + ':(.+/.+).git$' , 'i' ) ;
1162
1168
const httpsMatch = remoteUrl . match ( httpsUrlPattern ) ;
1163
1169
if ( httpsMatch ) {
1164
1170
return {
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export class GitHubHelper {
23
23
if ( token ) {
24
24
options . auth = `${ token } `
25
25
}
26
+ options . baseUrl = process . env [ 'GITHUB_API_URL' ] || 'https://api.github.com'
26
27
this . octokit = new Octokit ( options )
27
28
}
28
29
Original file line number Diff line number Diff line change @@ -39,8 +39,21 @@ interface RemoteDetail {
39
39
export function getRemoteDetail ( remoteUrl : string ) : RemoteDetail {
40
40
// Parse the protocol and github repository from a URL
41
41
// e.g. HTTPS, peter-evans/create-pull-request
42
- const httpsUrlPattern = / ^ h t t p s : \/ \/ .* @ ? g i t h u b .c o m \/ ( .+ \/ .+ ) $ / i
43
- const sshUrlPattern = / ^ g i t @ g i t h u b .c o m : ( .+ \/ .+ ) .g i t $ / i
42
+ const githubUrl = process . env [ 'GITHUB_SERVER_URL' ] || 'https://github.com'
43
+
44
+ const githubServerMatch = githubUrl . match ( / ^ h t t p s ? : \/ \/ ( .+ ) $ / i)
45
+ if ( ! githubServerMatch ) {
46
+ throw new Error ( 'Could not parse GitHub Server name' )
47
+ }
48
+
49
+ const httpsUrlPattern = new RegExp (
50
+ '^https?://.*@?' + githubServerMatch [ 1 ] + '/(.+/.+)$' ,
51
+ 'i'
52
+ )
53
+ const sshUrlPattern = new RegExp (
54
+ '^git@' + githubServerMatch [ 1 ] + ':(.+/.+).git$' ,
55
+ 'i'
56
+ )
44
57
45
58
const httpsMatch = remoteUrl . match ( httpsUrlPattern )
46
59
if ( httpsMatch ) {
You can’t perform that action at this time.
0 commit comments