Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
271a8d0340 | ||
|
|
6f7efd1c24 | ||
|
|
13c47c5747 | ||
|
|
63e58290d7 | ||
|
|
a92c90fcab | ||
|
|
b23b62d487 |
4
.github/workflows/cpr-example-command.yml
vendored
4
.github/workflows/cpr-example-command.yml
vendored
@@ -29,8 +29,8 @@ jobs:
|
|||||||
labels: |
|
labels: |
|
||||||
report
|
report
|
||||||
automated pr
|
automated pr
|
||||||
assignees: peter-evans
|
assignees: retepsnave
|
||||||
reviewers: peter-evans
|
reviewers: retepsnave
|
||||||
milestone: 1
|
milestone: 1
|
||||||
draft: false
|
draft: false
|
||||||
branch: example-patches
|
branch: example-patches
|
||||||
|
|||||||
39
dist/index.js
vendored
39
dist/index.js
vendored
@@ -660,12 +660,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||||
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||||
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.GitCommandManager = void 0;
|
exports.GitCommandManager = void 0;
|
||||||
const exec = __importStar(__nccwpck_require__(5236));
|
const exec = __importStar(__nccwpck_require__(5236));
|
||||||
const io = __importStar(__nccwpck_require__(4994));
|
const io = __importStar(__nccwpck_require__(4994));
|
||||||
const utils = __importStar(__nccwpck_require__(9277));
|
const utils = __importStar(__nccwpck_require__(9277));
|
||||||
const path = __importStar(__nccwpck_require__(6928));
|
const path = __importStar(__nccwpck_require__(6928));
|
||||||
|
const stream_1 = __importDefault(__nccwpck_require__(2203));
|
||||||
const tagsRefSpec = '+refs/tags/*:refs/tags/*';
|
const tagsRefSpec = '+refs/tags/*:refs/tags/*';
|
||||||
class GitCommandManager {
|
class GitCommandManager {
|
||||||
constructor(workingDirectory, gitPath) {
|
constructor(workingDirectory, gitPath) {
|
||||||
@@ -781,7 +785,7 @@ class GitCommandManager {
|
|||||||
'--no-abbrev',
|
'--no-abbrev',
|
||||||
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
||||||
ref
|
ref
|
||||||
]);
|
], { suppressGitCmdOutput: true });
|
||||||
const lines = output.stdout.split('\n');
|
const lines = output.stdout.split('\n');
|
||||||
const endOfBodyIndex = lines.lastIndexOf(endOfBody);
|
const endOfBodyIndex = lines.lastIndexOf(endOfBody);
|
||||||
const detailLines = lines.slice(0, endOfBodyIndex);
|
const detailLines = lines.slice(0, endOfBodyIndex);
|
||||||
@@ -895,7 +899,10 @@ class GitCommandManager {
|
|||||||
showFileAtRefBase64(ref, path) {
|
showFileAtRefBase64(ref, path) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const args = ['show', `${ref}:${path}`];
|
const args = ['show', `${ref}:${path}`];
|
||||||
const output = yield this.exec(args, { encoding: 'base64' });
|
const output = yield this.exec(args, {
|
||||||
|
encoding: 'base64',
|
||||||
|
suppressGitCmdOutput: true
|
||||||
|
});
|
||||||
return output.stdout.trim();
|
return output.stdout.trim();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -964,8 +971,12 @@ class GitCommandManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
exec(args_1) {
|
exec(args_1) {
|
||||||
return __awaiter(this, arguments, void 0, function* (args, { encoding = 'utf8', allowAllExitCodes = false } = {}) {
|
return __awaiter(this, arguments, void 0, function* (args, { encoding = 'utf8', allowAllExitCodes = false, suppressGitCmdOutput = false } = {}) {
|
||||||
const result = new GitOutput();
|
const result = new GitOutput();
|
||||||
|
if (process.env['CPR_SHOW_GIT_CMD_OUTPUT']) {
|
||||||
|
// debug mode overrides the suppressGitCmdOutput option
|
||||||
|
suppressGitCmdOutput = false;
|
||||||
|
}
|
||||||
const env = {};
|
const env = {};
|
||||||
for (const key of Object.keys(process.env)) {
|
for (const key of Object.keys(process.env)) {
|
||||||
env[key] = process.env[key];
|
env[key] = process.env[key];
|
||||||
@@ -987,7 +998,9 @@ class GitCommandManager {
|
|||||||
stderr.push(data);
|
stderr.push(data);
|
||||||
stderrLength += data.length;
|
stderrLength += data.length;
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
outStream: outStreamHandler(process.stdout, suppressGitCmdOutput),
|
||||||
|
errStream: outStreamHandler(process.stderr, suppressGitCmdOutput)
|
||||||
};
|
};
|
||||||
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
|
result.exitCode = yield exec.exec(`"${this.gitPath}"`, args, options);
|
||||||
result.stdout = Buffer.concat(stdout, stdoutLength).toString(encoding);
|
result.stdout = Buffer.concat(stdout, stdoutLength).toString(encoding);
|
||||||
@@ -1004,6 +1017,24 @@ class GitOutput {
|
|||||||
this.exitCode = 0;
|
this.exitCode = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const outStreamHandler = (outStream, suppressGitCmdOutput) => {
|
||||||
|
return new stream_1.default.Writable({
|
||||||
|
write(chunk, _, next) {
|
||||||
|
if (suppressGitCmdOutput) {
|
||||||
|
const lines = chunk.toString().trimEnd().split('\n');
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith('[command]')) {
|
||||||
|
outStream.write(`${line}\n`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
outStream.write(chunk);
|
||||||
|
}
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|||||||
50
package-lock.json
generated
50
package-lock.json
generated
@@ -12,7 +12,7 @@
|
|||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@octokit/core": "^6.1.4",
|
"@octokit/core": "^6.1.4",
|
||||||
"@octokit/plugin-paginate-rest": "^11.4.2",
|
"@octokit/plugin-paginate-rest": "^11.4.3",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
||||||
"@octokit/plugin-throttling": "^9.4.0",
|
"@octokit/plugin-throttling": "^9.4.0",
|
||||||
"node-fetch-native": "^1.6.6",
|
"node-fetch-native": "^1.6.6",
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
"@typescript-eslint/parser": "^7.18.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"@vercel/ncc": "^0.38.3",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-import-resolver-typescript": "^3.8.1",
|
"eslint-import-resolver-typescript": "^3.8.3",
|
||||||
"eslint-plugin-github": "^4.10.2",
|
"eslint-plugin-github": "^4.10.2",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jest": "^27.9.0",
|
"eslint-plugin-jest": "^27.9.0",
|
||||||
@@ -35,8 +35,8 @@
|
|||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "^3.5.1",
|
"prettier": "^3.5.2",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.6",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"undici": "^6.21.1"
|
"undici": "^6.21.1"
|
||||||
}
|
}
|
||||||
@@ -1321,9 +1321,9 @@
|
|||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@octokit/plugin-paginate-rest": {
|
"node_modules/@octokit/plugin-paginate-rest": {
|
||||||
"version": "11.4.2",
|
"version": "11.4.3",
|
||||||
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.4.2.tgz",
|
"resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.4.3.tgz",
|
||||||
"integrity": "sha512-BXJ7XPCTDXFF+wxcg/zscfgw2O/iDPtNSkwwR1W1W5c4Mb3zav/M2XvxQ23nVmKj7jpweB4g8viMeCQdm7LMVA==",
|
"integrity": "sha512-tBXaAbXkqVJlRoA/zQVe9mUdb8rScmivqtpv3ovsC5xhje/a+NOCivs7eUhWBwCApJVsR4G5HMeaLbq7PxqZGA==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@octokit/types": "^13.7.0"
|
"@octokit/types": "^13.7.0"
|
||||||
@@ -3591,9 +3591,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint-import-resolver-typescript": {
|
"node_modules/eslint-import-resolver-typescript": {
|
||||||
"version": "3.8.1",
|
"version": "3.8.3",
|
||||||
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/eslint-import-resolver-typescript/-/eslint-import-resolver-typescript-3.8.3.tgz",
|
||||||
"integrity": "sha512-qw5TPA12HTmb9CkcuiNrFtwhM1ae2FWysLeRrTbQ+/JKS///gbL3fQ5LRhAZnzkcqkScOvkB5Y5o+xgyQz1VVg==",
|
"integrity": "sha512-A0bu4Ks2QqDWNpeEgTQMPTngaMhuDu4yv6xpftBMAf+1ziXnpx+eSR1WRfoPTe2BAiAjHFZ7kSNx1fvr5g5pmQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -3603,7 +3603,7 @@
|
|||||||
"get-tsconfig": "^4.10.0",
|
"get-tsconfig": "^4.10.0",
|
||||||
"is-bun-module": "^1.0.2",
|
"is-bun-module": "^1.0.2",
|
||||||
"stable-hash": "^0.0.4",
|
"stable-hash": "^0.0.4",
|
||||||
"tinyglobby": "^0.2.10"
|
"tinyglobby": "^0.2.12"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "^14.18.0 || >=16.0.0"
|
"node": "^14.18.0 || >=16.0.0"
|
||||||
@@ -6759,9 +6759,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/prettier": {
|
"node_modules/prettier": {
|
||||||
"version": "3.5.1",
|
"version": "3.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.1.tgz",
|
"resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.2.tgz",
|
||||||
"integrity": "sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==",
|
"integrity": "sha512-lc6npv5PH7hVqozBR7lkBNOGXV9vMwROAPlumdBkX0wTbbzPu/U1hk5yL8p2pt4Xoc+2mkT8t/sow2YrV/M5qg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"bin": {
|
"bin": {
|
||||||
@@ -7111,10 +7111,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/semver": {
|
"node_modules/semver": {
|
||||||
"version": "7.6.3",
|
"version": "7.7.1",
|
||||||
"resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz",
|
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz",
|
||||||
"integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==",
|
"integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "ISC",
|
||||||
"bin": {
|
"bin": {
|
||||||
"semver": "bin/semver.js"
|
"semver": "bin/semver.js"
|
||||||
},
|
},
|
||||||
@@ -7498,9 +7499,9 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/tinyglobby": {
|
"node_modules/tinyglobby": {
|
||||||
"version": "0.2.11",
|
"version": "0.2.12",
|
||||||
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.11.tgz",
|
"resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.12.tgz",
|
||||||
"integrity": "sha512-32TmKeeKUahv0Go8WmQgiEp9Y21NuxjwjqiRC1nrUB51YacfSwuB44xgXD+HdIppmMRgjQNPdrHyA6vIybYZ+g==",
|
"integrity": "sha512-qkf4trmKSIiMTs/E63cxH+ojC2unam7rJ0WrauAzpT3ECNTxGRMlaXxVbfxMUC/w0LaYk6jQ4y/nGR9uBO3tww==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -7609,10 +7610,11 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/ts-jest": {
|
"node_modules/ts-jest": {
|
||||||
"version": "29.2.5",
|
"version": "29.2.6",
|
||||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.5.tgz",
|
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.2.6.tgz",
|
||||||
"integrity": "sha512-KD8zB2aAZrcKIdGk4OwpJggeLcH1FgrICqDSROWqlnJXGCXK4Mn6FcdK2B6670Xr73lHMG1kHw8R87A0ecZ+vA==",
|
"integrity": "sha512-yTNZVZqc8lSixm+QGVFcPe6+yj7+TWZwIesuOWvfcn4B9bz5x4NDzVCQQjOs7Hfouu36aEqfEbo9Qpo+gq8dDg==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"bs-logger": "^0.2.6",
|
"bs-logger": "^0.2.6",
|
||||||
"ejs": "^3.1.10",
|
"ejs": "^3.1.10",
|
||||||
@@ -7621,7 +7623,7 @@
|
|||||||
"json5": "^2.2.3",
|
"json5": "^2.2.3",
|
||||||
"lodash.memoize": "^4.1.2",
|
"lodash.memoize": "^4.1.2",
|
||||||
"make-error": "^1.3.6",
|
"make-error": "^1.3.6",
|
||||||
"semver": "^7.6.3",
|
"semver": "^7.7.1",
|
||||||
"yargs-parser": "^21.1.1"
|
"yargs-parser": "^21.1.1"
|
||||||
},
|
},
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@octokit/core": "^6.1.4",
|
"@octokit/core": "^6.1.4",
|
||||||
"@octokit/plugin-paginate-rest": "^11.4.2",
|
"@octokit/plugin-paginate-rest": "^11.4.3",
|
||||||
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
"@octokit/plugin-rest-endpoint-methods": "^13.3.1",
|
||||||
"@octokit/plugin-throttling": "^9.4.0",
|
"@octokit/plugin-throttling": "^9.4.0",
|
||||||
"node-fetch-native": "^1.6.6",
|
"node-fetch-native": "^1.6.6",
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
"@typescript-eslint/parser": "^7.18.0",
|
"@typescript-eslint/parser": "^7.18.0",
|
||||||
"@vercel/ncc": "^0.38.3",
|
"@vercel/ncc": "^0.38.3",
|
||||||
"eslint": "^8.57.1",
|
"eslint": "^8.57.1",
|
||||||
"eslint-import-resolver-typescript": "^3.8.1",
|
"eslint-import-resolver-typescript": "^3.8.3",
|
||||||
"eslint-plugin-github": "^4.10.2",
|
"eslint-plugin-github": "^4.10.2",
|
||||||
"eslint-plugin-import": "^2.31.0",
|
"eslint-plugin-import": "^2.31.0",
|
||||||
"eslint-plugin-jest": "^27.9.0",
|
"eslint-plugin-jest": "^27.9.0",
|
||||||
@@ -55,8 +55,8 @@
|
|||||||
"jest-circus": "^29.7.0",
|
"jest-circus": "^29.7.0",
|
||||||
"jest-environment-jsdom": "^29.7.0",
|
"jest-environment-jsdom": "^29.7.0",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "^3.5.1",
|
"prettier": "^3.5.2",
|
||||||
"ts-jest": "^29.2.5",
|
"ts-jest": "^29.2.6",
|
||||||
"typescript": "^5.7.3",
|
"typescript": "^5.7.3",
|
||||||
"undici": "^6.21.1"
|
"undici": "^6.21.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import * as exec from '@actions/exec'
|
|||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
import * as utils from './utils'
|
import * as utils from './utils'
|
||||||
import * as path from 'path'
|
import * as path from 'path'
|
||||||
|
import stream, {Writable} from 'stream'
|
||||||
|
|
||||||
const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
const tagsRefSpec = '+refs/tags/*:refs/tags/*'
|
||||||
|
|
||||||
@@ -24,6 +25,7 @@ export type Commit = {
|
|||||||
export type ExecOpts = {
|
export type ExecOpts = {
|
||||||
allowAllExitCodes?: boolean
|
allowAllExitCodes?: boolean
|
||||||
encoding?: 'utf8' | 'base64'
|
encoding?: 'utf8' | 'base64'
|
||||||
|
suppressGitCmdOutput?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GitCommandManager {
|
export class GitCommandManager {
|
||||||
@@ -161,17 +163,20 @@ export class GitCommandManager {
|
|||||||
|
|
||||||
async getCommit(ref: string): Promise<Commit> {
|
async getCommit(ref: string): Promise<Commit> {
|
||||||
const endOfBody = '###EOB###'
|
const endOfBody = '###EOB###'
|
||||||
const output = await this.exec([
|
const output = await this.exec(
|
||||||
'-c',
|
[
|
||||||
'core.quotePath=false',
|
'-c',
|
||||||
'show',
|
'core.quotePath=false',
|
||||||
'--raw',
|
'show',
|
||||||
'--cc',
|
'--raw',
|
||||||
'--no-renames',
|
'--cc',
|
||||||
'--no-abbrev',
|
'--no-renames',
|
||||||
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
'--no-abbrev',
|
||||||
ref
|
`--format=%H%n%T%n%P%n%G?%n%s%n%b%n${endOfBody}`,
|
||||||
])
|
ref
|
||||||
|
],
|
||||||
|
{suppressGitCmdOutput: true}
|
||||||
|
)
|
||||||
const lines = output.stdout.split('\n')
|
const lines = output.stdout.split('\n')
|
||||||
const endOfBodyIndex = lines.lastIndexOf(endOfBody)
|
const endOfBodyIndex = lines.lastIndexOf(endOfBody)
|
||||||
const detailLines = lines.slice(0, endOfBodyIndex)
|
const detailLines = lines.slice(0, endOfBodyIndex)
|
||||||
@@ -285,7 +290,10 @@ export class GitCommandManager {
|
|||||||
|
|
||||||
async showFileAtRefBase64(ref: string, path: string): Promise<string> {
|
async showFileAtRefBase64(ref: string, path: string): Promise<string> {
|
||||||
const args = ['show', `${ref}:${path}`]
|
const args = ['show', `${ref}:${path}`]
|
||||||
const output = await this.exec(args, {encoding: 'base64'})
|
const output = await this.exec(args, {
|
||||||
|
encoding: 'base64',
|
||||||
|
suppressGitCmdOutput: true
|
||||||
|
})
|
||||||
return output.stdout.trim()
|
return output.stdout.trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,10 +370,19 @@ export class GitCommandManager {
|
|||||||
|
|
||||||
async exec(
|
async exec(
|
||||||
args: string[],
|
args: string[],
|
||||||
{encoding = 'utf8', allowAllExitCodes = false}: ExecOpts = {}
|
{
|
||||||
|
encoding = 'utf8',
|
||||||
|
allowAllExitCodes = false,
|
||||||
|
suppressGitCmdOutput = false
|
||||||
|
}: ExecOpts = {}
|
||||||
): Promise<GitOutput> {
|
): Promise<GitOutput> {
|
||||||
const result = new GitOutput()
|
const result = new GitOutput()
|
||||||
|
|
||||||
|
if (process.env['CPR_SHOW_GIT_CMD_OUTPUT']) {
|
||||||
|
// debug mode overrides the suppressGitCmdOutput option
|
||||||
|
suppressGitCmdOutput = false
|
||||||
|
}
|
||||||
|
|
||||||
const env = {}
|
const env = {}
|
||||||
for (const key of Object.keys(process.env)) {
|
for (const key of Object.keys(process.env)) {
|
||||||
env[key] = process.env[key]
|
env[key] = process.env[key]
|
||||||
@@ -389,7 +406,9 @@ export class GitCommandManager {
|
|||||||
stderr.push(data)
|
stderr.push(data)
|
||||||
stderrLength += data.length
|
stderrLength += data.length
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
outStream: outStreamHandler(process.stdout, suppressGitCmdOutput),
|
||||||
|
errStream: outStreamHandler(process.stderr, suppressGitCmdOutput)
|
||||||
}
|
}
|
||||||
|
|
||||||
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
result.exitCode = await exec.exec(`"${this.gitPath}"`, args, options)
|
||||||
@@ -404,3 +423,24 @@ class GitOutput {
|
|||||||
stderr = ''
|
stderr = ''
|
||||||
exitCode = 0
|
exitCode = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const outStreamHandler = (
|
||||||
|
outStream: Writable,
|
||||||
|
suppressGitCmdOutput: boolean
|
||||||
|
): Writable => {
|
||||||
|
return new stream.Writable({
|
||||||
|
write(chunk, _, next) {
|
||||||
|
if (suppressGitCmdOutput) {
|
||||||
|
const lines = chunk.toString().trimEnd().split('\n')
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith('[command]')) {
|
||||||
|
outStream.write(`${line}\n`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
outStream.write(chunk)
|
||||||
|
}
|
||||||
|
next()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user