Skip to content

Commit

Permalink
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 6b541c6 commit 87ea4bb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 15 deletions.
12 changes: 4 additions & 8 deletions actions/update-standpoints/dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27874,13 +27874,11 @@ module.exports = parseParams
/* harmony export */ __nccwpck_require__.d(__webpack_exports__, {
/* harmony export */ "BP": () => (/* binding */ BRANCH_NAME),
/* harmony export */ "J1": () => (/* binding */ GIT_USERNAME),
/* harmony export */ "QH": () => (/* binding */ MAIN_BRANCH),
/* harmony export */ "gK": () => (/* binding */ TEMP_BRANCH_NAME),
/* harmony export */ "oT": () => (/* binding */ GIT_EMAIL)
/* harmony export */ });
// @ts-check

const MAIN_BRANCH = "main";
const BRANCH_NAME = "action-update-standpoints";
const TEMP_BRANCH_NAME = `temp-${BRANCH_NAME}`;

Expand Down Expand Up @@ -27931,12 +27929,10 @@ async function checkIfBranchExists(branch) {
}

/**
*
* @param {string} branch
* @param {string} base
*/
async function createBranch(branch, base) {
const command = ["checkout", "-b", branch, base];
async function createBranch(branch) {
const command = ["checkout", "-b", branch];
await exec(command);
}

Expand Down Expand Up @@ -28028,12 +28024,12 @@ const branchExists = await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .ch
if (branchExists) {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Branch ${_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .BRANCH_NAME */ .BP} already exists, rebasing...`);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info("Creating temp branch to store changes");
await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .createBranch */ .Qj)(_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TEMP_BRANCH_NAME */ .gK, _constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .MAIN_BRANCH */ .QH);
await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .createBranch */ .Qj)(_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TEMP_BRANCH_NAME */ .gK);
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info("Checking out temporary branch");
await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .checkout */ .JE)(_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .TEMP_BRANCH_NAME */ .gK);
} else {
_actions_core__WEBPACK_IMPORTED_MODULE_0__.info(`Branch ${_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .BRANCH_NAME */ .BP} does not exist, creating...`);
await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .createBranch */ .Qj)(_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .BRANCH_NAME */ .BP, _constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .MAIN_BRANCH */ .QH);
await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .createBranch */ .Qj)(_constants_mjs__WEBPACK_IMPORTED_MODULE_1__/* .BRANCH_NAME */ .BP);
}
await (0,_git_helper_mjs__WEBPACK_IMPORTED_MODULE_2__/* .commit */ .th)("Update standpoints");
_actions_core__WEBPACK_IMPORTED_MODULE_0__.endGroup();
Expand Down
1 change: 0 additions & 1 deletion actions/update-standpoints/src/constants.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// @ts-check

export const MAIN_BRANCH = "main";
export const BRANCH_NAME = "action-update-standpoints";
export const TEMP_BRANCH_NAME = `temp-${BRANCH_NAME}`;

Expand Down
6 changes: 2 additions & 4 deletions actions/update-standpoints/src/git-helper.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,10 @@ export async function checkIfBranchExists(branch) {
}

/**
*
* @param {string} branch
* @param {string} base
*/
export async function createBranch(branch, base) {
const command = ["checkout", "-b", branch, base];
export async function createBranch(branch) {
const command = ["checkout", "-b", branch];
await exec(command);
}

Expand Down
4 changes: 2 additions & 2 deletions actions/update-standpoints/src/main.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ const branchExists = await checkIfBranchExists(BRANCH_NAME);
if (branchExists) {
core.info(`Branch ${BRANCH_NAME} already exists, rebasing...`);
core.info("Creating temp branch to store changes");
await createBranch(TEMP_BRANCH_NAME, MAIN_BRANCH);
await createBranch(TEMP_BRANCH_NAME);
core.info("Checking out temporary branch");
await checkout(TEMP_BRANCH_NAME);
} else {
core.info(`Branch ${BRANCH_NAME} does not exist, creating...`);
await createBranch(BRANCH_NAME, MAIN_BRANCH);
await createBranch(BRANCH_NAME);
}
await commit("Update standpoints");
core.endGroup();
Expand Down

0 comments on commit 87ea4bb

Please sign in to comment.