Skip to content

Commit 9b662ca

Browse files
authored
Merge pull request #747 from MarkEWaite/reduce-jgit-portability-gap
Replace JGit 4.5 getRef with findRef or exactRef
2 parents 2db5cbf + ee5cea0 commit 9b662ca

File tree

2 files changed

+2
-7
lines changed

2 files changed

+2
-7
lines changed

src/main/java/jenkins/plugins/git/GitSCMFileSystem.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,7 @@ protected GitSCMFileSystem(GitClient client, String remote, final String head, @
113113
cacheEntry = AbstractGitSCMSource.getCacheEntry(remote);
114114
listener = new LogTaskListener(LOGGER, Level.FINER);
115115
this.client = client;
116-
commitId = rev == null ? invoke(new FSFunction<ObjectId>() {
117-
@Override
118-
public ObjectId invoke(Repository repository) throws IOException, InterruptedException {
119-
return repository.getRef(head).getObjectId();
120-
}
121-
}) : ObjectId.fromString(rev.getHash());
116+
commitId = rev == null ? invoke((Repository repository) -> repository.findRef(head).getObjectId()) : ObjectId.fromString(rev.getHash());
122117
}
123118

124119
@Override

src/test/java/hudson/plugins/git/GitSCMTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ public void testCheckoutToSpecificBranch() throws Exception {
16031603
GitClient gc = Git.with(StreamTaskListener.fromStdout(),null).in(b.getWorkspace()).getClient();
16041604
gc.withRepository(new RepositoryCallback<Void>() {
16051605
public Void invoke(Repository repo, VirtualChannel channel) throws IOException, InterruptedException {
1606-
Ref head = repo.getRef("HEAD");
1606+
Ref head = repo.findRef("HEAD");
16071607
assertTrue("Detached HEAD",head.isSymbolic());
16081608
Ref t = head.getTarget();
16091609
assertEquals(t.getName(),"refs/heads/master");

0 commit comments

Comments
 (0)