mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-20 17:57:14 -04:00
refactor improve NoBetterThan (#26126)
- The `NoBetterThan` function can only handle comparisons between "pending," "success," "error," and "failure." For any other comparison, we directly return false. This prevents logic errors like the one in #26121. - The callers of the `NoBetterThan` function should also avoid making incomparable calls. --------- Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
This commit is contained in:
parent
df9afe3aa8
commit
13359581df
4 changed files with 193 additions and 8 deletions
|
@ -48,7 +48,7 @@ func ToCombinedStatus(ctx context.Context, statuses []*git_model.CommitStatus, r
|
|||
retStatus.Statuses = make([]*api.CommitStatus, 0, len(statuses))
|
||||
for _, status := range statuses {
|
||||
retStatus.Statuses = append(retStatus.Statuses, ToCommitStatus(ctx, status))
|
||||
if status.State.NoBetterThan(retStatus.State) {
|
||||
if retStatus.State == "" || status.State.NoBetterThan(retStatus.State) {
|
||||
retStatus.State = status.State
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue