@@ -120,7 +120,7 @@ class ReleaseCommands extends TimedCommand {
|
||||
build.prepareVersions(iteration, Phase.CLEANUP);
|
||||
git.commit(iteration, "Prepare next development iteration.");
|
||||
|
||||
// Prepare master branch
|
||||
// Prepare main branch
|
||||
build.updateProjectDescriptors(iteration, Phase.CLEANUP);
|
||||
git.commit(iteration, "After release cleanups.");
|
||||
|
||||
@@ -141,7 +141,7 @@ class ReleaseCommands extends TimedCommand {
|
||||
build.updateProjectDescriptors(iteration, Phase.MAINTENANCE);
|
||||
git.commit(iteration, "After release cleanups.");
|
||||
|
||||
// Back to master branch
|
||||
// Back to main branch
|
||||
git.checkout(iteration);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,6 +23,8 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.bouncycastle.util.Iterable;
|
||||
|
||||
import org.springframework.data.release.model.ModuleIteration;
|
||||
import org.springframework.data.release.model.Train;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -34,7 +36,7 @@ class BackportTargets implements Iterable<Branch> {
|
||||
|
||||
/**
|
||||
* Creates a new {@link BackportTargets} instance for the given {@link ModuleIteration} and
|
||||
*
|
||||
*
|
||||
* @param module must not be {@literal null}.
|
||||
* @param targets must not be {@literal null}.
|
||||
*/
|
||||
@@ -49,11 +51,11 @@ class BackportTargets implements Iterable<Branch> {
|
||||
.flatMap(o -> o.map(Stream::of).orElse(Stream.empty()))//
|
||||
.map(Branch::from);
|
||||
|
||||
this.targets = Stream.concat(branches, source.isMasterBranch() ? Stream.empty() : Stream.of(Branch.MASTER))
|
||||
this.targets = Stream.concat(branches, source.isMainBranch() ? Stream.empty() : Stream.of(Branch.MAIN))
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see java.lang.Iterable#iterator()
|
||||
*/
|
||||
|
||||
@@ -27,20 +27,21 @@ import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Value type to represent an SCM branch.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@EqualsAndHashCode
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
public class Branch implements Comparable<Branch> {
|
||||
|
||||
public static final Branch MASTER = new Branch("master");
|
||||
public static final Branch MAIN = new Branch("main");
|
||||
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Branch} from the given {@link IterationVersion}.
|
||||
*
|
||||
*
|
||||
* @param iterationVersion must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
@@ -52,7 +53,7 @@ public class Branch implements Comparable<Branch> {
|
||||
return from((VersionAware) iterationVersion);
|
||||
}
|
||||
|
||||
return MASTER;
|
||||
return MAIN;
|
||||
}
|
||||
|
||||
public static Branch from(VersionAware versioned) {
|
||||
@@ -65,7 +66,7 @@ public class Branch implements Comparable<Branch> {
|
||||
|
||||
/**
|
||||
* Creates a new {@link Branch} from the given name. Uses the local part of it only.
|
||||
*
|
||||
*
|
||||
* @param name must not be {@literal null} or empty.
|
||||
* @return
|
||||
*/
|
||||
@@ -76,13 +77,13 @@ public class Branch implements Comparable<Branch> {
|
||||
return new Branch(slashIndex != -1 ? name.substring(slashIndex + 1) : name);
|
||||
}
|
||||
|
||||
public boolean isMasterBranch() {
|
||||
return MASTER.equals(this);
|
||||
public boolean isMainBranch() {
|
||||
return MAIN.equals(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current branch is an issue branch for the given {@link Tracker}.
|
||||
*
|
||||
*
|
||||
* @param tracker must not be {@literal null}.
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -140,7 +140,7 @@ public class GitOperations {
|
||||
update(train);
|
||||
}
|
||||
|
||||
AtomicBoolean masterSwitch = new AtomicBoolean();
|
||||
AtomicBoolean mainSwitch = new AtomicBoolean();
|
||||
ExecutionUtils.run(executor, train, module -> {
|
||||
|
||||
Project project = module.getProject();
|
||||
@@ -151,10 +151,10 @@ public class GitOperations {
|
||||
Optional<Tag> gaTag = findTagFor(project, ArtifactVersion.of(gaIteration));
|
||||
|
||||
if (!gaTag.isPresent()) {
|
||||
logger.log(project, "Checking out master branch as no GA release tag could be found!");
|
||||
logger.log(project, "Checking out main branch as no GA release tag could be found!");
|
||||
}
|
||||
|
||||
Branch branch = gaTag.isPresent() ? Branch.from(module) : Branch.MASTER;
|
||||
Branch branch = gaTag.isPresent() ? Branch.from(module) : Branch.MAIN;
|
||||
|
||||
CheckoutCommand command = git.checkout().setName(branch.toString());
|
||||
|
||||
@@ -174,9 +174,9 @@ public class GitOperations {
|
||||
});
|
||||
});
|
||||
|
||||
if (masterSwitch.get()) {
|
||||
if (mainSwitch.get()) {
|
||||
logger.warn(train,
|
||||
"Successfully checked out projects. There were switches to master for certain projects. This happens if the train has no branches yet.");
|
||||
"Successfully checked out projects. There were switches to main for certain projects. This happens if the train has no branches yet.");
|
||||
} else {
|
||||
logger.log(train, "Successfully checked out projects.");
|
||||
}
|
||||
@@ -304,7 +304,7 @@ public class GitOperations {
|
||||
|
||||
logger.log(project, "Found existing repository %s. Obtaining latest changes…", repositoryName);
|
||||
|
||||
checkout(project, Branch.MASTER);
|
||||
checkout(project, Branch.MAIN);
|
||||
|
||||
logger.log(project, "git fetch --tags");
|
||||
git.fetch().setTagOpt(TagOpt.FETCH_TAGS).call();
|
||||
@@ -507,7 +507,7 @@ public class GitOperations {
|
||||
private static String getFirstCommit(Repository repo) throws IOException {
|
||||
|
||||
try (RevWalk revWalk = new RevWalk(repo)) {
|
||||
return revWalk.parseCommit(repo.resolve("master")).getName();
|
||||
return revWalk.parseCommit(repo.resolve("main")).getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -782,7 +782,8 @@ public class GitOperations {
|
||||
|
||||
/**
|
||||
* Back-ports the change log created for the given {@link TrainIteration} to the given release {@link Train}s. If the
|
||||
* {@link TrainIteration} is a service iteration itself, the master branch will become an additional port target.
|
||||
* {@link TrainIteration} is a service iteration itself, the {@code main} branch will become an additional port
|
||||
* target.
|
||||
*
|
||||
* @param iteration must not be {@literal null}.
|
||||
* @param targets must not be {@literal null}.
|
||||
@@ -816,7 +817,7 @@ public class GitOperations {
|
||||
* Verify general Git operations.
|
||||
*/
|
||||
public void verify() {
|
||||
checkout(Projects.BUILD, Branch.MASTER);
|
||||
checkout(Projects.BUILD, Branch.MAIN);
|
||||
}
|
||||
|
||||
private void cherryPickCommitToBranch(ObjectId id, Project project, Branch branch) {
|
||||
@@ -963,7 +964,7 @@ public class GitOperations {
|
||||
.call();
|
||||
|
||||
git.checkout()//
|
||||
.setName(Branch.MASTER.toString())//
|
||||
.setName(Branch.MAIN.toString())//
|
||||
.call();
|
||||
|
||||
logger.log(project, "Cloning done!", project);
|
||||
|
||||
@@ -1,54 +1,54 @@
|
||||
package org.springframework.data.release.model;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Value object to represent a Version consisting of major, minor and bugfix part.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
@Getter
|
||||
public class Version implements Comparable<Version> {
|
||||
|
||||
private final int major;
|
||||
private final int minor;
|
||||
private final int bugfix;
|
||||
private final int build;
|
||||
private final BigDecimal major;
|
||||
private final BigDecimal minor;
|
||||
private final BigDecimal bugfix;
|
||||
private final BigDecimal build;
|
||||
|
||||
/**
|
||||
* Creates a new {@link Version} from the given integer values. At least one value has to be given but a maximum of 4.
|
||||
*
|
||||
*
|
||||
* @param parts must not be {@literal null} or empty.
|
||||
*/
|
||||
private Version(int... parts) {
|
||||
private Version(BigDecimal... parts) {
|
||||
|
||||
Assert.notNull(parts, "Parts must not be null!");
|
||||
Assert.isTrue(parts.length > 0 && parts.length < 5, "We need at least 1 at most 4 parts!");
|
||||
|
||||
this.major = parts[0];
|
||||
this.minor = parts.length > 1 ? parts[1] : 0;
|
||||
this.bugfix = parts.length > 2 ? parts[2] : 0;
|
||||
this.build = parts.length > 3 ? parts[3] : 0;
|
||||
this.minor = parts.length > 1 ? parts[1] : BigDecimal.ZERO;
|
||||
this.bugfix = parts.length > 2 ? parts[2] : BigDecimal.ZERO;
|
||||
this.build = parts.length > 3 ? parts[3] : BigDecimal.ZERO;
|
||||
|
||||
Assert.isTrue(major >= 0, "Major version must be greater or equal zero!");
|
||||
Assert.isTrue(minor >= 0, "Minor version must be greater or equal zero!");
|
||||
Assert.isTrue(bugfix >= 0, "Bugfix version must be greater or equal zero!");
|
||||
Assert.isTrue(build >= 0, "Build version must be greater or equal zero!");
|
||||
Assert.isTrue(major.longValue() >= 0, "Major version must be greater or equal zero!");
|
||||
Assert.isTrue(minor.longValue() >= 0, "Minor version must be greater or equal zero!");
|
||||
Assert.isTrue(bugfix.longValue() >= 0, "Bugfix version must be greater or equal zero!");
|
||||
Assert.isTrue(build.longValue() >= 0, "Build version must be greater or equal zero!");
|
||||
}
|
||||
|
||||
public static Version of(int... parts) {
|
||||
return new Version(parts);
|
||||
return new Version(Arrays.stream(parts).mapToObj(BigDecimal::valueOf).toArray(BigDecimal[]::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses the given string representation of a version into a {@link Version} object.
|
||||
*
|
||||
*
|
||||
* @param version must not be {@literal null} or empty.
|
||||
* @return
|
||||
*/
|
||||
@@ -57,18 +57,34 @@ public class Version implements Comparable<Version> {
|
||||
Assert.hasText(version, "Version must not be null or empty!");
|
||||
|
||||
String[] parts = version.trim().split("\\.");
|
||||
int[] intParts = new int[parts.length];
|
||||
BigDecimal[] intParts = new BigDecimal[parts.length];
|
||||
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
intParts[i] = Integer.parseInt(parts[i]);
|
||||
intParts[i] = new BigDecimal(parts[i]);
|
||||
}
|
||||
|
||||
return new Version(intParts);
|
||||
}
|
||||
|
||||
public int getMajor() {
|
||||
return major.intValueExact();
|
||||
}
|
||||
|
||||
public int getMinor() {
|
||||
return minor.intValueExact();
|
||||
}
|
||||
|
||||
public int getBugfix() {
|
||||
return bugfix.intValueExact();
|
||||
}
|
||||
|
||||
public int getBuild() {
|
||||
return build.intValueExact();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Version} is greater (newer) than the given one.
|
||||
*
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
@@ -78,7 +94,7 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Version} is greater (newer) or the same as the given one.
|
||||
*
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
@@ -88,7 +104,7 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Version} is the same as the given one.
|
||||
*
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
@@ -98,7 +114,7 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Version} is less (older) than the given one.
|
||||
*
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
@@ -108,7 +124,7 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
/**
|
||||
* Returns whether the current {@link Version} is less (older) or equal to the current one.
|
||||
*
|
||||
*
|
||||
* @param version
|
||||
* @return
|
||||
*/
|
||||
@@ -117,19 +133,23 @@ public class Version implements Comparable<Version> {
|
||||
}
|
||||
|
||||
public Version nextMajor() {
|
||||
return new Version(this.major + 1);
|
||||
return new Version(this.major.add(BigDecimal.ONE));
|
||||
}
|
||||
|
||||
public Version nextMinor() {
|
||||
return new Version(this.major, this.minor + 1);
|
||||
return new Version(this.major, this.minor.add(BigDecimal.ONE));
|
||||
}
|
||||
|
||||
public Version nextBugfix() {
|
||||
return new Version(this.major, this.minor, this.bugfix + 1);
|
||||
return new Version(this.major, this.minor, this.bugfix.add(BigDecimal.ONE));
|
||||
}
|
||||
|
||||
public Version withBugfix(BigDecimal bugfix) {
|
||||
return new Version(this.major, this.minor, bugfix);
|
||||
}
|
||||
|
||||
public Version withBugfix(int bugfix) {
|
||||
return new Version(this.major, this.minor, bugfix);
|
||||
return new Version(this.major, this.minor, BigDecimal.valueOf(bugfix));
|
||||
}
|
||||
|
||||
public String toMajorMinorBugfix() {
|
||||
@@ -146,20 +166,20 @@ public class Version implements Comparable<Version> {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (major != that.major) {
|
||||
return major - that.major;
|
||||
if (!Objects.equals(major, that.major)) {
|
||||
return major.compareTo(that.major);
|
||||
}
|
||||
|
||||
if (minor != that.minor) {
|
||||
return minor - that.minor;
|
||||
if (!Objects.equals(minor, that.minor)) {
|
||||
return minor.compareTo(that.minor);
|
||||
}
|
||||
|
||||
if (bugfix != that.bugfix) {
|
||||
return bugfix - that.bugfix;
|
||||
if (!Objects.equals(bugfix, that.bugfix)) {
|
||||
return bugfix.compareTo(that.bugfix);
|
||||
}
|
||||
|
||||
if (build != that.build) {
|
||||
return build - that.build;
|
||||
if (!Objects.equals(build, that.build)) {
|
||||
return build.compareTo(that.build);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -182,8 +202,8 @@ public class Version implements Comparable<Version> {
|
||||
|
||||
Version that = (Version) obj;
|
||||
|
||||
return this.major == that.major && this.minor == that.minor && this.bugfix == that.bugfix
|
||||
&& this.build == that.build;
|
||||
return Objects.equals(this.major, that.major) && Objects.equals(this.minor, that.minor)
|
||||
&& Objects.equals(this.bugfix, that.bugfix) && Objects.equals(this.build, that.build);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -194,10 +214,10 @@ public class Version implements Comparable<Version> {
|
||||
public int hashCode() {
|
||||
|
||||
int result = 17;
|
||||
result += 31 * major;
|
||||
result += 31 * minor;
|
||||
result += 31 * bugfix;
|
||||
result += 31 * build;
|
||||
result += 31 * major.hashCode();
|
||||
result += 31 * minor.hashCode();
|
||||
result += 31 * bugfix.hashCode();
|
||||
result += 31 * build.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -208,15 +228,15 @@ public class Version implements Comparable<Version> {
|
||||
@Override
|
||||
public String toString() {
|
||||
|
||||
List<Integer> digits = new ArrayList<Integer>();
|
||||
List<BigDecimal> digits = new ArrayList<>();
|
||||
digits.add(major);
|
||||
digits.add(minor);
|
||||
|
||||
if (build != 0 || bugfix != 0) {
|
||||
if (build.longValue() != 0 || bugfix.longValue() != 0) {
|
||||
digits.add(bugfix);
|
||||
}
|
||||
|
||||
if (build != 0) {
|
||||
if (build.longValue() != 0) {
|
||||
digits.add(build);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.data.release.model.TrainIteration;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link BackportTargets}.
|
||||
*
|
||||
*
|
||||
* @author Oliver Gierke
|
||||
*/
|
||||
class BackportTargetsUnitTests {
|
||||
@@ -51,7 +51,7 @@ class BackportTargetsUnitTests {
|
||||
}
|
||||
|
||||
@Test // #11
|
||||
void includesMasterBranchForServiceReleaseSource() {
|
||||
void includesMainBranchForServiceReleaseSource() {
|
||||
|
||||
TrainIteration iteration = new TrainIteration(ReleaseTrains.GOSLING, Iteration.SR2);
|
||||
ModuleIteration module = iteration.getModule(Projects.COMMONS);
|
||||
@@ -59,7 +59,7 @@ class BackportTargetsUnitTests {
|
||||
BackportTargets targets = new BackportTargets(module, Arrays.asList(ReleaseTrains.FOWLER));
|
||||
|
||||
assertThat(targets).hasSize(2);
|
||||
assertThat(targets).contains(Branch.MASTER, fowlerBranch);
|
||||
assertThat(targets).contains(Branch.MAIN, fowlerBranch);
|
||||
}
|
||||
|
||||
private static Branch getBranch(Train train) {
|
||||
|
||||
@@ -34,7 +34,7 @@ class BranchUnitTests {
|
||||
void testname() {
|
||||
|
||||
IterationVersion iterationVersion = new SimpleIterationVersion(Version.of(1, 4), Iteration.RC1);
|
||||
assertThat(Branch.from(iterationVersion).toString()).isEqualTo("master");
|
||||
assertThat(Branch.from(iterationVersion).toString()).isEqualTo("main");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,10 +23,6 @@ import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
|
||||
import org.eclipse.jgit.api.Git;
|
||||
import org.eclipse.jgit.internal.storage.file.FileRepository;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.revwalk.RevCommit;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -102,29 +98,4 @@ class GitOperationsIntegrationTests extends AbstractIntegrationTests {
|
||||
assertThat(hopperSR9.getIteration()).isEqualTo(Iteration.SR9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void verify() throws Exception {
|
||||
|
||||
// gitOperations.update(ReleaseTrains.HOPPER);
|
||||
|
||||
try (Git git = new Git(new FileRepository("/Users/mpaluch/git/data/spring-data-elasticsearch/.git"))) {
|
||||
|
||||
ObjectId resolve = git.getRepository().parseCommit(git.getRepository().resolve("3.0.0.RELEASE"));
|
||||
Iterable<RevCommit> master = git.log().addRange(resolve, git.getRepository().resolve("master")).call();
|
||||
|
||||
for (RevCommit revCommit : master) {
|
||||
|
||||
ParsedCommitMessage message = ParsedCommitMessage.parse(revCommit.getFullMessage());
|
||||
|
||||
if (message.getTicketReference() == null || message.getSummary() == null) {
|
||||
System.out.println(revCommit.getFullMessage());
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception o_O) {
|
||||
throw new RuntimeException(o_O);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user