Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove commit-meta property containing the merge-parent commit-ID #7646

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 0 additions & 11 deletions api/model/src/main/java/org/projectnessie/model/CommitMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,6 @@
@JsonDeserialize(using = CommitMetaDeserializer.class)
public abstract class CommitMeta {

/**
* Key of the {@link #getProperties() property} that indicates the merged commit ID, if the commit
* represents a merge commit.
*
* <p>If the commit is the result of a merge operation, the properties map <em>may</em> contain
* the key {@value #MERGE_PARENT_PROPERTY}, if the merge was performed with a Nessie server
* version, after 0.30.0, that persists the merged reference.
*/
@Deprecated // for removal
public static final String MERGE_PARENT_PROPERTY = "_merge_parent";

/**
* Hash of this commit.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ public void commitMergeTransplant() throws Exception {
singletonList("NessieHerself"),
singletonList("Arctic"),
Instant.EPOCH,
ImmutableMap.of("property", "value", "_merge_parent", branch.getHash()));
singletonMap("property", "value"));
} else {
api().mergeRefIntoBranch().fromRef(branch).branch(main).keepIndividualCommits(false).merge();
main2 = api().getReference().refName(main.getName()).get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@
import org.projectnessie.model.EntriesResponse.Entry;
import org.projectnessie.model.FetchOption;
import org.projectnessie.model.IdentifiedContentKey;
import org.projectnessie.model.ImmutableCommitMeta;
import org.projectnessie.model.ImmutableCommitResponse;
import org.projectnessie.model.ImmutableContentKeyDetails;
import org.projectnessie.model.ImmutableLogEntry;
Expand Down Expand Up @@ -553,9 +552,9 @@ private LogEntry logEntryOperationsAccessCheck(
}

private ImmutableLogEntry commitToLogEntry(boolean fetchAll, Commit commit) {
CommitMeta commitMetaWithHash = enhanceCommitMeta(commit.getHash(), commit.getCommitMeta());
CommitMeta commitMeta = commit.getCommitMeta();
ImmutableLogEntry.Builder logEntry = LogEntry.builder();
logEntry.commitMeta(commitMetaWithHash);
logEntry.commitMeta(commitMeta);
if (commit.getParentHash() != null) {
logEntry.parentCommitHash(commit.getParentHash().asString());
}
Expand All @@ -580,19 +579,6 @@ private ImmutableLogEntry commitToLogEntry(boolean fetchAll, Commit commit) {
return logEntry.build();
}

private static CommitMeta enhanceCommitMeta(Hash hash, CommitMeta commitMeta) {
if (commitMeta.getParentCommitHashes().size() > 1) {
ImmutableCommitMeta.Builder updatedCommitMeta = commitMeta.toBuilder().hash(hash.asString());
// Only add the 1st commit ID (merge parent) to the legacy MERGE_PARENT_PROPERTY. It was
// introduced for compatibility with older clients. There is currently only one use case for
// the property: exposing the commit ID of the merged commit.
updatedCommitMeta.putProperties(
CommitMeta.MERGE_PARENT_PROPERTY, commitMeta.getParentCommitHashes().get(1));
return updatedCommitMeta.build();
}
return commitMeta;
}

/**
* Produces the filter predicate for commit-log filtering.
*
Expand Down Expand Up @@ -1163,8 +1149,7 @@ private static ReferenceMetadata extractReferenceMetadata(ReferenceInfo<CommitMe
}
if (null != refWithHash.getHeadCommitMeta()) {
found = true;
builder.commitMetaOfHEAD(
enhanceCommitMeta(refWithHash.getHash(), refWithHash.getHeadCommitMeta()));
builder.commitMetaOfHEAD(refWithHash.getHeadCommitMeta());
}
if (0L != refWithHash.getCommitSeq()) {
found = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.tuple;
import static org.assertj.core.api.InstanceOfAssertFactories.list;
import static org.assertj.core.api.InstanceOfAssertFactories.map;
import static org.assertj.core.api.InstanceOfAssertFactories.type;
import static org.assertj.core.data.MapEntry.entry;
import static org.projectnessie.model.CommitMeta.fromMessage;
import static org.projectnessie.model.FetchOption.MINIMAL;
import static org.projectnessie.model.MergeBehavior.DROP;
Expand Down Expand Up @@ -258,12 +256,6 @@ private void mergeTransplant(
.extracting(CommitMeta::getParentCommitHashes)
.asInstanceOf(list(String.class))
.containsExactly(baseHead.getHash(), committed2.getHash());
soft.assertThat(logOfMerged)
.first()
.extracting(LogEntry::getCommitMeta)
.extracting(CommitMeta::getProperties)
.asInstanceOf(map(String.class, String.class))
.containsExactly(entry(CommitMeta.MERGE_PARENT_PROPERTY, committed2.getHash()));
}
}

Expand Down