summaryrefslogtreecommitdiffstats
path: root/routers/web
Commit message (Collapse)AuthorAgeFilesLines
* Fix bugs in rerunning jobs (#29955) (#29983)Giteabot2024-03-222-6/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #29955 by @Zettat123 Fix #28761 Fix #27884 Fix #28093 ## Changes ### Rerun all jobs When rerun all jobs, status of the jobs with `needs` will be set to `blocked` instead of `waiting`. Therefore, these jobs will not run until the required jobs are completed. ### Rerun a single job When a single job is rerun, its dependents should also be rerun, just like GitHub does (https://github.com/go-gitea/gitea/issues/28761#issuecomment-2008620820). In this case, only the specified job will be set to `waiting`, its dependents will be set to `blocked` to wait the job. ### Show warning if every job has `needs` If every job in a workflow has `needs`, all jobs will be blocked and no job can be run. So I add a warning message. <img src="https://github.com/go-gitea/gitea/assets/15528715/88f43511-2360-465d-be96-ee92b57ff67b" width="480px" /> --------- Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Performance improvements for pull request list page (#29900) (#29972)Lunny Xiao2024-03-221-0/+6
| | | | | | | | | This PR will avoid load pullrequest.Issue twice in pull request list page. It will reduce x times database queries for those WIP pull requests. Partially fix #29585 Backport #29900
* Add cache for dashbaord commit status (#29932)Lunny Xiao2024-03-201-20/+8
| | | backport #29444
* Only do counting when count_only=true for repo dashboard (#29884) (#29905)Lunny Xiao2024-03-201-10/+14
| | | | | | Ref: #29878 Backport #29884 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix template error when comment review doesn't exist (#29888) (#29889)wxiaoguang2024-03-191-0/+17
| | | Backport #29888
* Editor error message misleading due to re-used key. (#29859) (#29876)Giteabot2024-03-181-2/+2
| | | | | | | | | | | | | | | | | | | Backport #29859 by @buckybytes The error message: `editor.file_changed_while_editing = The file contents have changed since you started editing. <a target="_blank" rel="noopener noreferrer" href="%s">Click here</a> to see them or <strong>Commit Changes again</strong> to overwrite them.` Is re-used in inappropriate contexts. The link in the key goes to a 404 when the key is used in a situation where the file contents have not changed. Added two new keys to differentiate commit id mismatch and push out of date conditions. Co-authored-by: buckybytes <158571971+buckybytes@users.noreply.github.com>
* Fix codeowner detected diff base branch to mergebase (#29783) (#29807)Lunny Xiao2024-03-172-2/+2
| | | | | | | | | | | | | | | Fix #29763 Backport #29783 This PR fixes 2 problems with CodeOwner in the pull request. - Don't use the pull request base branch but merge-base as a diff base to detect the code owner. - CodeOwner detection in fork repositories will be disabled because almost all the fork repositories will not change CODEOWNERS files but it should not be used on fork repositories' pull requests. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix user router possbile panic (#29751) (#29786)Lunny Xiao2024-03-141-2/+5
| | | | regression from #28023 backport #29751
* Use Get but not Post to get actions artifacts (#29734) (#29737)Lunny Xiao2024-03-121-1/+1
| | | backport #29734
* Fix 500 when deleting account with incorrect password or unsupported login ↵Lunny Xiao2024-03-081-2/+17
| | | | | | | | type (#29579) (#29656) Fix #26210 Backport #29579 Co-authored-by: Jason Song <i@wolfogre.com>
* Add missing database transaction for new issue (#29490) (#29607)Lunny Xiao2024-03-054-16/+12
| | | | | | When creating an issue, inserting issue, assign users and set project should be in the same transaction. Backport #29490
* Make "/user/login" page redirect if the current user has signed in (#29583) ↵wxiaoguang2024-03-053-11/+63
| | | | | (#29599) Backport #29583
* Add a trailing slash to dashboard links (#29555) (#29573)wxiaoguang2024-03-041-0/+17
| | | Backport #29555
* Only use supported sort order for "explore/users" page (#29430) (#29443)wxiaoguang2024-03-032-7/+35
| | | | | | | | | | | | | | Backport #29430 Thanks to inferenceus : some sort orders on the "explore/users" page could list users by their lastlogintime/updatetime. It leaks user's activity unintentionally. This PR makes that page only use "supported" sort orders. Removing the "sort orders" could also be a good solution, while IMO at the moment keeping the "create time" and "name" orders is also fine, in case some users would like to find a target user in the search result, the "sort order" might help.
* Fix incorrect redirection when creating a PR fails (#29537) (#29543)Giteabot2024-03-021-1/+1
| | | | | | | Backport #29537 by wxiaoguang This is only a quick fix to make it easier to backport. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix incorrect relative/absolute URL usages (#29531) (#29547)Giteabot2024-03-021-1/+1
| | | | | | | | Backport #29531 by wxiaoguang Add two "HTMLURL" methods for PackageDescriptor. And rename "FullWebLink" to "VersionWebLink" Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix issue & comment history bugs (#29525) (#29527)Giteabot2024-03-021-1/+5
| | | | | | | | | | Backport #29525 by @wxiaoguang * Follow #17746: `HasIssueContentHistory` should use expr builder to make sure zero value (0) be respected. * Add "doer" check to make sure `canSoftDeleteContentHistory` only be called by sign-in users. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Not trigger all jobs any more, when re-running the first job (#29439) (#29441)Giteabot2024-02-271-3/+8
| | | | | | | | | | | Backport #29439 by @sillyguodong Previously, it will be treated as "re-run all jobs" when `jobIndex == 0`. So when you click re-run button on the first job, it triggers all the jobs actually. Caused by #26535. Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
* Do not double close reader (#29354) (#29370)Giteabot2024-02-241-3/+0
| | | | | | | | Backport #29354 by @KN4CK3R Fixes #29346 Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Display friendly error message (#29105) (#29363)Lunny Xiao2024-02-241-7/+7
| | | | | | | | Backport #29105 `ctx.Error` only displays the text but `ctx.ServerError` renders the usual error page. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix project counter in organization/individual profile (#28068) (#29361)Lunny Xiao2024-02-241-0/+17
| | | | | | | | | | | | | | | | | Fix #28052 Backport #28068 Before: ![image](https://github.com/go-gitea/gitea/assets/18380374/5f299983-4b38-4d68-ac0e-4be3c62c0558) ![image](https://github.com/go-gitea/gitea/assets/18380374/f0e12afd-483b-4882-80e9-0261beb3fe0c) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/47cccb7b-bb35-4a7d-9c5b-83133be0323a) ![image](https://github.com/go-gitea/gitea/assets/18380374/77825c0c-4bf2-4762-83a2-1a5a173cc22d) Co-authored-by: yp05327 <576951401@qq.com>
* Fix error display when merging PRs (#29288) (#29309)Zettat1232024-02-221-4/+4
| | | | | | | | | Backport #29288 Partially fix #29071, regression of Modernize merge button #28140 Fix some missing `Redirect` -> `JSONRedirect`. Thanks @yp05327 for the help in https://github.com/go-gitea/gitea/issues/29071#issuecomment-1931261075
* Disallow merge when required checked are missing (#29143) (#29268)Markus Amshove2024-02-191-0/+30
| | | | | | backport #29143 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix bug when the linked account was disactived and list the linked accounts ↵Lunny Xiao2024-02-192-5/+5
| | | | | | | | | (#29263) The bug has been fixed on v1.22 but not backport to v1.21. This original PR have many refactors so I don't think it's necessary to backport all of them. Fix #28667
* Load outdated comments when (un)resolving conversation on PR timeline ↵Jimmy Praet2024-02-182-3/+4
| | | | | | | | | | | | (#29203) (#29221) Backport #29203 Relates to #28654, #29039 and #29050. The "show outdated comments" flag should only apply to the file diff view. On the PR timeline, outdated comments are always shown. So they should also be loaded when (un)resolving a conversation on the timeline page.
* Refactor issue template parsing and fix API endpoint (#29069) (#29140)wxiaoguang2024-02-142-13/+11
| | | | | | | | | | | | | | | | | | Backport #29069 The old code `GetTemplatesFromDefaultBranch(...) ([]*api.IssueTemplate, map[string]error)` doesn't really follow Golang's habits, then the second returned value might be misused. For example, the API function `GetIssueTemplates` incorrectly checked the second returned value and always responds 500 error. This PR refactors GetTemplatesFromDefaultBranch to ParseTemplatesFromDefaultBranch and clarifies its behavior, and fixes the API endpoint bug, and adds some tests. And by the way, add proper prefix `X-` for the header generated in `checkDeprecatedAuthMethods`, because non-standard HTTP headers should have `X-` prefix, and it is also consistent with the new code in `GetIssueTemplates`
* Improve user experience for outdated comments (#29050) (#29086)Giteabot2024-02-083-15/+84
| | | | | | | | | | | | | | Backport #29050 by wxiaoguang Try to improve #28949 1. Make `ctx.Data["ShowOutdatedComments"] = true` by default: it brings consistent user experience, and sometimes the "outdated (source changed)" comments are still valuable. 2. Show a friendly message if the comment won't show, then the end users won't fell that "the comment disappears" (it is the special case when `ShowOutdatedComments = false`) Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Do not render empty comments (#29039) (#29049)Giteabot2024-02-041-1/+10
| | | | | | | | | | | Backport #29039 by wxiaoguang Follow #28654 The `comments` might be empty, so the templates shouldn't (and couldn't) use it to render. When there is no comment, the UI should also be updated to empty, so returning an empty body is good enough. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Preserve BOM in web editor (#28935) (#28959)Giteabot2024-01-276-8/+8
| | | | | | | | | | | | | | | | | | | | | | | Backport #28935 by @silverwind The `ToUTF8*` functions were stripping BOM, while BOM is actually valid in UTF8, so the stripping must be optional depending on use case. This does: - Add a options struct to all `ToUTF8*` functions, that by default will strip BOM to preserve existing behaviour - Remove `ToUTF8` function, it was dead code - Rename `ToUTF8WithErr` to `ToUTF8` - Preserve BOM in Monaco Editor - Remove a unnecessary newline in the textarea value. Browsers did ignore it, it seems but it's better not to rely on this behaviour. Fixes: https://github.com/go-gitea/gitea/issues/28743 Related: https://github.com/go-gitea/gitea/issues/6716 which seems to have once introduced a mechanism that strips and re-adds the BOM, but from what I can tell, this mechanism was removed at some point after that PR. Co-authored-by: silverwind <me@silverwind.io>
* Don't reload timeline page when (un)resolving or replying conversation ↵Jimmy Praet2024-01-241-16/+16
| | | | | | (#28654) (#28917) Backport #28654 Fixes #15981
* Rework markup link rendering (#26745) (#28803)KN4CK3R2024-01-1614-110/+171
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #26745 Fixes #26548 This PR refactors the rendering of markup links. The old code uses `strings.Replace` to change some urls while the new code uses more context to decide which link should be generated. The added tests should ensure the same output for the old and new behaviour (besides the bug). We may need to refactor the rendering a bit more to make it clear how the different helper methods render the input string. There are lots of options (resolve links / images / mentions / git hashes / emojis / ...) but you don't really know what helper uses which options. For example, we currently support images in the user description which should not be allowed I think: <details> <summary>Profile</summary> https://try.gitea.io/KN4CK3R ![grafik](https://github.com/go-gitea/gitea/assets/1666336/109ae422-496d-4200-b52e-b3a528f553e5) </details>
* Forbid removing the last admin user (#28337) (#28793)Giteabot2024-01-162-1/+20
| | | | | | Backport #28337 by @yp05327 Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Modernize merge button (#28140) (#28786)Giteabot2024-01-151-24/+21
| | | | | | | | | | | | | | | | | | Backport #28140 by @earl-warren - Make use of the `form-fetch-action` for the merge button, which will automatically prevent the action from happening multiple times and show a nice loading indicator as user feedback while the merge request is being processed by the server. - Adjust the merge PR code to JSON response as this is required for the `form-fetch-action` functionality. - Resolves https://codeberg.org/forgejo/forgejo/issues/774 - Likely resolves the cause of https://codeberg.org/forgejo/forgejo/issues/1688#issuecomment-1313044 (cherry picked from commit 4ec64c19507caefff7ddaad722b1b5792b97cc5a) Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Fix schedule tasks bugs (#28691) (#28780)Lunny Xiao2024-01-142-19/+9
| | | | | | | | | | | | | | Fix #28157 Backport #28691 This PR fix the possible bugs about actions schedule. - Move `UpdateRepositoryUnit` and `SetRepoDefaultBranch` from models to service layer - Remove schedules plan from database and cancel waiting & running schedules tasks in this repository when actions unit has been disabled or global disabled. - Remove schedules plan from database and cancel waiting & running schedules tasks in this repository when default branch changed.
* Assign pull request to project during creation (#28227) (#28775)Giteabot2024-01-122-1/+13
| | | | | | | | | | | | | | | | Backport #28227 by @denyskon When creating a pull request, allow directly assigning it to a project, as it is already possible for issues. After: ![grafik](https://github.com/go-gitea/gitea/assets/47871822/01dc2b3d-d56a-4053-b2fc-138725d7633a) --------- Co-authored-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: delvh <dev.lh@web.de>
* Fix issue dependencies (#27736) (#28776)Giteabot2024-01-121-27/+23
| | | | | | | | | | | | | | | | | | | | | | | | | Backport #27736 by @lng2020 Fix #27722 Fix #27357 Fix #25837 Fix #28732 1. Fix the typo `BlockingByDependenciesNotPermitted`, which causes the `not permitted message` not to show. The correct one is `Blocking` or `BlockedBy` 2. Rewrite the perm check. The perm check uses a very tricky way to avoid duplicate checks for a slice of issues, which is confusing. In fact, it's also the reason causing the bug. It uses `lastRepoID` and `lastPerm` to avoid duplicate checks, but forgets to assign the `lastPerm` at the end of the code block. So I rewrote this to avoid this trick. ![I U1AT{GNFY3 1HZ`6L{(2L](https://github.com/go-gitea/gitea/assets/70063547/79acd02a-a567-4316-ae0d-11c6461becf1) 3. It also reuses the `blocks` slice, which is even more confusing. So I rewrote this too. ![UARFPXRGGZQFB7J$2`R}5_R](https://github.com/go-gitea/gitea/assets/70063547/f21cff0f-d9ac-4ce4-ae4d-adffc98ecd99) Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* Avoid cycle-redirecting user/login page (#28636) (#28658)wxiaoguang2023-12-301-5/+5
| | | | | Backport #28636 Fix #28231, and remove some unused code.
* Refactor CORS handler (#28587) (#28611)wxiaoguang2023-12-253-34/+42
| | | | | | | | | | | | | Backport #28587, the only conflict is the test file. The CORS code has been unmaintained for long time, and the behavior is not correct. This PR tries to improve it. The key point is written as comment in code. And add more tests. Fix #28515 Fix #27642 Fix #17098
* Include heap pprof in diagnosis report to help debugging memory leaks ↵Giteabot2023-12-241-0/+7
| | | | (#28596) (#28599)
* Fix `status_check_contexts` matching bug (#28582) (#28589)Giteabot2023-12-221-1/+9
| | | | | | | | | | | | | | | | | | | | Backport #28582 by @Zettat123 Fix #28570 Follow #24633 --- Copied from https://github.com/go-gitea/gitea/issues/28570#issuecomment-1867327999 The feature introduced in #24633 should be compatible with `status_check_contexts`. However, if one or more of `status_check_contexts` is not a legal glob expressions, `glob.Compile` will fail and the contexts cannot match. https://github.com/go-gitea/gitea/blob/21229ed2c8ed00f57100adf9ebc5f4a08da9a66e/routers/web/repo/pull.go#L653-L663 Co-authored-by: Zettat123 <zettat123@gmail.com>
* Fix 405 method not allowed CORS / OIDC (#28583) (#28586)Giteabot2023-12-221-0/+2
| | | | | | | | | | Backport #28583 by @morphelinho Follow #28184 Follow #28515 Fix problem with 405 method not allowed for CORS wrt OIDC Co-authored-by: morphelinho <morphelinho@users.noreply.github.com>
* Use information from previous blame parts (#28572) (#28577)Giteabot2023-12-221-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #28572 by @KN4CK3R Fixes #28545 `git blame` output can contain blocks without commit information if it was outputted before (the `0dafa97ea3f6d9662299579e5be1875cd28baaae 48 26 1` line): ``` fec25436488499df7231f63b857f66457c193d5c 24 25 1 author Bastien Montagne author-mail <bastien@blender.org> author-time 1660731031 author-tz +0200 committer Bastien Montagne committer-mail <bastien@blender.org> committer-time 1660731031 committer-tz +0200 summary LibOverride: Add Make/Reset/Clear entries to IDTemplate contextual menu. previous 839ece6477203382b7a7483062961540180ff1cd source/blender/editors/interface/interface_ops.c filename source/blender/editors/interface/interface_ops.c #include "BLT_translation.h" 0dafa97ea3f6d9662299579e5be1875cd28baaae 48 26 1 3d57bc4397fca53bc9702a27bbf50102827829b0 27 27 1 author Hans Goudey author-mail <hans@blender.org> author-time 1700131315 author-tz +0100 committer Hans Goudey committer-mail <hooglyboogly@noreply.localhost> committer-time 1700131315 committer-tz +0100 summary Cleanup: Move several blenkernel headers to C++ previous 451c054d9b7d3148a646caa5a72fb127a5b5c408 source/blender/editors/interface/interface_ops.cc filename source/blender/editors/interface/interface_ops.cc #include "BKE_context.hh" ``` This PR reuses data from the previous blame part to fill these gaps. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Only check online runner when detecting matching runners in workflows ↵Giteabot2023-12-191-1/+3
| | | | | | | | | | | | | | | | | (#28286) (#28512) Backport #28286 by @yp05327 Mentioned: [#28277](https://github.com/go-gitea/gitea/issues/28277#issuecomment-1831325276) We should only check online runner when detecting matching runners in workflows, as if runner is not online, the workflow will not run. ![image](https://github.com/go-gitea/gitea/assets/18380374/11855e9d-7241-4b7a-b8d7-49dbb94ba1c5) Co-authored-by: yp05327 <576951401@qq.com>
* Add option to disable ambiguous unicode characters detection (#28454) (#28499)wxiaoguang2023-12-182-13/+12
| | | | | | | | Backport #28454 (the only conflict is caused by some comments) * Close #24483 * Close #28123 * Close #23682 * Close #23149
* Do some missing checks (#28423) (#28432)Lunny Xiao2023-12-121-2/+20
| | | backport #28423
* Also sync DB branches on push if necessary (#28361) (#28403)Lunny Xiao2023-12-111-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #28056 Backport #28361 This PR will check whether the repo has zero branch when pushing a branch. If that, it means this repository hasn't been synced. The reason caused that is after user upgrade from v1.20 -> v1.21, he just push branches without visit the repository user interface. Because all repositories routers will check whether a branches sync is necessary but push has not such check. For every repository, it has two states, synced or not synced. If there is zero branch for a repository, then it will be assumed as non-sync state. Otherwise, it's synced state. So if we think it's synced, we just need to update branch/insert new branch. Otherwise do a full sync. So that, for every push, there will be almost no extra load added. It's high performance than yours. For the implementation, we in fact will try to update the branch first, if updated success with affect records > 0, then all are done. Because that means the branch has been in the database. If no record is affected, that means the branch does not exist in database. So there are two possibilities. One is this is a new branch, then we just need to insert the record. Another is the branches haven't been synced, then we need to sync all the branches into database.
* Fix missing check (#28406) (#28411)Giteabot2023-12-112-4/+24
| | | | | Backport #28406 by @lunny Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix object does not exist error when checking citation file (#28314) (#28369)Giteabot2023-12-061-13/+6
| | | | | | | | | | | Backport #28314 by @yp05327 Fix #28264 `DataAsync()` will be called twice. Caused by https://github.com/go-gitea/gitea/pull/27958. I'm sorry, I didn't completely remove all unnecessary codes. Co-authored-by: yp05327 <576951401@qq.com>
* Fix the runs will not be displayed bug when the main branch have no ↵Giteabot2023-12-061-0/+1
| | | | | | | | | | | | | | workflows but other branches have (#28359) (#28365) Backport #28359 by @lunny The left menu will only display the default branch's workflows but the right side will display the runs triggered by all branches' workflows. So we cannot hide right side if default branch has no workflows. Fix #28332 Replace #28333 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Read `previous` info from git blame (#28306) (#28310)Giteabot2023-12-011-30/+8
| | | | | | | | | | Backport #28306 by @KN4CK3R Fixes #28280 Reads the `previous` info from the `git blame` output instead of calculating it afterwards. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>