From 0e8d9f459e3b16f80fc6eb4646ae33215535b71f Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Thu, 10 Sep 2020 17:22:02 -0400 Subject: [PATCH 1/4] Remove unneeded commit information from stdout --- dist/index.js | 5 +++-- src/git-command-manager.ts | 6 ++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index ae64f3fe9..7f8c7d7ac 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5885,7 +5885,7 @@ class GitCommandManager { } log1() { return __awaiter(this, void 0, void 0, function* () { - const output = yield this.execGit(['log', '-1']); + const output = yield this.execGit(['log', '-1'], false, true); return output.stdout; }); } @@ -6007,7 +6007,7 @@ class GitCommandManager { return result; }); } - execGit(args, allowAllExitCodes = false) { + execGit(args, allowAllExitCodes = false, silent = false) { return __awaiter(this, void 0, void 0, function* () { fshelper.directoryExistsSync(this.workingDirectory, true); const result = new GitOutput(); @@ -6022,6 +6022,7 @@ class GitCommandManager { const options = { cwd: this.workingDirectory, env, + silent, ignoreReturnCode: allowAllExitCodes, listeners: { stdout: (data) => { diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index 059e3d8ac..bbfd870d6 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -255,7 +255,7 @@ class GitCommandManager { } async log1(): Promise { - const output = await this.execGit(['log', '-1']) + const output = await this.execGit(['log', '-1'], false, true) return output.stdout } @@ -390,7 +390,8 @@ class GitCommandManager { private async execGit( args: string[], - allowAllExitCodes = false + allowAllExitCodes = false, + silent = false ): Promise { fshelper.directoryExistsSync(this.workingDirectory, true) @@ -409,6 +410,7 @@ class GitCommandManager { const options = { cwd: this.workingDirectory, env, + silent, ignoreReturnCode: allowAllExitCodes, listeners: { stdout: (data: Buffer) => { From 8940ec951940c609795b2ab14afbf35761e52887 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Tue, 22 Sep 2020 10:19:07 -0400 Subject: [PATCH 2/4] log commit sha as well --- dist/index.js | 9 ++++++--- src/git-command-manager.ts | 7 ++++--- src/git-source-provider.ts | 7 +++++-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7f8c7d7ac..ba1f70ee1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5883,9 +5883,10 @@ class GitCommandManager { yield this.execGit(['lfs', 'install', '--local']); }); } - log1() { + log1(format) { return __awaiter(this, void 0, void 0, function* () { - const output = yield this.execGit(['log', '-1'], false, true); + var args = format ? ['log', '-1', format] : ['log', '-1']; + const output = yield this.execGit(args, false, true); return output.stdout; }); } @@ -6268,8 +6269,10 @@ function getSource(settings) { yield authHelper.removeGlobalAuth(); } } - // Dump some info about the checked out commit + // Get commit information const commitInfo = yield git.log1(); + // Log commit sha + yield git.log1("--format='%H'"); // Check for incorrect pull request merge commit yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit); } diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index bbfd870d6..cc2efdeea 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -31,7 +31,7 @@ export interface IGitCommandManager { isDetached(): Promise lfsFetch(ref: string): Promise lfsInstall(): Promise - log1(): Promise + log1(format?: string): Promise remoteAdd(remoteName: string, remoteUrl: string): Promise removeEnvironmentVariable(name: string): void revParse(ref: string): Promise @@ -254,8 +254,9 @@ class GitCommandManager { await this.execGit(['lfs', 'install', '--local']) } - async log1(): Promise { - const output = await this.execGit(['log', '-1'], false, true) + async log1(format?: string): Promise { + var args = format ? ['log', '-1', format] : ['log', '-1'] + const output = await this.execGit(args, false, true) return output.stdout } diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 366ff3378..000a3acbd 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -201,8 +201,11 @@ export async function getSource(settings: IGitSourceSettings): Promise { } } - // Dump some info about the checked out commit - const commitInfo = await git.log1() + // Get commit information + const commitInfo = await git.log1(); + + // Log commit sha + await git.log1("--format='%H'"); // Check for incorrect pull request merge commit await refHelper.checkCommitInfo( From d52996e7c242d22c242ccdddf51d93416359be42 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Tue, 22 Sep 2020 11:14:09 -0400 Subject: [PATCH 3/4] don't use silent when echoing commit sha --- dist/index.js | 3 ++- src/git-command-manager.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index ba1f70ee1..9683c1140 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5886,7 +5886,8 @@ class GitCommandManager { log1(format) { return __awaiter(this, void 0, void 0, function* () { var args = format ? ['log', '-1', format] : ['log', '-1']; - const output = yield this.execGit(args, false, true); + var silent = format ? false : true; + const output = yield this.execGit(args, false, silent); return output.stdout; }); } diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index cc2efdeea..409a16191 100644 --- a/src/git-command-manager.ts +++ b/src/git-command-manager.ts @@ -256,7 +256,8 @@ class GitCommandManager { async log1(format?: string): Promise { var args = format ? ['log', '-1', format] : ['log', '-1'] - const output = await this.execGit(args, false, true) + var silent = format ? false : true + const output = await this.execGit(args, false, silent) return output.stdout } From c5dac4d4500cb973b1e7f68b9164ec53860dd2e5 Mon Sep 17 00:00:00 2001 From: Thomas Boop Date: Tue, 22 Sep 2020 15:14:00 -0400 Subject: [PATCH 4/4] run format --- src/git-source-provider.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 000a3acbd..42a12e04e 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -202,10 +202,10 @@ export async function getSource(settings: IGitSourceSettings): Promise { } // Get commit information - const commitInfo = await git.log1(); + const commitInfo = await git.log1() // Log commit sha - await git.log1("--format='%H'"); + await git.log1("--format='%H'") // Check for incorrect pull request merge commit await refHelper.checkCommitInfo(