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.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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. BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
  39. BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
  40. DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
  41. RequireSignedCommits bool `json:"require_signed_commits"`
  42. ProtectedFilePatterns string `json:"protected_file_patterns"`
  43. UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
  44. // swagger:strfmt date-time
  45. Created time.Time `json:"created_at"`
  46. // swagger:strfmt date-time
  47. Updated time.Time `json:"updated_at"`
  48. }
  49. // CreateBranchProtectionOption options for creating a branch protection
  50. type CreateBranchProtectionOption struct {
  51. BranchName string `json:"branch_name"`
  52. EnablePush bool `json:"enable_push"`
  53. EnablePushWhitelist bool `json:"enable_push_whitelist"`
  54. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  55. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  56. PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
  57. EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
  58. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  59. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  60. EnableStatusCheck bool `json:"enable_status_check"`
  61. StatusCheckContexts []string `json:"status_check_contexts"`
  62. RequiredApprovals int64 `json:"required_approvals"`
  63. EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
  64. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  65. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  66. BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
  67. BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
  68. BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
  69. DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
  70. RequireSignedCommits bool `json:"require_signed_commits"`
  71. ProtectedFilePatterns string `json:"protected_file_patterns"`
  72. UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
  73. }
  74. // EditBranchProtectionOption options for editing a branch protection
  75. type EditBranchProtectionOption struct {
  76. EnablePush *bool `json:"enable_push"`
  77. EnablePushWhitelist *bool `json:"enable_push_whitelist"`
  78. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  79. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  80. PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
  81. EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
  82. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  83. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  84. EnableStatusCheck *bool `json:"enable_status_check"`
  85. StatusCheckContexts []string `json:"status_check_contexts"`
  86. RequiredApprovals *int64 `json:"required_approvals"`
  87. EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
  88. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  89. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  90. BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
  91. BlockOnOfficialReviewRequests *bool `json:"block_on_official_review_requests"`
  92. BlockOnOutdatedBranch *bool `json:"block_on_outdated_branch"`
  93. DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
  94. RequireSignedCommits *bool `json:"require_signed_commits"`
  95. ProtectedFilePatterns *string `json:"protected_file_patterns"`
  96. UnprotectedFilePatterns *string `json:"unprotected_file_patterns"`
  97. }