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
6 changes: 1 addition & 5 deletions src/main/java/pl/project13/jgit/DescribeResult.java
Original file line number Diff line number Diff line change
Expand Up @@ -223,11 +223,7 @@ private static Optional<AbbreviatedObjectId> createAbbreviatedCommitId(@Nonnull

@Nullable
public ObjectId commitObjectId() {
if (commitId.isPresent()) {
return commitId.get();
} else {
return null;
}
return commitId.orElse(null);
}

@Nullable
Expand Down
9 changes: 1 addition & 8 deletions src/main/java/pl/project13/maven/git/GitCommitIdMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,8 @@ private void logProperties() {
}
}

private boolean isUseNativeGit() {
if (System.getProperty("maven.gitcommitid.nativegit") != null) {
return useNativeGitViaCommandLine;
}
return useNativeGit;
}

private void loadGitData(@Nonnull Properties properties) throws GitCommitIdExecutionException {
if (isUseNativeGit()) {
if (useNativeGit || useNativeGitViaCommandLine) {
loadGitDataWithNativeGit(properties);
} else {
loadGitDataWithJGit(properties);
Expand Down
34 changes: 17 additions & 17 deletions src/main/java/pl/project13/maven/git/GitDataProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ public void loadGitData(@Nonnull String evaluateOnCommit, @Nonnull Properties pr
this.evaluateOnCommit = evaluateOnCommit;
init();
// git.user.name
maybePut(properties, GitCommitPropertyConstant.BUILD_AUTHOR_NAME, () -> getBuildAuthorName());
maybePut(properties, GitCommitPropertyConstant.BUILD_AUTHOR_NAME, this::getBuildAuthorName);
// git.user.email
maybePut(properties, GitCommitPropertyConstant.BUILD_AUTHOR_EMAIL, () -> getBuildAuthorEmail());
maybePut(properties, GitCommitPropertyConstant.BUILD_AUTHOR_EMAIL, this::getBuildAuthorEmail);

try {
prepareGitToExtractMoreDetailedRepoInformation();
Expand All @@ -135,43 +135,43 @@ public void loadGitData(@Nonnull String evaluateOnCommit, @Nonnull Properties pr
// git.commit.id
switch (commitIdGenerationMode) {
case FULL: {
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_FULL, () -> getCommitId());
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_FULL, this::getCommitId);
break;
}
case FLAT: {
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_FLAT, () -> getCommitId());
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_FLAT, this::getCommitId);
break;
}
default: {
throw new GitCommitIdExecutionException("Unsupported commitIdGenerationMode: " + commitIdGenerationMode);
}
}
// git.commit.id.abbrev
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_ABBREV, () -> getAbbrevCommitId());
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_ABBREV, this::getAbbrevCommitId);
// git.dirty
maybePut(properties, GitCommitPropertyConstant.DIRTY, () -> Boolean.toString(isDirty()));
// git.commit.author.name
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_NAME, () -> getCommitAuthorName());
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_NAME, this::getCommitAuthorName);
// git.commit.author.email
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_EMAIL, () -> getCommitAuthorEmail());
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_EMAIL, this::getCommitAuthorEmail);
// git.commit.message.full
maybePut(properties, GitCommitPropertyConstant.COMMIT_MESSAGE_FULL, () -> getCommitMessageFull());
maybePut(properties, GitCommitPropertyConstant.COMMIT_MESSAGE_FULL, this::getCommitMessageFull);
// git.commit.message.short
maybePut(properties, GitCommitPropertyConstant.COMMIT_MESSAGE_SHORT, () -> getCommitMessageShort());
maybePut(properties, GitCommitPropertyConstant.COMMIT_MESSAGE_SHORT, this::getCommitMessageShort);
// git.commit.time
maybePut(properties, GitCommitPropertyConstant.COMMIT_TIME, () -> getCommitTime());
maybePut(properties, GitCommitPropertyConstant.COMMIT_TIME, this::getCommitTime);
// git remote.origin.url
maybePut(properties, GitCommitPropertyConstant.REMOTE_ORIGIN_URL, () -> getRemoteOriginUrl());
maybePut(properties, GitCommitPropertyConstant.REMOTE_ORIGIN_URL, this::getRemoteOriginUrl);

//
maybePut(properties, GitCommitPropertyConstant.TAGS, () -> getTags());
maybePut(properties, GitCommitPropertyConstant.TAGS, this::getTags);

maybePut(properties,GitCommitPropertyConstant.CLOSEST_TAG_NAME, () -> getClosestTagName());
maybePut(properties,GitCommitPropertyConstant.CLOSEST_TAG_COMMIT_COUNT, () -> getClosestTagCommitCount());
maybePut(properties,GitCommitPropertyConstant.CLOSEST_TAG_NAME, this::getClosestTagName);
maybePut(properties,GitCommitPropertyConstant.CLOSEST_TAG_COMMIT_COUNT, this::getClosestTagCommitCount);

maybePut(properties,GitCommitPropertyConstant.TOTAL_COMMIT_COUNT, () -> getTotalCommitCount());
maybePut(properties,GitCommitPropertyConstant.TOTAL_COMMIT_COUNT, this::getTotalCommitCount);

SupplierEx<AheadBehind> aheadBehindSupplier = memoize(() -> getAheadBehind());
SupplierEx<AheadBehind> aheadBehindSupplier = memoize(this::getAheadBehind);
maybePut(properties, GitCommitPropertyConstant.LOCAL_BRANCH_AHEAD, () -> aheadBehindSupplier.get().ahead());
maybePut(properties, GitCommitPropertyConstant.LOCAL_BRANCH_BEHIND, () -> aheadBehindSupplier.get().behind());
} finally {
Expand All @@ -184,7 +184,7 @@ private void maybePutGitDescribe(@Nonnull Properties properties) throws GitCommi
boolean isGitDescribeOptOutByConfiguration = (gitDescribe != null && !gitDescribe.isSkip());

if (isGitDescribeOptOutByDefault || isGitDescribeOptOutByConfiguration) {
maybePut(properties, GitCommitPropertyConstant.COMMIT_DESCRIBE, () -> getGitDescribe());
maybePut(properties, GitCommitPropertyConstant.COMMIT_DESCRIBE, this::getGitDescribe);
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/main/java/pl/project13/maven/git/JGitProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,9 @@ private String getBranchForCommitish() throws GitCommitIdExecutionException {
.filter(ref -> commitId.equals(ref.getObjectId().name()))
.map(ref -> Repository.shortenRefName(ref.getName()))
.distinct()
.sorted()
.collect(Collectors.toList());

Collections.sort(branchesForCommit);

String branch = branchesForCommit.stream()
.collect(Collectors.joining(","));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import javax.annotation.Nonnull;
import java.util.*;
import java.util.stream.Stream;

public class BambooBuildServerData extends BuildServerDataProvider {

Expand Down
1 change: 0 additions & 1 deletion src/test/java/pl/project13/maven/git/BigDiffTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

import junitparams.JUnitParamsRunner;
import org.apache.maven.project.MavenProject;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public void shouldExcludeAndIncludeAsConfiguredProperties(boolean useNativeGit)
setProjectToExecuteMojoIn(targetProject);
mojo.useNativeGit = useNativeGit;
mojo.includeOnlyProperties = Arrays.asList("git.remote.origin.url", ".*.user.*");
mojo.excludeProperties = Arrays.asList("git.build.user.email");
mojo.excludeProperties = Collections.singletonList("git.build.user.email");

// when
mojo.execute();
Expand Down