Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(GHE): support GHE #41

Merged
merged 1 commit into from
Jun 21, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,9 @@ export class GitHubSearchResultItem implements Item {

// owner/repo
get shortPath() {
// TODO: support GHE
// https://github.com/zeke/github-url-to-object#github-enterprise
const object = ghUrlToObject(this.htmlUrl);
const isEnterprise = !this.htmlUrl.startsWith("https://github.com/");
const object = ghUrlToObject(this.htmlUrl, { enterprise: isEnterprise });
return `${object.user}/${object.repo}`;
}

Expand Down
4 changes: 3 additions & 1 deletion src/use-case/GitHubSetting/CheckGrantGitHubAPIUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export class CheckGrantGitHubAPIUseCase extends UseCase {
const gitHub = new GitHubClient(setting);
// TODO: check `scopes`
// https://github.com/philschatz/octokat.js/issues/183
return gitHub.rateLimits();
// Use user api insteadof ratelimit api
// RateLimit API disable by some GHE. It return 404.
return gitHub.user();
}
}
2 changes: 1 addition & 1 deletion src/use-case/GitHubSetting/SaveGitHubSettingUseCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export class SaveGitHubSettingUseCase extends UseCase {
const setting = GitHubSetting.fromJSON(settingJSON);
const gitHub = new GitHubClient(setting);
try {
await gitHub.rateLimits();
await gitHub.user();
} catch (error) {
throw new Error(
"Can't access GitHub API by the setting:" + JSON.stringify(settingJSON)
Expand Down