Skip to content

Commit

Permalink
chore: Update git-helper to ignore return code when executing git com…
Browse files Browse the repository at this point in the history
…mands
  • Loading branch information
Ackuq committed Jun 3, 2024
1 parent 4f6bf09 commit 6b541c6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
13 changes: 5 additions & 8 deletions actions/update-standpoints/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27926,7 +27926,7 @@ async function setGitIdentity(name, email) {
*/
async function checkIfBranchExists(branch) {
const command = ["rev-parse", "--verify", branch];
const output = await exec(command, false);
const output = await exec(command, { ignoreReturnCode: true });
return output.exitCode === 0;
}

Expand Down Expand Up @@ -27977,22 +27977,19 @@ async function forcePush(branch) {

async function checkHasDiff() {
const command = ["diff", "--exit-code", "--stat"];
const output = await exec(command, false);
const output = await exec(command, { ignoreReturnCode: true });
// Exit code 1 means there are differences
return output.exitCode === 1;
}

/**
* Run a git command
* @param {string[]} command
* @param {boolean} throwOnError
* @param {import("@actions/exec").ExecOptions} options
*/
async function exec(command, throwOnError = true) {
async function exec(command, options = {}) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Running \`git ${command.join(" ")}\``);
const response = await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.getExecOutput)("git", command, {
failOnStdErr: throwOnError,
ignoreReturnCode: throwOnError,
});
const response = await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.getExecOutput)("git", command, options);

return response;
}
Expand Down
13 changes: 5 additions & 8 deletions actions/update-standpoints/src/git-helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export async function setGitIdentity(name, email) {
*/
export async function checkIfBranchExists(branch) {
const command = ["rev-parse", "--verify", branch];
const output = await exec(command, false);
const output = await exec(command, { ignoreReturnCode: true });
return output.exitCode === 0;
}

Expand Down Expand Up @@ -70,22 +70,19 @@ export async function forcePush(branch) {

export async function checkHasDiff() {
const command = ["diff", "--exit-code", "--stat"];
const output = await exec(command, false);
const output = await exec(command, { ignoreReturnCode: true });
// Exit code 1 means there are differences
return output.exitCode === 1;
}

/**
* Run a git command
* @param {string[]} command
* @param {boolean} throwOnError
* @param {import("@actions/exec").ExecOptions} options
*/
async function exec(command, throwOnError = true) {
async function exec(command, options = {}) {
core.info(`Running \`git ${command.join(" ")}\``);
const response = await getExecOutput("git", command, {
failOnStdErr: throwOnError,
ignoreReturnCode: throwOnError,
});
const response = await getExecOutput("git", command, options);

return response;
}

0 comments on commit 6b541c6

Please sign in to comment.