Skip to content

Commit 038d8d6

Browse files
authored
Bump to GitBucket 4.32, sbt-gitbucket-plugin 1.5.0 and Scala 2.13.0 (#57)
1 parent 4815585 commit 038d8d6

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This is a GitBucket plug-in which provides code snippet repository like Gist.
44

55
Plugin version | GitBucket version
66
:--------------|:--------------------
7+
4.18.x | 4.32.x -
78
4.17.x | 4.30.x -
89
4.16.x | 4.26.x -
910
4.15.x | 4.25.x -
@@ -29,7 +30,7 @@ Plugin version | GitBucket version
2930

3031
## Installation
3132

32-
Download jar file from [plugin registry](https://plugins.gitbucket-community.org/releases/gitbucket-gist-plugin) and put into `GITBUCKET_HOME/plugins`.
33+
Download jar file from [Releases page](https://github.com/gitbucket/gitbucket-gist-plugin/releases) and put into `GITBUCKET_HOME/plugins`.
3334

3435
**Note:** If you had used this plugin with GitBucket 3.x, it does not work after upgrading to GitBucket 4.x. Solution is below:
3536

build.sbt

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
organization := "io.github.gitbucket"
22
name := "gitbucket-gist-plugin"
3-
version := "4.18.0"
4-
scalaVersion := "2.12.8"
5-
gitbucketVersion := "4.31.2"
3+
version := "4.18.0-SNAPSHOT"
4+
scalaVersion := "2.13.0"
5+
gitbucketVersion := "4.32.0"
66

77
scalacOptions := Seq("-deprecation", "-feature", "-language:postfixOps")
88
javacOptions in compile ++= Seq("-target", "8", "-source", "8")

src/main/scala/Plugin.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ class Plugin extends gitbucket.core.plugin.Plugin {
3939
new Version("4.14.0"),
4040
new Version("4.15.0"),
4141
new Version("4.16.0"),
42-
new Version("4.17.0")
42+
new Version("4.17.0"),
43+
new Version("4.18.0")
4344
)
4445

4546
override def initialize(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = {

src/main/scala/gitbucket/gist/controller/GistController.scala

+8-7
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import org.eclipse.jgit.lib._
2525
import org.scalatra.Ok
2626
import play.twirl.api.Html
2727
import play.twirl.api.JavaScript
28+
import scala.util.Using
2829

2930
class GistController extends GistControllerBase with GistService with GistCommentService with AccountService
3031
with GistEditorAuthenticator with UsersAuthenticator
@@ -88,7 +89,7 @@ trait GistControllerBase extends ControllerBase {
8889
val repoName = params("repoName")
8990
val gitdir = new File(GistRepoDir, userName + "/" + repoName)
9091
if(gitdir.exists){
91-
using(Git.open(gitdir)){ git =>
92+
Using.resource(Git.open(gitdir)){ git =>
9293
val files: Seq[(String, JGitUtil.ContentInfo)] = JGitUtil.getFileList(git, "master", ".").map { file =>
9394
(if(isGistFile(file.name)) "" else file.name) -> JGitUtil.getContentInfo(git, file.name, file.id)
9495
}
@@ -126,7 +127,7 @@ trait GistControllerBase extends ControllerBase {
126127
)
127128

128129
// Commit files
129-
using(Git.open(gitdir)){ git =>
130+
Using.resource(Git.open(gitdir)){ git =>
130131
commitFiles(git, loginAccount, "Initial commit", files)
131132
}
132133

@@ -155,7 +156,7 @@ trait GistControllerBase extends ControllerBase {
155156

156157
// Commit files
157158
val gitdir = new File(GistRepoDir, userName + "/" + repoName)
158-
using(Git.open(gitdir)){ git =>
159+
Using.resource(Git.open(gitdir)){ git =>
159160
val commitId = commitFiles(git, loginAccount, "Update", files)
160161

161162
// update refs
@@ -189,7 +190,7 @@ trait GistControllerBase extends ControllerBase {
189190
val repoName = params("repoName")
190191
val gitdir = new File(GistRepoDir, userName + "/" + repoName)
191192

192-
using(Git.open(gitdir)){ git =>
193+
Using.resource(Git.open(gitdir)){ git =>
193194
JGitUtil.getCommitLog(git, "master") match {
194195
case Right((revisions, hasNext)) => {
195196
val commits = revisions.map { revision =>
@@ -222,7 +223,7 @@ trait GistControllerBase extends ControllerBase {
222223
val fileName = params("fileName")
223224
val gitdir = new File(GistRepoDir, userName + "/" + repoName)
224225
if(gitdir.exists){
225-
using(Git.open(gitdir)){ git =>
226+
Using.resource(Git.open(gitdir)){ git =>
226227
val gist = getGist(userName, repoName).get
227228

228229
if(gist.mode == "PUBLIC" || context.loginAccount.exists(x => x.isAdmin || x.userName == userName)){
@@ -245,7 +246,7 @@ trait GistControllerBase extends ControllerBase {
245246
val userName = params("userName")
246247
val repoName = params("repoName")
247248

248-
using(Git.open(new File(GistRepoDir, userName + "/" + repoName))){ git =>
249+
Using.resource(Git.open(new File(GistRepoDir, userName + "/" + repoName))){ git =>
249250
val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve("master"))
250251

251252
contentType = "application/octet-stream"
@@ -521,7 +522,7 @@ trait GistControllerBase extends ControllerBase {
521522

522523
private def getGistFiles(userName: String, repoName: String, revision: String = "master"): Seq[(String, String)] = {
523524
val gitdir = new File(GistRepoDir, userName + "/" + repoName)
524-
using(Git.open(gitdir)){ git =>
525+
Using.resource(Git.open(gitdir)){ git =>
525526
JGitUtil.getFileList(git, revision, ".").map { file =>
526527
file.name -> StringUtil.convertFromByteArray(JGitUtil.getContentFromId(git, file.id, true).get)
527528
}

src/main/twirl/gitbucket/gist/edit.scala.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ <h1 style="margin: 0px;">New snippet</h1>
3535
<form id="form" method="POST" action="#">
3636
<input type="text" name="description" id="description" class="form-control" style="margin-bottom: 8px;" value="@gist.map(_.description)" placeholder="Snippet descriptions..."/>
3737
<div id="editors">
38-
@files.zipWithIndex.map { case ((fileName, content), i) =>
38+
@files.zipWithIndex.map { case ((fileName, content), i) => {
3939
@gitbucket.gist.html.editor(i, fileName, content)
40-
}
40+
}}
4141
</div>
4242
<div>
4343
<input type="button" value="Add file" class="btn btn-default" id="add_file">

0 commit comments

Comments
 (0)