Skip to content

Commit

Permalink
Issue #38: Adapt to Gerrit 3.2
Browse files Browse the repository at this point in the history
Update to Gerrit API 3.2.0 and JGit 5.8.0.
  • Loading branch information
tomaswolf committed Nov 2, 2020
1 parent cdc8a76 commit 3dc7a92
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
4 changes: 2 additions & 2 deletions docu/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with full SSO through Gerrit.

* License: [Apache Public License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
* [Home page](https://github.com/tomaswolf/gerrit-gitblit-plugin)
* 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>
* 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>

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

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

<hr style="color: #C0C0C0; background-color: #C0C0C0; border-color: #C0C0C0; height: 2px;" />
<div style="float:right;">
<a href="https://github.com/tomaswolf/gerrit-gitblit-plugin" target="_blank">GitBlit plugin 3.1.171.0-SNAPSHOT</a>
<a href="https://github.com/tomaswolf/gerrit-gitblit-plugin" target="_blank">GitBlit plugin 3.2.171.0-SNAPSHOT</a>
</div>
<script type="text/javascript" src="version_check.js"></script>
6 changes: 3 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License.
<artifactId>gitblit-plugin</artifactId>
<description>GitBlit for Gerrit integrated as a plugin</description>
<name>Gerrit - GitBlit Plugin</name>
<version>3.1.171.0-SNAPSHOT</version><!-- Gerrit API version followed by collapsed GitBlit version, followed by plugin version -->
<version>3.2.171.0-SNAPSHOT</version><!-- Gerrit API version followed by collapsed GitBlit version, followed by plugin version -->
<licenses>
<license>
<name>Apache License 2.0</name>
Expand All @@ -29,8 +29,8 @@ limitations under the License.
</licenses>
<properties>
<Gerrit-ApiType>plugin</Gerrit-ApiType>
<Gerrit-ApiVersion>3.1.0</Gerrit-ApiVersion>
<JGit-Version>5.5.1.201910021850-r</JGit-Version>
<Gerrit-ApiVersion>3.2.0</Gerrit-ApiVersion>
<JGit-Version>5.8.0.202006091008-r</JGit-Version>
<GitBlit-Version>1.7.1</GitBlit-Version>
<Wicket-Version>1.4.22</Wicket-Version>
<Lucene-Version>6.6.5</Lucene-Version>
Expand Down
7 changes: 4 additions & 3 deletions src/main/java/com/gitblit/utils/JGitUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileVisitResult;
import java.nio.file.Files;
import java.nio.file.Path;
Expand Down Expand Up @@ -2169,7 +2170,7 @@ public static boolean createOrphanBranch(Repository repository, String branchNam
}
try (ObjectInserter odi = repository.newObjectInserter()) {
// Create a blob object to insert into a tree
ObjectId blobId = odi.insert(Constants.OBJ_BLOB, message.getBytes(Constants.CHARACTER_ENCODING));
ObjectId blobId = odi.insert(Constants.OBJ_BLOB, message.getBytes(StandardCharsets.UTF_8));

// Create a tree object to reference from a commit
TreeFormatter tree = new TreeFormatter();
Expand All @@ -2180,7 +2181,7 @@ public static boolean createOrphanBranch(Repository repository, String branchNam
CommitBuilder commit = new CommitBuilder();
commit.setAuthor(author);
commit.setCommitter(author);
commit.setEncoding(Constants.CHARACTER_ENCODING);
commit.setEncoding(StandardCharsets.UTF_8);
commit.setMessage(message);
commit.setTreeId(treeId);

Expand Down Expand Up @@ -2435,7 +2436,7 @@ public static MergeResult merge(Repository repository, String src, String toBran
CommitBuilder commitBuilder = new CommitBuilder();
commitBuilder.setCommitter(committer);
commitBuilder.setAuthor(committer);
commitBuilder.setEncoding(Constants.CHARSET);
commitBuilder.setEncoding(StandardCharsets.UTF_8);
if (StringUtils.isEmpty(message)) {
message = MessageFormat.format("merge {0} into {1}", srcTip.getName(), branchTip.getName());
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/com/gitblit/utils/RefLogUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@
package com.gitblit.utils;

import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
Expand Down Expand Up @@ -255,7 +257,7 @@ public static boolean updateRefLog(UserModel user, Repository repository, Collec
CommitBuilder commit = new CommitBuilder();
commit.setAuthor(ident);
commit.setCommitter(ident);
commit.setEncoding(Constants.ENCODING);
commit.setEncoding(StandardCharsets.UTF_8);
commit.setMessage(message);
commit.setParentId(headId);
commit.setTreeId(indexTreeId);
Expand Down Expand Up @@ -305,7 +307,7 @@ private static DirCache createIndex(Repository repo, ObjectId headId, Collection
DirCache inCoreIndex = DirCache.newInCore();
DirCacheBuilder dcBuilder = inCoreIndex.builder();

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

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

// add to temporary in-core index
dcBuilder.add(dcEntry);
Expand Down

0 comments on commit 3dc7a92

Please sign in to comment.