diff --git a/Gruntfile.js b/Gruntfile.js index 75e0c59..032d850 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -73,6 +73,9 @@ module.exports = function (grunt) { if (options.changes) { args.push('--changes'); } + if (options.gitRemote) { + args.push('--git-remote', options.gitRemote); + } if (options.debug) { args.push('--debug'); } diff --git a/src/index.ts b/src/index.ts index 5a8eb20..564d120 100644 --- a/src/index.ts +++ b/src/index.ts @@ -18,6 +18,9 @@ optimist.boolean('single-thread'); optimist.boolean('changes'); optimist.default('changes', false); +optimist.string('git-remote'); +optimist.default('git-remote', 'origin'); + optimist.boolean('dry'); optimist.default('dry', false); @@ -91,6 +94,7 @@ new TestRunner({ tslintConfig: path.join(path.dirname(testerPkgPath), 'conf', 'tslint.json'), changes: (testFull ? false : argv['changes']), + gitRemote: argv['git-remote'], tests: argv['dry'] ? false : argv['tests'], lint: argv['dry'] ? false : argv['lint'], headers: argv['dry'] ? false : argv['headers'], diff --git a/src/test/ITestOptions.ts b/src/test/ITestOptions.ts index 371e0d3..f9df8f2 100644 --- a/src/test/ITestOptions.ts +++ b/src/test/ITestOptions.ts @@ -6,6 +6,7 @@ export interface ITestOptions { tslintConfig: string; changes: boolean; + gitRemote: string; tests: boolean; lint: boolean; headers: boolean; diff --git a/src/test/TestRunner.ts b/src/test/TestRunner.ts index c1b8b59..fe44839 100644 --- a/src/test/TestRunner.ts +++ b/src/test/TestRunner.ts @@ -46,7 +46,7 @@ export default class TestRunner { this.options = options; this.index = new FileIndex(this.options); - this.changes = new GitChanges(this.options.dtPath); + this.changes = new GitChanges(this.options.dtPath, this.options.gitRemote); let tscVersion = 'unknown'; try { diff --git a/src/util/GitChanges.ts b/src/util/GitChanges.ts index c2c6147..369becb 100644 --- a/src/util/GitChanges.ts +++ b/src/util/GitChanges.ts @@ -8,20 +8,23 @@ import * as util from './util'; export default class GitChanges { private dtPath: string; + private remote: string; - constructor(dtPath: string) { + constructor(dtPath: string, remote: string) { this.dtPath = dtPath; + this.remote = remote; } public readChanges(): Promise { let dir = path.join(this.dtPath, '.git'); + const remote = this.remote; return util.fileExists(dir).then((exists) => { if (!exists) { throw new Error('cannot locate git-dir: ' + dir); } return new Promise((resolve: (result: string[]) => void, reject: (error: any) => void) => { - let args = ['--name-only HEAD~1']; + let args = ['--name-only ' + remote]; let opts = {}; let git = new Git({ 'git-dir': dir