Skip to content

Commit

Permalink
Upgrade jgit (#165)
Browse files Browse the repository at this point in the history
Upgrade Jgit to 5.3.2.201906051522-r
  • Loading branch information
ferozco authored and bulldozer-bot[bot] committed Sep 5, 2019
1 parent 99ac9e5 commit ce15b50
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 15 deletions.
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-165.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: Upgrade Jgit to 5.3.2.201906051522-r
links:
- https://github.com/palantir/gradle-git-version/pull/165
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,18 @@ private List<String> revList(ObjectId initialObjectId) throws IOException {
}

// Maps all commits returned by 'git show-ref --tags -d' to output of 'git describe --tags --exact-match <commit>'
private static Map<String, RefWithTagName> mapCommitsToTags(Git git) {
private static Map<String, RefWithTagName> mapCommitsToTags(Git git) throws IOException {
RefWithTagNameComparator comparator = new RefWithTagNameComparator(git);

// Maps commit hash to list of all refs pointing to given commit hash.
// All keys in this map should be same as commit hashes in 'git show-ref --tags -d'
Map<String, RefWithTagName> commitHashToTag = new HashMap<>();
for (Map.Entry<String, Ref> entry : git.getRepository().getTags().entrySet()) {
RefWithTagName refWithTagName = new RefWithTagName(entry.getValue(), entry.getKey());

for (Ref ref : git.getRepository().getRefDatabase().getRefsByPrefix(Constants.R_TAGS)) {
RefWithTagName refWithTagName = new RefWithTagName(ref, ref.getName().substring(Constants.R_TAGS.length()));
ObjectId peeledRef = refWithTagName.getRef().getPeeledObjectId();
if (peeledRef == null) {
// lightweight tag (commit object)
updateCommitHashMap(commitHashToTag, comparator, entry.getValue().getObjectId(), refWithTagName);
updateCommitHashMap(commitHashToTag, comparator, ref.getObjectId(), refWithTagName);
} else {
// annotated tag (tag object)
updateCommitHashMap(commitHashToTag, comparator, peeledRef, refWithTagName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,8 @@ class GitVersionPluginTests extends Specification {

// switch back to main branch and merge hotfix branch into main branch
git.checkout().setName(master).call()
git.merge().include(git.getRepository().getRef("hotfix")).setFastForward(MergeCommand.FastForwardMode.NO_FF).setMessage("merge commit").call()
git.merge().include(git.getRepository().getRefDatabase().findRef("hotfix"))
.setFastForward(MergeCommand.FastForwardMode.NO_FF).setMessage("merge commit").call()

when:
BuildResult buildResult = with('printVersion').build()
Expand Down Expand Up @@ -197,7 +198,8 @@ class GitVersionPluginTests extends Specification {

// switch back to main branch and merge hotfix branch into main branch
git.checkout().setName(master).call()
git.merge().include(git.getRepository().getRef("hotfix")).setFastForward(MergeCommand.FastForwardMode.NO_FF).setMessage("merge commit").call()
git.merge().include(git.getRepository().getRefDatabase().findRef("hotfix"))
.setFastForward(MergeCommand.FastForwardMode.NO_FF).setMessage("merge commit").call()

// tag merge commit on main branch as 2.0.0
git.tag().setAnnotated(true).setMessage('2.0.0').setName('2.0.0').call()
Expand Down
14 changes: 7 additions & 7 deletions versions.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ com.google.code.findbugs:jsr305:1.3.9 (1 constraints: 1f0af2b4)
com.google.errorprone:error_prone_annotations:2.0.18 (1 constraints: 4d0a33bf)
com.google.guava:guava:23.5-jre (1 constraints: 4c06b647)
com.google.j2objc:j2objc-annotations:1.1 (1 constraints: b609eba0)
com.googlecode.javaewah:JavaEWAH:0.7.9 (1 constraints: 500e8e50)
com.jcraft:jsch:0.1.53 (1 constraints: 790ef15e)
commons-codec:commons-codec:1.6 (1 constraints: c60f9b71)
commons-logging:commons-logging:1.1.3 (1 constraints: 2210a791)
org.apache.httpcomponents:httpclient:4.3.6 (1 constraints: 4d0e9350)
org.apache.httpcomponents:httpcore:4.3.3 (1 constraints: 2710bc91)
com.googlecode.javaewah:JavaEWAH:1.1.6 (1 constraints: 480e7e50)
com.jcraft:jsch:0.1.54 (1 constraints: 7a0ef25e)
com.jcraft:jzlib:1.1.1 (1 constraints: 430e7950)
org.bouncycastle:bcpg-jdk15on:1.60 (1 constraints: 190e4242)
org.bouncycastle:bcpkix-jdk15on:1.60 (1 constraints: 190e4242)
org.bouncycastle:bcprov-jdk15on:1.60 (3 constraints: e027607a)
org.checkerframework:checker-qual:2.0.0 (1 constraints: 140ae5b4)
org.codehaus.mojo:animal-sniffer-annotations:1.14 (1 constraints: ea09d5aa)
org.eclipse.jgit:org.eclipse.jgit:4.5.4.201711221230-r (1 constraints: 32085399)
org.eclipse.jgit:org.eclipse.jgit:5.3.2.201906051522-r (1 constraints: 3a087299)
org.slf4j:slf4j-api:1.7.2 (1 constraints: 4a0e8c50)

[Test dependencies]
Expand Down
2 changes: 1 addition & 1 deletion versions.props
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
org.eclipse.jgit:org.eclipse.jgit = 4.5.4.201711221230-r
org.eclipse.jgit:org.eclipse.jgit = 5.3.2.201906051522-r
com.google.guava:guava = 23.5-jre

# test dependencies
Expand Down

0 comments on commit ce15b50

Please sign in to comment.