Skip to content

Commit 3dc7a92

Browse files
committed
Issue #38: Adapt to Gerrit 3.2
Update to Gerrit API 3.2.0 and JGit 5.8.0.
1 parent cdc8a76 commit 3dc7a92

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

docu/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ with full SSO through Gerrit.
55

66
* License: [Apache Public License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
77
* [Home page](https://github.com/tomaswolf/gerrit-gitblit-plugin)
8-
* Installed plugin version: <em id='gerrit-gitblit-current-version'>3.1.171.0-SNAPSHOT</em> &mdash; <a id='gerrit-gitblit-version-check' style='display:none;' href='#'>Check for updates</a>
8+
* Installed plugin version: <em id='gerrit-gitblit-current-version'>3.2.171.0-SNAPSHOT</em> &mdash; <a id='gerrit-gitblit-version-check' style='display:none;' href='#'>Check for updates</a>
99

1010
For a list of contributors, see at [GitHub](https://github.com/tomaswolf/gerrit-gitblit-plugin/graphs/contributors).
1111

@@ -92,6 +92,6 @@ Report bugs or make feature requests at the [GitHub issue tracker](https://githu
9292

9393
<hr style="color: #C0C0C0; background-color: #C0C0C0; border-color: #C0C0C0; height: 2px;" />
9494
<div style="float:right;">
95-
<a href="https://github.com/tomaswolf/gerrit-gitblit-plugin" target="_blank">GitBlit plugin 3.1.171.0-SNAPSHOT</a>
95+
<a href="https://github.com/tomaswolf/gerrit-gitblit-plugin" target="_blank">GitBlit plugin 3.2.171.0-SNAPSHOT</a>
9696
</div>
9797
<script type="text/javascript" src="version_check.js"></script>

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ limitations under the License.
2020
<artifactId>gitblit-plugin</artifactId>
2121
<description>GitBlit for Gerrit integrated as a plugin</description>
2222
<name>Gerrit - GitBlit Plugin</name>
23-
<version>3.1.171.0-SNAPSHOT</version><!-- Gerrit API version followed by collapsed GitBlit version, followed by plugin version -->
23+
<version>3.2.171.0-SNAPSHOT</version><!-- Gerrit API version followed by collapsed GitBlit version, followed by plugin version -->
2424
<licenses>
2525
<license>
2626
<name>Apache License 2.0</name>
@@ -29,8 +29,8 @@ limitations under the License.
2929
</licenses>
3030
<properties>
3131
<Gerrit-ApiType>plugin</Gerrit-ApiType>
32-
<Gerrit-ApiVersion>3.1.0</Gerrit-ApiVersion>
33-
<JGit-Version>5.5.1.201910021850-r</JGit-Version>
32+
<Gerrit-ApiVersion>3.2.0</Gerrit-ApiVersion>
33+
<JGit-Version>5.8.0.202006091008-r</JGit-Version>
3434
<GitBlit-Version>1.7.1</GitBlit-Version>
3535
<Wicket-Version>1.4.22</Wicket-Version>
3636
<Lucene-Version>6.6.5</Lucene-Version>

src/main/java/com/gitblit/utils/JGitUtils.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.io.File;
1919
import java.io.IOException;
20+
import java.nio.charset.StandardCharsets;
2021
import java.nio.file.FileVisitResult;
2122
import java.nio.file.Files;
2223
import java.nio.file.Path;
@@ -2169,7 +2170,7 @@ public static boolean createOrphanBranch(Repository repository, String branchNam
21692170
}
21702171
try (ObjectInserter odi = repository.newObjectInserter()) {
21712172
// Create a blob object to insert into a tree
2172-
ObjectId blobId = odi.insert(Constants.OBJ_BLOB, message.getBytes(Constants.CHARACTER_ENCODING));
2173+
ObjectId blobId = odi.insert(Constants.OBJ_BLOB, message.getBytes(StandardCharsets.UTF_8));
21732174

21742175
// Create a tree object to reference from a commit
21752176
TreeFormatter tree = new TreeFormatter();
@@ -2180,7 +2181,7 @@ public static boolean createOrphanBranch(Repository repository, String branchNam
21802181
CommitBuilder commit = new CommitBuilder();
21812182
commit.setAuthor(author);
21822183
commit.setCommitter(author);
2183-
commit.setEncoding(Constants.CHARACTER_ENCODING);
2184+
commit.setEncoding(StandardCharsets.UTF_8);
21842185
commit.setMessage(message);
21852186
commit.setTreeId(treeId);
21862187

@@ -2435,7 +2436,7 @@ public static MergeResult merge(Repository repository, String src, String toBran
24352436
CommitBuilder commitBuilder = new CommitBuilder();
24362437
commitBuilder.setCommitter(committer);
24372438
commitBuilder.setAuthor(committer);
2438-
commitBuilder.setEncoding(Constants.CHARSET);
2439+
commitBuilder.setEncoding(StandardCharsets.UTF_8);
24392440
if (StringUtils.isEmpty(message)) {
24402441
message = MessageFormat.format("merge {0} into {1}", srcTip.getName(), branchTip.getName());
24412442
}

src/main/java/com/gitblit/utils/RefLogUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616
package com.gitblit.utils;
1717

1818
import java.io.IOException;
19+
import java.nio.charset.StandardCharsets;
1920
import java.text.DateFormat;
2021
import java.text.MessageFormat;
2122
import java.text.SimpleDateFormat;
23+
import java.time.Instant;
2224
import java.util.ArrayList;
2325
import java.util.Arrays;
2426
import java.util.Collection;
@@ -255,7 +257,7 @@ public static boolean updateRefLog(UserModel user, Repository repository, Collec
255257
CommitBuilder commit = new CommitBuilder();
256258
commit.setAuthor(ident);
257259
commit.setCommitter(ident);
258-
commit.setEncoding(Constants.ENCODING);
260+
commit.setEncoding(StandardCharsets.UTF_8);
259261
commit.setMessage(message);
260262
commit.setParentId(headId);
261263
commit.setTreeId(indexTreeId);
@@ -305,7 +307,7 @@ private static DirCache createIndex(Repository repo, ObjectId headId, Collection
305307
DirCache inCoreIndex = DirCache.newInCore();
306308
DirCacheBuilder dcBuilder = inCoreIndex.builder();
307309

308-
long now = System.currentTimeMillis();
310+
Instant now = Instant.now();
309311
Set<String> ignorePaths = new TreeSet<String>();
310312
try (ObjectInserter inserter = repo.newObjectInserter()) {
311313
// add receive commands to the temporary index
@@ -345,7 +347,7 @@ private static DirCache createIndex(Repository repo, ObjectId headId, Collection
345347
dcEntry.setFileMode(FileMode.REGULAR_FILE);
346348

347349
// insert object
348-
dcEntry.setObjectId(inserter.insert(org.eclipse.jgit.lib.Constants.OBJ_BLOB, content.getBytes("UTF-8")));
350+
dcEntry.setObjectId(inserter.insert(org.eclipse.jgit.lib.Constants.OBJ_BLOB, content.getBytes(StandardCharsets.UTF_8)));
349351

350352
// add to temporary in-core index
351353
dcBuilder.add(dcEntry);

0 commit comments

Comments
 (0)