Skip to content

Commit

Permalink
Update 6 (minor fixes)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgrothe committed Nov 6, 2024
1 parent cc845b8 commit 241ea8e
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,18 @@ private static void linearize1(File repo, String main) throws IOException, Inter
for (int i = 0; i < branches.size(); i++) {
String b1 = branches.get(i);
for (int j = i + 1; j < branches.size(); j++) {
if (i != j) {
String b2 = branches.get(j);
System.out.printf("Check %s and %s.%n", b1, b2);
boolean a =
"0".equals(exec(false, repo, "git", "merge-base", "--is-ancestor", b1, b2).get(0));
if (a) {
ancestorMap.put(new AbstractMap.SimpleEntry<>(b1, b2), true);
ancestorMap.put(new AbstractMap.SimpleEntry<>(b2, b1), false);
} else {
boolean b =
"0".equals(exec(false, repo, "git", "merge-base", "--is-ancestor", b2, b1).get(0));
ancestorMap.put(new AbstractMap.SimpleEntry<>(b1, b2), false);
ancestorMap.put(new AbstractMap.SimpleEntry<>(b2, b1), b);
}
String b2 = branches.get(j);
System.out.printf("Check %s and %s.%n", b1, b2);
boolean a =
"0".equals(exec(false, repo, "git", "merge-base", "--is-ancestor", b1, b2).get(0));
if (a) {
ancestorMap.put(new AbstractMap.SimpleEntry<>(b1, b2), true);
ancestorMap.put(new AbstractMap.SimpleEntry<>(b2, b1), false);
} else {
boolean b =
"0".equals(exec(false, repo, "git", "merge-base", "--is-ancestor", b2, b1).get(0));
ancestorMap.put(new AbstractMap.SimpleEntry<>(b1, b2), false);
ancestorMap.put(new AbstractMap.SimpleEntry<>(b2, b1), b);
}
}
}
Expand Down Expand Up @@ -152,9 +150,16 @@ private static void linearize2(
}
}

private static final boolean shouldCmdWrappedToBash = true;

private static List<String> exec(boolean exitIfNoSuccess, File wd, String... cmd)
throws IOException, InterruptedException {
String[] newCmd = {"bash", "-c", String.join(" ", cmd)};
String[] newCmd;
if (shouldCmdWrappedToBash) {
newCmd = new String[] {"bash", "-c", String.join(" ", cmd)};
} else {
newCmd = cmd;
}
ProcessBuilder builder = new ProcessBuilder(newCmd);
builder.directory(wd);
builder.redirectErrorStream(true);
Expand Down

0 comments on commit 241ea8e

Please sign in to comment.