Skip to content

Commit

Permalink
chore: Refactor git-helper to use getWorkspacePath()
Browse files Browse the repository at this point in the history
  • Loading branch information
Ackuq committed Jun 3, 2024
1 parent ffcc1cf commit fec4c64
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 20 deletions.
11 changes: 1 addition & 10 deletions actions/update-standpoints/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27976,7 +27976,7 @@ async function forcePush(branch) {
}

async function checkHasDiff() {
const command = ["diff", "--quiet"];
const command = ["diff", "--exit-code", "--stat"];
const output = await exec(command, false);
// Exit code 1 means there are differences
return output.exitCode === 1;
Expand All @@ -27990,21 +27990,12 @@ async function checkHasDiff() {
async function exec(command, throwOnError = true) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Running \`git ${command.join(" ")}\``);
const response = await (0,_actions_exec__WEBPACK_IMPORTED_MODULE_1__.getExecOutput)("git", command, {
cwd: getWorkspacePath(),
failOnStdErr: throwOnError,
});

return response;
}

function getWorkspacePath() {
const githubWorkspacePath = process.env["GITHUB_WORKSPACE"];
if (!githubWorkspacePath) {
throw new Error("GITHUB_WORKSPACE not defined");
}
return githubWorkspacePath;
}


/***/ }),

Expand Down
11 changes: 1 addition & 10 deletions actions/update-standpoints/src/git-helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function forcePush(branch) {
}

export async function checkHasDiff() {
const command = ["diff", "--quiet"];
const command = ["diff", "--exit-code", "--stat"];
const output = await exec(command, false);
// Exit code 1 means there are differences
return output.exitCode === 1;
Expand All @@ -83,17 +83,8 @@ export async function checkHasDiff() {
async function exec(command, throwOnError = true) {
core.info(`Running \`git ${command.join(" ")}\``);
const response = await getExecOutput("git", command, {
cwd: getWorkspacePath(),
failOnStdErr: throwOnError,
});

return response;
}

function getWorkspacePath() {
const githubWorkspacePath = process.env["GITHUB_WORKSPACE"];
if (!githubWorkspacePath) {
throw new Error("GITHUB_WORKSPACE not defined");
}
return githubWorkspacePath;
}

0 comments on commit fec4c64

Please sign in to comment.