Using Git Switch as opposed to checkout

This commit is contained in:
James Ives 2019-11-09 08:37:58 -05:00
parent 8a6a3ab51b
commit 7ec4ff590a
2 changed files with 8 additions and 8 deletions

View File

@ -52,8 +52,8 @@ function generateBranch() {
return __awaiter(this, void 0, void 0, function* () { return __awaiter(this, void 0, void 0, function* () {
try { try {
console.log(`Creating ${constants_1.action.branch} branch...`); console.log(`Creating ${constants_1.action.branch} branch...`);
yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"} ---`, constants_1.workspace); yield util_1.execute(`git switch ${constants_1.action.baseBranch || "master"}`, constants_1.workspace);
yield util_1.execute(`git checkout --orphan ${constants_1.action.branch} ---`, constants_1.workspace); yield util_1.execute(`git switch --orphan ${constants_1.action.branch}`, constants_1.workspace);
yield util_1.execute(`git reset --hard`, constants_1.workspace); yield util_1.execute(`git reset --hard`, constants_1.workspace);
yield util_1.execute(`git commit --allow-empty -m "Initial ${constants_1.action.branch} commit."`, constants_1.workspace); yield util_1.execute(`git commit --allow-empty -m "Initial ${constants_1.action.branch} commit."`, constants_1.workspace);
yield util_1.execute(`git push ${constants_1.repositoryPath} ${constants_1.action.branch}`, constants_1.workspace); yield util_1.execute(`git push ${constants_1.repositoryPath} ${constants_1.action.branch}`, constants_1.workspace);
@ -84,7 +84,7 @@ function deploy() {
yield generateBranch(); yield generateBranch();
} }
// Checks out the base branch to begin the deployment process. // Checks out the base branch to begin the deployment process.
yield util_1.execute(`git checkout ${constants_1.action.baseBranch || "master"} ---`, constants_1.workspace); yield util_1.execute(`git switch ${constants_1.action.baseBranch || "master"}`, constants_1.workspace);
yield util_1.execute(`git fetch origin`, constants_1.workspace); yield util_1.execute(`git fetch origin`, constants_1.workspace);
yield util_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${constants_1.action.branch}`, constants_1.workspace); yield util_1.execute(`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${constants_1.action.branch}`, constants_1.workspace);
/* /*
@ -96,7 +96,7 @@ function deploy() {
}); });
// Commits to GitHub. // Commits to GitHub.
yield util_1.execute(`git add --all .`, temporaryDeploymentDirectory); yield util_1.execute(`git add --all .`, temporaryDeploymentDirectory);
yield util_1.execute(`git checkout -b ${temporaryDeploymentBranch} ---`, temporaryDeploymentDirectory); yield util_1.execute(`git switch -c ${temporaryDeploymentBranch}`, temporaryDeploymentDirectory);
yield util_1.execute(`git commit -m "Deploying to ${constants_1.action.branch} from ${constants_1.action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`, temporaryDeploymentDirectory); yield util_1.execute(`git commit -m "Deploying to ${constants_1.action.branch} from ${constants_1.action.baseBranch} ${process.env.GITHUB_SHA}" --quiet`, temporaryDeploymentDirectory);
yield util_1.execute(`git push ${constants_1.repositoryPath} ${temporaryDeploymentBranch}:${constants_1.action.branch}`, temporaryDeploymentDirectory); yield util_1.execute(`git push ${constants_1.repositoryPath} ${temporaryDeploymentBranch}:${constants_1.action.branch}`, temporaryDeploymentDirectory);
return Promise.resolve("Commit step complete..."); return Promise.resolve("Commit step complete...");

View File

@ -36,8 +36,8 @@ export async function init(): Promise<any> {
export async function generateBranch(): Promise<any> { export async function generateBranch(): Promise<any> {
try { try {
console.log(`Creating ${action.branch} branch...`); console.log(`Creating ${action.branch} branch...`);
await execute(`git checkout ${action.baseBranch || "master"} ---`, workspace); await execute(`git switch ${action.baseBranch || "master"}`, workspace);
await execute(`git checkout --orphan ${action.branch} ---`, workspace); await execute(`git switch --orphan ${action.branch}`, workspace);
await execute(`git reset --hard`, workspace); await execute(`git reset --hard`, workspace);
await execute( await execute(
`git commit --allow-empty -m "Initial ${action.branch} commit."`, `git commit --allow-empty -m "Initial ${action.branch} commit."`,
@ -74,7 +74,7 @@ export async function deploy(): Promise<any> {
} }
// Checks out the base branch to begin the deployment process. // Checks out the base branch to begin the deployment process.
await execute(`git checkout ${action.baseBranch || "master"} ---`, workspace); await execute(`git switch ${action.baseBranch || "master"}`, workspace);
await execute(`git fetch origin`, workspace); await execute(`git fetch origin`, workspace);
await execute( await execute(
`git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`, `git worktree add --checkout ${temporaryDeploymentDirectory} origin/${action.branch}`,
@ -92,7 +92,7 @@ export async function deploy(): Promise<any> {
// Commits to GitHub. // Commits to GitHub.
await execute(`git add --all .`, temporaryDeploymentDirectory); await execute(`git add --all .`, temporaryDeploymentDirectory);
await execute( await execute(
`git checkout -b ${temporaryDeploymentBranch} ---`, `git switch -c ${temporaryDeploymentBranch}`,
temporaryDeploymentDirectory temporaryDeploymentDirectory
); );
await execute( await execute(