Skip to content

Commit

Permalink
fix: Do not attempt pull or push on diverged state
Browse files Browse the repository at this point in the history
As there's no guarantee that merge can be done automatically
  • Loading branch information
medikoo committed Jul 1, 2019
1 parent 4d71be5 commit 481ba58
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions lib/setup-repository.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,21 +41,15 @@ module.exports = async (path, repoUrl, options = {}) => {
const { stdoutBuffer } = await runProgram("git", ["status"], { cwd: path });
const localStatus = String(stdoutBuffer);

if (
tryPull &&
(localStatus.includes("Your branch is behind") || localStatus.includes("have diverged"))
) {
if (tryPull && localStatus.includes("Your branch is behind")) {
await runProgram("git", ["merge", "FETCH_HEAD"], {
cwd: path,
logger: log.levelRoot.get("git:merge")
});
report.add("pull");
}

if (
tryPush &&
(localStatus.includes("Your branch is ahead") || localStatus.includes("have diverged"))
) {
if (tryPush && localStatus.includes("Your branch is ahead")) {
await runProgram("git", ["push"], { cwd: path, logger: log.levelRoot.get("git:push") });
report.add("push");
}
Expand Down

0 comments on commit 481ba58

Please sign in to comment.