mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-08-01 17:38:33 +00:00
fix: ensure consistent empty repository topics field (#7920)
Resolves #7878 An empty repository topic was not stored consistently across databases, this caused the `ONLY_SHOW_RELEVANT_REPOS` feature to not work correctly. Always store empty repository topics as an empty array to fix this. Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/7920 Reviewed-by: Gusted <gusted@noreply.codeberg.org> Co-authored-by: Maks1mS <maks1ms@noreply.codeberg.org> Co-committed-by: Maks1mS <maks1ms@noreply.codeberg.org>
This commit is contained in:
parent
d6ab2a464f
commit
8e2747859b
10 changed files with 163 additions and 2 deletions
|
@ -28,3 +28,4 @@
|
|||
size: 0
|
||||
is_fsck_enabled: true
|
||||
close_issues_via_commit_in_any_branch: false
|
||||
topics: '[]'
|
||||
|
|
|
@ -183,7 +183,7 @@ type Repository struct {
|
|||
StatsIndexerStatus *RepoIndexerStatus `xorm:"-"`
|
||||
IsFsckEnabled bool `xorm:"NOT NULL DEFAULT true"`
|
||||
CloseIssuesViaCommitInAnyBranch bool `xorm:"NOT NULL DEFAULT false"`
|
||||
Topics []string `xorm:"TEXT JSON"`
|
||||
Topics []string `xorm:"TEXT JSON NOT NULL"`
|
||||
ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"`
|
||||
|
||||
TrustModel TrustModelType
|
||||
|
@ -196,6 +196,13 @@ type Repository struct {
|
|||
ArchivedUnix timeutil.TimeStamp `xorm:"DEFAULT 0"`
|
||||
}
|
||||
|
||||
// BeforeInsert will be invoked by XORM before updating a record
|
||||
func (repo *Repository) BeforeInsert() {
|
||||
if repo.Topics == nil {
|
||||
repo.Topics = []string{}
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
db.RegisterModel(new(Repository))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue