Merge pull request #2084 from gitbucket/github-compatible-url-lfs
Add forwarding GitHub compatible LFS url
commit 0e36ca0f7190ec8dfc69aa10618524428b4b9634
2 parents 3de7a3b + 5d8f1a7
@Naoki Takezoe Naoki Takezoe authored on 29 Jun 2018
GitHub committed on 29 Jun 2018
Showing 1 changed file
View
24
src/main/scala/gitbucket/core/controller/PreProcessController.scala
 
trait PreProcessControllerBase extends ControllerBase {
 
/**
* Provides GitHub compatible URLs for Git client.
*
* <ul>
* <li>git clone http://localhost:8080/owner/repo</li>
* <li>git clone http://localhost:8080/owner/repo.git</li>
* </ul>
*
* @see https://git-scm.com/book/en/v2/Git-Internals-Transfer-Protocols
* Provides GitHub compatible URLs (e.g. http://localhost:8080/owner/repo.git) for Git client.
*/
get("/*/*/info/refs") {
val query = Option(request.getQueryString).map("?" + _).getOrElse("")
halt(MovedPermanently(baseUrl + "/git" + request.getRequestURI + query))
}
 
/**
* Provides GitHub compatible URLs for GitLFS client.
*/
post("/*/*/info/lfs/objects/batch") {
val dispatcher = request.getRequestDispatcher("/git" + request.getRequestURI)
dispatcher.forward(request, response)
}
 
/**
* Filter requests from anonymous users.