From 8c21f017daa2c813faf0fa4a07948f022913a614 Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Wed, 28 May 2025 04:30:14 +0800 Subject: [PATCH] improve comments --- models/git/commit_status.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/models/git/commit_status.go b/models/git/commit_status.go index e8c080b130..6a74e3a3c6 100644 --- a/models/git/commit_status.go +++ b/models/git/commit_status.go @@ -231,8 +231,8 @@ func (status *CommitStatus) HideActionsURL(ctx context.Context) { // CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc 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. + // If all commits are "skipped", GitHub will return "success" as the combined status. + // FIXME: But the bad case here is: Gitea just returns the first status, which is still "skipped". // Ideally it should return something like "CommitStatusSummary" with proper aggregated state. var lastStatus *CommitStatus state := api.CommitStatusSuccess @@ -244,8 +244,10 @@ func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus { } if lastStatus == nil { if len(statuses) > 0 { + // the bad case mentioned above: only the first status is returned, its status is "skipped" lastStatus = statuses[0] } else { + // FIXME: this is another bad case, if the "statuses" slice is empty, the returned value is an invalid CommitStatus, all its fields are empty. lastStatus = &CommitStatus{} } }