mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-10 15:35:59 +01:00
Format
This commit is contained in:
@@ -31,7 +31,8 @@ case class ApiPullRequest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
object ApiPullRequest{
|
object ApiPullRequest{
|
||||||
def apply(issue: Issue, pullRequest: PullRequest, headRepo: ApiRepository, baseRepo: ApiRepository, user: ApiUser): ApiPullRequest = ApiPullRequest(
|
def apply(issue: Issue, pullRequest: PullRequest, headRepo: ApiRepository, baseRepo: ApiRepository, user: ApiUser): ApiPullRequest =
|
||||||
|
ApiPullRequest(
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
updated_at = issue.updatedDate,
|
updated_at = issue.updatedDate,
|
||||||
created_at = issue.registeredDate,
|
created_at = issue.registeredDate,
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ case class ApiRepository(
|
|||||||
`private`: Boolean,
|
`private`: Boolean,
|
||||||
default_branch: String,
|
default_branch: String,
|
||||||
owner: ApiUser)(urlIsHtmlUrl: Boolean) {
|
owner: ApiUser)(urlIsHtmlUrl: Boolean) {
|
||||||
val forks_count = forks
|
val forks_count = forks
|
||||||
val watchers_count = watchers
|
val watchers_count = watchers
|
||||||
val url = if(urlIsHtmlUrl){
|
val url = if(urlIsHtmlUrl){
|
||||||
ApiPath(s"/${full_name}")
|
ApiPath(s"/${full_name}")
|
||||||
}else{
|
} else {
|
||||||
ApiPath(s"/api/v3/repos/${full_name}")
|
ApiPath(s"/api/v3/repos/${full_name}")
|
||||||
}
|
}
|
||||||
val http_url = ApiPath(s"/git/${full_name}.git")
|
val http_url = ApiPath(s"/git/${full_name}.git")
|
||||||
@@ -34,14 +34,14 @@ object ApiRepository{
|
|||||||
watchers: Int = 0,
|
watchers: Int = 0,
|
||||||
urlIsHtmlUrl: Boolean = false): ApiRepository =
|
urlIsHtmlUrl: Boolean = false): ApiRepository =
|
||||||
ApiRepository(
|
ApiRepository(
|
||||||
name = repository.repositoryName,
|
name = repository.repositoryName,
|
||||||
full_name = s"${repository.userName}/${repository.repositoryName}",
|
full_name = s"${repository.userName}/${repository.repositoryName}",
|
||||||
description = repository.description.getOrElse(""),
|
description = repository.description.getOrElse(""),
|
||||||
watchers = 0,
|
watchers = 0,
|
||||||
forks = forkedCount,
|
forks = forkedCount,
|
||||||
`private` = repository.isPrivate,
|
`private` = repository.isPrivate,
|
||||||
default_branch = repository.defaultBranch,
|
default_branch = repository.defaultBranch,
|
||||||
owner = owner
|
owner = owner
|
||||||
)(urlIsHtmlUrl)
|
)(urlIsHtmlUrl)
|
||||||
|
|
||||||
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
||||||
|
|||||||
@@ -119,7 +119,9 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
}) getOrElse NotFound
|
}) getOrElse NotFound
|
||||||
})
|
})
|
||||||
|
|
||||||
/** 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/:branch")(ownerOnly { repository =>
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api._
|
||||||
(for{
|
(for{
|
||||||
@@ -261,18 +263,28 @@ trait ApiControllerBase extends ControllerBase {
|
|||||||
* https://developer.github.com/v3/pulls/#list-pull-requests
|
* https://developer.github.com/v3/pulls/#list-pull-requests
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository/pulls")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository/pulls")(referrersOnly { repository =>
|
||||||
val page = IssueSearchCondition.page(request)
|
val page = IssueSearchCondition.page(request)
|
||||||
// TODO: more api spec condition
|
// TODO: more api spec condition
|
||||||
val condition = IssueSearchCondition(request)
|
val condition = IssueSearchCondition(request)
|
||||||
val baseOwner = getAccountByUserName(repository.owner).get
|
val baseOwner = getAccountByUserName(repository.owner).get
|
||||||
val issues:List[(Issue, Account, Int, PullRequest, Repository, Account)] = searchPullRequestByApi(condition, (page - 1) * PullRequestLimit, PullRequestLimit, repository.owner -> repository.name)
|
|
||||||
JsonFormat(issues.map{case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
val issues: List[(Issue, Account, Int, PullRequest, Repository, Account)] =
|
||||||
|
searchPullRequestByApi(
|
||||||
|
condition = condition,
|
||||||
|
offset = (page - 1) * PullRequestLimit,
|
||||||
|
limit = PullRequestLimit,
|
||||||
|
repos = repository.owner -> repository.name
|
||||||
|
)
|
||||||
|
|
||||||
|
JsonFormat(issues.map { case (issue, issueUser, commentCount, pullRequest, headRepo, headOwner) =>
|
||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
issue,
|
issue,
|
||||||
pullRequest,
|
pullRequest,
|
||||||
ApiRepository(headRepo, ApiUser(headOwner)),
|
ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
ApiRepository(repository, ApiUser(baseOwner)),
|
ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
ApiUser(issueUser)) })
|
ApiUser(issueUser)
|
||||||
|
)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user