Skip to content

Commit b88256b

Browse files
committed
Squashed commit of the following:
commit 32eef4a Author: Lunny Xiao <[email protected]> Date: Wed Sep 7 05:32:20 2022 +0800 Add changelog for v1.17.2 (go-gitea#21089) Co-authored-by: John Olheiser <[email protected]> Co-authored-by: 6543 <[email protected]> Co-authored-by: delvh <[email protected]> Co-authored-by: techknowlogick <[email protected]> commit 449b39e Author: Tyrone Yeh <[email protected]> Date: Tue Sep 6 16:42:05 2022 +0800 Fix sub folder in repository missing add file dropdown (go-gitea#21069) (go-gitea#21083) Backport go-gitea#21069 In repository sub folder missing add file dropdown menu, Probably broken since go-gitea#20602 commit 06f968d Author: zeripath <[email protected]> Date: Tue Sep 6 07:54:47 2022 +0100 Fix hard-coded timeout and error panic in API archive download endpoint (go-gitea#20925) (go-gitea#21051) Backport go-gitea#20925 This commit updates the `GET /api/v1/repos/{owner}/{repo}/archive/{archive}` endpoint which prior to this PR had a couple of issues. 1. The endpoint had a hard-coded 20s timeout for the archiver to complete after which a 500 (Internal Server Error) was returned to client. For a scripted API client there was no clear way of telling that the operation timed out and that it should retry. 2. Whenever the timeout _did occur_, the code used to panic. This was caused by the API endpoint "delegating" to the same call path as the web, which uses a slightly different way of reporting errors (HTML rather than JSON for example). More specifically, `api/v1/repo/file.go#GetArchive` just called through to `web/repo/repo.go#Download`, which expects the `Context` to have a `Render` field set, but which is `nil` for API calls. Hence, a `nil` pointer error. The code addresses (1) by dropping the hard-coded timeout. Instead, any timeout/cancelation on the incoming `Context` is used. The code addresses (2) by updating the API endpoint to use a separate call path for the API-triggered archive download. This avoids producing HTML-errors on errors (it now produces JSON errors). Signed-off-by: Peter Gardfjäll <[email protected]> Signed-off-by: Peter Gardfjäll <[email protected]> Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Peter Gardfjäll <[email protected]> Co-authored-by: Lunny Xiao <[email protected]> commit 084797b Author: Lunny Xiao <[email protected]> Date: Tue Sep 6 06:48:57 2022 +0800 Fix delete user missed some comments (go-gitea#21067) (go-gitea#21068) commit 7888a55 Author: zeripath <[email protected]> Date: Sun Sep 4 17:17:48 2022 +0100 Delete unreferenced packages when deleting a package version (go-gitea#20977) (go-gitea#21060) Backport go-gitea#20977 Delete a package if its last version got deleted. Otherwise removing the owner works only after the clean up job ran. Fix go-gitea#20969 Co-authored-by: KN4CK3R <[email protected]> commit ea416d7 Author: zeripath <[email protected]> Date: Sun Sep 4 17:17:35 2022 +0100 Redirect if user does not exist on admin pages (go-gitea#20981) (go-gitea#21059) Backport go-gitea#20981 When on /admin/users/ endpoints if the user is no longer in the DB, redirect instead of causing a http 500. Co-authored-by: KN4CK3R <[email protected]> commit 0db6add Author: zeripath <[email protected]> Date: Sun Sep 4 17:17:27 2022 +0100 Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (go-gitea#20902) (go-gitea#21058) Backport go-gitea#20902 When setting.Git.DisablePartialClone is set to false then the web server will add filter support to web http. It does this by using`-c` command arguments but this will not work on gitea serv as the upload-pack and receive-pack commands do not support this. Instead we move these options into the .gitconfig instead. Fix go-gitea#20400 Signed-off-by: Andrew Thornton <[email protected]> Signed-off-by: Andrew Thornton <[email protected]> commit 0ecbb71 Author: qwerty287 <[email protected]> Date: Sun Sep 4 17:12:37 2022 +0200 Fix 500 on time in timeline API (go-gitea#21052) (go-gitea#21057) Backport go-gitea#21052 Before converting a TrackedTime for the API we need to load its attributes - otherwise we get an NPE. Fix go-gitea#21041 commit ea38455 Author: Jason Song <[email protected]> Date: Sun Sep 4 23:12:01 2022 +0800 Fill the specified ref in webhook test payload (go-gitea#20961) (go-gitea#21055) Backport go-gitea#20961 The webhook payload should use the right ref when it‘s specified in the testing request. The compare URL should not be empty, a URL like `compare/A...A` seems useless in most cases but is helpful when testing. commit 8fc80b3 Author: zeripath <[email protected]> Date: Sun Sep 4 16:11:02 2022 +0100 Add another index for Action table on postgres (go-gitea#21033) (go-gitea#21054) Backport go-gitea#21033 In go-gitea#21031 we have discovered that on very big tables postgres will use a search involving the sort term in preference to the restrictive index. Therefore we add another index for postgres and update the original migration. Fix go-gitea#21031 Signed-off-by: Andrew Thornton <[email protected]> commit 71aa64a Author: zeripath <[email protected]> Date: Sun Sep 4 14:59:20 2022 +0100 fix broken insecureskipverify handling in rediss connection uris (go-gitea#20967) (go-gitea#21053) Backport go-gitea#20967 Currently, it's impossible to connect to self-signed TLS encrypted redis instances. The problem lies in inproper error handling, when building redis tls options - only invalid booleans are allowed to be used in `tlsConfig` builder. The problem is, when `strconv.ParseBool(...)` returns error, it always defaults to false - meaning it's impossible to set `tlsOptions.InsecureSkipVerify` to true. Fixes go-gitea#19213 Co-authored-by: Igor Rzegocki <[email protected]> commit 3aba72c Author: zeripath <[email protected]> Date: Sun Sep 4 14:41:21 2022 +0100 Add more checks in migration code (go-gitea#21011) (go-gitea#21050) Backport go-gitea#21011 When migrating add several more important sanity checks: * SHAs must be SHAs * Refs must be valid Refs * URLs must be reasonable Signed-off-by: Andrew Thornton <[email protected]> commit bd1412c Author: José Carlos <[email protected]> Date: Sat Sep 3 21:11:03 2022 +0200 Add Dev, Peer and Optional dependencies to npm PackageMetadataVersion (go-gitea#21017) (go-gitea#21044) Backport go-gitea#21017 Set DevDependencies, PeerDependencies & OptionalDependencies in npm package metadatas Fix go-gitea#21013 commit 3973ce3 Author: silverwind <[email protected]> Date: Sat Sep 3 19:51:09 2022 +0200 Improve arc-green code theme (go-gitea#21039) (go-gitea#21042) Backport go-gitea#21039 - Increase contrasts overall - Add various missing theme classes - Ensure strings and constants are colored the same across languages commit fbde31f Author: Tyrone Yeh <[email protected]> Date: Sat Sep 3 21:36:27 2022 +0800 Add down key check has tribute container (go-gitea#21016) (go-gitea#21038) Backport go-gitea#21016 Fixes an issue where users would not be able to select by pressing the down arrow when using @tag above a message Bug videos: https://user-images.githubusercontent.com/1255041/188095999-c4ccde18-e53b-4251-8a14-d90c4042d768.mp4
1 parent 9987c04 commit b88256b

Some content is hidden

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

47 files changed

+1141
-482
lines changed

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,50 @@ This changelog goes through all the changes that have been made in each release
44
without substantial changes to our git log; to see the highlights of what has
55
been added to each release, please refer to the [blog](https://blog.gitea.io).
66

7+
## [1.17.2](https://github.com/go-gitea/gitea/releases/tag/v1.17.2) - 2022-09-06
8+
9+
* SECURITY
10+
* Double check CloneURL is acceptable (#20869) (#20892)
11+
* Add more checks in migration code (#21011) (#21050)
12+
* ENHANCEMENTS
13+
* Fix hard-coded timeout and error panic in API archive download endpoint (#20925) (#21051)
14+
* Improve arc-green code theme (#21039) (#21042)
15+
* Enable contenthash in filename for dynamic assets (#20813) (#20932)
16+
* Don't open new page for ext wiki on same repository (#20725) (#20910)
17+
* Disable doctor logging on panic (#20847) (#20898)
18+
* Remove calls to load Mirrors in user.Dashboard (#20855) (#20897)
19+
* Update codemirror to 5.65.8 (#20875)
20+
* Rework repo buttons (#20602, #20718) (#20719)
21+
* BUGFIXES
22+
* Ensure delete user deletes all comments (#21067) (#21068)
23+
* Delete unreferenced packages when deleting a package version (#20977) (#21060)
24+
* Redirect if user does not exist on admin pages (#20981) (#21059)
25+
* Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (#20902) (#21058)
26+
* Fix 500 on time in timeline API (#21052) (#21057)
27+
* Fill the specified ref in webhook test payload (#20961) (#21055)
28+
* Add another index for Action table on postgres (#21033) (#21054)
29+
* Fix broken insecureskipverify handling in redis connection uris (#20967) (#21053)
30+
* Add Dev, Peer and Optional dependencies to npm PackageMetadataVersion (#21017) (#21044)
31+
* Do not add links to Posters or Assignees with ID < 0 (#20577) (#21037)
32+
* Fix modified due date message (#20388) (#21032)
33+
* Fix missed sort bug (#21006)
34+
* Fix input.value attr for RequiredClaimName/Value (#20946) (#21001)
35+
* Change review buttons to icons to make space for text (#20934) (#20978)
36+
* Fix download archiver of a commit (#20962) (#20971)
37+
* Return 404 NotFound if requested attachment does not exist (#20886) (#20941)
38+
* Set no-tags in git fetch on compare (#20893) (#20936)
39+
* Allow multiple metadata files for Maven packages (#20674) (#20916)
40+
* Increase Content field size of gpg_key and public_key to MEDIUMTEXT (#20896) (#20911)
41+
* Fix mirror address setting not working (#20850) (#20904)
42+
* Fix push mirror address backend get error Address cause setting page display error (#20593) (#20901)
43+
* Fix panic when an invalid oauth2 name is passed (#20820) (#20900)
44+
* In PushMirrorsIterate and MirrorsIterate if limit is negative do not set it (#20837) (#20899)
45+
* Ensure that graceful start-up is informed of unused SSH listener (#20877) (#20888)
46+
* Pad GPG Key ID with preceding zeroes (#20878) (#20885)
47+
* Fix SQL Query for `SearchTeam` (#20844) (#20872)
48+
* Fix the mode of custom dir to 0700 in docker-rootless (#20861) (#20867)
49+
* Fix UI mis-align for PR commit history (#20845) (#20859)
50+
751
## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17
852

953
* SECURITY

cmd/migrate_storage.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,8 @@ func migrateRepoAvatars(ctx context.Context, dstStorage storage.ObjectStorage) e
112112

113113
func migrateRepoArchivers(ctx context.Context, dstStorage storage.ObjectStorage) error {
114114
return db.IterateObjects(ctx, func(archiver *repo_model.RepoArchiver) error {
115-
p, err := archiver.RelativePath()
116-
if err != nil {
117-
return err
118-
}
119-
_, err = storage.Copy(dstStorage, p, storage.RepoArchives, p)
115+
p := archiver.RelativePath()
116+
_, err := storage.Copy(dstStorage, p, storage.RepoArchives, p)
120117
return err
121118
})
122119
}

models/action.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,14 @@ func (a *Action) TableIndices() []*schemas.Index {
9898
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
9999
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
100100

101-
return []*schemas.Index{actUserIndex, repoIndex}
101+
indices := []*schemas.Index{actUserIndex, repoIndex}
102+
if setting.Database.UsePostgreSQL {
103+
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
104+
cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
105+
indices = append(indices, cudIndex)
106+
}
107+
108+
return indices
102109
}
103110

104111
// GetOpType gets the ActionType of this action.
@@ -275,7 +282,7 @@ func (a *Action) GetRefLink() string {
275282
return a.GetRepoLink() + "/src/branch/" + util.PathEscapeSegments(strings.TrimPrefix(a.RefName, git.BranchPrefix))
276283
case strings.HasPrefix(a.RefName, git.TagPrefix):
277284
return a.GetRepoLink() + "/src/tag/" + util.PathEscapeSegments(strings.TrimPrefix(a.RefName, git.TagPrefix))
278-
case len(a.RefName) == 40 && git.SHAPattern.MatchString(a.RefName):
285+
case len(a.RefName) == 40 && git.IsValidSHAPattern(a.RefName):
279286
return a.GetRepoLink() + "/src/commit/" + a.RefName
280287
default:
281288
// FIXME: we will just assume it's a branch - this was the old way - at some point we may want to enforce that there is always a ref here.

models/migrations/v218.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package migrations
66

77
import (
8+
"code.gitea.io/gitea/modules/setting"
89
"code.gitea.io/gitea/modules/timeutil"
910

1011
"xorm.io/xorm"
@@ -37,8 +38,14 @@ func (*improveActionTableIndicesAction) TableIndices() []*schemas.Index {
3738

3839
actUserIndex := schemas.NewIndex("au_r_c_u_d", schemas.IndexType)
3940
actUserIndex.AddColumn("act_user_id", "repo_id", "created_unix", "user_id", "is_deleted")
40-
41-
return []*schemas.Index{actUserIndex, repoIndex}
41+
indices := []*schemas.Index{actUserIndex, repoIndex}
42+
if setting.Database.UsePostgreSQL {
43+
cudIndex := schemas.NewIndex("c_u_d", schemas.IndexType)
44+
cudIndex.AddColumn("created_unix", "user_id", "is_deleted")
45+
indices = append(indices, cudIndex)
46+
}
47+
48+
return indices
4249
}
4350

4451
func improveActionTableIndices(x *xorm.Engine) error {

models/packages/package.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,16 @@ func FindUnreferencedPackages(ctx context.Context) ([]*Package, error) {
214214
Find(&ps)
215215
}
216216

217-
// HasOwnerPackages tests if a user/org has packages
217+
// HasOwnerPackages tests if a user/org has accessible packages
218218
func HasOwnerPackages(ctx context.Context, ownerID int64) (bool, error) {
219-
return db.GetEngine(ctx).Where("owner_id = ?", ownerID).Exist(&Package{})
219+
return db.GetEngine(ctx).
220+
Table("package_version").
221+
Join("INNER", "package", "package.id = package_version.package_id").
222+
Where(builder.Eq{
223+
"package_version.is_internal": false,
224+
"package.owner_id": ownerID,
225+
}).
226+
Exist(&PackageVersion{})
220227
}
221228

222229
// HasRepositoryPackages tests if a repository has packages

models/packages/package_test.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// Copyright 2022 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 packages_test
6+
7+
import (
8+
"path/filepath"
9+
"testing"
10+
11+
"code.gitea.io/gitea/models/db"
12+
packages_model "code.gitea.io/gitea/models/packages"
13+
"code.gitea.io/gitea/models/unittest"
14+
user_model "code.gitea.io/gitea/models/user"
15+
16+
_ "code.gitea.io/gitea/models"
17+
18+
"github.com/stretchr/testify/assert"
19+
)
20+
21+
func TestMain(m *testing.M) {
22+
unittest.MainTest(m, &unittest.TestOptions{
23+
GiteaRootPath: filepath.Join("..", ".."),
24+
})
25+
}
26+
27+
func TestHasOwnerPackages(t *testing.T) {
28+
assert.NoError(t, unittest.PrepareTestDatabase())
29+
30+
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).(*user_model.User)
31+
32+
p, err := packages_model.TryInsertPackage(db.DefaultContext, &packages_model.Package{
33+
OwnerID: owner.ID,
34+
LowerName: "package",
35+
})
36+
assert.NotNil(t, p)
37+
assert.NoError(t, err)
38+
39+
// A package without package versions gets automatically cleaned up and should return false
40+
has, err := packages_model.HasOwnerPackages(db.DefaultContext, owner.ID)
41+
assert.False(t, has)
42+
assert.NoError(t, err)
43+
44+
pv, err := packages_model.GetOrInsertVersion(db.DefaultContext, &packages_model.PackageVersion{
45+
PackageID: p.ID,
46+
LowerVersion: "internal",
47+
IsInternal: true,
48+
})
49+
assert.NotNil(t, pv)
50+
assert.NoError(t, err)
51+
52+
// A package with an internal package version gets automaticaly cleaned up and should return false
53+
has, err = packages_model.HasOwnerPackages(db.DefaultContext, owner.ID)
54+
assert.False(t, has)
55+
assert.NoError(t, err)
56+
57+
pv, err = packages_model.GetOrInsertVersion(db.DefaultContext, &packages_model.PackageVersion{
58+
PackageID: p.ID,
59+
LowerVersion: "normal",
60+
IsInternal: false,
61+
})
62+
assert.NotNil(t, pv)
63+
assert.NoError(t, err)
64+
65+
// A package with a normal package version should return true
66+
has, err = packages_model.HasOwnerPackages(db.DefaultContext, owner.ID)
67+
assert.True(t, has)
68+
assert.NoError(t, err)
69+
}

models/repo.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error {
385385

386386
archivePaths := make([]string, 0, len(archives))
387387
for _, v := range archives {
388-
p, _ := v.RelativePath()
389-
archivePaths = append(archivePaths, p)
388+
archivePaths = append(archivePaths, v.RelativePath())
390389
}
391390

392391
if _, err := db.DeleteByBean(ctx, &repo_model.RepoArchiver{RepoID: repoID}); err != nil {

models/repo/archiver.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ func init() {
3939
db.RegisterModel(new(RepoArchiver))
4040
}
4141

42-
// RelativePath returns relative path
43-
func (archiver *RepoArchiver) RelativePath() (string, error) {
44-
return fmt.Sprintf("%d/%s/%s.%s", archiver.RepoID, archiver.CommitID[:2], archiver.CommitID, archiver.Type.String()), nil
42+
// RelativePath returns the archive path relative to the archive storage root.
43+
func (archiver *RepoArchiver) RelativePath() string {
44+
return fmt.Sprintf("%d/%s/%s.%s", archiver.RepoID, archiver.CommitID[:2], archiver.CommitID, archiver.Type.String())
4545
}
4646

4747
var delRepoArchiver = new(RepoArchiver)

models/user.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@ func DeleteUser(ctx context.Context, u *user_model.User) (err error) {
100100

101101
// Delete Comments
102102
const batchSize = 50
103-
for start := 0; ; start += batchSize {
103+
for {
104104
comments := make([]*issues_model.Comment, 0, batchSize)
105-
if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, start).Find(&comments); err != nil {
105+
if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, 0).Find(&comments); err != nil {
106106
return err
107107
}
108108
if len(comments) == 0 {
@@ -200,7 +200,7 @@ func DeleteUser(ctx context.Context, u *user_model.User) (err error) {
200200
// ***** END: ExternalLoginUser *****
201201

202202
if _, err = e.ID(u.ID).Delete(new(user_model.User)); err != nil {
203-
return fmt.Errorf("Delete: %v", err)
203+
return fmt.Errorf("delete: %v", err)
204204
}
205205

206206
return nil

modules/convert/issue_comment.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ func ToTimelineComment(c *issues_model.Comment, doer *user_model.User) *api.Time
101101
}
102102

103103
if c.Time != nil {
104+
err = c.Time.LoadAttributes()
105+
if err != nil {
106+
log.Error("Time.LoadAttributes: %v", err)
107+
return nil
108+
}
109+
104110
comment.TrackedTime = ToTrackedTime(c.Time)
105111
}
106112

0 commit comments

Comments
 (0)