Skip to content

Commit 5764d7c

Browse files
authored
Merge branch 'main' into order-BranchProtection-non-glob-by-name
2 parents 8cac5fc + 2abdbe8 commit 5764d7c

File tree

25 files changed

+401
-245
lines changed

25 files changed

+401
-245
lines changed

models/git/protected_branch.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type ProtectedBranch struct {
6363
RequireSignedCommits bool `xorm:"NOT NULL DEFAULT false"`
6464
ProtectedFilePatterns string `xorm:"TEXT"`
6565
UnprotectedFilePatterns string `xorm:"TEXT"`
66+
BlockAdminMergeOverride bool `xorm:"NOT NULL DEFAULT false"`
6667

6768
CreatedUnix timeutil.TimeStamp `xorm:"created"`
6869
UpdatedUnix timeutil.TimeStamp `xorm:"updated"`

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ var migrations = []Migration{
603603
NewMigration("Add index for release sha1", v1_23.AddIndexForReleaseSha1),
604604
// v305 -> v306
605605
NewMigration("Add Repository Licenses", v1_23.AddRepositoryLicenses),
606+
// v306 -> v307
607+
NewMigration("Add BlockAdminMergeOverride to ProtectedBranch", v1_23.AddBlockAdminMergeOverrideBranchProtection),
606608
}
607609

608610
// GetCurrentDBVersion returns the current db version

models/migrations/v1_23/v306.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright 2024 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_23 //nolint
5+
6+
import "xorm.io/xorm"
7+
8+
func AddBlockAdminMergeOverrideBranchProtection(x *xorm.Engine) error {
9+
type ProtectedBranch struct {
10+
BlockAdminMergeOverride bool `xorm:"NOT NULL DEFAULT false"`
11+
}
12+
return x.Sync(new(ProtectedBranch))
13+
}

modules/structs/repo_branch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ type BranchProtection struct {
5252
RequireSignedCommits bool `json:"require_signed_commits"`
5353
ProtectedFilePatterns string `json:"protected_file_patterns"`
5454
UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
55+
BlockAdminMergeOverride bool `json:"block_admin_merge_override"`
5556
// swagger:strfmt date-time
5657
Created time.Time `json:"created_at"`
5758
// swagger:strfmt date-time
@@ -90,6 +91,7 @@ type CreateBranchProtectionOption struct {
9091
RequireSignedCommits bool `json:"require_signed_commits"`
9192
ProtectedFilePatterns string `json:"protected_file_patterns"`
9293
UnprotectedFilePatterns string `json:"unprotected_file_patterns"`
94+
BlockAdminMergeOverride bool `json:"block_admin_merge_override"`
9395
}
9496

9597
// EditBranchProtectionOption options for editing a branch protection
@@ -121,4 +123,5 @@ type EditBranchProtectionOption struct {
121123
RequireSignedCommits *bool `json:"require_signed_commits"`
122124
ProtectedFilePatterns *string `json:"protected_file_patterns"`
123125
UnprotectedFilePatterns *string `json:"unprotected_file_patterns"`
126+
BlockAdminMergeOverride *bool `json:"block_admin_merge_override"`
124127
}

options/locale/locale_en-US.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2461,6 +2461,8 @@ settings.block_on_official_review_requests = Block merge on official review requ
24612461
settings.block_on_official_review_requests_desc = Merging will not be possible when it has official review requests, even if there are enough approvals.
24622462
settings.block_outdated_branch = Block merge if pull request is outdated
24632463
settings.block_outdated_branch_desc = Merging will not be possible when head branch is behind base branch.
2464+
settings.block_admin_merge_override = Administrators must follow branch protection rules
2465+
settings.block_admin_merge_override_desc = Administrators must follow branch protection rules and can not circumvent it.
24642466
settings.default_branch_desc = Select a default repository branch for pull requests and code commits:
24652467
settings.merge_style_desc = Merge Styles
24662468
settings.default_merge_style_desc = Default Merge Style

0 commit comments

Comments
 (0)