Skip to content

Commit 9111d8a

Browse files
authored
Merge branch 'main' into lunny/upgrade_orgmode
2 parents 61f6741 + 224aa64 commit 9111d8a

Some content is hidden

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

46 files changed

+1025
-613
lines changed

.dockerignore

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,6 @@ _testmain.go
3636
coverage.all
3737
cpu.out
3838

39-
/modules/migration/bindata.go
40-
/modules/migration/bindata.go.hash
41-
/modules/options/bindata.go
42-
/modules/options/bindata.go.hash
43-
/modules/public/bindata.go
44-
/modules/public/bindata.go.hash
45-
/modules/templates/bindata.go
46-
/modules/templates/bindata.go.hash
47-
4839
*.db
4940
*.log
5041

.ignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
*.min.css
22
*.min.js
33
/assets/*.json
4-
/modules/options/bindata.go
5-
/modules/public/bindata.go
6-
/modules/templates/bindata.go
74
/options/gitignore
85
/options/license
96
/public/assets

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ WEBPACK_CONFIGS := webpack.config.js tailwind.config.js
120120
WEBPACK_DEST := public/assets/js/index.js public/assets/css/index.css
121121
WEBPACK_DEST_ENTRIES := public/assets/js public/assets/css public/assets/fonts
122122

123-
BINDATA_DEST := modules/public/bindata.dat modules/options/bindata.dat modules/templates/bindata.dat
123+
BINDATA_DEST_WILDCARD := modules/migration/bindata.* modules/public/bindata.* modules/options/bindata.* modules/templates/bindata.*
124124

125125
GENERATED_GO_DEST := modules/charset/invisible_gen.go modules/charset/ambiguous_gen.go
126126

@@ -219,7 +219,7 @@ clean-all: clean ## delete backend, frontend and integration files
219219

220220
.PHONY: clean
221221
clean: ## delete backend and integration files
222-
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST) \
222+
rm -rf $(EXECUTABLE) $(DIST) $(BINDATA_DEST_WILDCARD) \
223223
integrations*.test \
224224
e2e*.test \
225225
tests/integration/gitea-integration-* \

models/fixtures/branch.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,15 @@
201201
is_deleted: false
202202
deleted_by_id: 0
203203
deleted_unix: 0
204+
205+
-
206+
id: 25
207+
repo_id: 54
208+
name: 'master'
209+
commit_id: '73cf03db6ece34e12bf91e8853dc58f678f2f82d'
210+
commit_message: 'Initial commit'
211+
commit_time: 1671663402
212+
pusher_id: 2
213+
is_deleted: false
214+
deleted_by_id: 0
215+
deleted_unix: 0

models/issues/pull.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -649,12 +649,6 @@ func GetAllUnmergedAgitPullRequestByPoster(ctx context.Context, uid int64) ([]*P
649649
return pulls, err
650650
}
651651

652-
// Update updates all fields of pull request.
653-
func (pr *PullRequest) Update(ctx context.Context) error {
654-
_, err := db.GetEngine(ctx).ID(pr.ID).AllCols().Update(pr)
655-
return err
656-
}
657-
658652
// UpdateCols updates specific fields of pull request.
659653
func (pr *PullRequest) UpdateCols(ctx context.Context, cols ...string) error {
660654
_, err := db.GetEngine(ctx).ID(pr.ID).Cols(cols...).Update(pr)

models/issues/pull_test.go

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -248,19 +248,6 @@ func TestGetPullRequestByIssueID(t *testing.T) {
248248
assert.True(t, issues_model.IsErrPullRequestNotExist(err))
249249
}
250250

251-
func TestPullRequest_Update(t *testing.T) {
252-
assert.NoError(t, unittest.PrepareTestDatabase())
253-
pr := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: 1})
254-
pr.BaseBranch = "baseBranch"
255-
pr.HeadBranch = "headBranch"
256-
pr.Update(db.DefaultContext)
257-
258-
pr = unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
259-
assert.Equal(t, "baseBranch", pr.BaseBranch)
260-
assert.Equal(t, "headBranch", pr.HeadBranch)
261-
unittest.CheckConsistencyFor(t, pr)
262-
}
263-
264251
func TestPullRequest_UpdateCols(t *testing.T) {
265252
assert.NoError(t, unittest.PrepareTestDatabase())
266253
pr := &issues_model.PullRequest{

models/packages/container/const.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
package container
55

66
const (
7+
ContentTypeDockerDistributionManifestV2 = "application/vnd.docker.distribution.manifest.v2+json"
8+
79
ManifestFilename = "manifest.json"
810
UploadVersion = "_upload"
911
)

models/packages/container/search.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ type BlobSearchOptions struct {
2525
Digest string
2626
Tag string
2727
IsManifest bool
28+
OnlyLead bool
2829
Repository string
2930
}
3031

@@ -45,6 +46,9 @@ func (opts *BlobSearchOptions) toConds() builder.Cond {
4546
if opts.IsManifest {
4647
cond = cond.And(builder.Eq{"package_file.lower_name": ManifestFilename})
4748
}
49+
if opts.OnlyLead {
50+
cond = cond.And(builder.Eq{"package_file.is_lead": true})
51+
}
4852
if opts.Digest != "" {
4953
var propsCond builder.Cond = builder.Eq{
5054
"package_property.ref_type": packages.PropertyTypeFile,
@@ -73,11 +77,9 @@ func GetContainerBlob(ctx context.Context, opts *BlobSearchOptions) (*packages.P
7377
pfds, err := getContainerBlobsLimit(ctx, opts, 1)
7478
if err != nil {
7579
return nil, err
76-
}
77-
if len(pfds) != 1 {
80+
} else if len(pfds) == 0 {
7881
return nil, ErrContainerBlobNotExist
7982
}
80-
8183
return pfds[0], nil
8284
}
8385

models/packages/package_file.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ func DeleteFileByID(ctx context.Context, fileID int64) error {
115115
return err
116116
}
117117

118+
func UpdateFile(ctx context.Context, pf *PackageFile, cols []string) error {
119+
_, err := db.GetEngine(ctx).ID(pf.ID).Cols(cols...).Update(pf)
120+
return err
121+
}
122+
118123
// PackageFileSearchOptions are options for SearchXXX methods
119124
type PackageFileSearchOptions struct {
120125
OwnerID int64

models/packages/package_property.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,20 @@ func UpdateProperty(ctx context.Context, pp *PackageProperty) error {
6666
return err
6767
}
6868

69+
func InsertOrUpdateProperty(ctx context.Context, refType PropertyType, refID int64, name, value string) error {
70+
pp := PackageProperty{RefType: refType, RefID: refID, Name: name}
71+
ok, err := db.GetEngine(ctx).Get(&pp)
72+
if err != nil {
73+
return err
74+
}
75+
if ok {
76+
_, err = db.GetEngine(ctx).Where("ref_type=? AND ref_id=? AND name=?", refType, refID, name).Cols("value").Update(&PackageProperty{Value: value})
77+
return err
78+
}
79+
_, err = InsertProperty(ctx, refType, refID, name, value)
80+
return err
81+
}
82+
6983
// DeleteAllProperties deletes all properties of a ref
7084
func DeleteAllProperties(ctx context.Context, refType PropertyType, refID int64) error {
7185
_, err := db.GetEngine(ctx).Where("ref_type = ? AND ref_id = ?", refType, refID).Delete(&PackageProperty{})

0 commit comments

Comments
 (0)