mirror of
https://github.com/gitbucket/gitbucket.git
synced 2025-11-07 05:55:51 +01:00
This reverts commit 841e6d110c.
This commit is contained in:
@@ -1,58 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<changeSet>
|
|
||||||
<!-- add ID column to REPOSITORY table -->
|
|
||||||
|
|
||||||
<!-- drop other table's foreign keys -->
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_ACTIVITY_FK0" baseTableName="ACTIVITY"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_COLLABORATOR_FK0" baseTableName="COLLABORATOR"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_COMMIT_COMMENT_FK0" baseTableName="COMMIT_COMMENT"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_COMMIT_STATUS_FK1" baseTableName="COMMIT_STATUS"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_LABEL_FK0" baseTableName="LABEL"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_MILESTONE_FK0" baseTableName="MILESTONE"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_ISSUE_FK0" baseTableName="ISSUE"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_ISSUE_ID_FK1" baseTableName="ISSUE_ID"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_FK0" baseTableName="PROTECTED_BRANCH"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_DEPLOY_KEY_FK0" baseTableName="DEPLOY_KEY"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_PRIORITY_FK0" baseTableName="PRIORITY"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_RELEASE_TAG_FK0" baseTableName="RELEASE_TAG"/>
|
|
||||||
|
|
||||||
<!-- modify REPOSITORY table -->
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_REPOSITORY_FK0" baseTableName="REPOSITORY"/>
|
|
||||||
<dropPrimaryKey tableName="REPOSITORY" constraintName="IDX_REPOSITORY_PK"/>
|
|
||||||
<addColumn tableName="REPOSITORY">
|
|
||||||
<column name="REPOSITORY_ID" type="int" nullable="false" autoIncrement="false" unique="true"/>
|
|
||||||
</addColumn>
|
|
||||||
<addPrimaryKey constraintName="IDX_REPOSITORY_PK" tableName="REPOSITORY" columnNames="REPOSITORY_ID"/>
|
|
||||||
<addAutoIncrement tableName="REPOSITORY" columnName="REPOSITORY_ID" columnDataType="int"/>
|
|
||||||
<addUniqueConstraint constraintName="IDX_REPOSITORY_1" tableName="REPOSITORY" columnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_REPOSITORY_FK0" baseTableName="REPOSITORY" baseColumnNames="USER_NAME" referencedTableName="ACCOUNT" referencedColumnNames="USER_NAME"/>
|
|
||||||
|
|
||||||
<!-- Repair other table's foreign keys -->
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_ACTIVITY_FK0" baseTableName="ACTIVITY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_COLLABORATOR_FK0" baseTableName="COLLABORATOR" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_COMMIT_COMMENT_FK0" baseTableName="COMMIT_COMMENT" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_COMMIT_STATUS_FK1" baseTableName="COMMIT_STATUS" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_LABEL_FK0" baseTableName="LABEL" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_MILESTONE_FK0" baseTableName="MILESTONE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_ISSUE_FK0" baseTableName="ISSUE" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_ISSUE_ID_FK1" baseTableName="ISSUE_ID" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_PROTECTED_BRANCH_FK0" baseTableName="PROTECTED_BRANCH" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME" onDelete="CASCADE" onUpdate="CASCADE"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_DEPLOY_KEY_FK0" baseTableName="DEPLOY_KEY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_PRIORITY_FK0" baseTableName="PRIORITY" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_RELEASE_TAG_FK0" baseTableName="RELEASE_TAG" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
|
|
||||||
<!-- add ID column to WEB_HOOK table -->
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT"/>
|
|
||||||
<dropForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK"/>
|
|
||||||
<dropPrimaryKey tableName="WEB_HOOK" constraintName="IDX_WEB_HOOK_PK"/>
|
|
||||||
<addColumn tableName="WEB_HOOK">
|
|
||||||
<column name="WEB_HOOK_ID" type="int" nullable="false" autoIncrement="false" unique="true"/>
|
|
||||||
</addColumn>
|
|
||||||
<addPrimaryKey constraintName="IDX_WEB_HOOK_PK" tableName="WEB_HOOK" columnNames="WEB_HOOK_ID"/>
|
|
||||||
<addAutoIncrement tableName="WEB_HOOK" columnName="WEB_HOOK_ID" columnDataType="int"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_FK0" baseTableName="WEB_HOOK" baseColumnNames="USER_NAME, REPOSITORY_NAME" referencedTableName="REPOSITORY" referencedColumnNames="USER_NAME, REPOSITORY_NAME"/>
|
|
||||||
<addUniqueConstraint constraintName="IDX_WEB_HOOK_1" tableName="WEB_HOOK" columnNames="USER_NAME, REPOSITORY_NAME, URL"/>
|
|
||||||
<addForeignKeyConstraint constraintName="IDX_WEB_HOOK_EVENT_FK0" baseTableName="WEB_HOOK_EVENT" baseColumnNames="USER_NAME, REPOSITORY_NAME, URL" referencedTableName="WEB_HOOK" referencedColumnNames="USER_NAME, REPOSITORY_NAME, URL" onDelete="CASCADE" onUpdate="CASCADE"/>
|
|
||||||
</changeSet>
|
|
||||||
@@ -63,6 +63,5 @@ object GitBucketCoreModule
|
|||||||
new Version("4.30.1"),
|
new Version("4.30.1"),
|
||||||
new Version("4.31.0", new LiquibaseMigration("update/gitbucket-core_4.31.xml")),
|
new Version("4.31.0", new LiquibaseMigration("update/gitbucket-core_4.31.xml")),
|
||||||
new Version("4.31.1"),
|
new Version("4.31.1"),
|
||||||
new Version("4.31.2"),
|
new Version("4.31.2")
|
||||||
new Version("4.32.0", new LiquibaseMigration("update/gitbucket-core_4.32.xml"))
|
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
package gitbucket.core.api
|
|
||||||
import gitbucket.core.model.Account
|
|
||||||
|
|
||||||
case class ApiEmail(
|
|
||||||
email: String,
|
|
||||||
primary: Boolean
|
|
||||||
) {
|
|
||||||
val verified = true
|
|
||||||
val visibility = "public"
|
|
||||||
}
|
|
||||||
|
|
||||||
object ApiEmail {
|
|
||||||
def fromMailAddresses(primaryMailAddress: String, extraMailAddresses: List[String]): List[ApiEmail] = {
|
|
||||||
ApiEmail(primaryMailAddress, true) :: extraMailAddresses.map { ApiEmail(_, false) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
package gitbucket.core.api
|
|
||||||
import gitbucket.core.service.RepositoryService
|
|
||||||
|
|
||||||
case class ApiPermission(
|
|
||||||
admin: Boolean,
|
|
||||||
push: Boolean,
|
|
||||||
pull: Boolean
|
|
||||||
)
|
|
||||||
|
|
||||||
object ApiPermission {
|
|
||||||
def apply(permission: RepositoryService.RepositoryPermission): ApiPermission =
|
|
||||||
ApiPermission(permission.isOwner, permission.isDeveloper, permission.isGuest)
|
|
||||||
}
|
|
||||||
@@ -1,9 +1,6 @@
|
|||||||
package gitbucket.core.api
|
package gitbucket.core.api
|
||||||
|
|
||||||
import java.time.Instant
|
|
||||||
|
|
||||||
import gitbucket.core.model.{Account, Repository}
|
import gitbucket.core.model.{Account, Repository}
|
||||||
import gitbucket.core.service.RepositoryService
|
|
||||||
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
import gitbucket.core.service.RepositoryService.RepositoryInfo
|
||||||
|
|
||||||
// https://developer.github.com/v3/repos/
|
// https://developer.github.com/v3/repos/
|
||||||
@@ -11,17 +8,13 @@ case class ApiRepository(
|
|||||||
name: String,
|
name: String,
|
||||||
full_name: String,
|
full_name: String,
|
||||||
description: String,
|
description: String,
|
||||||
id: Int,
|
|
||||||
watchers: Int,
|
watchers: Int,
|
||||||
forks: Int,
|
forks: Int,
|
||||||
`private`: Boolean,
|
`private`: Boolean,
|
||||||
fork: Boolean,
|
|
||||||
default_branch: String,
|
default_branch: String,
|
||||||
owner: ApiUser,
|
owner: ApiUser
|
||||||
created_at: java.util.Date,
|
|
||||||
updated_at: java.util.Date,
|
|
||||||
permissions: Option[ApiPermission]
|
|
||||||
) {
|
) {
|
||||||
|
val id = 0 // dummy id
|
||||||
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 = ApiPath(s"/api/v3/repos/${full_name}")
|
||||||
@@ -35,7 +28,6 @@ object ApiRepository {
|
|||||||
def apply(
|
def apply(
|
||||||
repository: Repository,
|
repository: Repository,
|
||||||
owner: ApiUser,
|
owner: ApiUser,
|
||||||
permission: Option[RepositoryService.RepositoryPermission],
|
|
||||||
forkedCount: Int = 0,
|
forkedCount: Int = 0,
|
||||||
watchers: Int = 0
|
watchers: Int = 0
|
||||||
): ApiRepository =
|
): ApiRepository =
|
||||||
@@ -43,45 +35,28 @@ object 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(""),
|
||||||
id = repository.repositoryId,
|
|
||||||
watchers = watchers,
|
watchers = watchers,
|
||||||
forks = forkedCount,
|
forks = forkedCount,
|
||||||
`private` = repository.isPrivate,
|
`private` = repository.isPrivate,
|
||||||
fork = repository.parentRepositoryName.isDefined,
|
|
||||||
default_branch = repository.defaultBranch,
|
default_branch = repository.defaultBranch,
|
||||||
owner = owner,
|
owner = owner
|
||||||
created_at = repository.registeredDate,
|
|
||||||
updated_at = repository.updatedDate,
|
|
||||||
permission.map(ApiPermission(_))
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def apply(
|
def apply(repositoryInfo: RepositoryInfo, owner: ApiUser): ApiRepository =
|
||||||
repositoryInfo: RepositoryInfo,
|
ApiRepository(repositoryInfo.repository, owner, forkedCount = repositoryInfo.forkedCount)
|
||||||
owner: Account,
|
|
||||||
permission: RepositoryService.RepositoryPermission
|
|
||||||
): ApiRepository =
|
|
||||||
ApiRepository(repositoryInfo.repository, ApiUser(owner), Some(permission), forkedCount = repositoryInfo.forkedCount)
|
|
||||||
|
|
||||||
def apply(
|
def apply(repositoryInfo: RepositoryInfo, owner: Account): ApiRepository =
|
||||||
repositoryInfo: RepositoryInfo,
|
this(repositoryInfo, ApiUser(owner))
|
||||||
owner: Account
|
|
||||||
): ApiRepository =
|
|
||||||
ApiRepository(repositoryInfo.repository, ApiUser(owner), None, forkedCount = repositoryInfo.forkedCount)
|
|
||||||
|
|
||||||
def forDummyPayload(owner: ApiUser): ApiRepository =
|
def forDummyPayload(owner: ApiUser): ApiRepository =
|
||||||
ApiRepository(
|
ApiRepository(
|
||||||
name = "dummy",
|
name = "dummy",
|
||||||
full_name = s"${owner.login}/dummy",
|
full_name = s"${owner.login}/dummy",
|
||||||
description = "",
|
description = "",
|
||||||
id = 0,
|
|
||||||
watchers = 0,
|
watchers = 0,
|
||||||
forks = 0,
|
forks = 0,
|
||||||
`private` = false,
|
`private` = false,
|
||||||
fork = false,
|
|
||||||
default_branch = "master",
|
default_branch = "master",
|
||||||
owner = owner,
|
owner = owner
|
||||||
new java.util.Date,
|
|
||||||
new java.util.Date,
|
|
||||||
Some(ApiPermission(RepositoryService.RepositoryPermission(true, true, true)))
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
package gitbucket.core.api
|
|
||||||
import gitbucket.core.model.RepositoryWebHook
|
|
||||||
import gitbucket.core.model.WebHook
|
|
||||||
|
|
||||||
case class ApiRepositoryWebhook(
|
|
||||||
id: Int,
|
|
||||||
events: Seq[String],
|
|
||||||
config: ApiWebhook
|
|
||||||
) {
|
|
||||||
val active = true
|
|
||||||
val name = "web"
|
|
||||||
}
|
|
||||||
|
|
||||||
object ApiRepositoryWebhook {
|
|
||||||
def apply(repositoryWebhook: RepositoryWebHook, events: Set[WebHook.Event]): ApiRepositoryWebhook =
|
|
||||||
ApiRepositoryWebhook(
|
|
||||||
id = repositoryWebhook.webHookId,
|
|
||||||
events = events.map { e =>
|
|
||||||
e.name
|
|
||||||
}.toSeq,
|
|
||||||
config = ApiWebhook(repositoryWebhook.url, repositoryWebhook.ctype.ctype)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
package gitbucket.core.api
|
|
||||||
import gitbucket.core.model.WebHook
|
|
||||||
|
|
||||||
case class ApiWebhook(url: String, content_type: String)
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package gitbucket.core.api
|
|
||||||
|
|
||||||
case class CreateAWebhookConfig(
|
|
||||||
url: String,
|
|
||||||
content_type: String = "form",
|
|
||||||
secret: Option[String],
|
|
||||||
insecure_ssl: Option[String]
|
|
||||||
)
|
|
||||||
|
|
||||||
case class CreateAWebhook(
|
|
||||||
name: Option[String],
|
|
||||||
config: CreateAWebhookConfig,
|
|
||||||
events: Seq[String],
|
|
||||||
active: Option[Boolean]
|
|
||||||
)
|
|
||||||
@@ -45,10 +45,6 @@ object JsonFormat {
|
|||||||
FieldSerializer[ApiCommits.File]() +
|
FieldSerializer[ApiCommits.File]() +
|
||||||
FieldSerializer[ApiRelease]() +
|
FieldSerializer[ApiRelease]() +
|
||||||
FieldSerializer[ApiReleaseAsset]() +
|
FieldSerializer[ApiReleaseAsset]() +
|
||||||
FieldSerializer[ApiPermission]() +
|
|
||||||
FieldSerializer[ApiWebhook]() +
|
|
||||||
FieldSerializer[ApiRepositoryWebhook]() +
|
|
||||||
FieldSerializer[ApiEmail]() +
|
|
||||||
ApiBranchProtection.enforcementLevelSerializer
|
ApiBranchProtection.enforcementLevelSerializer
|
||||||
|
|
||||||
def apiPathSerializer(c: Context) =
|
def apiPathSerializer(c: Context) =
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ class ApiController
|
|||||||
with ApiRepositoryContentsControllerBase
|
with ApiRepositoryContentsControllerBase
|
||||||
with ApiRepositoryControllerBase
|
with ApiRepositoryControllerBase
|
||||||
with ApiRepositoryStatusControllerBase
|
with ApiRepositoryStatusControllerBase
|
||||||
with ApiRepositoryWebhookcontrollerBase
|
|
||||||
with ApiUserControllerBase
|
with ApiUserControllerBase
|
||||||
with RepositoryService
|
with RepositoryService
|
||||||
with AccountService
|
with AccountService
|
||||||
|
|||||||
@@ -53,12 +53,8 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
issue = issue,
|
issue = issue,
|
||||||
pullRequest = pullRequest,
|
pullRequest = pullRequest,
|
||||||
headRepo = ApiRepository(
|
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
headRepo,
|
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
ApiUser(headOwner),
|
|
||||||
Some(getPermission(headRepo.userName, headRepo.repositoryName, context.loginAccount))
|
|
||||||
),
|
|
||||||
baseRepo = ApiRepository(repository, baseOwner),
|
|
||||||
user = ApiUser(issueUser),
|
user = ApiUser(issueUser),
|
||||||
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository))),
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
@@ -243,8 +239,8 @@ trait ApiPullRequestControllerBase extends ControllerBase {
|
|||||||
ApiPullRequest(
|
ApiPullRequest(
|
||||||
issue = issue,
|
issue = issue,
|
||||||
pullRequest = pullRequest,
|
pullRequest = pullRequest,
|
||||||
headRepo = ApiRepository(headRepo, headOwner),
|
headRepo = ApiRepository(headRepo, ApiUser(headOwner)),
|
||||||
baseRepo = ApiRepository(repository, baseOwner),
|
baseRepo = ApiRepository(repository, ApiUser(baseOwner)),
|
||||||
user = ApiUser(issueUser),
|
user = ApiUser(issueUser),
|
||||||
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
labels = getIssueLabels(repository.owner, repository.name, issue.issueId)
|
||||||
.map(ApiLabel(_, RepositoryName(repository))),
|
.map(ApiLabel(_, RepositoryName(repository))),
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/api/v3/user/repos")(usersOnly {
|
get("/api/v3/user/repos")(usersOnly {
|
||||||
JsonFormat(getVisibleRepositories(context.loginAccount, Option(context.loginAccount.get.userName)).map { r =>
|
JsonFormat(getVisibleRepositories(context.loginAccount, Option(context.loginAccount.get.userName)).map { r =>
|
||||||
ApiRepository(r, getAccountByUserName(r.owner).get, getPermission(r.owner, r.name, context.loginAccount))
|
ApiRepository(r, getAccountByUserName(r.owner).get)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/api/v3/users/:userName/repos") {
|
get("/api/v3/users/:userName/repos") {
|
||||||
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("userName"))).map { r =>
|
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("userName"))).map { r =>
|
||||||
ApiRepository(r, getAccountByUserName(r.owner).get, getPermission(r.owner, r.name, context.loginAccount))
|
ApiRepository(r, getAccountByUserName(r.owner).get)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,7 +50,7 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
*/
|
*/
|
||||||
get("/api/v3/orgs/:orgName/repos") {
|
get("/api/v3/orgs/:orgName/repos") {
|
||||||
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("orgName"))).map { r =>
|
JsonFormat(getVisibleRepositories(context.loginAccount, Some(params("orgName"))).map { r =>
|
||||||
ApiRepository(r, getAccountByUserName(r.owner).get, getPermission(r.owner, r.name, context.loginAccount))
|
ApiRepository(r, getAccountByUserName(r.owner).get)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -90,13 +90,7 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
val repository = Database() withTransaction { session =>
|
val repository = Database() withTransaction { session =>
|
||||||
getRepository(owner, data.name)(session).get
|
getRepository(owner, data.name)(session).get
|
||||||
}
|
}
|
||||||
JsonFormat(
|
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(owner).get)))
|
||||||
ApiRepository(
|
|
||||||
repository,
|
|
||||||
getAccountByUserName(owner).get,
|
|
||||||
getPermission(repository.owner, repository.name, context.loginAccount)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
ApiError(
|
ApiError(
|
||||||
"A repository with this name already exists on this account",
|
"A repository with this name already exists on this account",
|
||||||
@@ -130,13 +124,7 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
val repository = Database() withTransaction { session =>
|
val repository = Database() withTransaction { session =>
|
||||||
getRepository(groupName, data.name).get
|
getRepository(groupName, data.name).get
|
||||||
}
|
}
|
||||||
JsonFormat(
|
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(groupName).get)))
|
||||||
ApiRepository(
|
|
||||||
repository,
|
|
||||||
getAccountByUserName(groupName).get,
|
|
||||||
getPermission(repository.owner, repository.name, context.loginAccount)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
ApiError(
|
ApiError(
|
||||||
"A repository with this name already exists for this group",
|
"A repository with this name already exists for this group",
|
||||||
@@ -152,13 +140,7 @@ trait ApiRepositoryControllerBase extends ControllerBase {
|
|||||||
* https://developer.github.com/v3/repos/#get
|
* https://developer.github.com/v3/repos/#get
|
||||||
*/
|
*/
|
||||||
get("/api/v3/repos/:owner/:repository")(referrersOnly { repository =>
|
get("/api/v3/repos/:owner/:repository")(referrersOnly { repository =>
|
||||||
JsonFormat(
|
JsonFormat(ApiRepository(repository, ApiUser(getAccountByUserName(repository.owner).get)))
|
||||||
ApiRepository(
|
|
||||||
repository,
|
|
||||||
getAccountByUserName(repository.owner).get,
|
|
||||||
getPermission(repository.owner, repository.name, context.loginAccount)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -1,100 +0,0 @@
|
|||||||
package gitbucket.core.controller.api
|
|
||||||
import gitbucket.core.api.{ApiRepositoryWebhook, CreateAWebhook, JsonFormat}
|
|
||||||
import gitbucket.core.controller.ControllerBase
|
|
||||||
import gitbucket.core.model.{WebHook, WebHookContentType}
|
|
||||||
import gitbucket.core.service.WebHookService
|
|
||||||
import gitbucket.core.util.OwnerAuthenticator
|
|
||||||
import gitbucket.core.util.Implicits._
|
|
||||||
import org.scalatra.{NoContent, NotFound}
|
|
||||||
|
|
||||||
trait ApiRepositoryWebhookcontrollerBase extends ControllerBase {
|
|
||||||
self: WebHookService with OwnerAuthenticator =>
|
|
||||||
|
|
||||||
/**
|
|
||||||
* i. List hooks
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#list-hooks
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/hooks")(ownerOnly { repository =>
|
|
||||||
JsonFormat(getWebHooks(repository.owner, repository.name).map {
|
|
||||||
case (wh, events) =>
|
|
||||||
ApiRepositoryWebhook(wh, events)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ii. Get single hook
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#get-single-hook
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
get("/api/v3/repos/:owner/:repository/hooks/:id")(ownerOnly { repository =>
|
|
||||||
params
|
|
||||||
.get("id")
|
|
||||||
.map { id =>
|
|
||||||
getWebHookById(repository.owner, repository.name, id.toInt)
|
|
||||||
.map {
|
|
||||||
case (hook, events) =>
|
|
||||||
JsonFormat(ApiRepositoryWebhook(hook, events))
|
|
||||||
}
|
|
||||||
.getOrElse(NotFound)
|
|
||||||
}
|
|
||||||
.getOrElse(NotFound)
|
|
||||||
})
|
|
||||||
|
|
||||||
/**
|
|
||||||
* iii. Create a hook
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#create-a-hook
|
|
||||||
*/
|
|
||||||
post("/api/v3/repos/:owner/:repository/hooks")(ownerOnly { repository =>
|
|
||||||
(for {
|
|
||||||
data <- extractFromJsonBody[CreateAWebhook]
|
|
||||||
loginAccount <- context.loginAccount
|
|
||||||
} yield {
|
|
||||||
val url = data.config.url
|
|
||||||
val events = data.events.map(WebHook.Event.valueOf(_)).toSet
|
|
||||||
val ctype = WebHookContentType.valueOf(data.config.content_type)
|
|
||||||
val webHook = addWebHook(repository.owner, repository.name, url, events, ctype, data.config.secret)
|
|
||||||
JsonFormat(ApiRepositoryWebhook(webHook, events))
|
|
||||||
}).getOrElse(NotFound())
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
|
||||||
* iv. Edit a hook
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#edit-a-hook
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* v. Test a push hook
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#test-a-push-hook
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* vi. Ping a hook
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#ping-a-hook
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* vii. Delete a hook
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#delete-a-hook
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
delete("/api/v3/repos/:owner/:repository/hooks/:id")(ownerOnly { repository =>
|
|
||||||
deleteWebHook(repository.owner, repository.name, params("id").toInt)
|
|
||||||
NoContent()
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
|
||||||
* viii. Receiving Webhooks
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#receiving-webhooks
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ix. PubSubHubbub
|
|
||||||
* https://developer.github.com/v3/repos/hooks/#pubsubhubbub
|
|
||||||
* not implemented
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
package gitbucket.core.controller.api
|
package gitbucket.core.controller.api
|
||||||
import gitbucket.core.api._
|
import gitbucket.core.api.{ApiUser, CreateAUser, JsonFormat, UpdateAUser}
|
||||||
import gitbucket.core.controller.ControllerBase
|
import gitbucket.core.controller.ControllerBase
|
||||||
import gitbucket.core.service.{AccountService, RepositoryService}
|
import gitbucket.core.service.{AccountService, RepositoryService}
|
||||||
import gitbucket.core.util.{AdminAuthenticator, UsersAuthenticator}
|
import gitbucket.core.util.{AdminAuthenticator, UsersAuthenticator}
|
||||||
@@ -111,37 +111,4 @@ trait ApiUserControllerBase extends ControllerBase {
|
|||||||
NotFound()
|
NotFound()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
/**
|
|
||||||
* Emails i. List email addresses for a user
|
|
||||||
* https://developer.github.com/v3/users/emails/#list-email-addresses-for-a-user
|
|
||||||
*/
|
|
||||||
get("/api/v3/user/emails")(usersOnly {
|
|
||||||
JsonFormat(
|
|
||||||
ApiEmail.fromMailAddresses(
|
|
||||||
context.loginAccount.get.mailAddress,
|
|
||||||
getAccountExtraMailAddresses(context.loginAccount.get.userName)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ii. List public email addresses for a user
|
|
||||||
* https://developer.github.com/v3/users/emails/#list-public-email-addresses-for-a-user
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* iii. Add email address(es)
|
|
||||||
* https://developer.github.com/v3/users/emails/#add-email-addresses
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* iv. Delete email address(es)
|
|
||||||
* https://developer.github.com/v3/users/emails/#delete-email-addresses
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* v. Toggle primary email visibility
|
|
||||||
* https://developer.github.com/v3/users/emails/#toggle-primary-email-visibility
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
val isPrivate = column[Boolean]("PRIVATE")
|
val isPrivate = column[Boolean]("PRIVATE")
|
||||||
val description = column[String]("DESCRIPTION")
|
val description = column[String]("DESCRIPTION")
|
||||||
val defaultBranch = column[String]("DEFAULT_BRANCH")
|
val defaultBranch = column[String]("DEFAULT_BRANCH")
|
||||||
val repositoryId = column[Int]("REPOSITORY_ID", O AutoInc)
|
|
||||||
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
val registeredDate = column[java.util.Date]("REGISTERED_DATE")
|
||||||
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
val updatedDate = column[java.util.Date]("UPDATED_DATE")
|
||||||
val lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
val lastActivityDate = column[java.util.Date]("LAST_ACTIVITY_DATE")
|
||||||
@@ -37,7 +36,6 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
registeredDate,
|
registeredDate,
|
||||||
updatedDate,
|
updatedDate,
|
||||||
lastActivityDate,
|
lastActivityDate,
|
||||||
repositoryId,
|
|
||||||
originUserName.?,
|
originUserName.?,
|
||||||
originRepositoryName.?,
|
originRepositoryName.?,
|
||||||
parentUserName.?,
|
parentUserName.?,
|
||||||
@@ -59,7 +57,6 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
repository._10,
|
repository._10,
|
||||||
repository._11,
|
repository._11,
|
||||||
repository._12,
|
repository._12,
|
||||||
repository._13,
|
|
||||||
RepositoryOptions.tupled.apply(options)
|
RepositoryOptions.tupled.apply(options)
|
||||||
)
|
)
|
||||||
}, { (r: Repository) =>
|
}, { (r: Repository) =>
|
||||||
@@ -74,7 +71,6 @@ trait RepositoryComponent extends TemplateComponent { self: Profile =>
|
|||||||
r.registeredDate,
|
r.registeredDate,
|
||||||
r.updatedDate,
|
r.updatedDate,
|
||||||
r.lastActivityDate,
|
r.lastActivityDate,
|
||||||
r.repositoryId,
|
|
||||||
r.originUserName,
|
r.originUserName,
|
||||||
r.originRepositoryName,
|
r.originRepositoryName,
|
||||||
r.parentUserName,
|
r.parentUserName,
|
||||||
@@ -100,7 +96,6 @@ case class Repository(
|
|||||||
registeredDate: java.util.Date,
|
registeredDate: java.util.Date,
|
||||||
updatedDate: java.util.Date,
|
updatedDate: java.util.Date,
|
||||||
lastActivityDate: java.util.Date,
|
lastActivityDate: java.util.Date,
|
||||||
repositoryId: Int = 0,
|
|
||||||
originUserName: Option[String],
|
originUserName: Option[String],
|
||||||
originRepositoryName: Option[String],
|
originRepositoryName: Option[String],
|
||||||
parentUserName: Option[String],
|
parentUserName: Option[String],
|
||||||
|
|||||||
@@ -12,15 +12,11 @@ trait RepositoryWebHookComponent extends TemplateComponent { self: Profile =>
|
|||||||
val url = column[String]("URL")
|
val url = column[String]("URL")
|
||||||
val token = column[Option[String]]("TOKEN")
|
val token = column[Option[String]]("TOKEN")
|
||||||
val ctype = column[WebHookContentType]("CTYPE")
|
val ctype = column[WebHookContentType]("CTYPE")
|
||||||
val webHookId = column[Int]("WEB_HOOK_ID", O AutoInc)
|
|
||||||
def * =
|
def * =
|
||||||
(userName, repositoryName, url, ctype, token, webHookId) <> ((RepositoryWebHook.apply _).tupled, RepositoryWebHook.unapply)
|
(userName, repositoryName, url, ctype, token) <> ((RepositoryWebHook.apply _).tupled, RepositoryWebHook.unapply)
|
||||||
|
|
||||||
def byPrimaryKey(owner: String, repository: String, url: String) =
|
def byPrimaryKey(owner: String, repository: String, url: String) =
|
||||||
byRepository(owner, repository) && (this.url === url.bind)
|
byRepository(owner, repository) && (this.url === url.bind)
|
||||||
|
|
||||||
def byId(owner: String, repository: String, id: Int) =
|
|
||||||
byRepository(owner, repository) && (this.webHookId === id.bind)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +25,5 @@ case class RepositoryWebHook(
|
|||||||
repositoryName: String,
|
repositoryName: String,
|
||||||
url: String,
|
url: String,
|
||||||
ctype: WebHookContentType,
|
ctype: WebHookContentType,
|
||||||
token: Option[String],
|
token: Option[String]
|
||||||
webHookId: Int = 0
|
|
||||||
) extends WebHook
|
) extends WebHook
|
||||||
|
|||||||
@@ -728,15 +728,6 @@ trait RepositoryService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def getPermission(owner: String, repository: String, loginAccount: Option[Account])(
|
|
||||||
implicit s: Session
|
|
||||||
): RepositoryPermission =
|
|
||||||
RepositoryPermission(
|
|
||||||
hasOwnerRole(owner, repository, loginAccount),
|
|
||||||
hasDeveloperRole(owner, repository, loginAccount),
|
|
||||||
hasGuestRole(owner, repository, loginAccount)
|
|
||||||
)
|
|
||||||
|
|
||||||
private def getForkedCount(userName: String, repositoryName: String)(implicit s: Session): Int =
|
private def getForkedCount(userName: String, repositoryName: String)(implicit s: Session): Int =
|
||||||
Query(Repositories.filter { t =>
|
Query(Repositories.filter { t =>
|
||||||
(t.originUserName === userName.bind) && (t.originRepositoryName === repositoryName.bind)
|
(t.originUserName === userName.bind) && (t.originRepositoryName === repositoryName.bind)
|
||||||
@@ -787,8 +778,6 @@ trait RepositoryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
object RepositoryService {
|
object RepositoryService {
|
||||||
case class RepositoryPermission(isOwner: Boolean, isDeveloper: Boolean, isGuest: Boolean)
|
|
||||||
|
|
||||||
case class RepositoryInfo(
|
case class RepositoryInfo(
|
||||||
owner: String,
|
owner: String,
|
||||||
name: String,
|
name: String,
|
||||||
|
|||||||
@@ -74,22 +74,6 @@ trait WebHookService {
|
|||||||
.list
|
.list
|
||||||
.distinct
|
.distinct
|
||||||
|
|
||||||
/** get WebHook by Id */
|
|
||||||
def getWebHookById(owner: String, repository: String, id: Int)(
|
|
||||||
implicit s: Session
|
|
||||||
): Option[(RepositoryWebHook, Set[WebHook.Event])] =
|
|
||||||
RepositoryWebHooks
|
|
||||||
.filter(_.byId(owner, repository, id))
|
|
||||||
.join(RepositoryWebHookEvents)
|
|
||||||
.on { (w, t) =>
|
|
||||||
t.byRepositoryWebHook(w)
|
|
||||||
}
|
|
||||||
.map { case (w, t) => w -> t.event }
|
|
||||||
.list
|
|
||||||
.groupBy(_._1)
|
|
||||||
.mapValues(_.map(_._2).toSet)
|
|
||||||
.headOption
|
|
||||||
|
|
||||||
/** get All WebHook information from repository to url */
|
/** get All WebHook information from repository to url */
|
||||||
def getWebHook(owner: String, repository: String, url: String)(
|
def getWebHook(owner: String, repository: String, url: String)(
|
||||||
implicit s: Session
|
implicit s: Session
|
||||||
@@ -113,14 +97,11 @@ trait WebHookService {
|
|||||||
events: Set[WebHook.Event],
|
events: Set[WebHook.Event],
|
||||||
ctype: WebHookContentType,
|
ctype: WebHookContentType,
|
||||||
token: Option[String]
|
token: Option[String]
|
||||||
)(implicit s: Session): RepositoryWebHook = {
|
)(implicit s: Session): Unit = {
|
||||||
val hook = RepositoryWebHook(owner, repository, url, ctype, token)
|
RepositoryWebHooks insert RepositoryWebHook(owner, repository, url, ctype, token)
|
||||||
RepositoryWebHooks insert hook
|
|
||||||
events.map { event: WebHook.Event =>
|
events.map { event: WebHook.Event =>
|
||||||
RepositoryWebHookEvents insert RepositoryWebHookEvent(owner, repository, url, event)
|
RepositoryWebHookEvents insert RepositoryWebHookEvent(owner, repository, url, event)
|
||||||
event
|
}
|
||||||
}.toSet
|
|
||||||
hook
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def updateWebHook(
|
def updateWebHook(
|
||||||
@@ -144,9 +125,6 @@ trait WebHookService {
|
|||||||
def deleteWebHook(owner: String, repository: String, url: String)(implicit s: Session): Unit =
|
def deleteWebHook(owner: String, repository: String, url: String)(implicit s: Session): Unit =
|
||||||
RepositoryWebHooks.filter(_.byPrimaryKey(owner, repository, url)).delete
|
RepositoryWebHooks.filter(_.byPrimaryKey(owner, repository, url)).delete
|
||||||
|
|
||||||
def deleteWebHook(owner: String, repository: String, id: Int)(implicit s: Session): Unit =
|
|
||||||
RepositoryWebHooks.filter(_.byId(owner, repository, id)).delete
|
|
||||||
|
|
||||||
/** get All AccountWebHook informations of user */
|
/** get All AccountWebHook informations of user */
|
||||||
def getAccountWebHooks(owner: String)(implicit s: Session): List[(AccountWebHook, Set[WebHook.Event])] =
|
def getAccountWebHooks(owner: String)(implicit s: Session): List[(AccountWebHook, Set[WebHook.Event])] =
|
||||||
AccountWebHooks
|
AccountWebHooks
|
||||||
@@ -344,7 +322,7 @@ trait WebHookPullRequestService extends WebHookService {
|
|||||||
WebHookIssuesPayload(
|
WebHookIssuesPayload(
|
||||||
action = action,
|
action = action,
|
||||||
number = issue.issueId,
|
number = issue.issueId,
|
||||||
repository = ApiRepository(repository, repoOwner),
|
repository = ApiRepository(repository, ApiUser(repoOwner)),
|
||||||
issue = ApiIssue(
|
issue = ApiIssue(
|
||||||
issue,
|
issue,
|
||||||
RepositoryName(repository),
|
RepositoryName(repository),
|
||||||
|
|||||||
@@ -182,8 +182,7 @@ object ApiSpecModels {
|
|||||||
repository = repository,
|
repository = repository,
|
||||||
owner = apiUser,
|
owner = apiUser,
|
||||||
forkedCount = repositoryInfo.forkedCount,
|
forkedCount = repositoryInfo.forkedCount,
|
||||||
watchers = 0,
|
watchers = 0
|
||||||
permission = None
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val apiLabel = ApiLabel(
|
val apiLabel = ApiLabel(
|
||||||
@@ -410,8 +409,6 @@ object ApiSpecModels {
|
|||||||
assets = Seq(apiReleaseAsset)
|
assets = Seq(apiReleaseAsset)
|
||||||
)
|
)
|
||||||
|
|
||||||
val apiEmail = ApiEmail("root@localhost", true)
|
|
||||||
|
|
||||||
// JSON String for APIs
|
// JSON String for APIs
|
||||||
|
|
||||||
val jsonUser = """{
|
val jsonUser = """{
|
||||||
@@ -430,15 +427,12 @@ object ApiSpecModels {
|
|||||||
|"name":"Hello-World",
|
|"name":"Hello-World",
|
||||||
|"full_name":"octocat/Hello-World",
|
|"full_name":"octocat/Hello-World",
|
||||||
|"description":"This your first repo!",
|
|"description":"This your first repo!",
|
||||||
|"id":0,
|
|
||||||
|"watchers":0,
|
|"watchers":0,
|
||||||
|"forks":1,
|
|"forks":1,
|
||||||
|"private":false,
|
|"private":false,
|
||||||
|"fork":true,
|
|
||||||
|"default_branch":"master",
|
|"default_branch":"master",
|
||||||
|"owner":$jsonUser,
|
|"owner":$jsonUser,
|
||||||
|"created_at":"2011-04-14T16:00:49Z",
|
|"id":0,
|
||||||
|"updated_at":"2011-04-14T16:00:49Z",
|
|
||||||
|"forks_count":1,
|
|"forks_count":1,
|
||||||
|"watchers_count":0,
|
|"watchers_count":0,
|
||||||
|"url":"http://gitbucket.exmple.com/api/v3/repos/octocat/Hello-World",
|
|"url":"http://gitbucket.exmple.com/api/v3/repos/octocat/Hello-World",
|
||||||
@@ -693,12 +687,4 @@ object ApiSpecModels {
|
|||||||
|"author":${jsonUser},
|
|"author":${jsonUser},
|
||||||
|"assets":[${jsonReleaseAsset}]
|
|"assets":[${jsonReleaseAsset}]
|
||||||
|}""".stripMargin
|
|}""".stripMargin
|
||||||
|
|
||||||
val jsonEmail =
|
|
||||||
s"""{
|
|
||||||
|"email":"root@localhost",
|
|
||||||
|"primary":true,
|
|
||||||
|"verified":true,
|
|
||||||
|"visibility":"public"
|
|
||||||
|}""".stripMargin
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,4 @@ class JsonFormatSpec extends FunSuite {
|
|||||||
test("apiRelease") {
|
test("apiRelease") {
|
||||||
assert(JsonFormat(apiRelease) == expected(jsonRelease))
|
assert(JsonFormat(apiRelease) == expected(jsonRelease))
|
||||||
}
|
}
|
||||||
test("apiEmail") {
|
|
||||||
assert(JsonFormat(apiEmail) == expected(jsonEmail))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,27 +52,19 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
val formType = WebHookContentType.FORM
|
val formType = WebHookContentType.FORM
|
||||||
val jsonType = WebHookContentType.JSON
|
val jsonType = WebHookContentType.JSON
|
||||||
service.addWebHook("user1", "repo1", "http://example.com", Set(WebHook.PullRequest), formType, Some("key"))
|
service.addWebHook("user1", "repo1", "http://example.com", Set(WebHook.PullRequest), formType, Some("key"))
|
||||||
val hookId = 1
|
|
||||||
|
|
||||||
assert(
|
assert(
|
||||||
service.getWebHooks("user1", "repo1") == List(
|
service.getWebHooks("user1", "repo1") == List(
|
||||||
(
|
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key")), Set(WebHook.PullRequest))
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key"), hookId),
|
|
||||||
Set(WebHook.PullRequest)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
service.getWebHook("user1", "repo1", "http://example.com") == Some(
|
service.getWebHook("user1", "repo1", "http://example.com") == Some(
|
||||||
(
|
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key")), Set(WebHook.PullRequest))
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key"), hookId),
|
|
||||||
Set(WebHook.PullRequest)
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == List(
|
service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == List(
|
||||||
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key"), hookId))
|
(RepositoryWebHook("user1", "repo1", "http://example.com", formType, Some("key")))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
assert(service.getWebHooksByEvent("user1", "repo1", WebHook.Push) == Nil)
|
assert(service.getWebHooksByEvent("user1", "repo1", WebHook.Push) == Nil)
|
||||||
@@ -90,7 +82,7 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
assert(
|
assert(
|
||||||
service.getWebHook("user1", "repo1", "http://example.com") == Some(
|
service.getWebHook("user1", "repo1", "http://example.com") == Some(
|
||||||
(
|
(
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key"), hookId),
|
RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key")),
|
||||||
Set(WebHook.Push, WebHook.Issues)
|
Set(WebHook.Push, WebHook.Issues)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -98,7 +90,7 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
assert(service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == Nil)
|
assert(service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == Nil)
|
||||||
assert(
|
assert(
|
||||||
service.getWebHooksByEvent("user1", "repo1", WebHook.Push) == List(
|
service.getWebHooksByEvent("user1", "repo1", WebHook.Push) == List(
|
||||||
(RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key"), hookId))
|
(RepositoryWebHook("user1", "repo1", "http://example.com", jsonType, Some("key")))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
service.deleteWebHook("user1", "repo1", "http://example.com")
|
service.deleteWebHook("user1", "repo1", "http://example.com")
|
||||||
@@ -122,11 +114,9 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
service.getWebHooks("user1", "repo1") == List(
|
service.getWebHooks("user1", "repo1") == List(
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key"), 1) -> Set(
|
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key")) -> Set(WebHook.PullRequest),
|
||||||
WebHook.PullRequest
|
RepositoryWebHook("user1", "repo1", "http://example.com/2", ctype, Some("key")) -> Set(WebHook.Push),
|
||||||
),
|
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key")) -> Set(
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com/2", ctype, Some("key"), 2) -> Set(WebHook.Push),
|
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key"), 3) -> Set(
|
|
||||||
WebHook.PullRequest,
|
WebHook.PullRequest,
|
||||||
WebHook.Push
|
WebHook.Push
|
||||||
)
|
)
|
||||||
@@ -134,8 +124,8 @@ class WebHookServiceSpec extends FunSuite with ServiceSpecBase {
|
|||||||
)
|
)
|
||||||
assert(
|
assert(
|
||||||
service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == List(
|
service.getWebHooksByEvent("user1", "repo1", WebHook.PullRequest) == List(
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key"), 1),
|
RepositoryWebHook("user1", "repo1", "http://example.com/1", ctype, Some("key")),
|
||||||
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key"), 3)
|
RepositoryWebHook("user1", "repo1", "http://example.com/3", ctype, Some("key"))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user