Skip to content

Commit

Permalink
Deploy Production Code for Commit e9abb9c 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesIves committed May 18, 2024
1 parent e9abb9c commit 5c6e9e9
Show file tree
Hide file tree
Showing 362 changed files with 3,307 additions and 11,697 deletions.
28 changes: 25 additions & 3 deletions lib/worktree.d.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,34 @@
import { ActionInterface } from './constants';
/**
* Git checkout command.
*/
export declare class GitCheckout {
/**
* @param orphan - Bool indicating if the branch is an orphan.
*/
orphan: boolean;
/**
* @param commitish - The commitish to check out.
*/
commitish?: string | null;
/**
* @param branch - The branch name.
*/
branch: string;
constructor(branch: string);
/**
* @param branch - The branch name.
* @param commitish - The commitish to check out.
*/
constructor(branch: string, commitish?: string);
/**
* Returns the string representation of the git checkout command.
*/
toString(): string;
}
/**
* Generate the worktree and set initial content if it exists
* Generates a git worktree.
* @param action - The action interface.
* @param worktreedir - The worktree directory.
* @param branchExists - Bool indicating if the branch exists.
*/
export declare function generateWorktree(action: ActionInterface, worktreedir: string, branchExists: unknown): Promise<void>;
export declare function generateWorktree(action: ActionInterface, worktreedir: string, branchExists: boolean | number): Promise<void>;
41 changes: 35 additions & 6 deletions lib/worktree.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,29 @@ exports.generateWorktree = exports.GitCheckout = void 0;
const core_1 = require("@actions/core");
const execute_1 = require("./execute");
const util_1 = require("./util");
/**
* Git checkout command.
*/
class GitCheckout {
constructor(branch) {
/**
* @param branch - The branch name.
* @param commitish - The commitish to check out.
*/
constructor(branch, commitish) {
/**
* @param orphan - Bool indicating if the branch is an orphan.
*/
this.orphan = false;
/**
* @param commitish - The commitish to check out.
*/
this.commitish = null;
this.branch = branch;
this.commitish = commitish || null;
}
/**
* Returns the string representation of the git checkout command.
*/
toString() {
return [
'git',
Expand All @@ -31,7 +48,10 @@ class GitCheckout {
}
exports.GitCheckout = GitCheckout;
/**
* Generate the worktree and set initial content if it exists
* Generates a git worktree.
* @param action - The action interface.
* @param worktreedir - The worktree directory.
* @param branchExists - Bool indicating if the branch exists.
*/
function generateWorktree(action, worktreedir, branchExists) {
return __awaiter(this, void 0, void 0, function* () {
Expand All @@ -41,7 +61,8 @@ function generateWorktree(action, worktreedir, branchExists) {
yield (0, execute_1.execute)(`git fetch --no-recurse-submodules --depth=1 origin ${action.branch}`, action.workspace, action.silent);
}
yield (0, execute_1.execute)(`git worktree add --no-checkout --detach ${worktreedir}`, action.workspace, action.silent);
const checkout = new GitCheckout(action.branch);
let branchName = action.branch;
let checkout = new GitCheckout(branchName);
if (branchExists) {
// There's existing data on the branch to check out
checkout.commitish = `origin/${action.branch}`;
Expand All @@ -52,14 +73,22 @@ function generateWorktree(action, worktreedir, branchExists) {
If the ref name is the same as the branch name, do not attempt to create an orphan of it. */
checkout.orphan = true;
}
yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent);
try {
yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent);
}
catch (error) {
(0, core_1.info)('Error encountered while checking out branch. Attempting to continue with a new branch name.');
branchName = `temp-${Date.now()}`;
checkout = new GitCheckout(branchName, `origin/${action.branch}`);
yield (0, execute_1.execute)(checkout.toString(), `${action.workspace}/${worktreedir}`, action.silent);
}
if (!branchExists) {
(0, core_1.info)(`Created the ${action.branch} branch… 🔧`);
(0, core_1.info)(`Created the ${branchName} branch… 🔧`);
// Our index is in HEAD state, reset
yield (0, execute_1.execute)('git reset --hard', `${action.workspace}/${worktreedir}`, action.silent);
if (!action.singleCommit) {
// New history isn't singleCommit, create empty initial commit
yield (0, execute_1.execute)(`git commit --no-verify --allow-empty -m "Initial ${action.branch} commit"`, `${action.workspace}/${worktreedir}`, action.silent);
yield (0, execute_1.execute)(`git commit --no-verify --allow-empty -m "Initial ${branchName} commit"`, `${action.workspace}/${worktreedir}`, action.silent);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@eslint/eslintrc/dist/eslintrc.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node_modules/@eslint/eslintrc/dist/eslintrc.cjs.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion node_modules/@eslint/eslintrc/lib/config-array-factory.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion node_modules/@eslint/eslintrc/lib/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions node_modules/@eslint/eslintrc/node_modules/debug/LICENSE

This file was deleted.

Loading

0 comments on commit 5c6e9e9

Please sign in to comment.