Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use JGit 7.0.0, require Java 17 and Jenkins 2.463 or newer #1170

Merged
merged 2 commits into from
Sep 12, 2024
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
12 changes: 8 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,19 @@
</scm>

<properties>
<revision>5.0.1</revision>
<revision>6.0.0</revision>
<changelist>-SNAPSHOT</changelist>
<!-- Character set tests fail unless file.encoding is set -->
<argLine>-Dfile.encoding=${project.build.sourceEncoding}</argLine>
<gitHubRepo>jenkinsci/${project.artifactId}-plugin</gitHubRepo>
<!-- https://www.jenkins.io/doc/developer/plugin-development/choosing-jenkins-baseline/ -->
<jenkins.baseline>2.440</jenkins.baseline>
<jenkins.version>${jenkins.baseline}.3</jenkins.version>
<jgit.version>6.10.0.202406032230-r</jgit.version>
<jenkins.baseline>2.462</jenkins.baseline>
<!-- TODO Replace with the standard jenkins.baseline references after LTS requires Java 17 -->
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This TODO can now be completed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<!-- <jenkins.version>${jenkins.baseline}.1</jenkins.version> -->
<jenkins.version>2.463</jenkins.version>
<jgit.version>7.0.0.202409031743-r</jgit.version>
<!-- TODO JENKINS-73339 until in parent POM -->
<maven.compiler.release>17</maven.compiler.release>
<spotbugs.effort>Max</spotbugs.effort>
<spotbugs.threshold>Low</spotbugs.threshold>
<spotless.check.skip>false</spotless.check.skip>
Expand Down
22 changes: 15 additions & 7 deletions src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@

if (repo.resolve(ref) != null) {
// ref is either an existing reference or a shortcut to a tag or branch (without refs/heads/)
git(repo).checkout().setName(ref).setForce(true).call();
git(repo).checkout().setName(ref).setForceRefUpdate(true).call();
return;
}

Expand Down Expand Up @@ -550,7 +550,7 @@
.checkout()
.setName(branch)
.setCreateBranch(true)
.setForce(true)
.setForceRefUpdate(true)
.setStartPoint(ref)
.call();
} catch (GitAPIException e) {
Expand Down Expand Up @@ -2063,7 +2063,11 @@
}
final boolean found;
try (Repository repo = getRepository()) {
found = repo.hasObject(commit);
try {
found = repo.getObjectDatabase().has(commit);
} catch (IOException ioe) {
throw new GitException(ioe);

Check warning on line 2069 in src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 2068-2069 are not covered by tests
}
}
return found;
}
Expand Down Expand Up @@ -2903,7 +2907,7 @@

Map<ObjectId, Ref> tags = new HashMap<>();
for (Ref r : repo.getTags().values()) {
ObjectId key = repo.peel(r).getPeeledObjectId();
ObjectId key = repo.getRefDatabase().peel(r).getPeeledObjectId();
if (key == null) {
key = r.getObjectId();
}
Expand Down Expand Up @@ -3157,9 +3161,13 @@
String tagName = entry.getKey();
Ref tagRef = entry.getValue();
if (!tagRef.isPeeled()) {
Ref peeledRef = repo.peel(tagRef);
if (peeledRef.getPeeledObjectId() != null) {
tagRef = peeledRef; // Use peeled ref instead of annotated ref
try {
Ref peeledRef = repo.getRefDatabase().peel(tagRef);
if (peeledRef.getPeeledObjectId() != null) {
tagRef = peeledRef; // Use peeled ref instead of annotated ref
}
} catch (IOException ioe) {
throw new GitException(ioe);

Check warning on line 3170 in src/main/java/org/jenkinsci/plugins/gitclient/JGitAPIImpl.java

View check run for this annotation

ci.jenkins.io / Code Coverage

Not covered lines

Lines 3169-3170 are not covered by tests
}
}
/* Packed lightweight (non-annotated) tags can wind up peeled with no peeled obj ID */
Expand Down