aboutsummaryrefslogtreecommitdiffstats
path: root/services/context
Commit message (Collapse)AuthorAgeFilesLines
* Fix SSH LFS timeout (#34838)wxiaoguang9 days1-6/+3
| | | Fix #34834
* Edit file workflow for creating a fork and proposing changes (#34240)Brecht Van Lommel11 days2-45/+82
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When viewing a file that the user can't edit because they can't write to the branch, the new, upload, patch, edit and delete functionality is no longer disabled. If no user fork of the repository exists, there is now a page to create one. It will automatically create a fork with a single branch matching the one being viewed, and a unique repository name will be automatically picked. When a fork exists, but it's archived, a mirror or the user can't write code to it, there will instead be a message explaining the situation. If the usable fork exists, a message will appear at the top of the edit page explaining that the changes will be applied to a branch in the fork. The base repository branch will be pushed to a new branch to the fork, and then the edits will be applied on top. The suggestion to fork happens when accessing /_edit/, so that for example online documentation can have an "edit this page" link to the base repository that does the right thing. Also includes changes to properly report errors when trying to commit to a new branch that is protected, and when trying to commit to an existing branch when choosing the new branch option. Resolves #9017, #20882 --------- Co-authored-by: Brecht Van Lommel <brecht@blender.org> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor editor (#34780)wxiaoguang12 days2-15/+21
| | | A complete rewrite
* Add workflow_run api + webhook (#33964)ChristopherHX13 days1-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements - https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#list-jobs-for-a-workflow-run--code-samples - https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#get-a-job-for-a-workflow-run--code-samples - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#get-a-workflow-run - `/actions/runs` for global + user + org (Gitea only) - `/actions/jobs` for global + user + org + repository (Gitea only) - workflow_run webhook + action trigger - limitations - workflow id is assigned to a string, this may result into problems in strongly typed clients Fixes - workflow_job webhook url to no longer contain the `runs/<run>` part to align with api - workflow instance does now use it's name inside the file instead of filename if set Refactoring - Moved a lot of logic from workflows/workflow_job into a shared module used by both webhook and api TODO - [x] Verify Keda Compatibility - [x] Edit Webhook API bug is resolved Closes https://github.com/go-gitea/gitea/issues/23670 Closes https://github.com/go-gitea/gitea/issues/23796 Closes https://github.com/go-gitea/gitea/issues/24898 Replaces https://github.com/go-gitea/gitea/pull/28047 and is much more complete --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Run `gopls modernize` on codebase (#34751)silverwind2025-06-183-12/+6
| | | | Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
* Improve the performance when detecting the file editable (#34653)Lunny Xiao2025-06-121-2/+3
| | | | | | | | | | | | Noticed the SQL will be executed 4 times when visit the file render view page. For a repository which have many pull requests, it maybe slow. ```SQL 2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 2.004167ms 2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 1.03975ms 2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 881.583µs 2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 935.084µs ``` This PR did a refactor to query it once only.
* Improve instance wide ssh commit signing (#34341)ChristopherHX2025-06-111-1/+1
| | | | | | | | | | | | | | | | | * Signed SSH commits can look in the UI like on GitHub, just like gpg keys today in Gitea * SSH format can be added in gitea config * SSH Signing worked before with DEFAULT_TRUST_MODEL=committer `TRUSTED_SSH_KEYS` can be a list of additional ssh public key contents to trust for every user of this instance Closes #34329 Related #31392 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Performance optimization for tags synchronization (#34355)Lunny Xiao2025-05-221-0/+9
| | | | | | | | | The tags synchronization is very slow for a non-mirror repository with many tags especially forking. This PR make all repositories' tags synchronization use the same function and remove the low performance synchronization function. The commit count of tag now will not be stored into database when syncing. Since the commits count will always be read from cache or git data, the `NumCommits` in the release table will be updated for the first read from git data.
* Add endpoint deleting workflow run (#34337)NorthRealm2025-05-132-3/+11
| | | | | | | | | | | Add endpoint deleting workflow run Resolves #26219 /claim #26219 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix repo broken check (#34444)wxiaoguang2025-05-131-2/+2
| | | Fix #34424
* Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)wxiaoguang2025-04-282-4/+17
| | | | | | | | | | | | | | | | | | | | | Fix #880 Design: 1. A global setting `security.TWO_FACTOR_AUTH`. * To support org-level config, we need to introduce a better "owner setting" system first (in the future) 2. A user without 2FA can login and may explore, but can NOT read or write to any repositories via API/web. 3. Keep things as simple as possible. * This option only aggressively suggest users to enable their 2FA at the moment, it does NOT guarantee that users must have 2FA before all other operations, it should be good enough for real world use cases. * Some details and tests could be improved in the future since this change only adds a check and seems won't affect too much. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Improve "not found" error messages for API (#34267)wxiaoguang2025-04-231-1/+1
| | | Make the message clear, for example: #34266
* Add API endpoint to request contents of multiple files simultaniously (#34139)Denys Konovalov2025-04-221-27/+16
| | | | | | | | | | | | | | | | Adds an API POST endpoint under `/repos/{owner}/{repo}/file-contents` which receives a list of paths and returns a list of the contents of these files. This API endpoint will be helpful for applications like headless CMS (reference: https://github.com/sveltia/sveltia-cms/issues/198) which need to retrieve a large number of files by reducing the amount of needed API calls. Close #33495 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix team permission (#34128)wxiaoguang2025-04-081-2/+2
| | | | The `team.access_mode` should be either `none` or `admin/owner`. For non-admin team, the real permissions are provided by `team_unit`.
* Remove dead code: RepoRef (#34131)wxiaoguang2025-04-061-6/+0
| | | The RepoRef is a no-op since Refactor ref type (#33242) (Jan 14)
* Refactor Branch struct in package modules/git (#33980)Lunny Xiao2025-04-021-2/+2
| | | | The `Branch` struct in `modules/git` package is unnecessary. We can just use a `string` to represent a branch
* Do not show 500 error when default branch doesn't exist (#34096)wxiaoguang2025-04-011-1/+1
| | | Fix #34090
* Enable addtional linters (#34085)TheFox0x72025-04-017-14/+14
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enable testifylint rules (#34075)TheFox0x72025-03-311-1/+1
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054
* Add a config option to block "expensive" pages for anonymous users (#34024)wxiaoguang2025-03-301-1/+1
| | | | | | | | | | | Fix #33966 ``` ;; User must sign in to view anything. ;; It could be set to "expensive" to block anonymous users accessing some pages which consume a lot of resources, ;; for example: block anonymous AI crawlers from accessing repo code pages. ;; The "expensive" mode is experimental and subject to change. ;REQUIRE_SIGNIN_VIEW = false ```
* enable staticcheck QFxxxx rules (#34064)TheFox0x72025-03-291-3/+4
|
* Add anonymous access support for private repositories (backend) (#33257)wxiaoguang2025-03-281-1/+1
| | | | | | | | | | | Follow #33127 This PR add backend logic and test for "anonymous access", it shares the same logic as "everyone access", so not too much change. By the way, split `SettingsPost` into small functions to make it easier to make frontend-related changes in the future. Next PR will add frontend support for "anonymous access"
* Git client will follow 301 but 307 (#34005)Lunny Xiao2025-03-251-1/+3
| | | | | | | Fix #28460 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Only use prev and next buttons for pagination on user dashboard (#33981)Lunny Xiao2025-03-231-0/+6
| | | | | | | | | | | The pagination on the user dashboard sounds unnecessary, this will change it to a prev/next buttons. For instances with around `10 million` records in the action table, this option affects how the user dashboard is loaded on first visit. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Move git references checking to gitrepo packages to reduce expose of ↵Lunny Xiao2025-03-152-5/+5
| | | | repository path (#33891)
* Refactor cache-control (#33861)wxiaoguang2025-03-132-2/+2
| | | And fix #21391
* Improve log format (#33814)wxiaoguang2025-03-082-2/+2
|
* Improve "generate new access token" form (#33730)Guillaume2025-02-271-4/+7
| | | | | | | | | | | | | | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/33519 As discussed in [PR #33614](https://github.com/go-gitea/gitea/pull/33614), the ScopedAccessTokenSelector Vue component is not particularly useful. This PR removes the component and reverts to using HTML templates. It also introduces some (hopefully) useful refactoring. The Vue component was causing the UX bug reported in the linked issue. Required form fields are now properly working, as expected (see screenshot). ![Screenshot from 2025-02-25 22-00-28](https://github.com/user-attachments/assets/41167854-0718-48b0-a3ee-75ca3a7b8b20) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix git empty check and HEAD request (#33690)wxiaoguang2025-02-241-0/+5
|
* Refactor error system (#33626)wxiaoguang2025-02-172-6/+12
|
* Refactor error system (#33610)wxiaoguang2025-02-168-79/+73
|
* Avoid duplicate SetContextValue call (#33564)wxiaoguang2025-02-122-3/+2
| | | And fix FIXME and TODO
* Fix context usage (#33554)wxiaoguang2025-02-112-5/+6
| | | | | | | | | Some old code use direct type-casting to get context, it causes problems. This PR fixes all legacy problems and use correct `ctx.Value` to get low-level contexts. Fix #33518
* Feature: Support workflow event dispatch via API (#33545)wxiaoguang2025-02-113-1/+11
| | | | | | | | | Fix: https://github.com/go-gitea/gitea/issues/31765 (Re-open #32059) --------- Co-authored-by: Bence Santha <git@santha.eu> Co-authored-by: Bence Sántha <7604637+bencurio@users.noreply.github.com> Co-authored-by: Christopher Homberger <christopher.homberger@web.de>
* Refactor web route handler (#33488)wxiaoguang2025-02-051-178/+154
|
* Worktime tracking for the organization level (#19808)K Kovacs2025-02-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Dear Gitea team, first of all, thanks for the great work you're doing with this project. I'm planning to introduce Gitea at a client site, and noticed that while there is time recording, there are no project-manager-friendly reports to actually make use of that data, as were also mentioned by others in #4870 #8684 and #13531. Since I had a little time last weekend, I had put together something that I hope to be a useful contribution to this great project (while of course useful for me too). This PR adds a new "Worktime" tab to the Organisation level. There is a date range selector (by default set to the current month), and there are three possible views: - by repository, - by milestone, and - by team member. Happy to receive any feedback! There are several possible future improvements of course (predefined date ranges, charts, a member time sheet, matrix of repos/members, etc) but I hope that even in this relatively simple state this would be useful to lots of people. <img width="1161" alt="Screen Shot 2022-05-25 at 22 12 58" src="https://user-images.githubusercontent.com/118010/170366976-af00c7af-c4f3-4117-86d7-00356d6797a5.png"> Keep up the good work! Kristof --------- Co-authored-by: user <user@kk-git1> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix "redirect link" handling (#33440)wxiaoguang2025-01-312-13/+26
| | | | | | | `a%2fb` should not redirect to `a/b` --------- Co-authored-by: delvh <dev.lh@web.de>
* Refactor repository transfer (#33211)Lunny Xiao2025-01-301-1/+1
| | | | | | | | | | | | | - Both have `RejectTransfer` and `CancelTransfer` because the permission checks are not the same. `CancelTransfer` can be done by the doer or those who have admin permission to access this repository. `RejectTransfer` can be done by the receiver user if it's an individual or those who can create repositories if it's an organization. - Some tests are wrong, this PR corrects them. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor context flash msg and global variables (#33375)wxiaoguang2025-01-251-11/+3
| | | | | | 1. add `GetSiteCookieFlashMessage` to help to parse flash message 2. clarify `handleRepoHomeFeed` logic 3. remove unnecessary global variables, use `sync.OnceValue` instead 4. add some tests for `IsUsableUsername` and `IsUsableRepoName`
* Do not access GitRepo when a repo is being created (#33380)wxiaoguang2025-01-241-0/+3
|
* Remove duplicate "ResponseWriter.Status" method (#33346)wxiaoguang2025-01-223-15/+4
|
* Refactor response writer & access logger (#33323)wxiaoguang2025-01-203-64/+151
| | | And add comments & tests
* Fix incorrect ref usages (#33301)wxiaoguang2025-01-161-0/+12
| | | | | Fix #33297 By the way, improve some locales
* Prepare for support performance trace (#33286)wxiaoguang2025-01-151-13/+11
| | | For #32973
* Fix incorrect TagName/BranchName usages (#33279)wxiaoguang2025-01-151-4/+0
| | | Add add a new test
* Simplify context ref name (#33267)wxiaoguang2025-01-151-29/+10
|
* Refactor ref type (#33242)Lunny Xiao2025-01-142-55/+27
| | | | | | | | | | | | Major changes: 1. do not sync ".keep" file during tests 2. fix incorrect route handler and empty repo handling (backported as #33253 with tests) 3. do not use `RepoRef`: most of the calls are abuses. 4. Use `git.RefType` instead of a new type definition `RepoRefType` on `context`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support public code/issue access for private repositories (#33127)wxiaoguang2025-01-141-65/+9
| | | Close #8649, close #639 (will add "anonymous access" in following PRs)
* Fix incorrect ref "blob" (#33240)wxiaoguang2025-01-131-10/+0
| | | | | 1. "blob" is not a "ref", it shouldn't (and not unable to) be handled by `RepoRefByType` 2. the `/blob/{sha}` handle should use the path param "sha" directly
* Refactor RefName (#33234)wxiaoguang2025-01-131-10/+1
| | | And fix some FIXMEs