From 0dfa1cb46b89829e68c089bd6de74add7392bf8f Mon Sep 17 00:00:00 2001 From: James Ives Date: Tue, 19 Nov 2019 18:07:27 -0500 Subject: [PATCH] Skips deployment if the working tree is clean (#55) * Adding procelain * Update git.ts --- lib/git.js | 5 +++++ src/git.ts | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/lib/git.js b/lib/git.js index f3d5f56b..162f333f 100644 --- a/lib/git.js +++ b/lib/git.js @@ -102,6 +102,11 @@ function deploy() { force: true }); } + const hasFilesToCommit = yield util_1.execute(`git status --porcelain`, temporaryDeploymentDirectory); + if (!hasFilesToCommit) { + console.log('There is nothing to commit. Exiting...'); + return Promise.resolve(); + } // Commits to GitHub. yield util_1.execute(`git add --all .`, temporaryDeploymentDirectory); yield util_1.execute(`git switch -c ${temporaryDeploymentBranch}`, temporaryDeploymentDirectory); diff --git a/src/git.ts b/src/git.ts index f7001575..66e1f79d 100644 --- a/src/git.ts +++ b/src/git.ts @@ -99,6 +99,16 @@ export async function deploy(): Promise { }); } + const hasFilesToCommit = await execute( + `git status --porcelain`, + temporaryDeploymentDirectory + ); + + if (!hasFilesToCommit) { + console.log("There is nothing to commit. Exiting..."); + return Promise.resolve(); + } + // Commits to GitHub. await execute(`git add --all .`, temporaryDeploymentDirectory); await execute(