mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Remember diff view style (#163)
This commit is contained in:
committed by
Lunny Xiao
parent
bd76e156bb
commit
739f07c98e
@@ -72,6 +72,8 @@ var migrations = []Migration{
|
||||
|
||||
// v13 -> v14:v0.9.87
|
||||
NewMigration("set comment updated with created", setCommentUpdatedWithCreated),
|
||||
|
||||
NewMigration("create user column diff view style", createUserColumnDiffViewStyle),
|
||||
}
|
||||
|
||||
// Migrate database to current version
|
||||
@@ -96,7 +98,7 @@ func Migrate(x *xorm.Engine) error {
|
||||
|
||||
v := currentVersion.Version
|
||||
if _MIN_DB_VER > v {
|
||||
log.Fatal(4, `Gogs no longer supports auto-migration from your previously installed version.
|
||||
log.Fatal(4, `Gogs no longer supports auto-migration from your previously installed version.
|
||||
Please try to upgrade to a lower version (>= v0.6.0) first, then upgrade to current version.`)
|
||||
return nil
|
||||
}
|
||||
|
@@ -22,3 +22,15 @@ func setCommentUpdatedWithCreated(x *xorm.Engine) (err error) {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type UserV14 struct {
|
||||
DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`
|
||||
}
|
||||
|
||||
func (*UserV14) TableName() string {
|
||||
return "user"
|
||||
}
|
||||
|
||||
func createUserColumnDiffViewStyle(x *xorm.Engine) error {
|
||||
return x.Sync2(new(UserV14))
|
||||
}
|
||||
|
@@ -107,6 +107,9 @@ type User struct {
|
||||
NumMembers int
|
||||
Teams []*Team `xorm:"-"`
|
||||
Members []*User `xorm:"-"`
|
||||
|
||||
// Preferences
|
||||
DiffViewStyle string `xorm:"NOT NULL DEFAULT ''"`
|
||||
}
|
||||
|
||||
func (u *User) BeforeInsert() {
|
||||
@@ -126,6 +129,11 @@ func (u *User) SetLastLogin() {
|
||||
u.LastLoginUnix = time.Now().Unix()
|
||||
}
|
||||
|
||||
func (u *User) UpdateDiffViewStyle(style string) error {
|
||||
u.DiffViewStyle = style
|
||||
return UpdateUser(u)
|
||||
}
|
||||
|
||||
func (u *User) AfterSet(colName string, _ xorm.Cell) {
|
||||
switch colName {
|
||||
case "full_name":
|
||||
|
Reference in New Issue
Block a user