Skip to content

Commit 39a1b4c

Browse files
committed
Merge remote-tracking branch 'origin/actually_disable_stars' into actually_disable_stars
2 parents 2c5d553 + 7527a40 commit 39a1b4c

File tree

284 files changed

+4138
-3029
lines changed

Some content is hidden

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

284 files changed

+4138
-3029
lines changed

.eslintrc.cjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ module.exports = {
403403
'github/a11y-svg-has-accessible-name': [0],
404404
'github/array-foreach': [0],
405405
'github/async-currenttarget': [2],
406-
'github/async-preventdefault': [2],
406+
'github/async-preventdefault': [0], // https://github.com/github/eslint-plugin-github/issues/599
407407
'github/authenticity-token': [0],
408408
'github/get-attribute': [0],
409409
'github/js-class-name': [0],

cmd/web.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@ import (
1818

1919
"code.gitea.io/gitea/modules/container"
2020
"code.gitea.io/gitea/modules/graceful"
21+
"code.gitea.io/gitea/modules/gtprof"
2122
"code.gitea.io/gitea/modules/log"
2223
"code.gitea.io/gitea/modules/process"
2324
"code.gitea.io/gitea/modules/public"
2425
"code.gitea.io/gitea/modules/setting"
26+
"code.gitea.io/gitea/modules/util"
2527
"code.gitea.io/gitea/routers"
2628
"code.gitea.io/gitea/routers/install"
2729

@@ -218,6 +220,8 @@ func serveInstalled(ctx *cli.Context) error {
218220
}
219221
}
220222

223+
gtprof.EnableBuiltinTracer(util.Iif(setting.IsProd, 2000*time.Millisecond, 100*time.Millisecond))
224+
221225
// Set up Chi routes
222226
webRoutes := routers.NormalRoutes()
223227
err := listen(webRoutes, true)

flake.lock

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

flake.nix

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,14 @@
2929
poetry
3030

3131
# backend
32+
go_1_23
3233
gofumpt
3334
sqlite
3435
];
36+
shellHook = ''
37+
export GO="${pkgs.go_1_23}/bin/go"
38+
export GOROOT="${pkgs.go_1_23}/share/go"
39+
'';
3540
};
3641
}
3742
);

models/actions/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ func (run *ActionRun) RefLink() string {
8888
if refName.IsPull() {
8989
return run.Repo.Link() + "/pulls/" + refName.ShortName()
9090
}
91-
return git.RefURL(run.Repo.Link(), run.Ref)
91+
return run.Repo.Link() + "/src/" + refName.RefWebLinkPath()
9292
}
9393

9494
// PrettyRef return #id for pull ref or ShortName for others

models/activities/action.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ func (a *Action) GetBranch() string {
355355

356356
// GetRefLink returns the action's ref link.
357357
func (a *Action) GetRefLink(ctx context.Context) string {
358-
return git.RefURL(a.GetRepoLink(ctx), a.RefName)
358+
return a.GetRepoLink(ctx) + "/src/" + git.RefName(a.RefName).RefWebLinkPath()
359359
}
360360

361361
// GetTag returns the action's repository tag.

models/db/engine_hook.go

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,36 @@ import (
77
"context"
88
"time"
99

10+
"code.gitea.io/gitea/modules/gtprof"
1011
"code.gitea.io/gitea/modules/log"
12+
"code.gitea.io/gitea/modules/setting"
1113

1214
"xorm.io/xorm/contexts"
1315
)
1416

15-
type SlowQueryHook struct {
17+
type EngineHook struct {
1618
Threshold time.Duration
1719
Logger log.Logger
1820
}
1921

20-
var _ contexts.Hook = (*SlowQueryHook)(nil)
22+
var _ contexts.Hook = (*EngineHook)(nil)
2123

22-
func (*SlowQueryHook) BeforeProcess(c *contexts.ContextHook) (context.Context, error) {
23-
return c.Ctx, nil
24+
func (*EngineHook) BeforeProcess(c *contexts.ContextHook) (context.Context, error) {
25+
ctx, _ := gtprof.GetTracer().Start(c.Ctx, gtprof.TraceSpanDatabase)
26+
return ctx, nil
2427
}
2528

26-
func (h *SlowQueryHook) AfterProcess(c *contexts.ContextHook) error {
29+
func (h *EngineHook) AfterProcess(c *contexts.ContextHook) error {
30+
span := gtprof.GetContextSpan(c.Ctx)
31+
if span != nil {
32+
// Do not record SQL parameters here:
33+
// * It shouldn't expose the parameters because they contain sensitive information, end users need to report the trace details safely.
34+
// * Some parameters contain quite long texts, waste memory and are difficult to display.
35+
span.SetAttributeString(gtprof.TraceAttrDbSQL, c.SQL)
36+
span.End()
37+
} else {
38+
setting.PanicInDevOrTesting("span in database engine hook is nil")
39+
}
2740
if c.ExecuteTime >= h.Threshold {
2841
// 8 is the amount of skips passed to runtime.Caller, so that in the log the correct function
2942
// is being displayed (the function that ultimately wants to execute the query in the code)

models/db/engine_init.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func InitEngine(ctx context.Context) error {
7272
xe.SetDefaultContext(ctx)
7373

7474
if setting.Database.SlowQueryThreshold > 0 {
75-
xe.AddHook(&SlowQueryHook{
75+
xe.AddHook(&EngineHook{
7676
Threshold: setting.Database.SlowQueryThreshold,
7777
Logger: log.GetLogger("xorm"),
7878
})

models/fixtures/access.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,3 +171,9 @@
171171
user_id: 40
172172
repo_id: 61
173173
mode: 4
174+
175+
-
176+
id: 30
177+
user_id: 40
178+
repo_id: 1
179+
mode: 2

models/fixtures/webhook.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,31 @@
2222
content_type: 1 # json
2323
events: '{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}'
2424
is_active: true
25+
2526
-
2627
id: 4
2728
repo_id: 2
2829
url: www.example.com/url4
2930
content_type: 1 # json
3031
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
3132
is_active: true
33+
34+
-
35+
id: 5
36+
repo_id: 0
37+
owner_id: 0
38+
url: www.example.com/url5
39+
content_type: 1 # json
40+
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
41+
is_active: true
42+
is_system_webhook: true
43+
44+
-
45+
id: 6
46+
repo_id: 0
47+
owner_id: 0
48+
url: www.example.com/url6
49+
content_type: 1 # json
50+
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
51+
is_active: true
52+
is_system_webhook: false

0 commit comments

Comments
 (0)