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: 3 additions & 3 deletions src/main/java/pl/project13/core/GitDataProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -286,9 +286,9 @@ protected void loadGitData(@Nonnull String evaluateOnCommit, @Nonnull Map<String
maybePut(properties, GitCommitPropertyConstant.COMMIT_ID_ABBREV, this::getAbbrevCommitId);
// git.dirty
maybePut(properties, GitCommitPropertyConstant.DIRTY, () -> Boolean.toString(isDirty()));
// git.commit.author.name
// git.commit.user.name
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_NAME, this::getCommitAuthorName);
// git.commit.author.email
// git.commit.user.email
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_EMAIL, this::getCommitAuthorEmail);
// git.commit.message.full
maybePut(properties, GitCommitPropertyConstant.COMMIT_MESSAGE_FULL, this::getCommitMessageFull);
Expand All @@ -299,7 +299,7 @@ protected void loadGitData(@Nonnull String evaluateOnCommit, @Nonnull Map<String
// commit.author.time
maybePut(properties, GitCommitPropertyConstant.COMMIT_AUTHOR_TIME, this::getCommitAuthorTime);
// commit.committer.time
maybePut(properties, GitCommitPropertyConstant.COMMIT_COMMITTER_TIME, this::getCommitAuthorTime);
maybePut(properties, GitCommitPropertyConstant.COMMIT_COMMITTER_TIME, this::getCommitCommitterTime);
// git remote.origin.url
maybePut(properties, GitCommitPropertyConstant.REMOTE_ORIGIN_URL, this::getRemoteOriginUrl);

Expand Down
7 changes: 7 additions & 0 deletions src/test/java/pl/project13/core/AvailableGitTestRepo.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public enum AvailableGitTestRepo {
*/
WITH_TAG_ON_DIFFERENT_BRANCH("src/test/resources/_git_with_tag_on_different_branch"),
WITH_ONE_COMMIT_WITH_SPECIAL_CHARACTERS("src/test/resources/_git_one_commit_with_umlaut"),
/**
* <pre>
* $ log --date=iso-strict --format='%h | cd=%cd | ad=%ad'
* 7002d5c | cd=2014-09-19T17:23:04+02:00 | ad=2012-07-04T15:54:01+02:00
* </pre>
*/
COMMITTER_DIFFERENT_FROM_AUTHOR("src/test/resources/_git_one_commit_with_umlaut"),
/**
* <pre>
* b0c6d28b3b83bf7b905321bae67d9ca4c75a203f 2015-06-04 00:50:18 +0200 (HEAD, master)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@
import org.junit.runner.RunWith;
import pl.project13.core.git.GitDescribeConfig;
import pl.project13.core.util.GenericFileManager;
import pl.project13.core.util.JsonManager;
import pl.project13.core.util.XmlManager;
import pl.project13.core.util.YmlManager;

import javax.annotation.Nonnull;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -1061,6 +1057,45 @@ public void shouldGenerateClosestTagInformationWhenCommitHasTwoTags(boolean useN
assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "0");
}

@Test
@Parameters(method = "useNativeGit")
public void shouldGenerateCommitterAndAuthorInformation(boolean useNativeGit) throws Exception {
// given
File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.COMMITTER_DIFFERENT_FROM_AUTHOR);

GitCommitIdPlugin.Callback cb =
new GitCommitIdTestCallback()
.setDotGitDirectory(dotGitDirectory)
.setDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX")
.setDateFormatTimeZone("UTC")
.setUseNativeGit(useNativeGit)
.build();
Properties properties = new Properties();

// when
GitCommitIdPlugin.runPlugin(cb, properties);

// then
assertThat(properties)
.containsKeys(
"git.commit.time",
"git.commit.committer.time",
"git.commit.author.time",
"git.commit.user.email",
"git.commit.user.name");

assertThat(properties.getProperty("git.commit.committer.time")).isNotEqualTo(properties.getProperty("git.commit.author.time"));

// Committer
assertPropertyPresentAndEqual(properties, "git.commit.committer.time", "2014-09-19T15:23:04Z");
assertThat(properties.getProperty("git.commit.committer.time")).isEqualTo(properties.getProperty("git.commit.time"));

// Author
assertPropertyPresentAndEqual(properties, "git.commit.author.time", "2012-07-04T13:54:01Z");
assertPropertyPresentAndEqual(properties, "git.commit.user.email", "john.doe@domain.com");
assertPropertyPresentAndEqual(properties, "git.commit.user.name", "John Doe");
}

@Test
@Parameters(method = "useNativeGit")
public void shouldUseDateFormatTimeZone(boolean useNativeGit) throws Exception {
Expand Down