Skip to content

Commit

Permalink
feat: Allow user to set git remote
Browse files Browse the repository at this point in the history
Fixes #1130
  • Loading branch information
Gerrit0 committed Mar 15, 2020
1 parent c828319 commit 5cbd44d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/lib/converter/plugins/GitHubPlugin.ts
Expand Up @@ -130,7 +130,7 @@ export class Repository {
* @param path The potential repository root.
* @returns A new instance of [[Repository]] or undefined.
*/
static tryCreateRepository(path: string, gitRevision: string): Repository | undefined {
static tryCreateRepository(path: string, gitRevision: string, gitRemote: string): Repository | undefined {
ShellJS.pushd(path);
const out = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git rev-parse --show-toplevel', {silent: true});
ShellJS.popd();
Expand All @@ -139,7 +139,7 @@ export class Repository {
return;
}

let remotesOutput = <ShellJS.ExecOutputReturnValue> ShellJS.exec('git ls-remote --get-url', {silent: true});
const remotesOutput = <ShellJS.ExecOutputReturnValue> ShellJS.exec(`git remote get-url ${gitRemote}`, {silent: true});
let remotes: string[] = (remotesOutput.code === 0) ? remotesOutput.stdout.split('\n') : [];

return new Repository(BasePath.normalize(out.stdout.replace('\n', '')), gitRevision, remotes);
Expand All @@ -163,7 +163,10 @@ export class GitHubPlugin extends ConverterComponent {
private ignoredPaths: string[] = [];

@BindOption('gitRevision')
gitRevision!: string;
readonly gitRevision!: string;

@BindOption('gitRemote')
readonly gitRemote!: string;

/**
* Create a new GitHubHandler instance.
Expand Down Expand Up @@ -203,7 +206,7 @@ export class GitHubPlugin extends ConverterComponent {
}

// Try to create a new repository
const repository = Repository.tryCreateRepository(dirName, this.gitRevision);
const repository = Repository.tryCreateRepository(dirName, this.gitRevision, this.gitRemote);
if (repository) {
this.repositories[repository.path.toLowerCase()] = repository;
return repository;
Expand Down
1 change: 1 addition & 0 deletions src/lib/utils/options/declaration.ts
Expand Up @@ -68,6 +68,7 @@ export interface TypeDocOptionMap {
categoryOrder: string[];
categorizeByGroup: boolean;
gitRevision: string;
gitRemote: string;
gaID: string;
gaSite: string;
hideGenerator: boolean;
Expand Down
5 changes: 5 additions & 0 deletions src/lib/utils/options/sources/typedoc.ts
Expand Up @@ -147,6 +147,11 @@ export function addTypeDocOptions(options: Options) {
name: 'gitRevision',
help: 'Use specified revision instead of the last revision for linking to GitHub source files.'
});
options.addDeclaration({
name: 'gitRemote',
help: 'Use the specified remote for linking to GitHub source files.',
defaultValue: 'origin'
});
options.addDeclaration({
name: 'gaID',
help: 'Set the Google Analytics tracking ID and activate tracking code.'
Expand Down

0 comments on commit 5cbd44d

Please sign in to comment.