use of org.projectnessie.model.CommitMeta in project nessie by projectnessie.
the class BaseApiImpl method namedRefWithHashOrThrow.
WithHash<NamedRef> namedRefWithHashOrThrow(@Nullable String namedRef, @Nullable String hashOnRef) throws NessieNotFoundException {
if (null == namedRef) {
namedRef = config.getDefaultBranch();
}
if (DetachedRef.REF_NAME.equals(namedRef)) {
Objects.requireNonNull(hashOnRef, String.format("hashOnRef must not be null for '%s'", DetachedRef.REF_NAME));
return WithHash.of(Hash.of(hashOnRef), DetachedRef.INSTANCE);
}
WithHash<NamedRef> namedRefWithHash;
try {
ReferenceInfo<CommitMeta> ref = getStore().getNamedRef(namedRef, GetNamedRefsParams.DEFAULT);
namedRefWithHash = WithHash.of(ref.getHash(), ref.getNamedRef());
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
}
try {
if (null == hashOnRef) {
return namedRefWithHash;
}
if (store.noAncestorHash().asString().equals(hashOnRef)) {
// necessarily the same, so construct a new instance to return.
return WithHash.of(store.noAncestorHash(), namedRefWithHash.getValue());
}
// hash actually exists on the named reference and return early here
if (namedRefWithHash.getHash().asString().equals(hashOnRef)) {
return namedRefWithHash;
}
// we need to make sure that the hash in fact exists on the named ref
return WithHash.of(getStore().hashOnReference(namedRefWithHash.getValue(), Optional.of(Hash.of(hashOnRef))), namedRefWithHash.getValue());
} catch (ReferenceNotFoundException e) {
throw new NessieReferenceNotFoundException(e.getMessage(), e);
}
}
use of org.projectnessie.model.CommitMeta in project nessie by projectnessie.
the class TestNessieIcebergViews method verifyCommitMetadata.
private void verifyCommitMetadata() throws NessieNotFoundException {
// check that the author is properly set
List<LogEntry> log = api.getCommitLog().refName(BRANCH).get().getLogEntries();
assertThat(log).isNotNull().isNotEmpty().allSatisfy(logEntry -> {
CommitMeta commit = logEntry.getCommitMeta();
assertThat(commit.getAuthor()).isNotNull().isNotEmpty();
assertThat(commit.getAuthor()).isEqualTo(System.getProperty("user.name"));
assertThat(commit.getProperties().get(NessieUtil.APPLICATION_TYPE)).isEqualTo("iceberg");
assertThat(commit.getMessage()).startsWith("Iceberg");
});
}
Aggregations