Skip to content

Commit d2370bc

Browse files
committed
Merge remote-tracking branch 'giteaofficial/main'
* giteaofficial/main: [skip ci] Updated licenses and gitignores Prevent anonymous container access if `RequireSignInView` is enabled (go-gitea#28877) Don't show new pr button when page is not compare pull (go-gitea#26431) Avoid duplicate JS error messages on UI (go-gitea#28873) Fix branch list bug which displayed default branch twice (go-gitea#28878) Revert adding htmx until we finaly decide to add it (go-gitea#28879) Don't do a full page load when clicking the follow button (go-gitea#28872) Don't do a full page load when clicking the subscribe button (go-gitea#28871) Fix incorrect PostgreSQL connection string for Unix sockets (go-gitea#28865) Run `npm audit fix` (go-gitea#28866) Fix migrate storage bug (go-gitea#28830) Set the `isPermaLink` attribute to `false` in the `guid` sub-element (go-gitea#28860) In administration documentation about environment variables, point to those for the Go runtime instead of Go compiler (go-gitea#28859) Move doctor package from modules to services (go-gitea#28856) Add support for sha256 repositories (go-gitea#23894) Fix incorrect action duration time when rerun the job before executed once (go-gitea#28364) Fix some RPM registry flaws (go-gitea#28782) tests: missing refs/ in bare repositories (go-gitea#28844) Fix archive creating LFS hooks and breaking pull requests (go-gitea#28848)
2 parents 0fa3966 + 692929b commit d2370bc

File tree

159 files changed

+1896
-614
lines changed

Some content is hidden

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

159 files changed

+1896
-614
lines changed

cmd/doctor.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ import (
1515
"code.gitea.io/gitea/models/migrations"
1616
migrate_base "code.gitea.io/gitea/models/migrations/base"
1717
"code.gitea.io/gitea/modules/container"
18-
"code.gitea.io/gitea/modules/doctor"
1918
"code.gitea.io/gitea/modules/log"
2019
"code.gitea.io/gitea/modules/setting"
20+
"code.gitea.io/gitea/services/doctor"
2121

2222
"github.com/urfave/cli/v2"
2323
"xorm.io/xorm"

cmd/doctor_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import (
77
"context"
88
"testing"
99

10-
"code.gitea.io/gitea/modules/doctor"
1110
"code.gitea.io/gitea/modules/log"
11+
"code.gitea.io/gitea/services/doctor"
1212

1313
"github.com/stretchr/testify/assert"
1414
"github.com/urfave/cli/v2"

cmd/migrate_storage.go

+6
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ func migrateLFS(ctx context.Context, dstStorage storage.ObjectStorage) error {
110110

111111
func migrateAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error {
112112
return db.Iterate(ctx, nil, func(ctx context.Context, user *user_model.User) error {
113+
if user.CustomAvatarRelativePath() == "" {
114+
return nil
115+
}
113116
_, err := storage.Copy(dstStorage, user.CustomAvatarRelativePath(), storage.Avatars, user.CustomAvatarRelativePath())
114117
return err
115118
})
116119
}
117120

118121
func migrateRepoAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error {
119122
return db.Iterate(ctx, nil, func(ctx context.Context, repo *repo_model.Repository) error {
123+
if repo.CustomAvatarRelativePath() == "" {
124+
return nil
125+
}
120126
_, err := storage.Copy(dstStorage, repo.CustomAvatarRelativePath(), storage.RepoAvatars, repo.CustomAvatarRelativePath())
121127
return err
122128
})

docs/content/administration/environment-variables.en-us.md

+6-5
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ GITEA_CUSTOM=/home/gitea/custom ./gitea web
2727

2828
## From Go language
2929

30-
As Gitea is written in Go, it uses some Go variables, such as:
30+
As Gitea is written in Go, it uses some variables that influence the behaviour of Go's runtime, such as:
3131

32-
- `GOOS`
33-
- `GOARCH`
34-
- [`GOPATH`](https://golang.org/cmd/go/#hdr-GOPATH_environment_variable)
32+
- `GOMEMLIMIT`
33+
- `GOGC`
34+
- `GOMAXPROCS`
35+
- `GODEBUG`
3536

3637
For documentation about each of the variables available, refer to the
37-
[official Go documentation](https://golang.org/cmd/go/#hdr-Environment_variables).
38+
[official Go documentation on runtime environment variables](https://pkg.go.dev/runtime#hdr-Environment_Variables).
3839

3940
## Gitea files
4041

docs/content/usage/packages/rpm.en-us.md

+35-14
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,34 @@ The following examples use `dnf`.
2424

2525
## Configuring the package registry
2626

27-
To register the RPM registry add the url to the list of known apt sources:
27+
To register the RPM registry add the url to the list of known sources:
2828

2929
```shell
3030
dnf config-manager --add-repo https://gitea.example.com/api/packages/{owner}/rpm/{group}.repo
3131
```
3232

33-
| Placeholder | Description |
34-
| ----------- |----------------------------------------------------|
35-
| `owner` | The owner of the package. |
36-
| `group` | Everything, e.g. `el7`, `rocky/el9` , `test/fc38`.|
33+
| Placeholder | Description |
34+
| ----------- | ----------- |
35+
| `owner` | The owner of the package. |
36+
| `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. |
37+
38+
Example:
39+
40+
```shell
41+
# without a group
42+
dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm.repo
43+
44+
# with the group 'centos/el7'
45+
dnf config-manager --add-repo https://gitea.example.com/api/packages/testuser/rpm/centos/el7.repo
46+
```
3747

3848
If the registry is private, provide credentials in the url. You can use a password or a [personal access token](development/api-usage.md#authentication):
3949

4050
```shell
4151
dnf config-manager --add-repo https://{username}:{your_password_or_token}@gitea.example.com/api/packages/{owner}/rpm/{group}.repo
4252
```
4353

44-
You have to add the credentials to the urls in the `rpm.repo` file in `/etc/yum.repos.d` too.
54+
You have to add the credentials to the urls in the created `.repo` file in `/etc/yum.repos.d` too.
4555

4656
## Publish a package
4757

@@ -54,11 +64,17 @@ PUT https://gitea.example.com/api/packages/{owner}/rpm/{group}/upload
5464
| Parameter | Description |
5565
| --------- | ----------- |
5666
| `owner` | The owner of the package. |
57-
| `group` | Everything, e.g. `el7`, `rocky/el9` , `test/fc38`.|
67+
| `group` | Optional: Everything, e.g. empty, `el7`, `rocky/el9`, `test/fc38`. |
5868

5969
Example request using HTTP Basic authentication:
6070

6171
```shell
72+
# without a group
73+
curl --user your_username:your_password_or_token \
74+
--upload-file path/to/file.rpm \
75+
https://gitea.example.com/api/packages/testuser/rpm/upload
76+
77+
# with the group 'centos/el7'
6278
curl --user your_username:your_password_or_token \
6379
--upload-file path/to/file.rpm \
6480
https://gitea.example.com/api/packages/testuser/rpm/centos/el7/upload
@@ -83,17 +99,22 @@ To delete an RPM package perform a HTTP DELETE operation. This will delete the p
8399
DELETE https://gitea.example.com/api/packages/{owner}/rpm/{group}/package/{package_name}/{package_version}/{architecture}
84100
```
85101

86-
| Parameter | Description |
87-
|-------------------|----------------------------|
88-
| `owner` | The owner of the package. |
89-
| `group` | The package group . |
90-
| `package_name` | The package name. |
91-
| `package_version` | The package version. |
92-
| `architecture` | The package architecture. |
102+
| Parameter | Description |
103+
| ----------------- | ----------- |
104+
| `owner` | The owner of the package. |
105+
| `group` | Optional: The package group. |
106+
| `package_name` | The package name. |
107+
| `package_version` | The package version. |
108+
| `architecture` | The package architecture. |
93109

94110
Example request using HTTP Basic authentication:
95111

96112
```shell
113+
# without a group
114+
curl --user your_username:your_token_or_password -X DELETE \
115+
https://gitea.example.com/api/packages/testuser/rpm/package/test-package/1.0.0/x86_64
116+
117+
# with the group 'centos/el7'
97118
curl --user your_username:your_token_or_password -X DELETE \
98119
https://gitea.example.com/api/packages/testuser/rpm/centos/el7/package/test-package/1.0.0/x86_64
99120
```

go.mod

+2
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,8 @@ replace github.com/shurcooL/vfsgen => github.com/lunny/vfsgen v0.0.0-20220105142
306306

307307
replace github.com/nektos/act => gitea.com/gitea/act v0.2.51
308308

309+
replace github.com/gorilla/feeds => github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5
310+
309311
exclude github.com/gofrs/uuid v3.2.0+incompatible
310312

311313
exclude github.com/gofrs/uuid v4.0.0+incompatible

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,6 @@ github.com/gorilla/context v1.1.1 h1:AWwleXJkX/nhcU9bZSnZoi3h/qGYqQAGhq6zZe/aQW8
501501
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
502502
github.com/gorilla/css v1.0.1 h1:ntNaBIghp6JmvWnxbZKANoLyuXTPZ4cAMlo6RyhlbO8=
503503
github.com/gorilla/css v1.0.1/go.mod h1:BvnYkspnSzMmwRK+b8/xgNPLiIuNZr6vbZBTPQ2A3b0=
504-
github.com/gorilla/feeds v1.1.2 h1:pxzZ5PD3RJdhFH2FsJJ4x6PqMqbgFk1+Vez4XWBW8Iw=
505-
github.com/gorilla/feeds v1.1.2/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
506504
github.com/gorilla/handlers v1.5.2 h1:cLTUSsNkgcwhgRqvCNmdbRWG0A3N4F+M2nWKdScwyEE=
507505
github.com/gorilla/handlers v1.5.2/go.mod h1:dX+xVpaxdSw+q0Qek8SSsl3dfMk3jNddUkMzo0GtH0w=
508506
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
@@ -904,6 +902,8 @@ github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMx
904902
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
905903
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=
906904
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
905+
github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5 h1:3seWKGVhGoc66Ht5QlhQsr4xT2caDnFegsnh2NqvENU=
906+
github.com/yardenshoham/feeds v0.0.0-20240110072658-f3d0c21c0bd5/go.mod h1:WMib8uJP3BbY+X8Szd1rA5Pzhdfh+HCCAYT2z7Fza6Y=
907907
github.com/yohcop/openid-go v1.0.1 h1:DPRd3iPO5F6O5zX2e62XpVAbPT6wV51cuucH0z9g3js=
908908
github.com/yohcop/openid-go v1.0.1/go.mod h1:b/AvD03P0KHj4yuihb+VtLD6bYYgsy0zqBzPCRjkCNs=
909909
github.com/youmark/pkcs8 v0.0.0-20181117223130-1be2e3e5546d/go.mod h1:rHwXgn7JulP+udvsHwJoVG1YGAP6VLg4y9I5dyZdqmA=

models/actions/run.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,13 @@ type ActionRun struct {
4646
TriggerEvent string // the trigger event defined in the `on` configuration of the triggered workflow
4747
Status Status `xorm:"index"`
4848
Version int `xorm:"version default 0"` // Status could be updated concomitantly, so an optimistic lock is needed
49-
Started timeutil.TimeStamp
50-
Stopped timeutil.TimeStamp
51-
Created timeutil.TimeStamp `xorm:"created"`
52-
Updated timeutil.TimeStamp `xorm:"updated"`
49+
// Started and Stopped is used for recording last run time, if rerun happened, they will be reset to 0
50+
Started timeutil.TimeStamp
51+
Stopped timeutil.TimeStamp
52+
// PreviousDuration is used for recording previous duration
53+
PreviousDuration time.Duration
54+
Created timeutil.TimeStamp `xorm:"created"`
55+
Updated timeutil.TimeStamp `xorm:"updated"`
5356
}
5457

5558
func init() {
@@ -118,7 +121,7 @@ func (run *ActionRun) LoadAttributes(ctx context.Context) error {
118121
}
119122

120123
func (run *ActionRun) Duration() time.Duration {
121-
return calculateDuration(run.Started, run.Stopped, run.Status)
124+
return calculateDuration(run.Started, run.Stopped, run.Status) + run.PreviousDuration
122125
}
123126

124127
func (run *ActionRun) GetPushEventPayload() (*api.PushPayload, error) {

models/git/commit_status.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type CommitStatus struct {
3737
SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_sha_index)"`
3838
TargetURL string `xorm:"TEXT"`
3939
Description string `xorm:"TEXT"`
40-
ContextHash string `xorm:"char(40) index"`
40+
ContextHash string `xorm:"VARCHAR(64) index"`
4141
Context string `xorm:"TEXT"`
4242
Creator *user_model.User `xorm:"-"`
4343
CreatorID int64

models/issues/comment.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ type Comment struct {
270270
UpdatedUnix timeutil.TimeStamp `xorm:"INDEX updated"`
271271

272272
// Reference issue in commit message
273-
CommitSHA string `xorm:"VARCHAR(40)"`
273+
CommitSHA string `xorm:"VARCHAR(64)"`
274274

275275
Attachments []*repo_model.Attachment `xorm:"-"`
276276
Reactions ReactionList `xorm:"-"`

models/issues/pull.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -171,11 +171,11 @@ type PullRequest struct {
171171
HeadBranch string
172172
HeadCommitID string `xorm:"-"`
173173
BaseBranch string
174-
MergeBase string `xorm:"VARCHAR(40)"`
174+
MergeBase string `xorm:"VARCHAR(64)"`
175175
AllowMaintainerEdit bool `xorm:"NOT NULL DEFAULT false"`
176176

177177
HasMerged bool `xorm:"INDEX"`
178-
MergedCommitID string `xorm:"VARCHAR(40)"`
178+
MergedCommitID string `xorm:"VARCHAR(64)"`
179179
MergerID int64 `xorm:"INDEX"`
180180
Merger *user_model.User `xorm:"-"`
181181
MergedUnix timeutil.TimeStamp `xorm:"updated INDEX"`

models/issues/review.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ type Review struct {
116116
Content string `xorm:"TEXT"`
117117
// Official is a review made by an assigned approver (counts towards approval)
118118
Official bool `xorm:"NOT NULL DEFAULT false"`
119-
CommitID string `xorm:"VARCHAR(40)"`
119+
CommitID string `xorm:"VARCHAR(64)"`
120120
Stale bool `xorm:"NOT NULL DEFAULT false"`
121121
Dismissed bool `xorm:"NOT NULL DEFAULT false"`
122122

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# type Repository struct {
2+
# ID int64 `xorm:"pk autoincr"`
3+
# }
4+
-
5+
id: 1
6+
-
7+
id: 2
8+
-
9+
id: 3
10+
-
11+
id: 10

models/migrations/migrations.go

+4
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,10 @@ var migrations = []Migration{
554554
NewMigration("Add combined Index to issue_user.uid and issue_id", v1_22.AddCombinedIndexToIssueUser),
555555
// v284 -> v285
556556
NewMigration("Add ignore stale approval column on branch table", v1_22.AddIgnoreStaleApprovalsColumnToProtectedBranchTable),
557+
// v285 -> v286
558+
NewMigration("Add PreviousDuration to ActionRun", v1_22.AddPreviousDurationToActionRun),
559+
// v286 -> v287
560+
NewMigration("Add support for SHA256 git repositories", v1_22.AdjustDBForSha256),
557561
}
558562

559563
// GetCurrentDBVersion returns the current db version

models/migrations/v1_22/v285.go

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package v1_22 //nolint
5+
6+
import (
7+
"time"
8+
9+
"xorm.io/xorm"
10+
)
11+
12+
func AddPreviousDurationToActionRun(x *xorm.Engine) error {
13+
type ActionRun struct {
14+
PreviousDuration time.Duration
15+
}
16+
17+
return x.Sync(&ActionRun{})
18+
}

models/migrations/v1_22/v286.go

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
// Copyright 2023 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
package v1_22 //nolint
4+
5+
import (
6+
"errors"
7+
"fmt"
8+
9+
"code.gitea.io/gitea/modules/log"
10+
"code.gitea.io/gitea/modules/setting"
11+
12+
"xorm.io/xorm"
13+
)
14+
15+
func expandHashReferencesToSha256(x *xorm.Engine) error {
16+
alteredTables := [][2]string{
17+
{"commit_status", "context_hash"},
18+
{"comment", "commit_sha"},
19+
{"pull_request", "merge_base"},
20+
{"pull_request", "merged_commit_id"},
21+
{"review", "commit_id"},
22+
{"review_state", "commit_sha"},
23+
{"repo_archiver", "commit_id"},
24+
{"release", "sha1"},
25+
{"repo_indexer_status", "commit_sha"},
26+
}
27+
28+
db := x.NewSession()
29+
defer db.Close()
30+
31+
if err := db.Begin(); err != nil {
32+
return err
33+
}
34+
35+
if !setting.Database.Type.IsSQLite3() {
36+
if setting.Database.Type.IsMSSQL() {
37+
// drop indexes that need to be re-created afterwards
38+
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",
42+
}
43+
for _, s := range droppedIndexes {
44+
_, err := db.Exec(s)
45+
if err != nil {
46+
return errors.New(s + " " + err.Error())
47+
}
48+
}
49+
}
50+
51+
for _, alts := range alteredTables {
52+
var err error
53+
if setting.Database.Type.IsMySQL() {
54+
_, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` MODIFY COLUMN `%s` VARCHAR(64)", alts[0], alts[1]))
55+
} else if setting.Database.Type.IsMSSQL() {
56+
_, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` VARCHAR(64)", alts[0], alts[1]))
57+
} else {
58+
_, err = db.Exec(fmt.Sprintf("ALTER TABLE `%s` ALTER COLUMN `%s` TYPE VARCHAR(64)", alts[0], alts[1]))
59+
}
60+
if err != nil {
61+
return fmt.Errorf("alter column '%s' of table '%s' failed: %w", alts[1], alts[0], err)
62+
}
63+
}
64+
65+
if setting.Database.Type.IsMSSQL() {
66+
recreateIndexes := []string{
67+
"CREATE INDEX IDX_commit_status_context_hash ON commit_status(context_hash)",
68+
"CREATE UNIQUE INDEX UQE_review_state_pull_commit_user ON review_state(user_id, pull_id, commit_sha)",
69+
"CREATE UNIQUE INDEX UQE_repo_archiver_s ON repo_archiver(repo_id, type, commit_id)",
70+
}
71+
for _, s := range recreateIndexes {
72+
_, err := db.Exec(s)
73+
if err != nil {
74+
return errors.New(s + " " + err.Error())
75+
}
76+
}
77+
}
78+
}
79+
log.Debug("Updated database tables to hold SHA256 git hash references")
80+
81+
return db.Commit()
82+
}
83+
84+
func addObjectFormatNameToRepository(x *xorm.Engine) error {
85+
type Repository struct {
86+
ObjectFormatName string `xorm:"VARCHAR(6) NOT NULL DEFAULT 'sha1'"`
87+
}
88+
89+
if err := x.Sync(new(Repository)); err != nil {
90+
return err
91+
}
92+
93+
// Here to catch weird edge-cases where column constraints above are
94+
// not applied by the DB backend
95+
_, err := x.Exec("UPDATE repository set object_format_name = 'sha1' WHERE object_format_name = '' or object_format_name IS NULL")
96+
return err
97+
}
98+
99+
func AdjustDBForSha256(x *xorm.Engine) error {
100+
if err := expandHashReferencesToSha256(x); err != nil {
101+
return err
102+
}
103+
return addObjectFormatNameToRepository(x)
104+
}

0 commit comments

Comments
 (0)