-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix wrong commit status in web ui #26121
Fix wrong commit status in web ui #26121
Conversation
It seems that this logic problem comes from #25839 default:
return css2 != CommitStatusError && css2 != CommitStatusFailure && css2 != CommitStatusWarning && css2 != CommitStatusPending |
Possible to add a test that verifies that "ok, fail" checks result in "fail"? |
Maybe a unit test for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be simplified to:
var lastStatus *CommitStatus
if lastStatus == nil || status.State.NoBetterThan(lastStatus.state) {
lastStatus = status
}
My fault, the gitea/services/convert/status.go Lines 41 to 54 in 6598d02
This place looks right. gitea/services/pull/commit_status.go Lines 38 to 49 in 6598d02
|
I believe this PR is good enough to merge, @CaiCandong please help to improve if you have any ideas. |
* giteaofficial/main: (21 commits) Only show newly pushed branches message in the same repository (go-gitea#26148) Docusaurus-ify (go-gitea#26051) Display deprecated warning in admin panel pages as well as in the log file (go-gitea#26094) Remove "misc" scope check from public API endpoints (go-gitea#26134) Fix LFS object list style (go-gitea#26133) Drop the correct deleted branch table (go-gitea#26028) Fix CLI allowing creation of access tokens with existing name (go-gitea#26071) Fix incorrect router logger (go-gitea#26137) Increase table cell horizontal padding (go-gitea#26140) Update xorm version (go-gitea#26128) Fix UI for release tag page / wiki page / subscription page (go-gitea#25948) added ssh mirror workaround description (go-gitea#26096) Improve "gitea doctor" sub-command and fix "help" commands (go-gitea#26072) Fix wrong commit status in web ui (go-gitea#26121) remove IsWarning in tmpl (go-gitea#26120) Fix minor capitalization error in string (go-gitea#26100) Improve commit graph alignment and truncating (go-gitea#26112) Fix wrong workflow status when rerun a job in an already finished workflow (go-gitea#26119) Allow Organisations to have a E-Mail (go-gitea#25082) doc sync authentication.md to zh-cn (go-gitea#26117) ...
- 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>
Before:
After:
There's a bug in the recent logic,
CalcCommitStatus
will always return the first item ofstatuses
or error status, becausestate
is defined with default value which should beCommitStatusSuccess
Then
this
if
will always return false unlessstatus.State = CommitStatusError
which makes no sense.So
lastStatus
will always benil
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 isSuccess
but notFailure
.gitea/models/git/commit_status.go
Lines 204 to 211 in af1ffbc