Skip to content

Commit 6718ea6

Browse files
authored
Fix can_push value to false in protected_branch (#2560)
1 parent 6f380a2 commit 6718ea6

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

models/branches.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ type ProtectedBranch struct {
2626
ID int64 `xorm:"pk autoincr"`
2727
RepoID int64 `xorm:"UNIQUE(s)"`
2828
BranchName string `xorm:"UNIQUE(s)"`
29+
CanPush bool `xorm:"NOT NULL DEFAULT false"`
2930
EnableWhitelist bool
3031
WhitelistUserIDs []int64 `xorm:"JSON TEXT"`
3132
WhitelistTeamIDs []int64 `xorm:"JSON TEXT"`

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ var migrations = []Migration{
134134
NewMigration("add default value to user prohibit_login", addDefaultValueToUserProhibitLogin),
135135
// v42 -> v43
136136
NewMigration("add tags to releases and sync existing repositories", releaseAddColumnIsTagAndSyncTags),
137+
// v43 -> v44
138+
NewMigration("fix protected branch can push value to false", fixProtectedBranchCanPushValue),
137139
}
138140

139141
// Migrate database to current version

models/migrations/v43.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2017 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package migrations
6+
7+
import (
8+
"code.gitea.io/gitea/models"
9+
10+
"github.com/go-xorm/xorm"
11+
)
12+
13+
func fixProtectedBranchCanPushValue(x *xorm.Engine) error {
14+
_, err := x.Cols("can_push").Update(&models.ProtectedBranch{
15+
CanPush: false,
16+
})
17+
return err
18+
}

0 commit comments

Comments
 (0)