@@ -200,39 +200,51 @@ func SettingsProtectedBranchPost(ctx *context.Context, f auth.ProtectBranchForm)
200
200
case "all" :
201
201
protectBranch .CanPush = true
202
202
protectBranch .EnableWhitelist = false
203
+ protectBranch .WhitelistDeployKeys = false
203
204
case "whitelist" :
204
205
protectBranch .CanPush = true
205
206
protectBranch .EnableWhitelist = true
207
+ protectBranch .WhitelistDeployKeys = f .WhitelistDeployKeys
208
+ if strings .TrimSpace (f .WhitelistUsers ) != "" {
209
+ whitelistUsers , _ = base .StringsToInt64s (strings .Split (f .WhitelistUsers , "," ))
210
+ }
211
+ if strings .TrimSpace (f .WhitelistTeams ) != "" {
212
+ whitelistTeams , _ = base .StringsToInt64s (strings .Split (f .WhitelistTeams , "," ))
213
+ }
206
214
default :
207
215
protectBranch .CanPush = false
208
216
protectBranch .EnableWhitelist = false
217
+ protectBranch .WhitelistDeployKeys = false
209
218
}
210
- if strings .TrimSpace (f .WhitelistUsers ) != "" {
211
- whitelistUsers , _ = base .StringsToInt64s (strings .Split (f .WhitelistUsers , "," ))
212
- }
213
- if strings .TrimSpace (f .WhitelistTeams ) != "" {
214
- whitelistTeams , _ = base .StringsToInt64s (strings .Split (f .WhitelistTeams , "," ))
215
- }
219
+
216
220
protectBranch .EnableMergeWhitelist = f .EnableMergeWhitelist
217
- if strings .TrimSpace (f .MergeWhitelistUsers ) != "" {
218
- mergeWhitelistUsers , _ = base .StringsToInt64s (strings .Split (f .MergeWhitelistUsers , "," ))
219
- }
220
- if strings .TrimSpace (f .MergeWhitelistTeams ) != "" {
221
- mergeWhitelistTeams , _ = base .StringsToInt64s (strings .Split (f .MergeWhitelistTeams , "," ))
221
+ if f .EnableMergeWhitelist {
222
+ if strings .TrimSpace (f .MergeWhitelistUsers ) != "" {
223
+ mergeWhitelistUsers , _ = base .StringsToInt64s (strings .Split (f .MergeWhitelistUsers , "," ))
224
+ }
225
+ if strings .TrimSpace (f .MergeWhitelistTeams ) != "" {
226
+ mergeWhitelistTeams , _ = base .StringsToInt64s (strings .Split (f .MergeWhitelistTeams , "," ))
227
+ }
222
228
}
223
229
224
230
protectBranch .EnableStatusCheck = f .EnableStatusCheck
225
- protectBranch .StatusCheckContexts = f .StatusCheckContexts
226
- protectBranch .WhitelistDeployKeys = f .WhitelistDeployKeys
231
+ if f .EnableStatusCheck {
232
+ protectBranch .StatusCheckContexts = f .StatusCheckContexts
233
+ } else {
234
+ protectBranch .StatusCheckContexts = nil
235
+ }
227
236
228
237
protectBranch .RequiredApprovals = f .RequiredApprovals
229
238
protectBranch .EnableApprovalsWhitelist = f .EnableApprovalsWhitelist
230
- if strings .TrimSpace (f .ApprovalsWhitelistUsers ) != "" {
231
- approvalsWhitelistUsers , _ = base .StringsToInt64s (strings .Split (f .ApprovalsWhitelistUsers , "," ))
232
- }
233
- if strings .TrimSpace (f .ApprovalsWhitelistTeams ) != "" {
234
- approvalsWhitelistTeams , _ = base .StringsToInt64s (strings .Split (f .ApprovalsWhitelistTeams , "," ))
239
+ if f .EnableApprovalsWhitelist {
240
+ if strings .TrimSpace (f .ApprovalsWhitelistUsers ) != "" {
241
+ approvalsWhitelistUsers , _ = base .StringsToInt64s (strings .Split (f .ApprovalsWhitelistUsers , "," ))
242
+ }
243
+ if strings .TrimSpace (f .ApprovalsWhitelistTeams ) != "" {
244
+ approvalsWhitelistTeams , _ = base .StringsToInt64s (strings .Split (f .ApprovalsWhitelistTeams , "," ))
245
+ }
235
246
}
247
+
236
248
err = models .UpdateProtectBranch (ctx .Repo .Repository , protectBranch , models.WhitelistOptions {
237
249
UserIDs : whitelistUsers ,
238
250
TeamIDs : whitelistTeams ,
0 commit comments