-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
changes to support ghes alpha release (#199)
- Loading branch information
1 parent
574281d
commit 85b1f35
Showing
5 changed files
with
93 additions
and
24 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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as assert from 'assert' | ||
import {IGitSourceSettings} from './git-source-settings' | ||
import {URL} from 'url' | ||
|
||
export function getApiUrl(): string { | ||
return process.env['GITHUB_API_URL'] || 'https://api.github.com' | ||
} | ||
|
||
export function getFetchUrl(settings: IGitSourceSettings): string { | ||
assert.ok( | ||
settings.repositoryOwner, | ||
'settings.repositoryOwner must be defined' | ||
) | ||
assert.ok(settings.repositoryName, 'settings.repositoryName must be defined') | ||
const serviceUrl = getServerUrl() | ||
const encodedOwner = encodeURIComponent(settings.repositoryOwner) | ||
const encodedName = encodeURIComponent(settings.repositoryName) | ||
if (settings.sshKey) { | ||
return `git@${serviceUrl.hostname}:${encodedOwner}/${encodedName}.git` | ||
} | ||
|
||
// "origin" is SCHEME://HOSTNAME[:PORT] | ||
return `${serviceUrl.origin}/${encodedOwner}/${encodedName}` | ||
} | ||
|
||
export function getServerUrl(): URL { | ||
return new URL(process.env['GITHUB_URL'] || 'https://github.com') | ||
} |
1,000