aboutsummaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* Performance optimization for tags synchronization (#34355)Lunny Xiao25 hours3-10/+13
| | | | | | | | | 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.
* Fix possible panic (#34508)Lunny Xiao33 hours1-25/+26
|
* Fix ephemeral runner deletion (#34447)ChristopherHX3 days2-0/+25
| | | | | | | | | * repository deletion, delete ephemeral runners with active tasks as well skips regular cleanup * user deletion, delete ephemeral runners with active tasks as well skips regular cleanup * delete ephemeral runners once status changes to done * You no longer see used ephemeral runners after the task is done * if you see one the cron job takes care of it
* Use run-name and evaluate workflow variables (#34301)badhezi4 days3-30/+116
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This addresses https://github.com/go-gitea/gitea/issues/34247 depends on https://gitea.com/gitea/act/pulls/137 I couldn't find any previous implementation for `run-name` support on workflows so I created one. Key points: All dispatched workflows, scheduled workflows and detected workflows (from different hooks) will use and evaluate `run-name` if exists, with the corresponding gitea context and variables. This will be used as the Action run title and replace the default commit message being used today. Had to change act package jobparser (see link above) and create two helpers https://github.com/go-gitea/gitea/blob/3a1320c70df82ae88e286612c1646cffb8e2c343/models/actions/utils.go#L86 and https://github.com/go-gitea/gitea/blob/3a1320c70df82ae88e286612c1646cffb8e2c343/services/actions/context.go#L169 to pass the correct types to [GenerateGiteaContext](https://github.com/go-gitea/gitea/pull/34301/files#diff-9c9c27cb61a33e55ad33dc2c2e6a3521957a3e5cc50ddf652fdcd1def87b044dR86) and [WithGitContext](https://gitea.com/gitea/act/src/commit/65c232c4a5a40e59e257ab5d956b32585f0405d7/pkg/jobparser/jobparser.go#L84) respectively. <img width="1336" alt="Screenshot 2025-04-28 at 17 13 01" src="https://github.com/user-attachments/assets/73cb03d0-23a0-4858-a466-bbf0748cea98" />
* Export repo's manual merge settings (#34502)Adam Majer4 days1-0/+6
|
* Change "rejected" to "changes requested" in 3rd party PR review notification ↵Sebastian Weigand8 days1-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#34481) This PR changes 3rd party notifications wording on a PR review that requests changes and can be considered a follow up for #5858 to also fix #5857 in 3rd party notifications. The difference in the actual notification would be the following: ```diff - Pull request review rejected + Pull request review changes requested ``` While this is a simple string change at first look, it has a deeper UX meaning. # Motivation We could observe that some developers are hesitant to press the "Request changes" button since their peers first see that their changes were rejected, thus a more appropriate wording that also falls in line with the meaning and UI would be beneficial. ## Meaning Pressing the `Request changes` button in a PR review means that as a reviewer you are willing to merge the general change in a PR if changes requested review comments are implemented. Rejecting a PR on the other hand would be equivalent with closing it since that change isn't welcome at all (e.g. out of scope feature). ## Sync with UI The UI button says `request changes` and the other options ![image](https://github.com/user-attachments/assets/3766cc89-40d7-4c5e-9ff7-a0e1f6991ea6) ## Considered Problems This might break some automation for users who rely on string matching.
* Add endpoint deleting workflow run (#34337)NorthRealm10 days3-10/+112
| | | | | | | | | | | 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 remove org user failure on mssql (#34449)ChristopherHX10 days1-1/+2
| | | | | | | | | | | * mssql does not support fetching 0 repositories * remove paging by NumRepos that might be 0 * extend admin api test to purge user 2 Fixes #34448 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix repo broken check (#34444)wxiaoguang11 days1-2/+2
| | | Fix #34424
* Only git operations should update `last changed` of a repository (#34388)Lunny Xiao12 days12-19/+19
| | | Try to fix #32046
* Fix incorrect divergence cache after switching default branch (#34370)GWDx2025-05-081-0/+5
| | | | | | | | | | Issue: After switching the default branch, other branches are still compared against the old default branch due to outdated divergence cache. Change: Clear the divergence cache in SetRepoDefaultBranch to ensure correct comparisons against the new default branch. Fixes #34369
* Fix LFS file not stored in LFS when uploaded/edited via API or web UI (#34367)bytedream2025-05-081-0/+7
| | | | | | | | Files that should be stored in LFS and are uploaded/edited from the API or web UI aren't stored in LFS. This may be a regression from #34154. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Upgrade go-github v61 -> v71 (#34385)Lunny Xiao2025-05-062-17/+27
| | | | | There will be a possible bug when migrating from Github https://github.com/google/go-github/issues/3229 This PR upgrades go-github from v61 to v71 to resolve that problem.
* feat: return time of last usage for public keys and access tokens in the api ↵Tobias Balle-Petersen2025-05-011-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | (#34323) In the Gitea GUI, the user can see the time that _AccessTokens_ and _PublicKeys_ were last used. This information is not returned by the _/users/{username}/tokens_ and _/user/keys_ endpoints in the API. This PR adds the missing data. The time of last usage for for _tokens_ & _keys_ seem to be stored in the _Updated_ field of the structs internally. For consistency, I have used the name _updated_at_ for the new field returned by the _API_. However, for the _API_ user, I don't think that name reflects the data returned, as I believe it is the time of last usage. I propose that we use the name _last_used_at_ instead. Let's hear reviewers opinion on that. * PublicKey 1. _last_used_at_: string($date-time) * AccessToken 1. _created_at_: string($date-time) (for parity with public keys) 2. _last_used_at_: string($date-time) Fix #34313
* fix: do not return archive download URLs in API if downloads are disabled ↵Tobias Balle-Petersen2025-04-301-2/+11
| | | | | | | | | | | | (#34324) If archive downloads are are disabled using _DISABLE_DOWNLOAD_SOURCE_ARCHIVES_, archive links are still returned by the API. This PR changes the data returned, so the fields _zipball_url_ and _tarball_url_ are omitted if archive downloads have been disabled. Resolve #32159
* support the open-icon of folder (#34168)Kerwin Bryant2025-04-282-21/+18
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix wrong review requests when updating the pull request (#34286)v1.25.0-devLunny Xiao2025-04-282-20/+23
| | | | | | | | Fix #34224 The previous implementation in #33744 will get the pushed commits changed files. But it's not always right when push a merged commit. This PR reverted the logic in #33744 and will always get the PR's changed files and get code owners.
* Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)wxiaoguang2025-04-2823-120/+88
| | | | | | | | | | | | | | | | | | | | | 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>
* Option to delay conflict checking of old pull requests until page view (#27779)Brecht Van Lommel2025-04-2410-102/+129
| | | | | | | | | | | | | | | | | | | | | | `[repository.pull-request] DELAY_CHECK_FOR_INACTIVE_DAYS` is a new setting to delay the mergeable check for pull requests that have been inactive for the specified number of days. This avoids potentially long delays for big repositories with many pull requests. and reduces system load overall when there are many repositories or pull requests. When viewing the PR, checking will start immediately and the PR merge box will automatically reload when complete. Accessing the PR through the API will also start checking immediately. The default value of `7` provides a balance between system load, and keeping behavior similar to what it was before both for users and API access. With `0` all conflict checking will be delayed, while `-1` always checks immediately to restore the previous behavior. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix panic when comment is nil (#34257)Lunny Xiao2025-04-241-0/+6
| | | Fix #34254
* 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-227-279/+112
| | | | | | | | | | | | | | | | 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>
* Add API routes to lock and unlock issues (#34165)YaFou2025-04-212-42/+0
| | | | | | | | | | | | | | | This pull request adds a GitHub-compatible API endpoint to lock and unlock an issue. The following routes exist now: - `PUT /api/v1/repos/{owner}/{repo}/issues/{id}/lock` to lock an issue - `DELETE /api/v1/repos/{owner}/{repo}/issues/{id}/lock` to unlock an issue Fixes #33677 Fixes #20012 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix notify watch failure when the content is too long (#34233)Lunny Xiao2025-04-201-15/+15
| | | | | | | Fix #28193 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Actions Runner rest api (#33873)ChristopherHX2025-04-182-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | Implements runner apis based on https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization - Add Post endpoints for registration-token, google/go-github revealed this as problem - We should deprecate Get Endpoints, leaving them for compatibility - Get endpoint of admin has api path /admin/runners/registration-token that feels wrong, /admin/actions/runners/registration-token seems more consistent with user/org/repo api - Get Runner Api - List Runner Api - Delete Runner Api - Tests admin / user / org / repo level endpoints Related to #33750 (implements point 1 and 2) Via needs discovered in #32461, this runner api is needed to allow cleanup of runners that are deallocated without user interaction. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Mark parent directory as viewed when all files are viewed (#33958)Kerwin Bryant2025-04-151-5/+8
| | | | | | | | Fix #25644 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix package upload temp path (#34196)wxiaoguang2025-04-141-6/+15
| | | | | Fix #34195 The temp dir should be created when it is used.
* Fix bug when migrating repository (#34182)Lunny Xiao2025-04-147-12/+14
| | | This PR fixed a bug which is a regression from #31035
* fix github migration error when using multiple tokens (#34144)TheFox0x72025-04-132-1/+50
| | | | | | | | | | Git authorization was not taking into account multiple token feature, leading to auth failures Closes: https://github.com/go-gitea/gitea/issues/34141 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move and rename UpdateRepository (#34136)Lunny Xiao2025-04-125-33/+145
|
* Refactor Git Attribute & performance optimization (#34154)Lunny Xiao2025-04-115-52/+25
| | | | | | | | | | | | | | | | This PR moved git attributes related code to `modules/git/attribute` sub package and moved language stats related code to `modules/git/languagestats` sub package to make it easier to maintain. And it also introduced a performance improvement which use the `git check-attr --source` which can be run in a bare git repository so that we don't need to create a git index file. The new parameter need a git version >= 2.40 . If git version less than 2.40, it will fall back to previous implementation. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: yp05327 <576951401@qq.com>
* feat: Add sorting by exclusive labels (issue priority) (#33206)Thomas E Lackey2025-04-101-6/+7
| | | | | | | | | | | | | Fix #2616 This PR adds a new sort option for exclusive labels. For exclusive labels, a new property is exposed called "order", while in the UI options are populated automatically in the `Sort` column (see screenshot below) for each exclusive label scope. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Cache GPG keys, emails and users when list commits (#34086)Lunny Xiao2025-04-093-25/+23
| | | | | | | | | | When list commits, some of the commits authors are the same at many situations. But current logic will always fetch the same GPG keys from database. This PR will cache the GPG keys, emails and users for the context so that reducing the database queries. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Uniform all temporary directories and allow customizing temp path (#32352)Lunny Xiao2025-04-087-47/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This PR uniform all temporary directory usage so that it will be easier to manage. Relate to #31792 - [x] Added a new setting to allow users to configure the global temporary directory. - [x] Move all temporary files and directories to be placed under os.Temp()/gitea. - [x] `setting.Repository.Local.LocalCopyPath` now will be `setting.TempPath/local-repo` and the customized path is removed. ```diff -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;[repository.local] -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;; -;; Path for local repository copy. Defaults to TEMP_PATH + `local-repo`, this is deprecated and cannot be changed -;LOCAL_COPY_PATH = local-repo ``` - [x] `setting.Repository.Upload.TempPath` now will be `settting.TempPath/uploads` and the customized path is removed. ```diff ;[repository.upload] -;; -;; Path for uploads. Defaults to TEMP_PATH + `uploads` -;TEMP_PATH = uploads ``` - [x] `setting.Packages.ChunkedUploadPath` now will be `settting.TempPath/package-upload` and the customized path is removed. ```diff ;[packages] -;; -;; Path for chunked uploads. Defaults it's `package-upload` under `TEMP_PATH` unless it's an absolute path. -;CHUNKED_UPLOAD_PATH = package-upload ``` - [x] `setting.SSH.KeyTestPath` now will be `settting.TempPath/ssh_key_test` and the customized path is removed. ```diff [server] -;; -;; Directory to create temporary files in when testing public keys using ssh-keygen, -;; default is the system temporary directory. -;SSH_KEY_TEST_PATH = ``` TODO: - [ ] setting.PprofDataPath haven't been changed because it may need to be kept until somebody read it but temp path may be clean up any time. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Check user/org repo limit instead of doer (#34147)DrMaxNix2025-04-076-21/+21
| | | | | | | | | | | | This PR tries to finally fix the bug mentioned in #30011 and #15504, where the user repo limit is checked when creating a repo in an organization. Fix #30011 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
* Rework create/fork/adopt/generate repository to make sure resources will be ↵Lunny Xiao2025-04-0710-321/+459
| | | | | | | | | | | | | | | | | | | cleanup once failed (#31035) Fix #28144 To make the resources will be cleanup once failed. All repository operations now follow a consistent pattern: - 1. Create a database record for the repository with the status being_migrated. - 2. Register a deferred cleanup function to delete the repository and its related data if the operation fails. - 3. Perform the actual Git and database operations step by step. - 4. Upon successful completion, update the repository’s status to ready. The adopt operation is a special case — if it fails, the repository on disk should not be deleted.
* Fix team permission (#34128)wxiaoguang2025-04-083-51/+2
| | | | The `team.access_mode` should be either `none` or `admin/owner`. For non-admin team, the real permissions are provided by `team_unit`.
* Keep file tree view icons consistent with icon theme (#33921)Kerwin Bryant2025-04-062-11/+46
| | | | | | | | | | | | | | | | | Fix #33914 before: ![3000-gogitea-gitea-y4ulxr46c4k ws-us118 gitpod io_test_test gitea_src_branch_main_ gitmodules](https://github.com/user-attachments/assets/ca50eeff-cc44-4041-b01f-c0c5bdd3b6aa) after: ![3000-gogitea-gitea-y4ulxr46c4k ws-us118 gitpod io_test_test gitea_src_branch_main_README md](https://github.com/user-attachments/assets/3b87fdbd-81d0-4831-8a74-4dbfcd5b6d91) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Remove dead code: RepoRef (#34131)wxiaoguang2025-04-061-6/+0
| | | The RepoRef is a no-op since Refactor ref type (#33242) (Jan 14)
* Avoid creating unnecessary temporary cat file sub process (#33942)Lunny Xiao2025-04-041-1/+1
| | | | | | | | | | | | | Extract from #33934 In the same goroutine, we should reuse the exist cat file sub process which exist in `git.Repository` to avoid creating a unnecessary temporary subprocess. This PR reuse the exist cate file writer and reader in `getCommitFromBatchReader`. It also move `prepareLatestCommitInfo` before creating dataRc which will hold the writer so other git operation will create a temporary cat file subprocess.
* Fix discord webhook 400 status code when description limit is exceeded (#34084)Mopcho2025-04-041-1/+8
| | | | | | | | | | | | Fixes [#34027](https://github.com/go-gitea/gitea/issues/34027) Discord does not allow for description bigger than 2048 bytes. If the description is bigger than that it will throw 400 and the event won't appear in discord. To fix that, in the createPayload method we now slice the description to ensure it doesn’t exceed the limit. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix invalid version in RPM package path (#34112)KN4CK3R2025-04-031-2/+1
|
* Add `last_committer_date` and `last_author_date` for file contents API (#32921)Lunny Xiao2025-04-023-24/+38
| | | | | | | | Fix #32886 Add `last_committer_date` and `last_author_date` in the content API which is not implemented by Github API v3 at the moment. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor Branch struct in package modules/git (#33980)Lunny Xiao2025-04-027-45/+39
| | | | 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
* Move ParseCommitWithSSHSignature to service layer (#34087)Lunny Xiao2025-04-011-1/+65
| | | No code change.
* Enable addtional linters (#34085)TheFox0x72025-04-0169-161/+186
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* fix users being able bypass limits with repo transfers (#34031)TheFox0x72025-03-312-1/+63
| | | | prevent user from being able to transfer repo to user who cannot have more repositories
* Improve pull request list api (#34052)Lunny Xiao2025-03-311-56/+27
| | | | | | | | The pull request list API is slow, for every pull request, it needs to open a git repository. Assume it has 30 records, there will be 30 sub processes back because every repository will open a git cat-file --batch sub process. This PR use base git repository to get the head commit id rather than read it from head repository to avoid open any head git repository.
* Enable testifylint rules (#34075)TheFox0x72025-03-3137-114/+114
| | | | enable testifylint rules disabled in: https://github.com/go-gitea/gitea/pull/34054