File tree Expand file tree Collapse file tree 3 files changed +9
-11
lines changed Expand file tree Collapse file tree 3 files changed +9
-11
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,12 @@ func runHookPreReceive(c *cli.Context) error {
127
127
}
128
128
129
129
if protectBranch != nil {
130
- if ! protectBranch .CanPush {
131
- // check and deletion
132
- if newCommitID == git .EmptySHA {
133
- fail (fmt .Sprintf ("branch %s is protected from deletion" , branchName ), "" )
134
- } else {
135
- fail (fmt .Sprintf ("protected branch %s can not be pushed to" , branchName ), "" )
136
- //fail(fmt.Sprintf("branch %s is protected from force push", branchName), "")
137
- }
130
+ // check and deletion
131
+ if newCommitID == git .EmptySHA {
132
+ fail (fmt .Sprintf ("branch %s is protected from deletion" , branchName ), "" )
133
+ } else if ! protectBranch .CanPush {
134
+ fail (fmt .Sprintf ("protected branch %s can not be pushed to" , branchName ), "" )
135
+ //fail(fmt.Sprintf("branch %s is protected from force push", branchName), "")
138
136
}
139
137
}
140
138
}
Original file line number Diff line number Diff line change @@ -625,7 +625,7 @@ function initProtectedBranch() {
625
625
var $this = $ ( this ) ;
626
626
$ . post ( $this . data ( 'url' ) , {
627
627
"_csrf" : csrf ,
628
- "canPush" : true ,
628
+ "canPush" : false ,
629
629
"branchName" : $this . val ( ) ,
630
630
} ,
631
631
function ( data ) {
@@ -642,7 +642,7 @@ function initProtectedBranch() {
642
642
var $this = $ ( this ) ;
643
643
$ . post ( $this . data ( 'url' ) , {
644
644
"_csrf" : csrf ,
645
- "canPush" : false ,
645
+ "canPush" : true ,
646
646
"branchName" : $this . data ( 'val' ) ,
647
647
} ,
648
648
function ( data ) {
Original file line number Diff line number Diff line change @@ -520,7 +520,7 @@ func ProtectedBranchPost(ctx *context.Context) {
520
520
521
521
canPush := ctx .QueryBool ("canPush" )
522
522
523
- if canPush {
523
+ if ! canPush {
524
524
if err := ctx .Repo .Repository .AddProtectedBranch (branchName , canPush ); err != nil {
525
525
ctx .Flash .Error (ctx .Tr ("repo.settings.add_protected_branch_failed" , branchName ))
526
526
ctx .JSON (200 , map [string ]string {
You can’t perform that action at this time.
0 commit comments