Skip to content

Commit

Permalink
Better handling of git conflicts when publishing to github pages.
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah committed Oct 1, 2023
1 parent 684a1f8 commit dc2eb31
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ private void publishToGithubPages() throws IOException, InterruptedException {
throw new IOException("Github pages publish path is null.");
}
File publishPath = new File(packageJSONFile.getParentFile(), githubPagesPublishPath);
boolean stashed = false;
if (!currentBranch.equals(githubPagesBranch)) {
executeGitCommand("git", "stash");
stashed = true;
checkoutBranch(githubPagesBranch, true, true);
}
try {
Expand All @@ -208,6 +211,9 @@ private void publishToGithubPages() throws IOException, InterruptedException {
publishPath.getParentFile().mkdirs();
publishToCurrentBranch(publishPath);
} finally {
if (stashed) {
executeGitCommand("git", "stash", "pop");
}
if (!currentBranch.equals(githubPagesBranch)) {
checkoutBranch(currentBranch, false, false);
}
Expand Down

0 comments on commit dc2eb31

Please sign in to comment.