aboutsummaryrefslogtreecommitdiffstats
path: root/modules
Commit message (Collapse)AuthorAgeFilesLines
* Remove legacy template helper functions (#34426)wxiaoguang6 days4-108/+2
| | | | These functions have been marked as `panicIfDevOrTesting` since 1.23 (#32422)
* Fix a bug when uploading file via lfs ssh command (#34408)Lunny Xiao8 days2-6/+40
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor commit message rendering and fix bugs (#34412)wxiaoguang8 days4-84/+83
| | | | | | Fix #34398, fix #33308 Remove all `repo.ComposeCommentMetas` from templates, only use `repo` to render commit message.
* Fix LFS file not stored in LFS when uploaded/edited via API or web UI (#34367)bytedream9 days2-2/+17
| | | | | | | | 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>
* feat: add label 'state' to metric 'gitea_users' (#34326)Tobias Balle-Petersen10 days1-2/+9
| | | | | | | | | | | | | | | | | | This PR adds the label _state_ to the metric _gitea_users_. With the change, _gitea_users_ would be reported like this: ``` ... # HELP gitea_users Number of Users # TYPE gitea_users gauge gitea_users{state="active"} 20 gitea_users{state="inactive"} 10 ... ``` The metrics above would be from a Gitea instance with 30 user accounts. 20 of the accounts are active and 10 of the accounts are not active. Resolve #34325
* feat: return time of last usage for public keys and access tokens in the api ↵Tobias Balle-Petersen2025-05-012-5/+8
| | | | | | | | | | | | | | | | | | | | | | | | (#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/+2
| | | | | | | | | | | | (#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-287-62/+120
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)wxiaoguang2025-04-282-0/+21
| | | | | | | | | | | | | | | | | | | | | 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>
* Update token creation API swagger documentation (#34288)Lunny Xiao2025-04-271-1/+3
| | | Fix #34231
* Option to delay conflict checking of old pull requests until page view (#27779)Brecht Van Lommel2025-04-241-0/+3
| | | | | | | | | | | | | | | | | | | | | | `[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 various trivial frontend problems (#34263)wxiaoguang2025-04-241-1/+1
| | | | | | | | | | 1. Fix #20606 2. Fix #34246 3. Fix missing spaces, fix misspells, no visual change. 4. Fix missing "not-mobile", fix #34265 --------- Co-authored-by: silverwind <me@silverwind.io>
* update go&js dependencies (#34262)wxiaoguang2025-04-231-1/+5
|
* Make public URL generation configurable (#34250)wxiaoguang2025-04-223-28/+51
| | | | | | | Follow up #32564 Co-authored-by: Jannis Pohl <838818+jannispl@users.noreply.github.com> Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
* Add API endpoint to request contents of multiple files simultaniously (#34139)Denys Konovalov2025-04-225-19/+13
| | | | | | | | | | | | | | | | 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-211-0/+5
| | | | | | | | | | | | | | | 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>
* Make ROOT_URL support using request Host header (#32564)Jannis Pohl2025-04-203-14/+60
| | | | | | | Resolve #32554 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Valid email address should only start with alphanumeric (#28174)Dejan Kitic2025-04-203-10/+43
| | | | | | | | | | | | This fixes issue #27847 where regular expression allowed email address to start with special symbols. Valid email addresses should start with alphanumeric character, and as such will be rendered as email. Added test cases from the bug report to validate, such input will not be rendered anymore as email address. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* markup: improve code block readability and isolate copy button (#34009)D2025-04-191-7/+2
| | | | | | | | Fix #33197 Improve the rendering of code blocks in markdown content for better readability and UI stability across screen sizes. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Actions Runner rest api (#33873)ChristopherHX2025-04-181-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Add middleware for request prioritization (#33951)Rowan Bohde2025-04-141-0/+17
| | | | | | | | | | | | | | | | | | | This adds a middleware for overload protection that is intended to help protect against malicious scrapers. It does this via [`codel`](https://github.com/bohde/codel), which will perform the following: 1. Limit the number of in-flight requests to some user-defined max 2. When in-flight requests have reached their begin queuing requests. Logged-in requests having priority above logged-out requests 3. Once a request has been queued for too long, it has a probabilistic chance to be rejected based on how overloaded the entire system is. When a server experiences more traffic than it can handle, this keeps latency low for logged-in users and rejects just enough requests from logged-out users to not overload the service. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Fix package upload temp path (#34196)wxiaoguang2025-04-141-10/+2
| | | | | Fix #34195 The temp dir should be created when it is used.
* Add package version api endpoints (#34173)KN4CK3R2025-04-131-2/+2
| | | | | | | | | Fixes #33544 Adds two new api endpoints to list a versions of a package and to get the latest version of a package by API. ⚠️ BREAKING ⚠️ the `size` field for this endpoint changes from `Size` to `size`.
* Add cache for common package queries (#22491)KN4CK3R2025-04-133-199/+124
| | | | | | | | | | This adds a cache for common package queries in `GetPackageDescriptor`. Code which needs to process a list of packages benefits from this change. This skips 350 queries in the package integration tests for example. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Move and rename UpdateRepository (#34136)Lunny Xiao2025-04-122-123/+0
|
* Refactor Git Attribute & performance optimization (#34154)Lunny Xiao2025-04-1120-485/+811
| | | | | | | | | | | | | | | | 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-107-23/+61
| | | | | | | | | | | | | 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-094-6/+20
| | | | | | | | | | 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>
* Set MERMAID_MAX_SOURCE_CHARACTERS to 50000 (#34152)wxiaoguang2025-04-091-1/+1
| | | Fix #32015
* Uniform all temporary directories and allow customizing temp path (#32352)Lunny Xiao2025-04-0823-159/+304
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Rework create/fork/adopt/generate repository to make sure resources will be ↵Lunny Xiao2025-04-071-27/+0
| | | | | | | | | | | | | | | | | | | 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.
* Keep file tree view icons consistent with icon theme (#33921)Kerwin Bryant2025-04-066-69/+88
| | | | | | | | | | | | | | | | | 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>
* Make markdown render match GitHub's behavior (#34129)wxiaoguang2025-04-062-4/+11
| | | For #2246
* Fix markdown render behaviors (#34122)wxiaoguang2025-04-0510-56/+243
| | | | | | | * Fix #27645 * Add config options `MATH_CODE_BLOCK_DETECTION`, problematic syntaxes are disabled by default * Fix #33639 * Add config options `RENDER_OPTIONS_*`, old behaviors are kept
* Avoid creating unnecessary temporary cat file sub process (#33942)Lunny Xiao2025-04-045-12/+18
| | | | | | | | | | | | | 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.
* Refactor markup render to fix various path problems (#34114)wxiaoguang2025-04-0420-247/+196
| | | | | | | | | | | * Fix #33972 * Use consistent path resolving for links and medias. * No need to make the markup renders to resolve the paths, instead, the paths are all correctly resolved in the "post process" step. * Fix #33274 * Since 1.23, all paths starting with "/" are relative to current render context (for example: the current repo branch) * Introduce `/:root/path-relative-to-root`, then the path will be rendered as relative to "ROOT_URL"
* Fix markdown frontmatter rendering (#34102)wxiaoguang2025-04-037-106/+124
| | | Fix #34101
* Get changed files based on merge base when checking `pull_request` actions ↵Zettat1232025-04-031-2/+2
| | | | | trigger (#34106) Fix #33941
* Add `last_committer_date` and `last_author_date` for file contents API (#32921)Lunny Xiao2025-04-021-0/+6
| | | | | | | | 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-022-69/+2
| | | | The `Branch` struct in `modules/git` package is unnecessary. We can just use a `string` to represent a branch
* Enable addtional linters (#34085)TheFox0x72025-04-0153-123/+128
| | | | | | | | enable mirror, usestdlibbars and perfsprint part of: https://github.com/go-gitea/gitea/issues/34083 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add flat-square action badge style (#34062)bytedream2025-04-012-15/+31
| | | | | | | | | Adds the `flat-square` style to action badges. Styles can be selected by adding `?style=<style>` to the badge endpoint. If no style query is given, or if the query is invalid, the style defaults to `flat`. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix some UI bugs and clean up unused tests (#34088)wxiaoguang2025-04-012-67/+5
| | | | | 1. Make the material icon falls back to basic theme correctly 2. Remove `TestAttributeReader`, the problem has been resolved. 3. Fix `toggleElem` bug and add tests
* Enable testifylint rules (#34075)TheFox0x72025-03-3178-423/+413
| | | | 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-303-10/+48
| | | | | | | | | | | 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-2916-48/+65
|
* Update action status badge layout (#34018)bytedream2025-03-282-44/+259
| | | | | | | | | | The current action status badge are looking different from most other badges renders, which is especially noticeable when using them along with other badges. This PR updates the action badges to match the commonly used badges from other providers. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Decouple Batch from git.Repository to simplify usage without requiring the ↵Lunny Xiao2025-03-274-24/+13
| | | | | creation of a Repository struct. (#34001) No logic change
* Fix the issue with error message logging for the `check-attr` command on ↵charles2025-03-271-1/+2
| | | | | | | | | | Windows OS. (#34035) Close #34022 , #33550 This error message always appears when using the `check-attr` command, even though it works correctly. The issue occurs when the stdin writer is closed, so I added a special case to handle and check the error message when the exit code is 1.
* Try to fix check-attr bug (#34029)wxiaoguang2025-03-271-1/+1
|