Fix wrong commit status in web ui (#26121)
Before:  After:  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>
This commit is contained in:
parent
ab72f7ee4a
commit
7a687caca4
1 changed files with 1 additions and 1 deletions
|
@ -194,7 +194,7 @@ func (status *CommitStatus) APIURL(ctx context.Context) string {
|
|||
// CalcCommitStatus returns commit status state via some status, the commit statues should order by id desc
|
||||
func CalcCommitStatus(statuses []*CommitStatus) *CommitStatus {
|
||||
var lastStatus *CommitStatus
|
||||
var state api.CommitStatusState
|
||||
state := api.CommitStatusSuccess
|
||||
for _, status := range statuses {
|
||||
if status.State.NoBetterThan(state) {
|
||||
state = status.State
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue