You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

repo_branch.go 5.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package structs
  5. import (
  6. "time"
  7. )
  8. // Branch represents a repository branch
  9. type Branch struct {
  10. Name string `json:"name"`
  11. Commit *PayloadCommit `json:"commit"`
  12. Protected bool `json:"protected"`
  13. RequiredApprovals int64 `json:"required_approvals"`
  14. EnableStatusCheck bool `json:"enable_status_check"`
  15. StatusCheckContexts []string `json:"status_check_contexts"`
  16. UserCanPush bool `json:"user_can_push"`
  17. UserCanMerge bool `json:"user_can_merge"`
  18. EffectiveBranchProtectionName string `json:"effective_branch_protection_name"`
  19. }
  20. // BranchProtection represents a branch protection for a repository
  21. type BranchProtection struct {
  22. BranchName string `json:"branch_name"`
  23. EnablePush bool `json:"enable_push"`
  24. EnablePushWhitelist bool `json:"enable_push_whitelist"`
  25. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  26. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  27. PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
  28. EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
  29. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  30. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  31. EnableStatusCheck bool `json:"enable_status_check"`
  32. StatusCheckContexts []string `json:"status_check_contexts"`
  33. RequiredApprovals int64 `json:"required_approvals"`
  34. EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
  35. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  36. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  37. BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
  38. BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
  39. DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
  40. RequireSignedCommits bool `json:"require_signed_commits"`
  41. ProtectedFilePatterns string `json:"protected_file_patterns"`
  42. // swagger:strfmt date-time
  43. Created time.Time `json:"created_at"`
  44. // swagger:strfmt date-time
  45. Updated time.Time `json:"updated_at"`
  46. }
  47. // CreateBranchProtectionOption options for creating a branch protection
  48. type CreateBranchProtectionOption struct {
  49. BranchName string `json:"branch_name"`
  50. EnablePush bool `json:"enable_push"`
  51. EnablePushWhitelist bool `json:"enable_push_whitelist"`
  52. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  53. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  54. PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
  55. EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
  56. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  57. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  58. EnableStatusCheck bool `json:"enable_status_check"`
  59. StatusCheckContexts []string `json:"status_check_contexts"`
  60. RequiredApprovals int64 `json:"required_approvals"`
  61. EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
  62. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  63. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  64. BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
  65. BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
  66. DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
  67. RequireSignedCommits bool `json:"require_signed_commits"`
  68. ProtectedFilePatterns string `json:"protected_file_patterns"`
  69. }
  70. // EditBranchProtectionOption options for editing a branch protection
  71. type EditBranchProtectionOption struct {
  72. EnablePush *bool `json:"enable_push"`
  73. EnablePushWhitelist *bool `json:"enable_push_whitelist"`
  74. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  75. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  76. PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
  77. EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
  78. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  79. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  80. EnableStatusCheck *bool `json:"enable_status_check"`
  81. StatusCheckContexts []string `json:"status_check_contexts"`
  82. RequiredApprovals *int64 `json:"required_approvals"`
  83. EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
  84. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  85. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  86. BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
  87. BlockOnOutdatedBranch *bool `json:"block_on_outdated_branch"`
  88. DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
  89. RequireSignedCommits *bool `json:"require_signed_commits"`
  90. ProtectedFilePatterns *string `json:"protected_file_patterns"`
  91. }