mirror of
https://github.com/go-gitea/gitea.git
synced 2025-07-20 19:08:29 +02:00
improve comments
This commit is contained in:
parent
8c21f017da
commit
ca6bcf0361
@ -231,9 +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
|
// 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.
|
// This function is widely used, but it is not quite right.
|
||||||
// If all commits are "skipped", GitHub will return "success" as the combined status.
|
// Ideally it should return something like "CommitStatusSummary" with properly aggregated state.
|
||||||
// FIXME: But the bad case here is: Gitea just returns the first status, which is still "skipped".
|
// GitHub's behavior: if all statuses are "skipped", GitHub will return "success" as the combined status.
|
||||||
// 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 {
|
||||||
@ -244,10 +243,10 @@ func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
|
|||||||
}
|
}
|
||||||
if lastStatus == nil {
|
if lastStatus == nil {
|
||||||
if len(statuses) > 0 {
|
if len(statuses) > 0 {
|
||||||
// the bad case mentioned above: only the first status is returned, its status is "skipped"
|
// FIXME: a bad case: Gitea just returns the first commit status, its status is "skipped" in this case.
|
||||||
lastStatus = statuses[0]
|
lastStatus = statuses[0]
|
||||||
} else {
|
} 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.
|
// FIXME: another bad case: if the "statuses" slice is empty, the returned value is an invalid CommitStatus, all its fields are empty.
|
||||||
lastStatus = &CommitStatus{}
|
lastStatus = &CommitStatus{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user