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.

Fix some pending problems (#29985)

These changes are quite independent and trivial, so I don't want to open
too many PRs.

* https://github.com/go-gitea/gitea/pull/29882#discussion_r1529607091
* the `f.Close` should be called properly
* the error message could be more meaningful
(https://github.com/go-gitea/gitea/pull/29882#pullrequestreview-1942557935)
*
https://github.com/go-gitea/gitea/pull/29859#pullrequestreview-1942324716
* the new translation strings don't take arguments
* https://github.com/go-gitea/gitea/pull/28710#discussion_r1443778807
* stale for long time
* #28140
* a form was forgotten to be changed to work with backend code

(cherry picked from commit 226231ea27d4f2b0f09fa4efb39501507613b284)

Conflicts:
templates/repo/issue/view_content/pull.tmpl
discarded because unexplained
templates/status/404.tmpl
implemented differently in Forgejo

authored by

wxiaoguang and committed by
Earl Warren
d4ea1c25 8848b0ea

+24 -28
+4 -5
models/asymkey/ssh_key_authorized_keys.go
··· 198 198 if err != nil { 199 199 return err 200 200 } 201 + defer f.Close() 202 + 201 203 scanner := bufio.NewScanner(f) 202 204 for scanner.Scan() { 203 205 line := scanner.Text() ··· 207 209 } 208 210 _, err = t.WriteString(line + "\n") 209 211 if err != nil { 210 - f.Close() 211 212 return err 212 213 } 213 214 } 214 - err = scanner.Err() 215 - if err != nil { 216 - return fmt.Errorf("scan: %w", err) 215 + if err = scanner.Err(); err != nil { 216 + return fmt.Errorf("RegeneratePublicKeys scan: %w", err) 217 217 } 218 - f.Close() 219 218 } 220 219 return nil 221 220 }
+4 -5
models/asymkey/ssh_key_authorized_principals.go
··· 120 120 if err != nil { 121 121 return err 122 122 } 123 + defer f.Close() 124 + 123 125 scanner := bufio.NewScanner(f) 124 126 for scanner.Scan() { 125 127 line := scanner.Text() ··· 129 131 } 130 132 _, err = t.WriteString(line + "\n") 131 133 if err != nil { 132 - f.Close() 133 134 return err 134 135 } 135 136 } 136 - err = scanner.Err() 137 - if err != nil { 138 - return fmt.Errorf("scan: %w", err) 137 + if err = scanner.Err(); err != nil { 138 + return fmt.Errorf("regeneratePrincipalKeys scan: %w", err) 139 139 } 140 - f.Close() 141 140 } 142 141 return nil 143 142 }
+1 -1
modules/actions/log.go
··· 100 100 } 101 101 102 102 if err := scanner.Err(); err != nil { 103 - return nil, fmt.Errorf("scan: %w", err) 103 + return nil, fmt.Errorf("ReadLogs scan: %w", err) 104 104 } 105 105 106 106 return rows, nil
+2 -3
modules/git/commit.go
··· 391 391 } 392 392 } 393 393 } 394 - err = scanner.Err() 395 - if err != nil { 396 - return nil, fmt.Errorf("scan: %w", err) 394 + if err = scanner.Err(); err != nil { 395 + return nil, fmt.Errorf("GetSubModules scan: %w", err) 397 396 } 398 397 399 398 return c.submoduleCache, nil
+3 -3
modules/git/repo_stats.go
··· 124 124 } 125 125 } 126 126 } 127 - err = scanner.Err() 128 - if err != nil { 129 - return fmt.Errorf("scan: %w", err) 127 + if err = scanner.Err(); err != nil { 128 + _ = stdoutReader.Close() 129 + return fmt.Errorf("GetCodeActivityStats scan: %w", err) 130 130 } 131 131 a := make([]*CodeActivityAuthor, 0, len(authors)) 132 132 for _, v := range authors {
+2 -3
modules/markup/csv/csv.go
··· 124 124 return err 125 125 } 126 126 } 127 - err = scan.Err() 128 - if err != nil { 129 - return fmt.Errorf("scan: %w", err) 127 + if err = scan.Err(); err != nil { 128 + return fmt.Errorf("fallbackRender scan: %w", err) 130 129 } 131 130 132 131 _, err = tmpBlock.WriteString("</pre>")
+2 -3
routers/web/repo/compare.go
··· 980 980 } 981 981 diffLines = append(diffLines, diffLine) 982 982 } 983 - err = scanner.Err() 984 - if err != nil { 985 - return nil, fmt.Errorf("scan: %w", err) 983 + if err = scanner.Err(); err != nil { 984 + return nil, fmt.Errorf("getExcerptLines scan: %w", err) 986 985 } 987 986 return diffLines, nil 988 987 }
+2 -2
routers/web/repo/editor.go
··· 374 374 ctx.Error(http.StatusInternalServerError, err.Error()) 375 375 } 376 376 } else if models.IsErrCommitIDDoesNotMatch(err) { 377 - ctx.RenderWithErr(ctx.Tr("repo.editor.commit_id_not_matching", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(ctx.Repo.CommitID)), tplEditFile, &form) 377 + ctx.RenderWithErr(ctx.Tr("repo.editor.commit_id_not_matching"), tplEditFile, &form) 378 378 } else if git.IsErrPushOutOfDate(err) { 379 - ctx.RenderWithErr(ctx.Tr("repo.editor.push_out_of_date", ctx.Repo.RepoLink+"/compare/"+util.PathEscapeSegments(form.LastCommit)+"..."+util.PathEscapeSegments(form.NewBranchName)), tplEditFile, &form) 379 + ctx.RenderWithErr(ctx.Tr("repo.editor.push_out_of_date"), tplEditFile, &form) 380 380 } else if git.IsErrPushRejected(err) { 381 381 errPushRej := err.(*git.ErrPushRejected) 382 382 if len(errPushRej.Message) == 0 {
+3 -3
services/doctor/authorizedkeys.go
··· 50 50 } 51 51 linesInAuthorizedKeys.Add(line) 52 52 } 53 - err = scanner.Err() 54 - if err != nil { 53 + if err = scanner.Err(); err != nil { 55 54 return fmt.Errorf("scan: %w", err) 56 55 } 57 - f.Close() 56 + // although there is a "defer close" above, here close explicitly before the generating, because it needs to open the file for writing again 57 + _ = f.Close() 58 58 59 59 // now we regenerate and check if there are any lines missing 60 60 regenerated := &bytes.Buffer{}
+1
web_src/js/components/PullRequestMergeForm.vue
··· 94 94 <!-- eslint-disable-next-line vue/no-v-html --> 95 95 <div v-if="mergeForm.hasPendingPullRequestMerge" v-html="mergeForm.hasPendingPullRequestMergeTip" class="ui info message"/> 96 96 97 + <!-- another similar form is in pull.tmpl (manual merge)--> 97 98 <form class="ui form form-fetch-action" v-if="showActionForm" :action="mergeForm.baseLink+'/merge'" method="post"> 98 99 <input type="hidden" name="_csrf" :value="csrfToken"> 99 100 <input type="hidden" name="head_commit_id" v-model="mergeForm.pullHeadCommitID">