@@ -15,10 +15,11 @@ import (
15
15
16
16
// CommitStatusSummary holds the latest commit Status of a single Commit
17
17
type 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"`
22
23
}
23
24
24
25
func init () {
@@ -44,9 +45,10 @@ func GetLatestCommitStatusForRepoAndSHAs(ctx context.Context, repoSHAs []RepoSHA
44
45
commitStatuses := make ([]* CommitStatus , 0 , len (repoSHAs ))
45
46
for _ , summary := range summaries {
46
47
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 ,
50
52
})
51
53
}
52
54
return commitStatuses , nil
@@ -61,22 +63,24 @@ func UpdateCommitStatusSummary(ctx context.Context, repoID int64, sha string) er
61
63
// mysql will return 0 when update a record which state hasn't been changed which behaviour is different from other database,
62
64
// so we need to use insert in on duplicate
63
65
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 )
66
68
return err
67
69
}
68
70
69
71
if cnt , err := db .GetEngine (ctx ).Where ("repo_id=? AND sha=?" , repoID , sha ).
70
- Cols ("state" ).
72
+ Cols ("state, target_url " ).
71
73
Update (& CommitStatusSummary {
72
- State : state .State ,
74
+ State : state .State ,
75
+ TargetURL : state .TargetURL ,
73
76
}); err != nil {
74
77
return err
75
78
} else if cnt == 0 {
76
79
_ , 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 ,
80
84
})
81
85
return err
82
86
}
0 commit comments