0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-07-18 13:02:54 +02:00

add comment for CalcCommitStatus

This commit is contained in:
wxiaoguang 2025-05-28 04:00:12 +08:00
parent e9b8a15000
commit e6dc1862ec

View File

@ -230,6 +230,10 @@ func (status *CommitStatus) HideActionsURL(ctx context.Context) {
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc // CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus { func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
// This function is widely used, but it is not quite right.
// The bad case is: if all commits are "skipped", GitHub will return "success" as the combined status.
// But here Gitea just returns the first status, which is still "skipped" in this case.
// Ideally it should return something like "CommitStatusSummary" with proper aggregated state.
var lastStatus *CommitStatus var lastStatus *CommitStatus
state := api.CommitStatusSuccess state := api.CommitStatusSuccess
for _, status := range statuses { for _, status := range statuses {