Skip to content

Commit 918f0d4

Browse files
committed
Fix can_push value to false in protected_branch (#2560)
1 parent 9026bc3 commit 918f0d4

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

models/branches.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ const (
1717

1818
// ProtectedBranch struct
1919
type ProtectedBranch struct {
20-
ID int64 `xorm:"pk autoincr"`
21-
RepoID int64 `xorm:"UNIQUE(s)"`
22-
BranchName string `xorm:"UNIQUE(s)"`
23-
CanPush bool
20+
ID int64 `xorm:"pk autoincr"`
21+
RepoID int64 `xorm:"UNIQUE(s)"`
22+
BranchName string `xorm:"UNIQUE(s)"`
23+
CanPush bool `xorm:"NOT NULL DEFAULT false"`
2424
Created time.Time `xorm:"-"`
2525
CreatedUnix int64
2626
Updated time.Time `xorm:"-"`

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ var migrations = []Migration{
126126
NewMigration("unescape user full names", unescapeUserFullNames),
127127
// v38 -> v39
128128
NewMigration("remove commits and settings unit types", removeCommitsUnitType),
129+
// v43 -> v44
130+
NewMigration("fix protected branch can push value to false", fixProtectedBranchCanPushValue),
129131
}
130132

131133
// 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)