@@ -15,10 +15,11 @@ import (
1515
1616// CommitStatusSummary holds the latest commit Status of a single Commit
1717type CommitStatusSummary struct {
18- ID int64 `xorm:"pk autoincr"`
19- RepoID int64 `xorm:"INDEX UNIQUE(repo_id_sha)"`
20- SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_id_sha)"`
21- State api.CommitStatusState `xorm:"VARCHAR(7) NOT NULL"`
18+ ID int64 `xorm:"pk autoincr"`
19+ RepoID int64 `xorm:"INDEX UNIQUE(repo_id_sha)"`
20+ SHA string `xorm:"VARCHAR(64) NOT NULL INDEX UNIQUE(repo_id_sha)"`
21+ State api.CommitStatusState `xorm:"VARCHAR(7) NOT NULL"`
22+ TargetURL string `xorm:"TEXT"`
2223}
2324
2425func init () {
@@ -44,9 +45,10 @@ func GetLatestCommitStatusForRepoAndSHAs(ctx context.Context, repoSHAs []RepoSHA
4445 commitStatuses := make ([]* CommitStatus , 0 , len (repoSHAs ))
4546 for _ , summary := range summaries {
4647 commitStatuses = append (commitStatuses , & CommitStatus {
47- RepoID : summary .RepoID ,
48- SHA : summary .SHA ,
49- State : summary .State ,
48+ RepoID : summary .RepoID ,
49+ SHA : summary .SHA ,
50+ State : summary .State ,
51+ TargetURL : summary .TargetURL ,
5052 })
5153 }
5254 return commitStatuses , nil
@@ -61,22 +63,24 @@ func UpdateCommitStatusSummary(ctx context.Context, repoID int64, sha string) er
6163 // mysql will return 0 when update a record which state hasn't been changed which behaviour is different from other database,
6264 // so we need to use insert in on duplicate
6365 if setting .Database .Type .IsMySQL () {
64- _ , err := db .GetEngine (ctx ).Exec ("INSERT INTO commit_status_summary (repo_id,sha,state) VALUES (?,?,?) ON DUPLICATE KEY UPDATE state=?" ,
65- repoID , sha , state .State , state .State )
66+ _ , err := db .GetEngine (ctx ).Exec ("INSERT INTO commit_status_summary (repo_id,sha,state,target_url ) VALUES (?, ?,?,?) ON DUPLICATE KEY UPDATE state=?" ,
67+ repoID , sha , state .State , state .TargetURL , state . State )
6668 return err
6769 }
6870
6971 if cnt , err := db .GetEngine (ctx ).Where ("repo_id=? AND sha=?" , repoID , sha ).
70- Cols ("state" ).
72+ Cols ("state, target_url " ).
7173 Update (& CommitStatusSummary {
72- State : state .State ,
74+ State : state .State ,
75+ TargetURL : state .TargetURL ,
7376 }); err != nil {
7477 return err
7578 } else if cnt == 0 {
7679 _ , err = db .GetEngine (ctx ).Insert (& CommitStatusSummary {
77- RepoID : repoID ,
78- SHA : sha ,
79- State : state .State ,
80+ RepoID : repoID ,
81+ SHA : sha ,
82+ State : state .State ,
83+ TargetURL : state .TargetURL ,
8084 })
8185 return err
8286 }
0 commit comments