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

Configure Feed

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

chore: Remove `ChangeMilestoneStatus` (#6741)

- Introduced in 5ed5aa5228feba935679df8cb676af62018cc25d and removed in
4027c5dd7c11c1256094e202be591ec1b86a011e.

Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/6741
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Co-authored-by: Gusted <postmaster@gusted.xyz>
Co-committed-by: Gusted <postmaster@gusted.xyz>

authored by

Gusted
Gusted
and committed by
Earl Warren
5813244f 76783861

+9 -83
-7
.deadcode-out
··· 22 22 ScheduleList.LoadTriggerUser 23 23 ScheduleList.LoadRepos 24 24 25 - code.gitea.io/gitea/models/asymkey 26 - ErrGPGKeyAccessDenied.Error 27 - ErrGPGKeyAccessDenied.Unwrap 28 - HasDeployKey 29 - 30 25 code.gitea.io/gitea/models/auth 31 26 GetSourceByName 32 27 WebAuthnCredentials ··· 54 49 55 50 code.gitea.io/gitea/models/issues 56 51 IsErrUnknownDependencyType 57 - ErrNewIssueInsert.Error 58 52 IsErrIssueWasClosed 59 - ChangeMilestoneStatus 60 53 61 54 code.gitea.io/gitea/models/organization 62 55 GetTeamNamesByID
-22
models/asymkey/error.go
··· 192 192 return util.ErrAlreadyExist 193 193 } 194 194 195 - // ErrGPGKeyAccessDenied represents a "GPGKeyAccessDenied" kind of Error. 196 - type ErrGPGKeyAccessDenied struct { 197 - UserID int64 198 - KeyID int64 199 - } 200 - 201 - // IsErrGPGKeyAccessDenied checks if an error is a ErrGPGKeyAccessDenied. 202 - func IsErrGPGKeyAccessDenied(err error) bool { 203 - _, ok := err.(ErrGPGKeyAccessDenied) 204 - return ok 205 - } 206 - 207 - // Error pretty-prints an error of type ErrGPGKeyAccessDenied. 208 - func (err ErrGPGKeyAccessDenied) Error() string { 209 - return fmt.Sprintf("user does not have access to the key [user_id: %d, key_id: %d]", 210 - err.UserID, err.KeyID) 211 - } 212 - 213 - func (err ErrGPGKeyAccessDenied) Unwrap() error { 214 - return util.ErrPermissionDenied 215 - } 216 - 217 195 // ErrKeyAccessDenied represents a "KeyAccessDenied" kind of error. 218 196 type ErrKeyAccessDenied struct { 219 197 UserID int64
-8
models/asymkey/ssh_key_deploy.go
··· 105 105 return key, db.Insert(ctx, key) 106 106 } 107 107 108 - // HasDeployKey returns true if public key is a deploy key of given repository. 109 - func HasDeployKey(ctx context.Context, keyID, repoID int64) bool { 110 - has, _ := db.GetEngine(ctx). 111 - Where("key_id = ? AND repo_id = ?", keyID, repoID). 112 - Get(new(DeployKey)) 113 - return has 114 - } 115 - 116 108 // AddDeployKey add new deploy key to database and authorized_keys file. 117 109 func AddDeployKey(ctx context.Context, repoID int64, name, content string, readOnly bool) (*DeployKey, error) { 118 110 fingerprint, err := CalcFingerprint(content)
-15
models/issues/issue.go
··· 63 63 return fmt.Sprintf("issue is closed [id: %d, repo_id: %d, index: %d]", err.ID, err.RepoID, err.Index) 64 64 } 65 65 66 - // ErrNewIssueInsert is used when the INSERT statement in newIssue fails 67 - type ErrNewIssueInsert struct { 68 - OriginalError error 69 - } 70 - 71 - // IsErrNewIssueInsert checks if an error is a ErrNewIssueInsert. 72 - func IsErrNewIssueInsert(err error) bool { 73 - _, ok := err.(ErrNewIssueInsert) 74 - return ok 75 - } 76 - 77 - func (err ErrNewIssueInsert) Error() string { 78 - return err.OriginalError.Error() 79 - } 80 - 81 66 // ErrIssueWasClosed is used when close a closed issue 82 67 type ErrIssueWasClosed struct { 83 68 ID int64
+1 -1
models/issues/issue_update.go
··· 433 433 LabelIDs: labelIDs, 434 434 Attachments: uuids, 435 435 }); err != nil { 436 - if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) || IsErrNewIssueInsert(err) { 436 + if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) { 437 437 return err 438 438 } 439 439 return fmt.Errorf("newIssue: %w", err)
-15
models/issues/milestone.go
··· 251 251 return committer.Commit() 252 252 } 253 253 254 - // ChangeMilestoneStatus changes the milestone open/closed status. 255 - func ChangeMilestoneStatus(ctx context.Context, m *Milestone, isClosed bool) (err error) { 256 - ctx, committer, err := db.TxContext(ctx) 257 - if err != nil { 258 - return err 259 - } 260 - defer committer.Close() 261 - 262 - if err := changeMilestoneStatus(ctx, m, isClosed); err != nil { 263 - return err 264 - } 265 - 266 - return committer.Commit() 267 - } 268 - 269 254 func changeMilestoneStatus(ctx context.Context, m *Milestone, isClosed bool) error { 270 255 m.IsClosed = isClosed 271 256 if isClosed {
+6 -7
models/issues/milestone_test.go
··· 298 298 unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: milestone.RepoID}, &issues_model.Milestone{}) 299 299 } 300 300 301 - func TestChangeMilestoneStatus(t *testing.T) { 301 + func TestChangeMilestoneStatusByRepoIDAndID(t *testing.T) { 302 302 require.NoError(t, unittest.PrepareTestDatabase()) 303 - milestone := unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}) 304 303 305 - require.NoError(t, issues_model.ChangeMilestoneStatus(db.DefaultContext, milestone, true)) 306 - unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}, "is_closed=1") 307 - unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: milestone.RepoID}, &issues_model.Milestone{}) 304 + require.NoError(t, issues_model.ChangeMilestoneStatusByRepoIDAndID(db.DefaultContext, 1, 1, true)) 305 + unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1, IsClosed: true}) 306 + unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: 1}, &issues_model.Milestone{}) 308 307 309 - require.NoError(t, issues_model.ChangeMilestoneStatus(db.DefaultContext, milestone, false)) 308 + require.NoError(t, issues_model.ChangeMilestoneStatusByRepoIDAndID(db.DefaultContext, 1, 1, false)) 310 309 unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1}, "is_closed=0") 311 - unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: milestone.RepoID}, &issues_model.Milestone{}) 310 + unittest.CheckConsistencyFor(t, &repo_model.Repository{ID: 1}, &issues_model.Milestone{}) 312 311 } 313 312 314 313 func TestDeleteMilestoneByRepoID(t *testing.T) {
+1 -1
models/issues/pull.go
··· 575 575 Attachments: uuids, 576 576 IsPull: true, 577 577 }); err != nil { 578 - if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) || IsErrNewIssueInsert(err) { 578 + if repo_model.IsErrUserDoesNotHaveAccessToRepo(err) { 579 579 return err 580 580 } 581 581 return fmt.Errorf("newIssue: %w", err)
+1 -7
routers/api/v1/user/gpg_key.go
··· 303 303 } 304 304 305 305 if err := asymkey_model.DeleteGPGKey(ctx, ctx.Doer, ctx.ParamsInt64(":id")); err != nil { 306 - if asymkey_model.IsErrGPGKeyAccessDenied(err) { 307 - ctx.Error(http.StatusForbidden, "", "You do not have access to this key") 308 - } else { 309 - ctx.Error(http.StatusInternalServerError, "DeleteGPGKey", err) 310 - } 306 + ctx.Error(http.StatusInternalServerError, "DeleteGPGKey", err) 311 307 return 312 308 } 313 309 ··· 317 313 // HandleAddGPGKeyError handle add GPGKey error 318 314 func HandleAddGPGKeyError(ctx *context.APIContext, err error, token string) { 319 315 switch { 320 - case asymkey_model.IsErrGPGKeyAccessDenied(err): 321 - ctx.Error(http.StatusUnprocessableEntity, "GPGKeyAccessDenied", "You do not have access to this GPG key") 322 316 case asymkey_model.IsErrGPGKeyIDAlreadyUsed(err): 323 317 ctx.Error(http.StatusUnprocessableEntity, "GPGKeyIDAlreadyUsed", "A key with the same id already exists") 324 318 case asymkey_model.IsErrGPGKeyParsing(err):