loading up the forgejo repo on tangled to test page performance
fork

Configure Feed

Select the types of activity you want to include in your feed.

Restore warning commit status (#27504)

Partial revert of https://github.com/go-gitea/gitea/pull/25839. This
commit status is used by a number of external integrations, so I think
we should not remove it (See
https://github.com/go-gitea/gitea/pull/25839#issuecomment-1729002077).
This is a rare case where an existing migration needed to be alterted to
avoid data loss.

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Giteabot <teabot@gitea.io>

authored by

silverwind
delvh
Giteabot
and committed by
GitHub
5bf367f9 0c2a3f4c

+26 -7
+4
models/git/commit_status_test.go
··· 31 31 assert.Equal(t, structs.CommitStatusPending, statuses[0].State) 32 32 assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[0].APIURL(db.DefaultContext)) 33 33 34 + assert.Equal(t, "cov/awesomeness", statuses[1].Context) 35 + assert.Equal(t, structs.CommitStatusWarning, statuses[1].State) 36 + assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[1].APIURL(db.DefaultContext)) 37 + 34 38 assert.Equal(t, "cov/awesomeness", statuses[2].Context) 35 39 assert.Equal(t, structs.CommitStatusSuccess, statuses[2].State) 36 40 assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/statuses/1234123412341234123412341234123412341234", statuses[2].APIURL(db.DefaultContext))
-3
models/migrations/v1_21/v266.go
··· 18 18 if _, err := sess.Exec(`UPDATE commit_status SET state='pending' WHERE state='running'`); err != nil { 19 19 return err 20 20 } 21 - if _, err := sess.Exec(`UPDATE commit_status SET state='failure' WHERE state='warning'`); err != nil { 22 - return err 23 - } 24 21 25 22 return sess.Commit() 26 23 }
+11 -3
modules/structs/commit_status.go
··· 16 16 CommitStatusError CommitStatusState = "error" 17 17 // CommitStatusFailure is for when the CommitStatus is Failure 18 18 CommitStatusFailure CommitStatusState = "failure" 19 + // CommitStatusWarning is for when the CommitStatus is Warning 20 + CommitStatusWarning CommitStatusState = "warning" 19 21 ) 20 22 21 23 var commitStatusPriorities = map[CommitStatusState]int{ 22 24 CommitStatusError: 0, 23 25 CommitStatusFailure: 1, 24 - CommitStatusPending: 2, 25 - CommitStatusSuccess: 3, 26 + CommitStatusWarning: 2, 27 + CommitStatusPending: 3, 28 + CommitStatusSuccess: 4, 26 29 } 27 30 28 31 func (css CommitStatusState) String() string { ··· 32 35 // NoBetterThan returns true if this State is no better than the given State 33 36 // This function only handles the states defined in CommitStatusPriorities 34 37 func (css CommitStatusState) NoBetterThan(css2 CommitStatusState) bool { 35 - // NoBetterThan only handles the 4 states above 38 + // NoBetterThan only handles the 5 states above 36 39 if _, exist := commitStatusPriorities[css]; !exist { 37 40 return false 38 41 } ··· 63 66 func (css CommitStatusState) IsFailure() bool { 64 67 return css == CommitStatusFailure 65 68 } 69 + 70 + // IsWarning represents if commit status state is warning 71 + func (css CommitStatusState) IsWarning() bool { 72 + return css == CommitStatusWarning 73 + }
+3
templates/repo/commit_status.tmpl
··· 11 11 {{if eq .State "failure"}} 12 12 {{svg "octicon-x" 18 "commit-status icon text red"}} 13 13 {{end}} 14 + {{if eq .State "warning"}} 15 + {{svg "gitea-exclamation" 18 "commit-status icon text yellow"}} 16 + {{end}}
+1 -1
templates/repo/issue/view_content/pull.tmpl
··· 13 13 {{- else if .IsBlockedByOutdatedBranch}}red 14 14 {{- else if .IsBlockedByChangedProtectedFiles}}red 15 15 {{- else if and .EnableStatusCheck (or .RequiredStatusCheckState.IsFailure .RequiredStatusCheckState.IsError)}}red 16 - {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending)}}yellow 16 + {{- else if and .EnableStatusCheck (or (not $.LatestCommitStatus) .RequiredStatusCheckState.IsPending .RequiredStatusCheckState.IsWarning)}}yellow 17 17 {{- else if and .AllowMerge .RequireSigned (not .WillSign)}}red 18 18 {{- else if .Issue.PullRequest.IsChecking}}yellow 19 19 {{- else if .Issue.PullRequest.IsEmpty}}grey
+2
tests/integration/pull_status_test.go
··· 53 53 api.CommitStatusError, 54 54 api.CommitStatusFailure, 55 55 api.CommitStatusSuccess, 56 + api.CommitStatusWarning, 56 57 } 57 58 58 59 statesIcons := map[api.CommitStatusState]string{ ··· 60 61 api.CommitStatusSuccess: "octicon-check", 61 62 api.CommitStatusError: "gitea-exclamation", 62 63 api.CommitStatusFailure: "octicon-x", 64 + api.CommitStatusWarning: "gitea-exclamation", 63 65 } 64 66 65 67 testCtx := NewAPITestContext(t, "user1", "repo1", auth_model.AccessTokenScopeWriteRepository)
+4
tests/integration/repo_commits_test.go
··· 125 125 doTestRepoCommitWithStatus(t, "failure", "octicon-x", "red") 126 126 } 127 127 128 + func TestRepoCommitsWithStatusWarning(t *testing.T) { 129 + doTestRepoCommitWithStatus(t, "warning", "gitea-exclamation", "yellow") 130 + } 131 + 128 132 func TestRepoCommitsStatusParallel(t *testing.T) { 129 133 defer tests.PrepareTestEnv(t)() 130 134
+1
web_src/js/components/DashboardRepoList.vue
··· 12 12 success: {name: 'octicon-check', color: 'green'}, 13 13 error: {name: 'gitea-exclamation', color: 'red'}, 14 14 failure: {name: 'octicon-x', color: 'red'}, 15 + warning: {name: 'gitea-exclamation', color: 'yellow'}, 15 16 }; 16 17 17 18 const sfc = {