aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2023-07-25 21:46:02 +0900
committerGitHub <noreply@github.com>2023-07-25 12:46:02 +0000
commit7a687caca4313eb8a77470f5b162618c4428010f (patch)
treede688acea19c1da1c8d67d9fb89187a7ef65ce43
parentab72f7ee4ab670c640187b841de0671fa5c43a51 (diff)
downloadgitea-7a687caca4313eb8a77470f5b162618c4428010f.tar.gz
gitea-7a687caca4313eb8a77470f5b162618c4428010f.zip
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`. https://github.com/go-gitea/gitea/blob/af1ffbcd63569df8646b20c524378f25710f129e/models/git/commit_status.go#L204-L211 Co-authored-by: Giteabot <teabot@gitea.io>
-rw-r--r--models/git/commit_status.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/models/git/commit_status.go b/models/git/commit_status.go
index c418cd23eb..17090f30dd 100644
--- a/models/git/commit_status.go
+++ b/models/git/commit_status.go
@@ -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