|
26 | 26 | import org.junit.runner.RunWith;
|
27 | 27 | import pl.project13.core.git.GitDescribeConfig;
|
28 | 28 | import pl.project13.core.util.GenericFileManager;
|
29 |
| -import pl.project13.core.util.JsonManager; |
30 |
| -import pl.project13.core.util.XmlManager; |
31 |
| -import pl.project13.core.util.YmlManager; |
32 | 29 |
|
33 | 30 | import javax.annotation.Nonnull;
|
34 | 31 | import java.io.File;
|
35 | 32 | import java.io.IOException;
|
36 |
| -import java.nio.charset.StandardCharsets; |
37 | 33 | import java.nio.file.Files;
|
38 | 34 | import java.nio.file.Path;
|
39 | 35 | import java.text.SimpleDateFormat;
|
@@ -1061,6 +1057,45 @@ public void shouldGenerateClosestTagInformationWhenCommitHasTwoTags(boolean useN
|
1061 | 1057 | assertPropertyPresentAndEqual(properties, "git.closest.tag.commit.count", "0");
|
1062 | 1058 | }
|
1063 | 1059 |
|
| 1060 | + @Test |
| 1061 | + @Parameters(method = "useNativeGit") |
| 1062 | + public void shouldGenerateCommitterAndAuthorInformation(boolean useNativeGit) throws Exception { |
| 1063 | + // given |
| 1064 | + File dotGitDirectory = createTmpDotGitDirectory(AvailableGitTestRepo.COMMITTER_DIFFERENT_FROM_AUTHOR); |
| 1065 | + |
| 1066 | + GitCommitIdPlugin.Callback cb = |
| 1067 | + new GitCommitIdTestCallback() |
| 1068 | + .setDotGitDirectory(dotGitDirectory) |
| 1069 | + .setDateFormat("yyyy-MM-dd'T'HH:mm:ssXXX") |
| 1070 | + .setDateFormatTimeZone("UTC") |
| 1071 | + .setUseNativeGit(useNativeGit) |
| 1072 | + .build(); |
| 1073 | + Properties properties = new Properties(); |
| 1074 | + |
| 1075 | + // when |
| 1076 | + GitCommitIdPlugin.runPlugin(cb, properties); |
| 1077 | + |
| 1078 | + // then |
| 1079 | + assertThat(properties) |
| 1080 | + .containsKeys( |
| 1081 | + "git.commit.time", |
| 1082 | + "git.commit.committer.time", |
| 1083 | + "git.commit.author.time", |
| 1084 | + "git.commit.user.email", |
| 1085 | + "git.commit.user.name"); |
| 1086 | + |
| 1087 | + assertThat(properties.getProperty("git.commit.committer.time")).isNotEqualTo(properties.getProperty("git.commit.author.time")); |
| 1088 | + |
| 1089 | + // Committer |
| 1090 | + assertPropertyPresentAndEqual(properties, "git.commit.committer.time", "2014-09-19T15:23:04Z"); |
| 1091 | + assertThat(properties.getProperty("git.commit.committer.time")).isEqualTo(properties.getProperty("git.commit.time")); |
| 1092 | + |
| 1093 | + // Author |
| 1094 | + assertPropertyPresentAndEqual(properties, "git.commit.author.time", "2012-07-04T13:54:01Z"); |
| 1095 | + assertPropertyPresentAndEqual(properties, "git.commit.user.email", "john.doe@domain.com"); |
| 1096 | + assertPropertyPresentAndEqual(properties, "git.commit.user.name", "John Doe"); |
| 1097 | + } |
| 1098 | + |
1064 | 1099 | @Test
|
1065 | 1100 | @Parameters(method = "useNativeGit")
|
1066 | 1101 | public void shouldUseDateFormatTimeZone(boolean useNativeGit) throws Exception {
|
|
0 commit comments