Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ public IExit invoke() throws Throwable {
switchToBranch(git);
// Commit any changes from a past prepare
commitUpstreamReversion(git);
project.preserveTemp();

// Prepare the project (stream stdio to the console)
getContext().getMaven().releasePrepare(project.getDirectory(), releaseProperties.getTag(), releaseProperties.getRelease(), releaseProperties.getDevelopment(), IMaven.PROFILES_RELEASE);
Expand All @@ -282,7 +283,7 @@ public IExit invoke() throws Throwable {
try {
// Skip ourselves & projects that don't depend on us
if ((downstream == project) || !downstream.getDependencies().getTransitive().keySet().contains(name)) continue;
log.info("\tFound downstream{}", downstream.getName());
log.info("\tFound downstream {}", downstream.getName());
// Record that we're updating this project so it needs to be re-installed at the end
unreleasedProjectsToReinstall.add(downstream.getName());
// Update all the downstreams to new release versions
Expand Down Expand Up @@ -352,6 +353,7 @@ public IExit invoke() throws Throwable {
// Commit anything dirty, since those are the things with version updates
switchToBranch(project.getGit());
commitUpstreamReversion(project.getGit());
project.preserveTemp();
}

// Re-install all the downstream projects that have had updated upstreams
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,14 @@ public void close() {
HIO.closeAll(getCloseables());
}

protected String computeCommit() {
try {
return getGit().getRepository().findRef(Constants.HEAD).getObjectId().getName();
} catch (IOException exception) {
throw new RuntimeIOException(String.format("Failed to determine commit for %1$s!", getName()), exception);
}
}

protected BulldozerDependencies computeDependencies() {
final Map<String, ? extends BulldozerProject> nameToProject = getContext().getNameToProject();
final Map<String, ? extends BulldozerProject> groupToProject = getContext().getGroupToProject();
Expand Down Expand Up @@ -190,28 +198,20 @@ public String getName() {
}

public <T> T loadTemp(IFunction1<BulldozerTemp, T> getter, IConsumer2<BulldozerTemp, T> setter, ISupplier<T> generator) {
final String commit;
try {
commit = getGit().getRepository().findRef(Constants.HEAD).getObjectId().getName();
} catch (IOException exception) {
throw new RuntimeIOException(String.format("Failed to determine commit for %1$s!", getName()), exception);
}
final String commit = computeCommit();

final Path path = getDirectory().resolve(BulldozerTemp.BULLDOZER_TEMP);
BulldozerTemp temp = null;
if (Files.exists(path)) {
try {
final BulldozerTemp read = getContext().getObjectMapper().readValue(path.toFile(), BulldozerTemp.class);
if (read.getKey().equals(commit)) temp = read;
if (read.isValidForCommit(commit)) temp = read;
else Files.delete(path);
} catch (IOException exception) {
log.warn(String.format("Failed to read bulldozer temp data for %1$s, will regenerate...", getName()));
}
}
if (temp == null) {
temp = new BulldozerTemp();
temp.setKey(commit);
}
if (temp == null) temp = BulldozerTemp.builder().commit(commit).build();
final T retVal0 = getter.apply(temp);
if (retVal0 != null) return retVal0;

Expand All @@ -229,4 +229,21 @@ public <T> T loadTemp(IFunction1<BulldozerTemp, T> getter, IConsumer2<BulldozerT
}
return retVal1;
}

public void preserveTemp() {
final String commit = computeCommit();

final Path path = getDirectory().resolve(BulldozerTemp.BULLDOZER_TEMP);
if (Files.exists(path)) {
try {
final BulldozerTemp read = getContext().getObjectMapper().readValue(path.toFile(), BulldozerTemp.class);
if (!read.isValidForCommit(commit)) {
final BulldozerTemp write = read.toBuilder().otherCommit(commit).build();
getContext().getObjectMapper().writeValue(path.toFile(), write);
}
} catch (IOException exception) {
log.warn(String.format("Failed to preserve bulldozer temp data for %1$s, will regenerate later...", getName()));
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
package com.g2forge.bulldozer.build.model;

import java.util.List;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.Singular;

@Data
@Builder
@Builder(toBuilder = true)
@AllArgsConstructor
@RequiredArgsConstructor
public class BulldozerTemp {
public static final String BULLDOZER_TEMP = "bulldozer-temp.json";

protected String key;
protected String commit;

@Singular
protected List<String> otherCommits;

protected String group;

Expand All @@ -21,4 +27,8 @@ public class BulldozerTemp {
protected BulldozerDependencies dependencies;

protected String parentGroup;

public boolean isValidForCommit(String commit) {
return getCommit().equals(commit) || ((getOtherCommits() != null) && getOtherCommits().contains(commit));
}
}