@@ -16,6 +16,7 @@ import (
1616	user_model "code.gitea.io/gitea/models/user" 
1717	"code.gitea.io/gitea/modules/git" 
1818	"code.gitea.io/gitea/modules/json" 
19+ 	"code.gitea.io/gitea/modules/setting" 
1920	api "code.gitea.io/gitea/modules/structs" 
2021	"code.gitea.io/gitea/modules/timeutil" 
2122	"code.gitea.io/gitea/modules/util" 
@@ -343,13 +344,13 @@ func InsertRun(ctx context.Context, run *ActionRun, jobs []*jobparser.SingleWork
343344	return  committer .Commit ()
344345}
345346
346- func  GetRunByID (ctx  context.Context , id  int64 ) (* ActionRun , error ) {
347+ func  GetRunByRepoAndID (ctx  context.Context , repoID ,  runID  int64 ) (* ActionRun , error ) {
347348	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 )
349350	if  err  !=  nil  {
350351		return  nil , err 
351352	} 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 )
353354	}
354355
355356	return  & run , nil 
@@ -420,17 +421,10 @@ func UpdateRun(ctx context.Context, run *ActionRun, cols ...string) error {
420421
421422	if  run .Status  !=  0  ||  slices .Contains (cols , "status" ) {
422423		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" )
427425		}
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 
434428		}
435429		if  err  :=  updateRepoRunsNumbers (ctx , run .Repo ); err  !=  nil  {
436430			return  err 
0 commit comments