Skip to content

Commit

Permalink
Ensure submodules have no staged changes between checkouts.
Browse files Browse the repository at this point in the history
  • Loading branch information
juanmuscaria committed Jul 17, 2023
1 parent 9d6baf5 commit 7de03af
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions archiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.eclipse.jgit.api.CreateBranchCommand.SetupUpstreamMode;
import org.eclipse.jgit.api.Git;
import org.eclipse.jgit.api.ListBranchCommand;
import org.eclipse.jgit.api.ResetCommand;
import org.eclipse.jgit.lib.*;
import org.eclipse.jgit.submodule.SubmoduleWalk;
import org.eclipse.jgit.transport.RefSpec;
Expand Down Expand Up @@ -227,6 +228,9 @@ public Integer call() throws Exception {
submodule.fetch().setRemote("upstream").call();
for (String branch : branches) {
if (upstreamBranches.containsKey(branch)) {
// Ensure we are clean
submodule.reset().setMode(ResetCommand.ResetType.HARD).call();

var checkout = submodule.checkout().setName(branch).setStartPoint("origin/" + branch).setForced(true);
// Ugh, I wish it was cleaner than doing this.
if (localBranches.contains(branch)) {
Expand Down

0 comments on commit 7de03af

Please sign in to comment.