Skip to content

Commit

Permalink
Fixes gitkraken#1845, gitkraken#1210 adds github enterprise remote su…
Browse files Browse the repository at this point in the history
…pport
  • Loading branch information
forestaa committed Jun 4, 2022
1 parent ec3f89d commit 5bb78d0
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ export const enum CustomRemoteType {
GoogleSource = 'GoogleSource',
Gitea = 'Gitea',
GitHub = 'GitHub',
GitHubEnterprise = 'GitHubEnterprise',
GitLab = 'GitLab',
}

Expand Down
4 changes: 4 additions & 0 deletions src/git/remotes/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CustomRemote } from './custom';
import { GerritRemote } from './gerrit';
import { GiteaRemote } from './gitea';
import { GitHubRemote } from './github';
import { GithubEnterpriseRemote } from './github-enterprise';
import { GitLabRemote } from './gitlab';
import { GoogleSourceRemote } from './google-source';
import { RemoteProvider } from './provider';
Expand Down Expand Up @@ -156,6 +157,9 @@ export class RemoteProviderFactory {
return (domain: string, path: string) => new GiteaRemote(domain, path, cfg.protocol, cfg.name, true);
case CustomRemoteType.GitHub:
return (domain: string, path: string) => new GitHubRemote(domain, path, cfg.protocol, cfg.name, true);
case CustomRemoteType.GitHubEnterprise:
return (domain: string, path: string) =>
new GithubEnterpriseRemote(domain, path, cfg.protocol, cfg.name, true);
case CustomRemoteType.GitLab:
return (domain: string, path: string) => new GitLabRemote(domain, path, cfg.protocol, cfg.name, true);
default:
Expand Down
21 changes: 21 additions & 0 deletions src/git/remotes/github-enterprise.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { GitHubRemote } from './github';

const authProvider = Object.freeze({ id: 'github-enterprise', scopes: ['repo', 'read:user', 'user:email'] });

export class GithubEnterpriseRemote extends GitHubRemote {
protected override get authProvider(): { id: string; scopes: string[] } {
return authProvider;
}

constructor(domain: string, path: string, protocol?: string, name?: string, custom: boolean = false) {
super(domain, path, protocol, name, custom);
}

override get id() {
return 'github-enterprise';
}

override get name() {
return this.formatName('GitHub Enterprise');
}
}
2 changes: 1 addition & 1 deletion src/git/remotes/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const rangeRegex = /^L(\d+)(?:-L(\d+))?$/;
const authProvider = Object.freeze({ id: 'github', scopes: ['repo', 'read:user', 'user:email'] });

export class GitHubRemote extends RichRemoteProvider {
protected get authProvider() {
protected get authProvider(): { id: string; scopes: string[] } {
return authProvider;
}

Expand Down

0 comments on commit 5bb78d0

Please sign in to comment.