Skip to content

Commit 66d8cdf

Browse files
Merge branch 'main' into [email protected]
2 parents 1cff2d4 + bb1f523 commit 66d8cdf

File tree

38 files changed

+466
-48
lines changed

38 files changed

+466
-48
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,6 @@ prime/
124124
/AGENT.md
125125
/CLAUDE.md
126126
/llms.txt
127+
128+
# Ignore worktrees when working on multiple branches
129+
.worktrees/

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ require (
109109
github.com/ulikunitz/xz v0.5.15
110110
github.com/urfave/cli-docs/v3 v3.0.0-alpha6
111111
github.com/urfave/cli/v3 v3.4.1
112-
github.com/wneessen/go-mail v0.7.0
112+
github.com/wneessen/go-mail v0.7.2
113113
github.com/xeipuuv/gojsonschema v1.2.0
114114
github.com/yohcop/openid-go v1.0.1
115115
github.com/yuin/goldmark v1.7.13

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -768,8 +768,8 @@ github.com/urfave/cli/v3 v3.4.1/go.mod h1:FJSKtM/9AiiTOJL4fJ6TbMUkxBXn7GO9guZqoZ
768768
github.com/valyala/fastjson v1.6.4 h1:uAUNq9Z6ymTgGhcm0UynUAB6tlbakBrz6CQFax3BXVQ=
769769
github.com/valyala/fastjson v1.6.4/go.mod h1:CLCAqky6SMuOcxStkYQvblddUtoRxhYMGLrsQns1aXY=
770770
github.com/willf/bitset v1.1.10/go.mod h1:RjeCKbqT1RxIR/KWY6phxZiaY1IyutSBfGjNPySAYV4=
771-
github.com/wneessen/go-mail v0.7.0 h1:/Wmgd5AVjp5PA+Ken5EFfr+QR83gmqHli9HcAhh0vnU=
772-
github.com/wneessen/go-mail v0.7.0/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k=
771+
github.com/wneessen/go-mail v0.7.2 h1:xxPnhZ6IZLSgxShebmZ6DPKh1b6OJcoHfzy7UjOkzS8=
772+
github.com/wneessen/go-mail v0.7.2/go.mod h1:+TkW6QP3EVkgTEqHtVmnAE/1MRhmzb8Y9/W3pweuS+k=
773773
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
774774
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
775775
github.com/xanzy/ssh-agent v0.3.3 h1:+/15pJfg/RsTxqYcX6fHqOXZwwMP+2VyYWJeWM2qQFM=

models/actions/main_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ func TestMain(m *testing.M) {
1313
unittest.MainTest(m, &unittest.TestOptions{
1414
FixtureFiles: []string{
1515
"action_runner_token.yml",
16+
"action_run.yml",
17+
"repository.yml",
1618
},
1719
})
1820
}

models/actions/run.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,11 @@ func (run *ActionRun) IsSchedule() bool {
193193
return run.ScheduleID > 0
194194
}
195195

196+
// UpdateRepoRunsNumbers updates the number of runs and closed runs of a repository.
196197
func UpdateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
197198
_, err := db.GetEngine(ctx).ID(repo.ID).
198199
NoAutoTime().
200+
Cols("num_action_runs", "num_closed_action_runs").
199201
SetExpr("num_action_runs",
200202
builder.Select("count(*)").From("action_run").
201203
Where(builder.Eq{"repo_id": repo.ID}),

models/actions/run_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2025 The Gitea Authors. All rights reserved.
2+
// SPDX-License-Identifier: MIT
3+
4+
package actions
5+
6+
import (
7+
"testing"
8+
9+
"code.gitea.io/gitea/models/db"
10+
repo_model "code.gitea.io/gitea/models/repo"
11+
"code.gitea.io/gitea/models/unittest"
12+
13+
"github.com/stretchr/testify/assert"
14+
)
15+
16+
func TestUpdateRepoRunsNumbers(t *testing.T) {
17+
assert.NoError(t, unittest.PrepareTestDatabase())
18+
19+
// update the number to a wrong one, the original is 3
20+
_, err := db.GetEngine(t.Context()).ID(4).Cols("num_closed_action_runs").Update(&repo_model.Repository{
21+
NumClosedActionRuns: 2,
22+
})
23+
assert.NoError(t, err)
24+
25+
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
26+
assert.Equal(t, 4, repo.NumActionRuns)
27+
assert.Equal(t, 2, repo.NumClosedActionRuns)
28+
29+
// now update will correct them, only num_actionr_runs and num_closed_action_runs should be updated
30+
err = UpdateRepoRunsNumbers(t.Context(), repo)
31+
assert.NoError(t, err)
32+
repo = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 4})
33+
assert.Equal(t, 5, repo.NumActionRuns)
34+
assert.Equal(t, 3, repo.NumClosedActionRuns)
35+
}

models/activities/notification.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ func SetNotificationStatus(ctx context.Context, notificationID int64, user *user
386386

387387
notification.Status = status
388388

389-
_, err = db.GetEngine(ctx).ID(notificationID).Update(notification)
389+
_, err = db.GetEngine(ctx).ID(notificationID).Cols("status").Update(notification)
390390
return notification, err
391391
}
392392

models/asymkey/gpg_key_verify.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func VerifyGPGKey(ctx context.Context, ownerID int64, keyID, token, signature st
7878
}
7979

8080
key.Verified = true
81-
if _, err := db.GetEngine(ctx).ID(key.ID).SetExpr("verified", true).Update(new(GPGKey)); err != nil {
81+
if _, err := db.GetEngine(ctx).ID(key.ID).Cols("verified").Update(key); err != nil {
8282
return "", err
8383
}
8484

models/fixtures/action_run.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,23 @@
159159
updated: 1683636626
160160
need_approval: 0
161161
approved_by: 0
162+
-
163+
id: 805
164+
title: "update actions"
165+
repo_id: 4
166+
owner_id: 1
167+
workflow_id: "artifact.yaml"
168+
index: 191
169+
trigger_user_id: 1
170+
ref: "refs/heads/master"
171+
commit_sha: "c2d72f548424103f01ee1dc02889c1e2bff816b0"
172+
event: "push"
173+
trigger_event: "push"
174+
is_fork_pull_request: 0
175+
status: 5
176+
started: 1683636528
177+
stopped: 1683636626
178+
created: 1683636108
179+
updated: 1683636626
180+
need_approval: 0
181+
approved_by: 0

models/fixtures/action_run_job.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,3 +143,17 @@
143143
status: 1
144144
started: 1683636528
145145
stopped: 1683636626
146+
-
147+
id: 206
148+
run_id: 805
149+
repo_id: 4
150+
owner_id: 1
151+
commit_sha: c2d72f548424103f01ee1dc02889c1e2bff816b0
152+
is_fork_pull_request: 0
153+
name: job_2
154+
attempt: 1
155+
job_id: job_2
156+
task_id: 56
157+
status: 3
158+
started: 1683636528
159+
stopped: 1683636626

0 commit comments

Comments
 (0)