Skip to content

Commit 6c1ffb7

Browse files
committed
api
1 parent 05fe316 commit 6c1ffb7

File tree

4 files changed

+24
-0
lines changed

4 files changed

+24
-0
lines changed

modules/structs/repo_branch.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type BranchProtection struct {
2525
// Deprecated: true
2626
BranchName string `json:"branch_name"`
2727
RuleName string `json:"rule_name"`
28+
Priority int64 `json:"priority"`
2829
EnablePush bool `json:"enable_push"`
2930
EnablePushWhitelist bool `json:"enable_push_whitelist"`
3031
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
@@ -63,6 +64,7 @@ type CreateBranchProtectionOption struct {
6364
// Deprecated: true
6465
BranchName string `json:"branch_name"`
6566
RuleName string `json:"rule_name"`
67+
Priority int64 `json:"priority"`
6668
EnablePush bool `json:"enable_push"`
6769
EnablePushWhitelist bool `json:"enable_push_whitelist"`
6870
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`
@@ -94,6 +96,7 @@ type CreateBranchProtectionOption struct {
9496

9597
// EditBranchProtectionOption options for editing a branch protection
9698
type EditBranchProtectionOption struct {
99+
Priority *int64 `json:"priority"`
97100
EnablePush *bool `json:"enable_push"`
98101
EnablePushWhitelist *bool `json:"enable_push_whitelist"`
99102
PushWhitelistUsernames []string `json:"push_whitelist_usernames"`

routers/api/v1/repo/branch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,7 @@ func CreateBranchProtection(ctx *context.APIContext) {
623623
protectBranch = &git_model.ProtectedBranch{
624624
RepoID: ctx.Repo.Repository.ID,
625625
RuleName: ruleName,
626+
Priority: form.Priority,
626627
CanPush: form.EnablePush,
627628
EnableWhitelist: form.EnablePush && form.EnablePushWhitelist,
628629
WhitelistDeployKeys: form.EnablePush && form.EnablePushWhitelist && form.PushWhitelistDeployKeys,
@@ -800,6 +801,10 @@ func EditBranchProtection(ctx *context.APIContext) {
800801
}
801802
}
802803

804+
if form.Priority != nil {
805+
protectBranch.Priority = *form.Priority
806+
}
807+
803808
if form.EnableMergeWhitelist != nil {
804809
protectBranch.EnableMergeWhitelist = *form.EnableMergeWhitelist
805810
}

services/convert/convert.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ func ToBranchProtection(ctx context.Context, bp *git_model.ProtectedBranch, repo
158158
return &api.BranchProtection{
159159
BranchName: branchName,
160160
RuleName: bp.RuleName,
161+
Priority: bp.Priority,
161162
EnablePush: bp.CanPush,
162163
EnablePushWhitelist: bp.EnableWhitelist,
163164
PushWhitelistUsernames: pushWhitelistUsernames,

templates/swagger/v1_json.tmpl

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)