From 6943eced8faa00b363a577a3e573551e2255efac Mon Sep 17 00:00:00 2001 From: Thomas Boop <52323235+thboop@users.noreply.github.com> Date: Wed, 23 Sep 2020 09:41:47 -0400 Subject: Remove unneeded commit information from build logs (#345) * Remove unneeded commit information from stdout --- src/git-command-manager.ts | 12 ++++++++---- src/git-source-provider.ts | 5 ++++- 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/git-command-manager.ts b/src/git-command-manager.ts index 059e3d8..409a161 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,10 @@ class GitCommandManager { await this.execGit(['lfs', 'install', '--local']) } - async log1(): Promise { - const output = await this.execGit(['log', '-1']) + async log1(format?: string): Promise { + var args = format ? ['log', '-1', format] : ['log', '-1'] + var silent = format ? false : true + const output = await this.execGit(args, false, silent) return output.stdout } @@ -390,7 +392,8 @@ class GitCommandManager { private async execGit( args: string[], - allowAllExitCodes = false + allowAllExitCodes = false, + silent = false ): Promise { fshelper.directoryExistsSync(this.workingDirectory, true) @@ -409,6 +412,7 @@ class GitCommandManager { const options = { cwd: this.workingDirectory, env, + silent, ignoreReturnCode: allowAllExitCodes, listeners: { stdout: (data: Buffer) => { diff --git a/src/git-source-provider.ts b/src/git-source-provider.ts index 366ff33..42a12e0 100644 --- a/src/git-source-provider.ts +++ b/src/git-source-provider.ts @@ -201,9 +201,12 @@ export async function getSource(settings: IGitSourceSettings): Promise { } } - // Dump some info about the checked out commit + // 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( settings.authToken, -- cgit v1.2.3