@@ -16,6 +16,7 @@ import (
16
16
user_model "code.gitea.io/gitea/models/user"
17
17
"code.gitea.io/gitea/modules/git"
18
18
"code.gitea.io/gitea/modules/json"
19
+ "code.gitea.io/gitea/modules/setting"
19
20
api "code.gitea.io/gitea/modules/structs"
20
21
"code.gitea.io/gitea/modules/timeutil"
21
22
"code.gitea.io/gitea/modules/util"
@@ -343,13 +344,13 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
343
344
return committer .Commit ()
344
345
}
345
346
346
- func GetRunByID (ctx context.Context , id int64 ) (* ActionRun , error ) {
347
+ func GetRunByRepoAndID (ctx context.Context , repoID , runID int64 ) (* ActionRun , error ) {
347
348
var run ActionRun
348
- has , err := db .GetEngine (ctx ).Where ("id=?" , id ).Get (& run )
349
+ has , err := db .GetEngine (ctx ).Where ("id=? AND repo_id=? " , runID , repoID ).Get (& run )
349
350
if err != nil {
350
351
return nil , err
351
352
} else if ! has {
352
- return nil , fmt .Errorf ("run with id %d: %w" , id , util .ErrNotExist )
353
+ return nil , fmt .Errorf ("run with id %d: %w" , runID , util .ErrNotExist )
353
354
}
354
355
355
356
return & run , nil
@@ -420,17 +421,10 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
420
421
421
422
if run .Status != 0 || slices .Contains (cols , "status" ) {
422
423
if run .RepoID == 0 {
423
- run , err = GetRunByID (ctx , run .ID )
424
- if err != nil {
425
- return err
426
- }
424
+ setting .PanicInDevOrTesting ("RepoID should not be 0" )
427
425
}
428
- if run .Repo == nil {
429
- repo , err := repo_model .GetRepositoryByID (ctx , run .RepoID )
430
- if err != nil {
431
- return err
432
- }
433
- run .Repo = repo
426
+ if err = run .LoadRepo (ctx ); err != nil {
427
+ return err
434
428
}
435
429
if err := updateRepoRunsNumbers (ctx , run .Repo ); err != nil {
436
430
return err
0 commit comments