1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-11-25 08:59:31 -05:00
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 Introduce path Clean/Join helper functions (#23495) 2023-03-21 16:02:49 -04:00
main_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00
protected_banch_list_test.go Fix branch protection priority (#24045) 2023-04-11 13:22:49 -04:00
protected_branch.go Rename repo.GetOwner to repo.LoadOwner (#22967) 2023-02-18 20:11:03 +08:00
protected_branch_list.go Sync branches into databases (#22743) 2023-06-29 10:03:20 +00:00
protected_branch_test.go Supports wildcard protected branch (#20825) 2023-01-16 16:00:22 +08:00
protected_tag.go Use context parameter in models/git (#22367) 2023-01-09 11:50:54 +08:00
protected_tag_test.go Implement FSFE REUSE for golang files (#21840) 2022-11-27 18:20:29 +00:00