Skip to content

Commit 76c3d51

Browse files
committed
Merge branch 'main' into feature/filter-branches
2 parents 4b907da + 4527748 commit 76c3d51

File tree

149 files changed

+1614
-815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1614
-815
lines changed

.github/workflows/files-changed.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ jobs:
4848
- "Makefile"
4949
- ".golangci.yml"
5050
- ".editorconfig"
51+
- "options/locale/locale_en-US.ini"
5152
5253
frontend:
5354
- "**/*.js"

.github/workflows/pull-db-tests.yml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ jobs:
4949
- run: make backend
5050
env:
5151
TAGS: bindata
52-
- run: make test-pgsql-migration test-pgsql
52+
- name: run migration tests
53+
run: make test-pgsql-migration
54+
- name: run tests
55+
run: make test-pgsql
5356
timeout-minutes: 50
5457
env:
5558
TAGS: bindata gogit
@@ -72,7 +75,10 @@ jobs:
7275
- run: make backend
7376
env:
7477
TAGS: bindata gogit sqlite sqlite_unlock_notify
75-
- run: make test-sqlite-migration test-sqlite
78+
- name: run migration tests
79+
run: make test-sqlite-migration
80+
- name: run tests
81+
run: make test-sqlite
7682
timeout-minutes: 50
7783
env:
7884
TAGS: bindata gogit sqlite sqlite_unlock_notify
@@ -175,8 +181,10 @@ jobs:
175181
- run: make backend
176182
env:
177183
TAGS: bindata
184+
- name: run migration tests
185+
run: make test-mysql-migration
178186
- name: run tests
179-
run: make test-mysql-migration integration-test-coverage
187+
run: make integration-test-coverage
180188
env:
181189
TAGS: bindata
182190
RACE_ENABLED: true
@@ -208,7 +216,9 @@ jobs:
208216
- run: make backend
209217
env:
210218
TAGS: bindata
211-
- run: make test-mssql-migration test-mssql
219+
- run: make test-mssql-migration
220+
- name: run tests
221+
run: make test-mssql
212222
timeout-minutes: 50
213223
env:
214224
TAGS: bindata

Makefile

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ LINUX_ARCHS ?= linux/amd64,linux/386,linux/arm-5,linux/arm-6,linux/arm64
115115

116116
GO_PACKAGES ?= $(filter-out code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
117117
GO_TEST_PACKAGES ?= $(filter-out $(shell $(GO) list code.gitea.io/gitea/models/migrations/...) code.gitea.io/gitea/tests/integration/migration-test code.gitea.io/gitea/tests code.gitea.io/gitea/tests/integration code.gitea.io/gitea/tests/e2e,$(shell $(GO) list ./... | grep -v /vendor/))
118+
MIGRATE_TEST_PACKAGES ?= $(shell $(GO) list code.gitea.io/gitea/models/migrations/...)
118119

119120
FOMANTIC_WORK_DIR := web_src/fomantic
120121

@@ -147,6 +148,7 @@ GO_DIRS := build cmd models modules routers services tests
147148
WEB_DIRS := web_src/js web_src/css
148149

149150
SPELLCHECK_FILES := $(GO_DIRS) $(WEB_DIRS) docs/content templates options/locale/locale_en-US.ini .github
151+
EDITORCONFIG_FILES := templates .github/workflows options/locale/locale_en-US.ini
150152

151153
GO_SOURCES := $(wildcard *.go)
152154
GO_SOURCES += $(shell find $(GO_DIRS) -type f -name "*.go" ! -path modules/options/bindata.go ! -path modules/public/bindata.go ! -path modules/templates/bindata.go)
@@ -426,7 +428,7 @@ lint-go-vet:
426428

427429
.PHONY: lint-editorconfig
428430
lint-editorconfig:
429-
$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) templates .github/workflows
431+
@$(GO) run $(EDITORCONFIG_CHECKER_PACKAGE) $(EDITORCONFIG_FILES)
430432

431433
.PHONY: lint-actions
432434
lint-actions:
@@ -709,40 +711,31 @@ migrations.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
709711

710712
.PHONY: migrations.individual.mysql.test
711713
migrations.individual.mysql.test: $(GO_SOURCES)
712-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
713-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
714-
done
714+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
715715

716716
.PHONY: migrations.individual.sqlite.test\#%
717717
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite
718718
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
719719

720720
.PHONY: migrations.individual.pgsql.test
721721
migrations.individual.pgsql.test: $(GO_SOURCES)
722-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
723-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
724-
done
722+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
725723

726724
.PHONY: migrations.individual.pgsql.test\#%
727725
migrations.individual.pgsql.test\#%: $(GO_SOURCES) generate-ini-pgsql
728726
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/pgsql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
729727

730-
731728
.PHONY: migrations.individual.mssql.test
732729
migrations.individual.mssql.test: $(GO_SOURCES) generate-ini-mssql
733-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
734-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg -test.failfast; \
735-
done
730+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
736731

737732
.PHONY: migrations.individual.mssql.test\#%
738733
migrations.individual.mssql.test\#%: $(GO_SOURCES) generate-ini-mssql
739734
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mssql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' code.gitea.io/gitea/models/migrations/$*
740735

741736
.PHONY: migrations.individual.sqlite.test
742737
migrations.individual.sqlite.test: $(GO_SOURCES) generate-ini-sqlite
743-
for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \
744-
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \
745-
done
738+
GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/sqlite.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' -p 1 $(MIGRATE_TEST_PACKAGES)
746739

747740
.PHONY: migrations.individual.sqlite.test\#%
748741
migrations.individual.sqlite.test\#%: $(GO_SOURCES) generate-ini-sqlite

docs/content/contributing/guidelines-frontend.en-us.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ We recommend [Google HTML/CSS Style Guide](https://google.github.io/styleguide/h
4747
9. Avoid unnecessary `!important` in CSS, add comments to explain why it's necessary if it can't be avoided.
4848
10. Avoid mixing different events in one event listener, prefer to use individual event listeners for every event.
4949
11. Custom event names are recommended to use `ce-` prefix.
50-
12. Gitea's tailwind-style CSS classes use `gt-` prefix (`gt-relative`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
50+
12. Prefer using Tailwind CSS which is available via `tw-` prefix, e.g. `tw-relative`. Gitea's helper CSS classes use `gt-` prefix (`gt-df`), while Gitea's own private framework-level CSS classes use `g-` prefix (`g-modal-confirm`).
5151
13. Avoid inline scripts & styles as much as possible, it's recommended to put JS code into JS files and use CSS classes. If inline scripts & styles are unavoidable, explain the reason why it can't be avoided.
5252

5353
### Accessibility / ARIA

docs/content/contributing/guidelines-frontend.zh-cn.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ HTML 页面由[Go HTML Template](https://pkg.go.dev/html/template)渲染。
4747
9. 避免在 CSS 中使用不必要的`!important`,如果无法避免,添加注释解释为什么需要它。
4848
10. 避免在一个事件监听器中混合不同的事件,优先为每个事件使用独立的事件监听器。
4949
11. 推荐使用自定义事件名称前缀`ce-`
50-
12. Gitea 的 tailwind-style CSS 类使用`gt-`前缀(`gt-relative`),Gitea 自身的私有框架级 CSS 类使用`g-`前缀(`g-modal-confirm`)。
50+
12. 建议使用 Tailwind CSS,它可以通过 `tw-` 前缀获得,例如 `tw-relative`. Gitea 自身的助手类 CSS 使用 `gt-` 前缀(`gt-df`),Gitea 自身的私有框架级 CSS 类使用 `g-` 前缀(`g-modal-confirm`)。
5151
13. 尽量避免内联脚本和样式,建议将JS代码放入JS文件中并使用CSS类。如果内联脚本和样式不可避免,请解释无法避免的原因。
5252

5353
### 可访问性 / ARIA

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ require (
113113
golang.org/x/text v0.14.0
114114
golang.org/x/tools v0.17.0
115115
google.golang.org/grpc v1.60.1
116-
google.golang.org/protobuf v1.32.0
116+
google.golang.org/protobuf v1.33.0
117117
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
118118
gopkg.in/ini.v1 v1.67.0
119119
gopkg.in/yaml.v3 v3.0.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,8 +1308,8 @@ google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlba
13081308
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
13091309
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
13101310
google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
1311-
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
1312-
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
1311+
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
1312+
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
13131313
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
13141314
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
13151315
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=

models/activities/action.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,10 +393,14 @@ func (a *Action) GetCreate() time.Time {
393393
return a.CreatedUnix.AsTime()
394394
}
395395

396-
// GetIssueInfos returns a list of issues associated with
397-
// the action.
396+
// GetIssueInfos returns a list of associated information with the action.
398397
func (a *Action) GetIssueInfos() []string {
399-
return strings.SplitN(a.Content, "|", 3)
398+
// make sure it always returns 3 elements, because there are some access to the a[1] and a[2] without checking the length
399+
ret := strings.SplitN(a.Content, "|", 3)
400+
for len(ret) < 3 {
401+
ret = append(ret, "")
402+
}
403+
return ret
400404
}
401405

402406
// GetIssueTitle returns the title of first issue associated with the action.

models/git/branch.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,11 @@ func GetBranch(ctx context.Context, repoID int64, branchName string) (*Branch, e
158158
return &branch, nil
159159
}
160160

161+
func GetBranches(ctx context.Context, repoID int64, branchNames []string) ([]*Branch, error) {
162+
branches := make([]*Branch, 0, len(branchNames))
163+
return branches, db.GetEngine(ctx).Where("repo_id=?", repoID).In("name", branchNames).Find(&branches)
164+
}
165+
161166
func AddBranches(ctx context.Context, branches []*Branch) error {
162167
for _, branch := range branches {
163168
if _, err := db.GetEngine(ctx).Insert(branch); err != nil {

models/migrations/base/db_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ func Test_DropTableColumns(t *testing.T) {
3636
"updated_unix",
3737
}
3838

39+
x.SetMapper(names.GonicMapper{})
40+
3941
for i := range columns {
40-
x.SetMapper(names.GonicMapper{})
4142
if err := x.Sync(new(DropTest)); err != nil {
4243
t.Errorf("unable to create DropTest table: %v", err)
4344
return
4445
}
46+
4547
sess := x.NewSession()
4648
if err := sess.Begin(); err != nil {
4749
sess.Close()
@@ -64,7 +66,6 @@ func Test_DropTableColumns(t *testing.T) {
6466
return
6567
}
6668
for j := range columns[i+1:] {
67-
x.SetMapper(names.GonicMapper{})
6869
if err := x.Sync(new(DropTest)); err != nil {
6970
t.Errorf("unable to create DropTest table: %v", err)
7071
return
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-
2+
id: 1
3+
repo_id: 1
4+
index: 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-
2+
id: 1
3+
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11
4+
issue_id: 1
5+
release_id: 0
6+
7+
-
8+
id: 2
9+
uuid: a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a12
10+
issue_id: 0
11+
release_id: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
repo_id: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
repo_id: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
context_hash: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-
2+
id: 1
3+
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d
4+
merge_base: 19fe5caf872476db265596eaac1dc35ad1c6422d
5+
merged_commit_id: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
sha1: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
commit_id: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
-
2+
id: 1
3+
commit_sha: 19fe5caf872476db265596eaac1dc35ad1c6422d
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-
2+
id: 1
3+
description: the badge
4+
image_url: https://gitea.com/myimage.png

models/migrations/migrations.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -562,6 +562,8 @@ var migrations = []Migration{
562562
NewMigration("Use Slug instead of ID for Badges", v1_22.UseSlugInsteadOfIDForBadges),
563563
// v288 -> v289
564564
NewMigration("Add user_blocking table", v1_22.AddUserBlockingTable),
565+
// v289 -> v290
566+
NewMigration("Add default_wiki_branch to repository table", v1_22.AddDefaultUncycloBranch),
565567
}
566568

567569
// GetCurrentDBVersion returns the current db version

models/migrations/v1_16/v193_test.go

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
1515
type Attachment struct {
1616
ID int64 `xorm:"pk autoincr"`
1717
UUID string `xorm:"uuid UNIQUE"`
18-
RepoID int64 `xorm:"INDEX"` // this should not be zero
1918
IssueID int64 `xorm:"INDEX"` // maybe zero when creating
2019
ReleaseID int64 `xorm:"INDEX"` // maybe zero when creating
2120
UploaderID int64 `xorm:"INDEX DEFAULT 0"`
@@ -44,25 +43,34 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
4443
return
4544
}
4645

47-
var issueAttachments []*Attachment
48-
err := x.Where("issue_id > 0").Find(&issueAttachments)
46+
type NewAttachment struct {
47+
ID int64 `xorm:"pk autoincr"`
48+
UUID string `xorm:"uuid UNIQUE"`
49+
RepoID int64 `xorm:"INDEX"` // this should not be zero
50+
IssueID int64 `xorm:"INDEX"` // maybe zero when creating
51+
ReleaseID int64 `xorm:"INDEX"` // maybe zero when creating
52+
UploaderID int64 `xorm:"INDEX DEFAULT 0"`
53+
}
54+
55+
var issueAttachments []*NewAttachment
56+
err := x.Table("attachment").Where("issue_id > 0").Find(&issueAttachments)
4957
assert.NoError(t, err)
5058
for _, attach := range issueAttachments {
51-
assert.Greater(t, attach.RepoID, 0)
52-
assert.Greater(t, attach.IssueID, 0)
59+
assert.Greater(t, attach.RepoID, int64(0))
60+
assert.Greater(t, attach.IssueID, int64(0))
5361
var issue Issue
5462
has, err := x.ID(attach.IssueID).Get(&issue)
5563
assert.NoError(t, err)
5664
assert.True(t, has)
5765
assert.EqualValues(t, attach.RepoID, issue.RepoID)
5866
}
5967

60-
var releaseAttachments []*Attachment
61-
err = x.Where("release_id > 0").Find(&releaseAttachments)
68+
var releaseAttachments []*NewAttachment
69+
err = x.Table("attachment").Where("release_id > 0").Find(&releaseAttachments)
6270
assert.NoError(t, err)
6371
for _, attach := range releaseAttachments {
64-
assert.Greater(t, attach.RepoID, 0)
65-
assert.Greater(t, attach.IssueID, 0)
72+
assert.Greater(t, attach.RepoID, int64(0))
73+
assert.Greater(t, attach.ReleaseID, int64(0))
6674
var release Release
6775
has, err := x.ID(attach.ReleaseID).Get(&release)
6876
assert.NoError(t, err)

models/migrations/v1_22/v283.go

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
package v1_22 //nolint
55

66
import (
7+
"fmt"
8+
79
"xorm.io/xorm"
10+
"xorm.io/xorm/schemas"
811
)
912

1013
func AddCombinedIndexToIssueUser(x *xorm.Engine) error {
@@ -20,8 +23,18 @@ func AddCombinedIndexToIssueUser(x *xorm.Engine) error {
2023
return err
2124
}
2225
for _, issueUser := range duplicatedIssueUsers {
23-
if _, err := x.Exec("delete from issue_user where id in (SELECT id FROM issue_user WHERE issue_id = ? and uid = ? limit ?)", issueUser.IssueID, issueUser.UID, issueUser.Cnt-1); err != nil {
24-
return err
26+
if x.Dialect().URI().DBType == schemas.MSSQL {
27+
if _, err := x.Exec(fmt.Sprintf("delete from issue_user where id in (SELECT top %d id FROM issue_user WHERE issue_id = ? and uid = ?)", issueUser.Cnt-1), issueUser.IssueID, issueUser.UID); err != nil {
28+
return err
29+
}
30+
} else {
31+
var ids []int64
32+
if err := x.SQL("SELECT id FROM issue_user WHERE issue_id = ? and uid = ? limit ?", issueUser.IssueID, issueUser.UID, issueUser.Cnt-1).Find(&ids); err != nil {
33+
return err
34+
}
35+
if _, err := x.Table("issue_user").In("id", ids).Delete(); err != nil {
36+
return err
37+
}
2538
}
2639
}
2740

models/migrations/v1_22/v286.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ func expandHashReferencesToSha256(x *xorm.Engine) error {
3636
if setting.Database.Type.IsMSSQL() {
3737
// drop indexes that need to be re-created afterwards
3838
droppedIndexes := []string{
39-
"DROP INDEX commit_status.IDX_commit_status_context_hash",
40-
"DROP INDEX review_state.UQE_review_state_pull_commit_user",
41-
"DROP INDEX repo_archiver.UQE_repo_archiver_s",
39+
"DROP INDEX IF EXISTS [IDX_commit_status_context_hash] ON [commit_status]",
40+
"DROP INDEX IF EXISTS [UQE_review_state_pull_commit_user] ON [review_state]",
41+
"DROP INDEX IF EXISTS [UQE_repo_archiver_s] ON [repo_archiver]",
4242
}
4343
for _, s := range droppedIndexes {
4444
_, err := db.Exec(s)
@@ -53,7 +53,7 @@ func expandHashReferencesToSha256(x *xorm.Engine) error {
5353
if setting.Database.Type.IsMySQL() {
5454
_, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` MODIFY COLUMN `%s` VARCHAR(64)", alts[0], alts[1]))
5555
} else if setting.Database.Type.IsMSSQL() {
56-
_, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` VARCHAR(64)", alts[0], alts[1]))
56+
_, err = db.Exec(fmt.Sprintf("ALTER TABLE [%s] ALTER COLUMN [%s] VARCHAR(64)", alts[0], alts[1]))
5757
} else {
5858
_, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` TYPE VARCHAR(64)", alts[0], alts[1]))
5959
}

0 commit comments

Comments
 (0)