mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-09 06:55:54 +01:00
fix repository.url on webhook push payload
This commit is contained in:
@@ -13,10 +13,14 @@ case class ApiRepository(
|
|||||||
forks: Int,
|
forks: Int,
|
||||||
`private`: Boolean,
|
`private`: Boolean,
|
||||||
default_branch: String,
|
default_branch: String,
|
||||||
owner: ApiUser) {
|
owner: ApiUser)(urlIsHtmlUrl: Boolean) {
|
||||||
val forks_count = forks
|
val forks_count = forks
|
||||||
val watchers_count = watchers
|
val watchers_count = watchers
|
||||||
val url = ApiPath(s"/api/v3/repos/${full_name}")
|
val url = if(urlIsHtmlUrl){
|
||||||
|
ApiPath(s"/${full_name}")
|
||||||
|
}else{
|
||||||
|
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")
|
||||||
val clone_url = ApiPath(s"/git/${full_name}.git")
|
val clone_url = ApiPath(s"/git/${full_name}.git")
|
||||||
val html_url = ApiPath(s"/${full_name}")
|
val html_url = ApiPath(s"/${full_name}")
|
||||||
@@ -27,7 +31,8 @@ object ApiRepository{
|
|||||||
repository: Repository,
|
repository: Repository,
|
||||||
owner: ApiUser,
|
owner: ApiUser,
|
||||||
forkedCount: Int =0,
|
forkedCount: Int =0,
|
||||||
watchers: Int = 0): ApiRepository =
|
watchers: Int = 0,
|
||||||
|
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}",
|
||||||
@@ -37,7 +42,7 @@ object ApiRepository{
|
|||||||
`private` = repository.isPrivate,
|
`private` = repository.isPrivate,
|
||||||
default_branch = repository.defaultBranch,
|
default_branch = repository.defaultBranch,
|
||||||
owner = owner
|
owner = owner
|
||||||
)
|
)(urlIsHtmlUrl)
|
||||||
|
|
||||||
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
||||||
ApiRepository(repositoryInfo.repository, owner, forkedCount=repositoryInfo.forkedCount)
|
ApiRepository(repositoryInfo.repository, owner, forkedCount=repositoryInfo.forkedCount)
|
||||||
@@ -45,4 +50,7 @@ object ApiRepository{
|
|||||||
def apply(repositoryInfo: RepositoryInfo, owner: Account): ApiRepository =
|
def apply(repositoryInfo: RepositoryInfo, owner: Account): ApiRepository =
|
||||||
this(repositoryInfo.repository, ApiUser(owner))
|
this(repositoryInfo.repository, ApiUser(owner))
|
||||||
|
|
||||||
|
def forPushPayload(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
||||||
|
ApiRepository(repositoryInfo.repository, owner, forkedCount=repositoryInfo.forkedCount, urlIsHtmlUrl=true)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -217,10 +217,9 @@ object WebHookService {
|
|||||||
before = ObjectId.toString(oldId),
|
before = ObjectId.toString(oldId),
|
||||||
after = ObjectId.toString(newId),
|
after = ObjectId.toString(newId),
|
||||||
commits = commits.map{ commit => ApiPushCommit(git, RepositoryName(repositoryInfo), commit) },
|
commits = commits.map{ commit => ApiPushCommit(git, RepositoryName(repositoryInfo), commit) },
|
||||||
repository = ApiRepository(
|
repository = ApiRepository.forPushPayload(
|
||||||
repositoryInfo,
|
repositoryInfo,
|
||||||
owner= ApiUser(repositoryOwner)
|
owner= ApiUser(repositoryOwner))
|
||||||
)
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class JsonFormatSpec extends Specification {
|
|||||||
forks = 0,
|
forks = 0,
|
||||||
`private` = false,
|
`private` = false,
|
||||||
default_branch = "master",
|
default_branch = "master",
|
||||||
owner = apiUser)
|
owner = apiUser)(urlIsHtmlUrl = false)
|
||||||
val repositoryJson = s"""{
|
val repositoryJson = s"""{
|
||||||
"name" : "Hello-World",
|
"name" : "Hello-World",
|
||||||
"full_name" : "octocat/Hello-World",
|
"full_name" : "octocat/Hello-World",
|
||||||
|
|||||||
Reference in New Issue
Block a user