mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 15:05:50 +01:00
Merge pull request #1683 from int128/fix-api-branch-with-slash
Fix branch API did not accept branch name with slash
This commit is contained in:
@@ -5,14 +5,15 @@ import gitbucket.core.model._
|
|||||||
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
import gitbucket.core.service.IssuesService.IssueSearchCondition
|
||||||
import gitbucket.core.service.PullRequestService._
|
import gitbucket.core.service.PullRequestService._
|
||||||
import gitbucket.core.service._
|
import gitbucket.core.service._
|
||||||
import gitbucket.core.util.SyntaxSugars._
|
|
||||||
import gitbucket.core.util.Directory._
|
import gitbucket.core.util.Directory._
|
||||||
import gitbucket.core.util.JGitUtil._
|
|
||||||
import gitbucket.core.util._
|
|
||||||
import gitbucket.core.util.Implicits._
|
import gitbucket.core.util.Implicits._
|
||||||
import gitbucket.core.view.helpers.{renderMarkup, isRenderable}
|
import gitbucket.core.util.JGitUtil._
|
||||||
|
import gitbucket.core.util.SyntaxSugars._
|
||||||
|
import gitbucket.core.util._
|
||||||
|
import gitbucket.core.view.helpers.{isRenderable, renderMarkup}
|
||||||
import org.eclipse.jgit.api.Git
|
import org.eclipse.jgit.api.Git
|
||||||
import org.scalatra.{NoContent, UnprocessableEntity, Created}
|
import org.scalatra.{Created, NoContent, UnprocessableEntity}
|
||||||
|
|
||||||
import scala.collection.JavaConverters._
|
import scala.collection.JavaConverters._
|
||||||
|
|
||||||
class ApiController extends ApiControllerBase
|
class ApiController extends ApiControllerBase
|
||||||
@@ -124,10 +125,10 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/repos/branches/#get-branch
|
* https://developer.github.com/v3/repos/branches/#get-branch
|
||||||
*/
|
*/
|
||||||
get ("/api/v3/repos/:owner/:repo/branches/:branch")(referrersOnly { repository =>
|
get ("/api/v3/repos/:owner/:repo/branches/*")(referrersOnly { repository =>
|
||||||
//import gitbucket.core.api._
|
//import gitbucket.core.api._
|
||||||
(for{
|
(for{
|
||||||
branch <- params.get("branch") if repository.branchList.contains(branch)
|
branch <- params.get("splat") if repository.branchList.contains(branch)
|
||||||
br <- getBranches(repository.owner, repository.name, repository.repository.defaultBranch, repository.repository.originUserName.isEmpty).find(_.name == branch)
|
br <- getBranches(repository.owner, repository.name, repository.repository.defaultBranch, repository.repository.originUserName.isEmpty).find(_.name == branch)
|
||||||
} yield {
|
} yield {
|
||||||
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
val protection = getProtectedBranchInfo(repository.owner, repository.name, branch)
|
||||||
@@ -286,10 +287,10 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
/**
|
/**
|
||||||
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
* https://developer.github.com/v3/repos/#enabling-and-disabling-branch-protection
|
||||||
*/
|
*/
|
||||||
patch("/api/v3/repos/:owner/:repo/branches/:branch")(ownerOnly { repository =>
|
patch("/api/v3/repos/:owner/:repo/branches/*")(ownerOnly { repository =>
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api._
|
||||||
(for{
|
(for{
|
||||||
branch <- params.get("branch") if repository.branchList.contains(branch)
|
branch <- params.get("splat") if repository.branchList.contains(branch)
|
||||||
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
protection <- extractFromJsonBody[ApiBranchProtection.EnablingAndDisabling].map(_.protection)
|
||||||
br <- getBranches(repository.owner, repository.name, repository.repository.defaultBranch, repository.repository.originUserName.isEmpty).find(_.name == branch)
|
br <- getBranches(repository.owner, repository.name, repository.repository.defaultBranch, repository.repository.originUserName.isEmpty).find(_.name == branch)
|
||||||
} yield {
|
} yield {
|
||||||
|
|||||||
Reference in New Issue
Block a user