forgejo/models/git
yp05327 7a687caca4
Fix wrong commit status in web ui (#26121)
Before:

![image](https://github.com/go-gitea/gitea/assets/18380374/8c5643b5-5c16-4674-9fe6-9e7fa2dda0b9)
After:

![image](https://github.com/go-gitea/gitea/assets/18380374/caf8891b-14df-418d-a7eb-977b54b9e9be)

There's a bug in the recent logic, `CalcCommitStatus` will always return
the first item of `statuses` or error status, because `state` is defined
with default value which should be `CommitStatusSuccess`

Then
``` golang
if status.State.NoBetterThan(state) {
```
this `if` will always return false unless `status.State =
CommitStatusError` which makes no sense.
So `lastStatus` will always be `nil` or error status.
Then we will always return the first item of `statuses` here or only
return error status, and this is why in the first picture the commit
status is `Success` but not `Failure`.

af1ffbcd63/models/git/commit_status.go (L204-L211)

Co-authored-by: Giteabot <teabot@gitea.io>
2023-07-25 12:46:02 +00:00
..
branch.go Exclude default branch from pushed branch hint (#25795) 2023-07-10 11:18:55 +00:00
branch_list.go Make FindBranches have stable result (#25631) 2023-07-03 04:11:32 +00:00
branch_test.go Fix branch commit message too long problem (#25588) 2023-06-30 17:03:05 +08:00
commit_status.go Fix wrong commit status in web ui (#26121) 2023-07-25 12:46:02 +00:00
commit_status_test.go Remove commit status running and warning to align GitHub (#25839) 2023-07-21 16:24:36 +08:00
lfs.go Replace interface{} with any (#25686) 2023-07-04 18:36:08 +00:00
lfs_lock.go
main_test.go
protected_banch_list_test.go
protected_branch.go
protected_branch_list.go Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
protected_branch_test.go
protected_tag.go
protected_tag_test.go