Skip to content

Commit 094c84e

Browse files
committed
Merge branch 'rebase-forgejo-dependency' into wip-forgejo
2 parents d7e1854 + 030cdd6 commit 094c84e

File tree

292 files changed

+8835
-1262
lines changed

Some content is hidden

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

292 files changed

+8835
-1262
lines changed

.deadcode-out

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ package "code.gitea.io/gitea/models/unittest"
100100
func LoadFixtures
101101
func Copy
102102
func CopyDir
103+
func NewMockWebServer
104+
func NormalizedFullPath
103105
func FixturesDir
104106
func fatalTestError
105107
func InitSettings
@@ -322,6 +324,7 @@ package "code.gitea.io/gitea/services/pull"
322324

323325
package "code.gitea.io/gitea/services/repository"
324326
func IsErrForkAlreadyExist
327+
func UpdateRepositoryUnits
325328

326329
package "code.gitea.io/gitea/services/repository/archiver"
327330
func ArchiveRepository

.golangci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ linters-settings:
9090
desc: do not use the internal package, use AddXxx function instead
9191
- pkg: gopkg.in/ini.v1
9292
desc: do not use the ini package, use gitea's config system instead
93+
- pkg: github.com/minio/sha256-simd
94+
desc: use crypto/sha256 instead, see https://codeberg.org/forgejo/forgejo/pulls/1528
9395

9496
issues:
9597
max-issues-per-linter: 0

assets/go-licenses.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/generate.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ func runGenerateInternalToken(c *cli.Context) error {
7070
}
7171

7272
func runGenerateLfsJwtSecret(c *cli.Context) error {
73-
_, jwtSecretBase64, err := generate.NewJwtSecretBase64()
73+
_, jwtSecretBase64, err := generate.NewJwtSecret()
7474
if err != nil {
7575
return err
7676
}

contrib/ide/vscode/settings.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"go.buildTags": "'sqlite sqlite_unlock_notify'",
2+
"go.buildTags": "sqlite,sqlite_unlock_notify",
33
"go.testFlags": ["-v"]
4-
}
4+
}

custom/conf/app.example.ini

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,10 @@ USER = root
412412
;;
413413
;; Whether execute database models migrations automatically
414414
;AUTO_MIGRATION = true
415+
;;
416+
;; Threshold value (in seconds) beyond which query execution time is logged as a warning in the xorm logger
417+
;;
418+
;SLOW_QUERY_TRESHOLD = 5s
415419

416420
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
417421
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -817,6 +821,11 @@ LEVEL = Info
817821
;; Every new user will have restricted permissions depending on this setting
818822
;DEFAULT_USER_IS_RESTRICTED = false
819823
;;
824+
;; Users will be able to use dots when choosing their username. Disabling this is
825+
;; helpful if your usersare having issues with e.g. RSS feeds or advanced third-party
826+
;; extensions that use strange regex patterns.
827+
; ALLOW_DOTS_IN_USERNAMES = true
828+
;;
820829
;; Either "public", "limited" or "private", default is "public"
821830
;; Limited is for users visible only to signed users
822831
;; Private is for users visible only to members of their organizations
@@ -903,6 +912,14 @@ LEVEL = Info
903912
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
904913
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
905914

915+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
916+
;[badges]
917+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
918+
;; Enable repository badges (via shields.io or a similar generator)
919+
;ENABLED = true
920+
;; Template for the badge generator.
921+
;GENERATOR_URL_TEMPLATE = https://img.shields.io/badge/{{.label}}-{{.text}}-{{.color}}
922+
906923
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
907924
;[repository]
908925
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1470,6 +1487,8 @@ LEVEL = Info
14701487
;;
14711488
;; Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
14721489
;DEFAULT_EMAIL_NOTIFICATIONS = enabled
1490+
;; Send an email to all admins when a new user signs up to inform the admins about this act. Options: true, false
1491+
;SEND_NOTIFICATION_EMAIL_ON_NEW_USER = false
14731492

14741493
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14751494
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1783,9 +1802,6 @@ LEVEL = Info
17831802
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17841803
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
17851804
;;
1786-
;AVATAR_UPLOAD_PATH = data/avatars
1787-
;REPOSITORY_AVATAR_UPLOAD_PATH = data/repo-avatars
1788-
;;
17891805
;; How Gitea deals with missing repository avatars
17901806
;; none = no avatar will be displayed; random = random avatar will be displayed; image = default image will be used
17911807
;REPOSITORY_AVATAR_FALLBACK = none

docs/content/administration/config-cheat-sheet.en-us.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -458,6 +458,7 @@ The following configuration set `Content-Type: application/vnd.android.package-a
458458
- `MAX_IDLE_CONNS` **2**: Max idle database connections on connection pool, default is 2 - this will be capped to `MAX_OPEN_CONNS`.
459459
- `CONN_MAX_LIFETIME` **0 or 3s**: Sets the maximum amount of time a DB connection may be reused - default is 0, meaning there is no limit (except on MySQL where it is 3s - see #6804 & #7071).
460460
- `AUTO_MIGRATION` **true**: Whether execute database models migrations automatically.
461+
- `SLOW_QUERY_THRESHOLD` **5s**: Threshold value in seconds beyond which query execution time is logged as a warning in the xorm logger.
461462

462463
[^1]: It may be necessary to specify a hostport even when listening on a unix socket, as the port is part of the socket name. see [#24552](https://github.com/go-gitea/gitea/issues/24552#issuecomment-1681649367) for additional details.
463464

@@ -517,6 +518,7 @@ And the following unique queues:
517518

518519
- `DEFAULT_EMAIL_NOTIFICATIONS`: **enabled**: Default configuration for email notifications for users (user configurable). Options: enabled, onmention, disabled
519520
- `DISABLE_REGULAR_ORG_CREATION`: **false**: Disallow regular (non-admin) users from creating organizations.
521+
- `SEND_NOTIFICATION_EMAIL_ON_NEW_USER`: **false**: Send an email to all admins when a new user signs up to inform the admins about this act.
520522

521523
## Security (`security`)
522524

go.mod

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ require (
1515
gitea.com/lunny/levelqueue v0.4.2-0.20230414023320-3c0159fe0fe4
1616
github.com/42wim/sshsig v0.0.0-20211121163825-841cf5bbc121
1717
github.com/Azure/go-ntlmssp v0.0.0-20221128193559-754e69321358
18-
github.com/NYTimes/gziphandler v1.1.1
1918
github.com/PuerkitoBio/goquery v1.8.1
2019
github.com/alecthomas/chroma/v2 v2.12.0
2120
github.com/blakesmith/ar v0.0.0-20190502131153-809d4375e1fb
@@ -77,14 +76,12 @@ require (
7776
github.com/mholt/archiver/v3 v3.5.1
7877
github.com/microcosm-cc/bluemonday v1.0.26
7978
github.com/minio/minio-go/v7 v7.0.66
80-
github.com/minio/sha256-simd v1.0.1
8179
github.com/msteinert/pam v1.2.0
8280
github.com/nektos/act v0.2.52
8381
github.com/niklasfasching/go-org v1.7.0
8482
github.com/olivere/elastic/v7 v7.0.32
8583
github.com/opencontainers/go-digest v1.0.0
8684
github.com/opencontainers/image-spec v1.1.0-rc6
87-
github.com/pkg/errors v0.9.1
8885
github.com/pquerna/otp v1.4.0
8986
github.com/prometheus/client_golang v1.18.0
9087
github.com/quasoft/websspi v1.1.2
@@ -100,7 +97,6 @@ require (
10097
github.com/ulikunitz/xz v0.5.11
10198
github.com/urfave/cli/v2 v2.27.1
10299
github.com/xanzy/go-gitlab v0.96.0
103-
github.com/xeipuuv/gojsonschema v1.2.0
104100
github.com/yohcop/openid-go v1.0.1
105101
github.com/yuin/goldmark v1.6.0
106102
github.com/yuin/goldmark-highlighting/v2 v2.0.0-20230729083705-37449abec8cc
@@ -230,6 +226,7 @@ require (
230226
github.com/mholt/acmez v1.2.0 // indirect
231227
github.com/miekg/dns v1.1.58 // indirect
232228
github.com/minio/md5-simd v1.1.2 // indirect
229+
github.com/minio/sha256-simd v1.0.1 // indirect
233230
github.com/mitchellh/copystructure v1.2.0 // indirect
234231
github.com/mitchellh/mapstructure v1.5.0 // indirect
235232
github.com/mitchellh/reflectwalk v1.0.2 // indirect
@@ -245,6 +242,7 @@ require (
245242
github.com/pelletier/go-toml/v2 v2.1.1 // indirect
246243
github.com/pierrec/lz4/v4 v4.1.21 // indirect
247244
github.com/pjbgf/sha1cd v0.3.0 // indirect
245+
github.com/pkg/errors v0.9.1 // indirect
248246
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
249247
github.com/prometheus/client_model v0.5.0 // indirect
250248
github.com/prometheus/common v0.46.0 // indirect
@@ -275,8 +273,6 @@ require (
275273
github.com/valyala/fastjson v1.6.4 // indirect
276274
github.com/x448/float16 v0.8.4 // indirect
277275
github.com/xanzy/ssh-agent v0.3.3 // indirect
278-
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
279-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
280276
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 // indirect
281277
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e // indirect
282278
github.com/zeebo/blake3 v0.2.3 // indirect

go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,6 @@ github.com/Masterminds/sprig/v3 v3.2.3/go.mod h1:rXcFaZ2zZbLRJv/xSysmlgIM1u11eBa
9393
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
9494
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
9595
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
96-
github.com/NYTimes/gziphandler v1.1.1 h1:ZUDjpQae29j0ryrS0u/B8HZfJBtBQHjqw2rQ2cqUQ3I=
97-
github.com/NYTimes/gziphandler v1.1.1/go.mod h1:n/CVRwUEOgIxrgPvAQhUUr9oeUtvrhMomdKFjzJNB0c=
9896
github.com/ProtonMail/go-crypto v1.0.0 h1:LRuvITjQWX+WIfr930YHG2HNfjR1uOfyf5vE0kC2U78=
9997
github.com/ProtonMail/go-crypto v1.0.0/go.mod h1:EjAoLdwvbIOoOQr3ihjnSoLZRtE8azugULFRteWMNc0=
10098
github.com/PuerkitoBio/goquery v1.8.1 h1:uQxhNlArOIdbrH1tr0UXwdVFgDcZDrZVdcpygAcwmWM=
@@ -832,13 +830,6 @@ github.com/xdg-go/scram v1.1.1/go.mod h1:RaEWvsqvNKKvBPvcKeFjrG2cJqOkHTiyTpzz23n
832830
github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4=
833831
github.com/xdg-go/stringprep v1.0.3/go.mod h1:W3f5j4i+9rC0kuIEJL0ky1VpHXQU3ocBgklLGvcBnW8=
834832
github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM=
835-
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
836-
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
837-
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
838-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
839-
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
840-
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
841-
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
842833
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8 h1:nIPpBwaJSVYIxUFsDv3M8ofmx9yWTog9BfvIu0q41lo=
843834
github.com/xi2/xz v0.0.0-20171230120015-48954b6210f8/go.mod h1:HUYIGzjTL3rfEspMxjDjgmT5uz5wzYJKVo23qUhYTos=
844835
github.com/xrash/smetrics v0.0.0-20231213231151-1d8dd44e695e h1:+SOyEddqYF09QP7vr7CgJ1eti3pY9Fn3LHO1M1r/0sI=

models/actions/run.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -171,14 +171,13 @@ func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) err
171171
}
172172

173173
// CancelRunningJobs cancels all running and waiting jobs associated with a specific workflow.
174-
func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string, event webhook_module.HookEventType) error {
174+
func CancelRunningJobs(ctx context.Context, repoID int64, ref, workflowID string) error {
175175
// Find all runs in the specified repository, reference, and workflow with statuses 'Running' or 'Waiting'.
176176
runs, total, err := db.FindAndCount[ActionRun](ctx, FindRunOptions{
177-
RepoID: repoID,
178-
Ref: ref,
179-
WorkflowID: workflowID,
180-
TriggerEvent: event,
181-
Status: []Status{StatusRunning, StatusWaiting},
177+
RepoID: repoID,
178+
Ref: ref,
179+
WorkflowID: workflowID,
180+
Status: []Status{StatusRunning, StatusWaiting},
182181
})
183182
if err != nil {
184183
return err
@@ -312,6 +311,32 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
312311
return commiter.Commit()
313312
}
314313

314+
func GetLatestRun(ctx context.Context, repoID int64) (*ActionRun, error) {
315+
var run ActionRun
316+
has, err := db.GetEngine(ctx).Where("repo_id=?", repoID).OrderBy("id DESC").Limit(1).Get(&run)
317+
if err != nil {
318+
return nil, err
319+
} else if !has {
320+
return nil, fmt.Errorf("latest run: %w", util.ErrNotExist)
321+
}
322+
return &run, nil
323+
}
324+
325+
func GetLatestRunForBranchAndWorkflow(ctx context.Context, repoID int64, branch, workflowFile, event string) (*ActionRun, error) {
326+
var run ActionRun
327+
q := db.GetEngine(ctx).Where("repo_id=?", repoID).And("ref=?", branch).And("workflow_id=?", workflowFile)
328+
if event != "" {
329+
q = q.And("event=?", event)
330+
}
331+
has, err := q.Desc("id").Get(&run)
332+
if err != nil {
333+
return nil, err
334+
} else if !has {
335+
return nil, util.NewNotExistErrorf("run with repo_id %d, ref %s, workflow_id %s", repoID, branch, workflowFile)
336+
}
337+
return &run, nil
338+
}
339+
315340
func GetRunByID(ctx context.Context, id int64) (*ActionRun, error) {
316341
var run ActionRun
317342
has, err := db.GetEngine(ctx).Where("id=?", id).Get(&run)

0 commit comments

Comments
 (0)