mirror of
https://github.com/go-gitea/gitea
synced 2024-11-14 14:14:25 +00:00
9ff4e1d2d9
* add API branch protection endpoint * lint * Change to use team names instead of ids. * Status codes. * fix * Fix * Add new branch protection options (BlockOnRejectedReviews, DismissStaleApprovals, RequireSignedCommits) * Do xorm query directly * fix xorm GetUserNamesByIDs * Add some tests * Improved GetTeamNamesByID * http status created for CreateBranchProtection * Correct status code in integration test Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: zeripath <art27@cantab.net>
92 lines
5.0 KiB
Go
92 lines
5.0 KiB
Go
// Copyright 2016 The Gogs Authors. All rights reserved.
|
|
// Use of this source code is governed by a MIT-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
package structs
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// Branch represents a repository branch
|
|
type Branch struct {
|
|
Name string `json:"name"`
|
|
Commit *PayloadCommit `json:"commit"`
|
|
Protected bool `json:"protected"`
|
|
RequiredApprovals int64 `json:"required_approvals"`
|
|
EnableStatusCheck bool `json:"enable_status_check"`
|
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
|
UserCanPush bool `json:"user_can_push"`
|
|
UserCanMerge bool `json:"user_can_merge"`
|
|
EffectiveBranchProtectionName string `json:"effective_branch_protection_name"`
|
|
}
|
|
|
|
// BranchProtection represents a branch protection for a repository
|
|
type BranchProtection struct {
|
|
BranchName string `json:"branch_name"`
|
|
EnablePush bool `json:"enable_push"`
|
|
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
|
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
|
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
|
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
|
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
|
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
|
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
|
EnableStatusCheck bool `json:"enable_status_check"`
|
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
|
RequiredApprovals int64 `json:"required_approvals"`
|
|
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
|
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
|
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
|
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
|
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
|
RequireSignedCommits bool `json:"require_signed_commits"`
|
|
// swagger:strfmt date-time
|
|
Created time.Time `json:"created_at"`
|
|
// swagger:strfmt date-time
|
|
Updated time.Time `json:"updated_at"`
|
|
}
|
|
|
|
// CreateBranchProtectionOption options for creating a branch protection
|
|
type CreateBranchProtectionOption struct {
|
|
BranchName string `json:"branch_name"`
|
|
EnablePush bool `json:"enable_push"`
|
|
EnablePushWhitelist bool `json:"enable_push_whitelist"`
|
|
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
|
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
|
PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
|
|
EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
|
|
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
|
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
|
EnableStatusCheck bool `json:"enable_status_check"`
|
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
|
RequiredApprovals int64 `json:"required_approvals"`
|
|
EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
|
|
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
|
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
|
BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
|
|
DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
|
|
RequireSignedCommits bool `json:"require_signed_commits"`
|
|
}
|
|
|
|
// EditBranchProtectionOption options for editing a branch protection
|
|
type EditBranchProtectionOption struct {
|
|
EnablePush *bool `json:"enable_push"`
|
|
EnablePushWhitelist *bool `json:"enable_push_whitelist"`
|
|
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
|
|
PushWhitelistTeams []string `json:"push_whitelist_teams"`
|
|
PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
|
|
EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
|
|
MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
|
|
MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
|
|
EnableStatusCheck *bool `json:"enable_status_check"`
|
|
StatusCheckContexts []string `json:"status_check_contexts"`
|
|
RequiredApprovals *int64 `json:"required_approvals"`
|
|
EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
|
|
ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
|
|
ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
|
|
BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
|
|
DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
|
|
RequireSignedCommits *bool `json:"require_signed_commits"`
|
|
}
|