Skip to content

Commit a81bbbf

Browse files
authored
Remove unneeded commit information from build logs (#345)
* Remove unneeded commit information from stdout
1 parent 21dc310 commit a81bbbf

File tree

3 files changed

+21
-9
lines changed

3 files changed

+21
-9
lines changed

dist/index.js

+9-4
Original file line numberDiff line numberDiff line change
@@ -5883,9 +5883,11 @@ class GitCommandManager {
58835883
yield this.execGit(['lfs', 'install', '--local']);
58845884
});
58855885
}
5886-
log1() {
5886+
log1(format) {
58875887
return __awaiter(this, void 0, void 0, function* () {
5888-
const output = yield this.execGit(['log', '-1']);
5888+
var args = format ? ['log', '-1', format] : ['log', '-1'];
5889+
var silent = format ? false : true;
5890+
const output = yield this.execGit(args, false, silent);
58895891
return output.stdout;
58905892
});
58915893
}
@@ -6007,7 +6009,7 @@ class GitCommandManager {
60076009
return result;
60086010
});
60096011
}
6010-
execGit(args, allowAllExitCodes = false) {
6012+
execGit(args, allowAllExitCodes = false, silent = false) {
60116013
return __awaiter(this, void 0, void 0, function* () {
60126014
fshelper.directoryExistsSync(this.workingDirectory, true);
60136015
const result = new GitOutput();
@@ -6022,6 +6024,7 @@ class GitCommandManager {
60226024
const options = {
60236025
cwd: this.workingDirectory,
60246026
env,
6027+
silent,
60256028
ignoreReturnCode: allowAllExitCodes,
60266029
listeners: {
60276030
stdout: (data) => {
@@ -6267,8 +6270,10 @@ function getSource(settings) {
62676270
yield authHelper.removeGlobalAuth();
62686271
}
62696272
}
6270-
// Dump some info about the checked out commit
6273+
// Get commit information
62716274
const commitInfo = yield git.log1();
6275+
// Log commit sha
6276+
yield git.log1("--format='%H'");
62726277
// Check for incorrect pull request merge commit
62736278
yield refHelper.checkCommitInfo(settings.authToken, commitInfo, settings.repositoryOwner, settings.repositoryName, settings.ref, settings.commit);
62746279
}

src/git-command-manager.ts

+8-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface IGitCommandManager {
3131
isDetached(): Promise<boolean>
3232
lfsFetch(ref: string): Promise<void>
3333
lfsInstall(): Promise<void>
34-
log1(): Promise<string>
34+
log1(format?: string): Promise<string>
3535
remoteAdd(remoteName: string, remoteUrl: string): Promise<void>
3636
removeEnvironmentVariable(name: string): void
3737
revParse(ref: string): Promise<string>
@@ -254,8 +254,10 @@ class GitCommandManager {
254254
await this.execGit(['lfs', 'install', '--local'])
255255
}
256256

257-
async log1(): Promise<string> {
258-
const output = await this.execGit(['log', '-1'])
257+
async log1(format?: string): Promise<string> {
258+
var args = format ? ['log', '-1', format] : ['log', '-1']
259+
var silent = format ? false : true
260+
const output = await this.execGit(args, false, silent)
259261
return output.stdout
260262
}
261263

@@ -390,7 +392,8 @@ class GitCommandManager {
390392

391393
private async execGit(
392394
args: string[],
393-
allowAllExitCodes = false
395+
allowAllExitCodes = false,
396+
silent = false
394397
): Promise<GitOutput> {
395398
fshelper.directoryExistsSync(this.workingDirectory, true)
396399

@@ -409,6 +412,7 @@ class GitCommandManager {
409412
const options = {
410413
cwd: this.workingDirectory,
411414
env,
415+
silent,
412416
ignoreReturnCode: allowAllExitCodes,
413417
listeners: {
414418
stdout: (data: Buffer) => {

src/git-source-provider.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,12 @@ export async function getSource(settings: IGitSourceSettings): Promise<void> {
201201
}
202202
}
203203

204-
// Dump some info about the checked out commit
204+
// Get commit information
205205
const commitInfo = await git.log1()
206206

207+
// Log commit sha
208+
await git.log1("--format='%H'")
209+
207210
// Check for incorrect pull request merge commit
208211
await refHelper.checkCommitInfo(
209212
settings.authToken,

0 commit comments

Comments
 (0)