gitea源码

repo_branch.go 8.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package structs
  4. import (
  5. "time"
  6. )
  7. // Branch represents a repository branch
  8. type Branch struct {
  9. // Name is the branch name
  10. Name string `json:"name"`
  11. // Commit contains the latest commit information for this branch
  12. Commit *PayloadCommit `json:"commit"`
  13. // Protected indicates if the branch is protected
  14. Protected bool `json:"protected"`
  15. // RequiredApprovals is the number of required approvals for pull requests
  16. RequiredApprovals int64 `json:"required_approvals"`
  17. // EnableStatusCheck indicates if status checks are enabled
  18. EnableStatusCheck bool `json:"enable_status_check"`
  19. // StatusCheckContexts contains the list of required status check contexts
  20. StatusCheckContexts []string `json:"status_check_contexts"`
  21. // UserCanPush indicates if the current user can push to this branch
  22. UserCanPush bool `json:"user_can_push"`
  23. // UserCanMerge indicates if the current user can merge to this branch
  24. UserCanMerge bool `json:"user_can_merge"`
  25. // EffectiveBranchProtectionName is the name of the effective branch protection rule
  26. EffectiveBranchProtectionName string `json:"effective_branch_protection_name"`
  27. }
  28. // BranchProtection represents a branch protection for a repository
  29. type BranchProtection struct {
  30. // Deprecated: true
  31. BranchName string `json:"branch_name"`
  32. // RuleName is the name of the branch protection rule
  33. RuleName string `json:"rule_name"`
  34. // Priority is the priority of this branch protection rule
  35. Priority int64 `json:"priority"`
  36. EnablePush bool `json:"enable_push"`
  37. EnablePushWhitelist bool `json:"enable_push_whitelist"`
  38. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  39. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  40. PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
  41. EnableForcePush bool `json:"enable_force_push"`
  42. EnableForcePushAllowlist bool `json:"enable_force_push_allowlist"`
  43. ForcePushAllowlistUsernames []string `json:"force_push_allowlist_usernames"`
  44. ForcePushAllowlistTeams []string `json:"force_push_allowlist_teams"`
  45. ForcePushAllowlistDeployKeys bool `json:"force_push_allowlist_deploy_keys"`
  46. EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
  47. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  48. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  49. EnableStatusCheck bool `json:"enable_status_check"`
  50. StatusCheckContexts []string `json:"status_check_contexts"`
  51. RequiredApprovals int64 `json:"required_approvals"`
  52. EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
  53. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  54. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  55. BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
  56. BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
  57. BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
  58. DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
  59. IgnoreStaleApprovals bool `json:"ignore_stale_approvals"`
  60. RequireSignedCommits bool `json:"require_signed_commits"`
  61. ProtectedFilePatterns string `json:"protected_file_patterns"`
  62. UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
  63. BlockAdminMergeOverride bool `json:"block_admin_merge_override"`
  64. // swagger:strfmt date-time
  65. Created time.Time `json:"created_at"`
  66. // swagger:strfmt date-time
  67. Updated time.Time `json:"updated_at"`
  68. }
  69. // CreateBranchProtectionOption options for creating a branch protection
  70. type CreateBranchProtectionOption struct {
  71. // Deprecated: true
  72. BranchName string `json:"branch_name"`
  73. RuleName string `json:"rule_name"`
  74. Priority int64 `json:"priority"`
  75. EnablePush bool `json:"enable_push"`
  76. EnablePushWhitelist bool `json:"enable_push_whitelist"`
  77. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  78. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  79. PushWhitelistDeployKeys bool `json:"push_whitelist_deploy_keys"`
  80. EnableForcePush bool `json:"enable_force_push"`
  81. EnableForcePushAllowlist bool `json:"enable_force_push_allowlist"`
  82. ForcePushAllowlistUsernames []string `json:"force_push_allowlist_usernames"`
  83. ForcePushAllowlistTeams []string `json:"force_push_allowlist_teams"`
  84. ForcePushAllowlistDeployKeys bool `json:"force_push_allowlist_deploy_keys"`
  85. EnableMergeWhitelist bool `json:"enable_merge_whitelist"`
  86. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  87. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  88. EnableStatusCheck bool `json:"enable_status_check"`
  89. StatusCheckContexts []string `json:"status_check_contexts"`
  90. RequiredApprovals int64 `json:"required_approvals"`
  91. EnableApprovalsWhitelist bool `json:"enable_approvals_whitelist"`
  92. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  93. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  94. BlockOnRejectedReviews bool `json:"block_on_rejected_reviews"`
  95. BlockOnOfficialReviewRequests bool `json:"block_on_official_review_requests"`
  96. BlockOnOutdatedBranch bool `json:"block_on_outdated_branch"`
  97. DismissStaleApprovals bool `json:"dismiss_stale_approvals"`
  98. IgnoreStaleApprovals bool `json:"ignore_stale_approvals"`
  99. RequireSignedCommits bool `json:"require_signed_commits"`
  100. ProtectedFilePatterns string `json:"protected_file_patterns"`
  101. UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
  102. BlockAdminMergeOverride bool `json:"block_admin_merge_override"`
  103. }
  104. // EditBranchProtectionOption options for editing a branch protection
  105. type EditBranchProtectionOption struct {
  106. Priority *int64 `json:"priority"`
  107. EnablePush *bool `json:"enable_push"`
  108. EnablePushWhitelist *bool `json:"enable_push_whitelist"`
  109. PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
  110. PushWhitelistTeams []string `json:"push_whitelist_teams"`
  111. PushWhitelistDeployKeys *bool `json:"push_whitelist_deploy_keys"`
  112. EnableForcePush *bool `json:"enable_force_push"`
  113. EnableForcePushAllowlist *bool `json:"enable_force_push_allowlist"`
  114. ForcePushAllowlistUsernames []string `json:"force_push_allowlist_usernames"`
  115. ForcePushAllowlistTeams []string `json:"force_push_allowlist_teams"`
  116. ForcePushAllowlistDeployKeys *bool `json:"force_push_allowlist_deploy_keys"`
  117. EnableMergeWhitelist *bool `json:"enable_merge_whitelist"`
  118. MergeWhitelistUsernames []string `json:"merge_whitelist_usernames"`
  119. MergeWhitelistTeams []string `json:"merge_whitelist_teams"`
  120. EnableStatusCheck *bool `json:"enable_status_check"`
  121. StatusCheckContexts []string `json:"status_check_contexts"`
  122. RequiredApprovals *int64 `json:"required_approvals"`
  123. EnableApprovalsWhitelist *bool `json:"enable_approvals_whitelist"`
  124. ApprovalsWhitelistUsernames []string `json:"approvals_whitelist_username"`
  125. ApprovalsWhitelistTeams []string `json:"approvals_whitelist_teams"`
  126. BlockOnRejectedReviews *bool `json:"block_on_rejected_reviews"`
  127. BlockOnOfficialReviewRequests *bool `json:"block_on_official_review_requests"`
  128. BlockOnOutdatedBranch *bool `json:"block_on_outdated_branch"`
  129. DismissStaleApprovals *bool `json:"dismiss_stale_approvals"`
  130. IgnoreStaleApprovals *bool `json:"ignore_stale_approvals"`
  131. RequireSignedCommits *bool `json:"require_signed_commits"`
  132. ProtectedFilePatterns *string `json:"protected_file_patterns"`
  133. UnprotectedFilePatterns *string `json:"unprotected_file_patterns"`
  134. BlockAdminMergeOverride *bool `json:"block_admin_merge_override"`
  135. }
  136. // UpdateBranchProtectionPriories a list to update the branch protection rule priorities
  137. type UpdateBranchProtectionPriories struct {
  138. IDs []int64 `json:"ids"`
  139. }
  140. type MergeUpstreamRequest struct {
  141. Branch string `json:"branch"`
  142. FfOnly bool `json:"ff_only"`
  143. }
  144. type MergeUpstreamResponse struct {
  145. MergeStyle string `json:"merge_type"`
  146. }