diff --git a/CHANGELOG.md b/CHANGELOG.md index d8ac29d..ecfed8f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog All changes to the project will be documented in this file. +### 4.23.1 - 10 Apr 2018 +- Fix bug that the contents API doesn't work for the repository root +- Fix shutdown problem in Tomcat deployment +- Render by plugins at the blob view even if it's a binary file + ### 4.23.0 - 31 Mar 2018 - Allow tail slash in URL - Display commit message of tags at the releases page diff --git a/README.md b/README.md index e74498d..59c0b07 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,11 @@ What's New in 4.23.x ------------- +### 4.23.1 - 10 Apr 2018 +- Fix bug that the contents API doesn't work for the repository root +- Fix shutdown problem in Tomcat deployment +- Render by plugins at the blob view even if it's a binary file + ### 4.23.0 - 31 Mar 2018 - Allow tail slash in URL - Display commit message of tags at the releases page diff --git a/build.sbt b/build.sbt index 4b6145e..10723d9 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ val Organization = "io.github.gitbucket" val Name = "gitbucket" -val GitBucketVersion = "4.23.0" +val GitBucketVersion = "4.23.1" val ScalatraVersion = "2.6.1" val JettyVersion = "9.4.7.v20170914" diff --git a/project/build.properties b/project/build.properties index 0531343..609a2d1 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.2 +sbt.version=1.1.3 diff --git a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala index fb0bad1..656bc98 100644 --- a/src/main/scala/gitbucket/core/GitBucketCoreModule.scala +++ b/src/main/scala/gitbucket/core/GitBucketCoreModule.scala @@ -51,5 +51,7 @@ new Version("4.21.2"), new Version("4.22.0", new LiquibaseMigration("update/gitbucket-core_4.22.xml")), new Version("4.23.0", new LiquibaseMigration("update/gitbucket-core_4.23.xml")), + new Version("4.23.0", new LiquibaseMigration("update/gitbucket-core_4.23.xml")), + new Version("4.23.1") new Version("4.24.0", new LiquibaseMigration("update/gitbucket-core_4.24.xml")) ) diff --git a/src/main/scala/gitbucket/core/controller/ApiController.scala b/src/main/scala/gitbucket/core/controller/ApiController.scala index 1cf042d..79fd56e 100644 --- a/src/main/scala/gitbucket/core/controller/ApiController.scala +++ b/src/main/scala/gitbucket/core/controller/ApiController.scala @@ -161,7 +161,18 @@ /* * https://developer.github.com/v3/repos/contents/#get-contents */ + get("/api/v3/repos/:owner/:repo/contents")(referrersOnly { repository => + getContents(repository, ".", params.getOrElse("ref", repository.repository.defaultBranch)) + }) + + /* + * https://developer.github.com/v3/repos/contents/#get-contents + */ get("/api/v3/repos/:owner/:repo/contents/*")(referrersOnly { repository => + getContents(repository, multiParams("splat").head, params.getOrElse("ref", repository.repository.defaultBranch)) + }) + + private def getContents(repository: RepositoryService.RepositoryInfo, path: String, refStr: String) = { def getFileInfo(git: Git, revision: String, pathStr: String): Option[FileInfo] = { val (dirName, fileName) = pathStr.lastIndexOf('/') match { case -1 => @@ -172,69 +183,61 @@ getFileList(git, revision, dirName).find(f => f.name.equals(fileName)) } - val path = multiParams("splat").head match { - case s if s.isEmpty => "." - case s => s - } - val refStr = params.getOrElse("ref", repository.repository.defaultBranch) - - using(Git.open(getRepositoryDir(params("owner"), params("repo")))) { - git => - val fileList = getFileList(git, refStr, path) - if (fileList.isEmpty) { // file or NotFound - getFileInfo(git, refStr, path) - .flatMap(f => { - val largeFile = params.get("large_file").exists(s => s.equals("true")) - val content = getContentFromId(git, f.id, largeFile) - request.getHeader("Accept") match { - case "application/vnd.github.v3.raw" => { - contentType = "application/vnd.github.v3.raw" - content - } - case "application/vnd.github.v3.html" if isRenderable(f.name) => { - contentType = "application/vnd.github.v3.html" - content.map( - c => - List( - "
", - play.twirl.api.HtmlFormat.escape(new String(c)).body, - "", - "
", + play.twirl.api.HtmlFormat.escape(new String(c)).body, + "", + "