@@ -298,15 +298,15 @@ type CommitStatusIndex struct {
298298 MaxIndex int64 `xorm:"index"`
299299}
300300
301- var getBase = func (ctx context.Context , repoID int64 , sha string ) * xorm.Session {
301+ func makeRepoCommitQuery (ctx context.Context , repoID int64 , sha string ) * xorm.Session {
302302 return db .GetEngine (ctx ).Table (& CommitStatus {}).
303303 Where ("repo_id = ?" , repoID ).And ("sha = ?" , sha )
304304}
305305
306306// GetLatestCommitStatus returns all statuses with a unique context for a given commit.
307307func GetLatestCommitStatus (ctx context.Context , repoID int64 , sha string , listOptions db.ListOptions ) ([]* CommitStatus , error ) {
308308 indices := make ([]int64 , 0 , 10 )
309- sess := getBase (ctx , repoID , sha ).
309+ sess := makeRepoCommitQuery (ctx , repoID , sha ).
310310 Select ("max( `index` ) as `index`" ).
311311 GroupBy ("context_hash" ).
312312 OrderBy ("max( `index` ) desc" )
@@ -320,11 +320,12 @@ func GetLatestCommitStatus(ctx context.Context, repoID int64, sha string, listOp
320320 if len (indices ) == 0 {
321321 return statuses , nil
322322 }
323- return statuses , getBase (ctx , repoID , sha ).And (builder .In ("`index`" , indices )).Find (& statuses )
323+ err := makeRepoCommitQuery (ctx , repoID , sha ).And (builder .In ("`index`" , indices )).Find (& statuses )
324+ return statuses , err
324325}
325326
326327func CountLatestCommitStatus (ctx context.Context , repoID int64 , sha string ) (int64 , error ) {
327- return getBase (ctx , repoID , sha ).
328+ return makeRepoCommitQuery (ctx , repoID , sha ).
328329 Select ("count(context_hash)" ).
329330 GroupBy ("context_hash" ).
330331 Count ()
0 commit comments