#115 - Train checkout now correctly identifies when to checkout master branch.

We now try to find a GA release tag for each module on train checkout. If that's not found, we check out the master branch instead of the maintenance branch.

Removed unnecessary invocation of git pull as the checkout before has already pulled the respective branch.
This commit is contained in:
Oliver Drotbohm
2019-04-02 14:28:42 +02:00
parent 7d11a33642
commit 6aee8d0731
2 changed files with 17 additions and 35 deletions

View File

@@ -48,6 +48,7 @@ import org.springframework.data.release.io.Workspace;
import org.springframework.data.release.issues.IssueTracker; import org.springframework.data.release.issues.IssueTracker;
import org.springframework.data.release.issues.Ticket; import org.springframework.data.release.issues.Ticket;
import org.springframework.data.release.model.ArtifactVersion; import org.springframework.data.release.model.ArtifactVersion;
import org.springframework.data.release.model.Iteration;
import org.springframework.data.release.model.ModuleIteration; import org.springframework.data.release.model.ModuleIteration;
import org.springframework.data.release.model.Project; import org.springframework.data.release.model.Project;
import org.springframework.data.release.model.Train; import org.springframework.data.release.model.Train;
@@ -121,16 +122,15 @@ public class GitOperations {
doWithGit(project, git -> { doWithGit(project, git -> {
Branch branch = Branch.from(module); ModuleIteration gaIteration = train.getModuleIteration(project, Iteration.GA);
Optional<Tag> gaTag = findTagFor(project, ArtifactVersion.of(gaIteration));
if (!branchExists(project, branch) && !branchExists(project, Branch.from("origin/" + branch.toString()))) { if (!gaTag.isPresent()) {
logger.log(project, "Checking out master branch as no GA release tag could be found!");
logger.warn(project, "Branch %s does not exist. Using %s.", branch, Branch.MASTER);
masterSwitch.set(true);
branch = Branch.MASTER;
} }
Branch branch = gaTag.isPresent() ? Branch.from(module) : Branch.MASTER;
CheckoutCommand command = git.checkout().setName(branch.toString()); CheckoutCommand command = git.checkout().setName(branch.toString());
if (!branchExists(project, branch)) { if (!branchExists(project, branch)) {
@@ -285,9 +285,6 @@ public class GitOperations {
logger.log(project, "git fetch --tags"); logger.log(project, "git fetch --tags");
git.fetch().setTagOpt(TagOpt.FETCH_TAGS).call(); git.fetch().setTagOpt(TagOpt.FETCH_TAGS).call();
logger.log(project, "git pull");
git.pull().call();
} else { } else {
clone(project); clone(project);
} }

View File

@@ -1,5 +1,5 @@
/* /*
* Copyright 2014-2018 the original author or authors. * Copyright 2014-2019 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.data.release.model;
import static org.springframework.data.release.model.Iteration.*; import static org.springframework.data.release.model.Iteration.*;
import static org.springframework.data.release.model.Projects.*; import static org.springframework.data.release.model.Projects.*;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -56,19 +55,11 @@ public class ReleaseTrains {
LOVELACE = KAY.next("Lovelace", Transition.MINOR, new Module(JDBC, "1.0"), new Module(SOLR, "4.0")); LOVELACE = KAY.next("Lovelace", Transition.MINOR, new Module(JDBC, "1.0"), new Module(SOLR, "4.0"));
MOORE = LOVELACE.next("Moore", Transition.MINOR).withIterations(new Iterations(M1, M2, M3, RC1, RC2)); MOORE = LOVELACE.next("Moore", Transition.MINOR).withIterations(new Iterations(M1, M2, M3, RC1, RC2, GA));
// Trains // Trains
TRAINS = Arrays.asList(CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE); TRAINS = Arrays.asList(CODD, DIJKSTRA, EVANS, FOWLER, GOSLING, HOPPER, INGALLS, KAY, LOVELACE, MOORE);
// Train names
List<String> names = new ArrayList<>(TRAINS.size());
for (Train train : TRAINS) {
names.add(train.getName());
}
} }
private static Train codd() { private static Train codd() {
@@ -107,23 +98,17 @@ public class ReleaseTrains {
public static Train getTrainByName(String name) { public static Train getTrainByName(String name) {
for (Train train : TRAINS) { return TRAINS.stream() //
if (train.getName().equalsIgnoreCase(name)) { .filter(it -> it.getName().equalsIgnoreCase(name)) //
return train; .findFirst() //
} .orElse(null);
}
return null;
} }
public static Project getProjectByName(String name) { public static Project getProjectByName(String name) {
for (Project project : PROJECTS) { return PROJECTS.stream() //
if (project.getName().equalsIgnoreCase(name)) { .filter(it -> it.getName().equalsIgnoreCase(name)) //
return project; .findFirst() //
} .orElse(null);
}
return null;
} }
} }