Skip to content

Commit

Permalink
Support host name(fix microsoft#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikuyadeu committed Oct 19, 2017
1 parent 87b0bef commit 7d11e9c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@
"type": "array",
"default": [],
"description": "A list of repositories to query for issues."
},
"github.host": {
"type": "string",
"default": "https://api.github.com",
"description": "The host name to accessing GitHub. Please edit here if you use GitHub Enterprise"
}
}
}
Expand Down
11 changes: 7 additions & 4 deletions src/github-issues-prs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
private children: Promise<TreeItem[]> | undefined;

private username: string | undefined;
private host: string | undefined;
private repositories: string[];

constructor(private context: ExtensionContext) {
Expand All @@ -72,9 +73,11 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
const config = workspace.getConfiguration('github');
const newUsername = config.get<string>('username');
const newRepositories = config.get<string[]>('repositories') || [];
if (newUsername !== this.username || JSON.stringify(newRepositories) !== JSON.stringify(this.repositories)) {
const newHost = config.get<string>('host');
if (newUsername !== this.username || JSON.stringify(newRepositories) !== JSON.stringify(this.repositories) || newHost !== this.host) {
this.username = newUsername;
this.repositories = newRepositories;
this.host = newHost;
this.refresh();
}
}));
Expand Down Expand Up @@ -139,7 +142,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
return;
}

const github = new GitHub();
const github = new GitHub({host: this.host});

if (selectedRemote.remote.username && selectedRemote.remote.password) {
github.authenticate({
Expand Down Expand Up @@ -190,7 +193,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
const errors: TreeItem[] = [];
for (const remote of remotes) {
try {
const github = new GitHub();
const github = new GitHub({host: this.host});
if (remote.username && remote.password) {
github.authenticate({
type: 'basic',
Expand Down Expand Up @@ -305,7 +308,7 @@ export class GitHubIssuesPrsProvider implements TreeDataProvider<TreeItem> {
return window.showInformationMessage(`There are local changes in the workspace folder. Commit or stash them before checking out the pull request.`);
}

const github = new GitHub();
const github = new GitHub({host: this.host});
const p = Uri.parse(issue.item.repository_url).path;
const repo = path.basename(p);
const owner = path.basename(path.dirname(p));
Expand Down

0 comments on commit 7d11e9c

Please sign in to comment.