From 02a6b0b4893d7fd0e9c8f08c75975689d5594759 Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Sun, 2 Jun 2019 23:13:53 +0900 Subject: [PATCH 1/2] Bump to GitBucket 4.32 and sbt-gitbucket-plugin 1.5.0 --- README.md | 3 ++- build.sbt | 6 +++--- project/plugins.sbt | 2 +- src/main/scala/Plugin.scala | 3 ++- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 56901d0..e0459d0 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This is a GitBucket plug-in which provides code snippet repository like Gist. Plugin version | GitBucket version :--------------|:-------------------- +4.18.x | 4.32.x - 4.17.x | 4.30.x - 4.16.x | 4.26.x - 4.15.x | 4.25.x - @@ -29,7 +30,7 @@ Plugin version | GitBucket version ## Installation -Download jar file from [plugin registry](https://plugins.gitbucket-community.org/releases/gitbucket-gist-plugin) and put into `GITBUCKET_HOME/plugins`. +Download jar file from [Releases page](https://github.com/gitbucket/gitbucket-gist-plugin/releases) and put into `GITBUCKET_HOME/plugins`. **Note:** If you had used this plugin with GitBucket 3.x, it does not work after upgrading to GitBucket 4.x. Solution is below: diff --git a/build.sbt b/build.sbt index 4394b7e..3fdc401 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ organization := "io.github.gitbucket" name := "gitbucket-gist-plugin" -version := "4.17.0" -scalaVersion := "2.12.7" -gitbucketVersion := "4.30.0" +version := "4.18.0-SNAPSHOT" +scalaVersion := "2.12.8" +gitbucketVersion := "4.32.0-SNAPSHOT" scalacOptions := Seq("-deprecation", "-feature", "-language:postfixOps") javacOptions in compile ++= Seq("-target", "8", "-source", "8") diff --git a/project/plugins.sbt b/project/plugins.sbt index d07a76b..20a74a0 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1 +1 @@ -addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.3.0") \ No newline at end of file +addSbtPlugin("io.github.gitbucket" % "sbt-gitbucket-plugin" % "1.5.0") \ No newline at end of file diff --git a/src/main/scala/Plugin.scala b/src/main/scala/Plugin.scala index 095739c..56349ed 100755 --- a/src/main/scala/Plugin.scala +++ b/src/main/scala/Plugin.scala @@ -39,7 +39,8 @@ class Plugin extends gitbucket.core.plugin.Plugin { new Version("4.14.0"), new Version("4.15.0"), new Version("4.16.0"), - new Version("4.17.0") + new Version("4.17.0"), + new Version("4.18.0") ) override def initialize(registry: PluginRegistry, context: ServletContext, settings: SystemSettings): Unit = { From 5313f96b4f21ca5a1d8bc16cf903baed50dd0eac Mon Sep 17 00:00:00 2001 From: Naoki Takezoe Date: Tue, 6 Aug 2019 23:27:47 +0900 Subject: [PATCH 2/2] Bump to Scala 2.13.0 --- build.sbt | 4 ++-- .../gist/controller/GistController.scala | 15 ++++++++------- src/main/twirl/gitbucket/gist/edit.scala.html | 4 ++-- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/build.sbt b/build.sbt index 3fdc401..81295dc 100644 --- a/build.sbt +++ b/build.sbt @@ -1,8 +1,8 @@ organization := "io.github.gitbucket" name := "gitbucket-gist-plugin" version := "4.18.0-SNAPSHOT" -scalaVersion := "2.12.8" -gitbucketVersion := "4.32.0-SNAPSHOT" +scalaVersion := "2.13.0" +gitbucketVersion := "4.32.0" scalacOptions := Seq("-deprecation", "-feature", "-language:postfixOps") javacOptions in compile ++= Seq("-target", "8", "-source", "8") diff --git a/src/main/scala/gitbucket/gist/controller/GistController.scala b/src/main/scala/gitbucket/gist/controller/GistController.scala index 5eec55f..1b9493e 100644 --- a/src/main/scala/gitbucket/gist/controller/GistController.scala +++ b/src/main/scala/gitbucket/gist/controller/GistController.scala @@ -25,6 +25,7 @@ import org.eclipse.jgit.lib._ import org.scalatra.Ok import play.twirl.api.Html import play.twirl.api.JavaScript +import scala.util.Using class GistController extends GistControllerBase with GistService with GistCommentService with AccountService with GistEditorAuthenticator with UsersAuthenticator @@ -88,7 +89,7 @@ trait GistControllerBase extends ControllerBase { val repoName = params("repoName") val gitdir = new File(GistRepoDir, userName + "/" + repoName) if(gitdir.exists){ - using(Git.open(gitdir)){ git => + Using.resource(Git.open(gitdir)){ git => val files: Seq[(String, JGitUtil.ContentInfo)] = JGitUtil.getFileList(git, "master", ".").map { file => (if(isGistFile(file.name)) "" else file.name) -> JGitUtil.getContentInfo(git, file.name, file.id) } @@ -126,7 +127,7 @@ trait GistControllerBase extends ControllerBase { ) // Commit files - using(Git.open(gitdir)){ git => + Using.resource(Git.open(gitdir)){ git => commitFiles(git, loginAccount, "Initial commit", files) } @@ -155,7 +156,7 @@ trait GistControllerBase extends ControllerBase { // Commit files val gitdir = new File(GistRepoDir, userName + "/" + repoName) - using(Git.open(gitdir)){ git => + Using.resource(Git.open(gitdir)){ git => val commitId = commitFiles(git, loginAccount, "Update", files) // update refs @@ -189,7 +190,7 @@ trait GistControllerBase extends ControllerBase { val repoName = params("repoName") val gitdir = new File(GistRepoDir, userName + "/" + repoName) - using(Git.open(gitdir)){ git => + Using.resource(Git.open(gitdir)){ git => JGitUtil.getCommitLog(git, "master") match { case Right((revisions, hasNext)) => { val commits = revisions.map { revision => @@ -222,7 +223,7 @@ trait GistControllerBase extends ControllerBase { val fileName = params("fileName") val gitdir = new File(GistRepoDir, userName + "/" + repoName) if(gitdir.exists){ - using(Git.open(gitdir)){ git => + Using.resource(Git.open(gitdir)){ git => val gist = getGist(userName, repoName).get if(gist.mode == "PUBLIC" || context.loginAccount.exists(x => x.isAdmin || x.userName == userName)){ @@ -245,7 +246,7 @@ trait GistControllerBase extends ControllerBase { val userName = params("userName") val repoName = params("repoName") - using(Git.open(new File(GistRepoDir, userName + "/" + repoName))){ git => + Using.resource(Git.open(new File(GistRepoDir, userName + "/" + repoName))){ git => val revCommit = JGitUtil.getRevCommitFromId(git, git.getRepository.resolve("master")) contentType = "application/octet-stream" @@ -521,7 +522,7 @@ trait GistControllerBase extends ControllerBase { private def getGistFiles(userName: String, repoName: String, revision: String = "master"): Seq[(String, String)] = { val gitdir = new File(GistRepoDir, userName + "/" + repoName) - using(Git.open(gitdir)){ git => + Using.resource(Git.open(gitdir)){ git => JGitUtil.getFileList(git, revision, ".").map { file => file.name -> StringUtil.convertFromByteArray(JGitUtil.getContentFromId(git, file.id, true).get) } diff --git a/src/main/twirl/gitbucket/gist/edit.scala.html b/src/main/twirl/gitbucket/gist/edit.scala.html index 968e94c..dd056fc 100644 --- a/src/main/twirl/gitbucket/gist/edit.scala.html +++ b/src/main/twirl/gitbucket/gist/edit.scala.html @@ -35,9 +35,9 @@

New snippet

- @files.zipWithIndex.map { case ((fileName, content), i) => + @files.zipWithIndex.map { case ((fileName, content), i) => { @gitbucket.gist.html.editor(i, fileName, content) - } + }}