@@ -660,12 +660,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
660
660
step((generator = generator.apply(thisArg, _arguments || [])).next());
661
661
});
662
662
};
663
+ var __importDefault = (this && this.__importDefault) || function (mod) {
664
+ return (mod && mod.__esModule) ? mod : { "default": mod };
665
+ };
663
666
Object.defineProperty(exports, "__esModule", ({ value: true }));
664
667
exports.GitCommandManager = void 0;
665
668
const exec = __importStar(__nccwpck_require__(5236));
666
669
const io = __importStar(__nccwpck_require__(4994));
667
670
const utils = __importStar(__nccwpck_require__(9277));
668
671
const path = __importStar(__nccwpck_require__(6928));
672
+ const stream_1 = __importDefault(__nccwpck_require__(2203));
669
673
const tagsRefSpec = '+refs/tags/*:refs/tags/*';
670
674
class GitCommandManager {
671
675
constructor(workingDirectory, gitPath) {
@@ -781,7 +785,7 @@ class GitCommandManager {
781
785
'--no-abbrev',
782
786
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
783
787
ref
784
- ]);
788
+ ], { suppressGitCmdOutput: true } );
785
789
const lines = output.stdout.split('\n');
786
790
const endOfBodyIndex = lines.lastIndexOf(endOfBody);
787
791
const detailLines = lines.slice(0, endOfBodyIndex);
@@ -895,7 +899,10 @@ class GitCommandManager {
895
899
showFileAtRefBase64(ref, path) {
896
900
return __awaiter(this, void 0, void 0, function* () {
897
901
const args = ['show', `${ref}:${path}`];
898
- const output = yield this.exec(args, { encoding: 'base64' });
902
+ const output = yield this.exec(args, {
903
+ encoding: 'base64',
904
+ suppressGitCmdOutput: true
905
+ });
899
906
return output.stdout.trim();
900
907
});
901
908
}
@@ -964,8 +971,12 @@ class GitCommandManager {
964
971
});
965
972
}
966
973
exec(args_1) {
967
- return __awaiter(this, arguments, void 0, function* (args, { encoding = 'utf8', allowAllExitCodes = false } = {}) {
974
+ return __awaiter(this, arguments, void 0, function* (args, { encoding = 'utf8', allowAllExitCodes = false, suppressGitCmdOutput = false } = {}) {
968
975
const result = new GitOutput();
976
+ if (process.env['CPR_SHOW_GIT_CMD_OUTPUT']) {
977
+ // debug mode overrides the suppressGitCmdOutput option
978
+ suppressGitCmdOutput = false;
979
+ }
969
980
const env = {};
970
981
for (const key of Object.keys(process.env)) {
971
982
env[key] = process.env[key];
@@ -987,7 +998,9 @@ class GitCommandManager {
987
998
stderr.push(data);
988
999
stderrLength += data.length;
989
1000
}
990
- }
1001
+ },
1002
+ outStream: outStreamHandler(process.stdout, suppressGitCmdOutput),
1003
+ errStream: outStreamHandler(process.stderr, suppressGitCmdOutput)
991
1004
};
992
1005
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
993
1006
result.stdout = Buffer.concat(stdout, stdoutLength).toString(encoding);
@@ -1004,6 +1017,24 @@ class GitOutput {
1004
1017
this.exitCode = 0;
1005
1018
}
1006
1019
}
1020
+ const outStreamHandler = (outStream, suppressGitCmdOutput) => {
1021
+ return new stream_1.default.Writable({
1022
+ write(chunk, _, next) {
1023
+ if (suppressGitCmdOutput) {
1024
+ const lines = chunk.toString().trimEnd().split('\n');
1025
+ for (const line of lines) {
1026
+ if (line.startsWith('[command]')) {
1027
+ outStream.write(`${line}\n`);
1028
+ }
1029
+ }
1030
+ }
1031
+ else {
1032
+ outStream.write(chunk);
1033
+ }
1034
+ next();
1035
+ }
1036
+ });
1037
+ };
1007
1038
1008
1039
1009
1040
/***/ }),
0 commit comments