Skip to content

Commit 2bb522d

Browse files
author
S L
committed
maven-git-commit-id-plugin are not in sync, updating to latest maven-git-commit-id-plugin
1 parent b3d93c4 commit 2bb522d

File tree

1,920 files changed

+10887
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,920 files changed

+10887
-200
lines changed

pom.xml

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,36 @@
1111
<artifactId>git-commit-id-plugin</artifactId>
1212
<packaging>pom</packaging>
1313

14-
<version>2.1.8-SNAPSHOT</version>
14+
<version>2.1.10</version>
1515

1616
<name>Git Commit Id Plugin Maven Mojo</name>
17+
<description>
18+
git-commit-id-plugin is a plugin quite similar to
19+
https://fisheye.codehaus.org/browse/mojo/tags/buildnumber-maven-plugin-1.0-beta-4 for example but as buildnumber
20+
only supports svn (which is very sad) and cvs (which is even more sad).
21+
This plugin makes basic repository information available through maven resources. This can be used to display
22+
"what version is this?" or "who has deployed this and when, from which branch?" information at runtime - making
23+
it easy to find things like "oh, that isn't deployed yet, I'll test it tomorrow" and making both testers and
24+
developers life easier.
25+
26+
The data currently exported is like this (that's the end effect from the GitRepositoryState Bean):
27+
{
28+
"branch" : "testing-maven-git-plugin",
29+
"commitTime" : "06.01.1970 @ 16:16:26 CET",
30+
"commitId" : "787e39f61f99110e74deed68ab9093088d64b969",
31+
"commitUserName" : "Konrad Malawski",
32+
"commitUserEmail" : "konrad.malawski@java.pl",
33+
"commitMessageFull" : "releasing my fun plugin :-) + fixed some typos + cleaned up directory structure + added
34+
license etc",
35+
"commitMessageShort" : "releasing my fun plugin :-)",
36+
"buildTime" : "06.01.1970 @ 16:17:53 CET",
37+
"buildUserName" : "Konrad Malawski",
38+
"buildUserEmail" : "konrad.malawski@java.pl"
39+
}
40+
41+
Note that the data is exported via maven resource filtering and is really easy to use with spring -
42+
which I've explained in detail in this readme https://github.com/ktoso/maven-git-commit-id-plugin
43+
</description>
1744
<url>http://www.blog.project13.pl</url>
1845

1946
<modules>
@@ -64,6 +91,12 @@
6491
<version>${maven-plugin-api.version}</version>
6592
</dependency>
6693

94+
<dependency>
95+
<groupId>com.fasterxml.jackson.core</groupId>
96+
<artifactId>jackson-databind</artifactId>
97+
<version>2.2.3</version>
98+
</dependency>
99+
67100
<dependency>
68101
<groupId>com.google.inject</groupId>
69102
<artifactId>guice</artifactId>
@@ -81,7 +114,7 @@
81114
<dependency>
82115
<groupId>com.google.guava</groupId>
83116
<artifactId>guava</artifactId>
84-
<version>13.0</version>
117+
<version>15.0</version>
85118
</dependency>
86119

87120
<!-- IntelliJ Annotations -->
@@ -135,6 +168,13 @@
135168
<type>jar</type>
136169
<scope>test</scope>
137170
</dependency>
171+
172+
<dependency>
173+
<groupId>pl.pragmatists</groupId>
174+
<artifactId>JUnitParams</artifactId>
175+
<version>1.0.2</version>
176+
<scope>test</scope>
177+
</dependency>
138178
</dependencies>
139179

140180
<build>

src/main/java/pl/project13/jgit/DescribeCommand.java

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public DescribeCommand always(boolean always) {
180180
public DescribeCommand forceLongFormat(@Nullable Boolean forceLongFormat) {
181181
if (forceLongFormat != null) {
182182
this.forceLongFormat = forceLongFormat;
183-
log("--long = %s", forceLongFormat);
183+
log("--long =", forceLongFormat);
184184
}
185185
return this;
186186
}
@@ -312,21 +312,22 @@ public DescribeResult call() throws GitAPIException {
312312
// check if dirty
313313
boolean dirty = findDirtyState(repo);
314314

315-
if (hasTags(headCommit, tagObjectIdToName)) {
315+
if (hasTags(headCommit, tagObjectIdToName) && !forceLongFormat) {
316316
String tagName = tagObjectIdToName.get(headCommit).iterator().next();
317-
log("The commit we're on is a Tag ([",tagName,"]), returning.");
317+
log("The commit we're on is a Tag ([",tagName,"]) and forceLongFormat == false, returning.");
318318

319319
return new DescribeResult(tagName, dirty, dirtyOption);
320320
}
321321

322-
if (foundZeroTags(tagObjectIdToName)) {
322+
// get commits, up until the nearest tag
323+
List<RevCommit> commits = findCommitsUntilSomeTag(repo, headCommit, tagObjectIdToName);
324+
325+
// if there is no tags or any tag is not on that branch then return generic describe
326+
if (foundZeroTags(tagObjectIdToName) || commits.isEmpty()) {
323327
return new DescribeResult(objectReader, headCommitId, dirty, dirtyOption)
324328
.withCommitIdAbbrev(abbrev);
325329
}
326330

327-
// get commits, up until the nearest tag
328-
List<RevCommit> commits = findCommitsUntilSomeTag(repo, headCommit, tagObjectIdToName);
329-
330331
// check how far away from a tag we are
331332

332333
int distance = distanceBetween(repo, headCommit, commits.get(0));
@@ -350,7 +351,7 @@ private DescribeResult createDescribeResult(ObjectReader objectReader, ObjectId
350351
.withCommitIdAbbrev(abbrev);
351352

352353
} else if (howFarFromWhichTag.first > 0 || forceLongFormat) {
353-
return new DescribeResult(objectReader, howFarFromWhichTag.second, howFarFromWhichTag.first, headCommitId, dirty, dirtyOption)
354+
return new DescribeResult(objectReader, howFarFromWhichTag.second, howFarFromWhichTag.first, headCommitId, dirty, dirtyOption, forceLongFormat)
354355
.withCommitIdAbbrev(abbrev); // we're a bit away from a tag
355356

356357
} else if (howFarFromWhichTag.first == 0) {
@@ -425,7 +426,7 @@ private List<RevCommit> findCommitsUntilSomeTag(Repository repo, RevCommit head,
425426
}
426427
}
427428

428-
throw new RuntimeException("Did not find any commits until some tag");
429+
return Collections.emptyList();
429430
} catch (Exception e) {
430431
throw new RuntimeException("Unable to find commits until some tag", e);
431432
}

src/main/java/pl/project13/jgit/DescribeResult.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ public class DescribeResult {
4949
private boolean dirty;
5050
private String dirtyMarker;
5151

52+
private boolean forceLongFormat;
53+
5254
private ObjectReader objectReader;
5355

5456
public static final DescribeResult EMPTY = new DescribeResult("");
@@ -58,7 +60,7 @@ public DescribeResult(@NotNull String tagName) {
5860
}
5961

6062
public DescribeResult(@NotNull ObjectReader objectReader, String tagName, int commitsAwayFromTag, @Nullable ObjectId commitId) {
61-
this(objectReader, tagName, commitsAwayFromTag, commitId, false, Optional.<String>absent());
63+
this(objectReader, tagName, commitsAwayFromTag, commitId, false, Optional.<String>absent(), false);
6264
}
6365

6466
public DescribeResult(@NotNull ObjectReader objectReader, @NotNull ObjectId commitId) {
@@ -69,13 +71,14 @@ public DescribeResult(@NotNull ObjectReader objectReader, @NotNull ObjectId comm
6971
}
7072

7173
public DescribeResult(@NotNull ObjectReader objectReader, String tagName, int commitsAwayFromTag, ObjectId commitId, boolean dirty, String dirtyMarker) {
72-
this(objectReader, tagName, commitsAwayFromTag, commitId, dirty, Optional.of(dirtyMarker));
74+
this(objectReader, tagName, commitsAwayFromTag, commitId, dirty, Optional.of(dirtyMarker), false);
7375
}
7476

75-
public DescribeResult(@NotNull ObjectReader objectReader, String tagName, int commitsAwayFromTag, ObjectId commitId, boolean dirty, Optional<String> dirtyMarker) {
77+
public DescribeResult(@NotNull ObjectReader objectReader, String tagName, int commitsAwayFromTag, ObjectId commitId, boolean dirty, Optional<String> dirtyMarker, boolean forceLongFormat) {
7678
this(objectReader, commitId, dirty, dirtyMarker);
7779
this.tagName = Optional.of(tagName);
7880
this.commitsAwayFromTag = commitsAwayFromTag;
81+
this.forceLongFormat = forceLongFormat;
7982
}
8083

8184
public DescribeResult(@NotNull ObjectReader objectReader, @NotNull ObjectId commitId, boolean dirty, @NotNull Optional<String> dirtyMarker) {
@@ -145,6 +148,9 @@ private boolean abbrevZeroHidesCommitsPartOfDescribe() {
145148

146149
@Nullable
147150
public String commitsAwayFromTag() {
151+
if (forceLongFormat) {
152+
return String.valueOf(commitsAwayFromTag);
153+
}
148154
return commitsAwayFromTag == 0 ? null : String.valueOf(commitsAwayFromTag);
149155
}
150156

0 commit comments

Comments
 (0)