summaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* Performance improvements for pull request list page (#29900) (#29972)Lunny Xiao2024-03-225-19/+45
| | | | | | | | | 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
* Fix template error when comment review doesn't exist (#29888) (#29889)wxiaoguang2024-03-192-0/+17
| | | Backport #29888
* Fix user id column case (#29863) (#29867)Giteabot2024-03-171-2/+2
| | | | | | | Backport #29863 by @lng2020 Sometimes the column name is case-sensitive and it may cause 500. Co-authored-by: Nanguan Lin <nanguanlin6@gmail.com>
* Fix codeowner detected diff base branch to mergebase (#29783) (#29807)Lunny Xiao2024-03-172-83/+7
| | | | | | | | | | | | | | | 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>
* Make runs-on support variable expression (#29468) (#29782)sillyguodong2024-03-142-0/+72
| | | | | | | | | backport #29468 Close issue: https://gitea.com/gitea/act_runner/issues/445 Follow: https://gitea.com/gitea/act/pulls/91 Move `getSecretsOfTask` and `getVariablesOfTask` under models because of circular dependency issues.
* Fix bug hidden on CI and make ci failed if tests failure (#29254) (#29662)Lunny Xiao2024-03-096-11/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #29254 The tests on migration tests failed but CI reports successfully https://github.com/go-gitea/gitea/actions/runs/7364373807/job/20044685969#step:8:141 This PR will fix the bug on migrations and also the CI hidden behaviour. The reason is on the Makefile `GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags='$(TEST_TAGS)' $(MIGRATE_TEST_PACKAGES)` will return the error exit code. But `for pkg in $(shell $(GO) list code.gitea.io/gitea/models/migrations/...); do \ GITEA_ROOT="$(CURDIR)" GITEA_CONF=tests/mysql.ini $(GO) test $(GOTESTFLAGS) -tags '$(TEST_TAGS)' $$pkg; \ done` will not work. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Avoid issue info panic (#29625) (#29632)Giteabot2024-03-061-3/+7
| | | | | | | Backport #29625 by wxiaoguang Fix #29624 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add missing database transaction for new issue (#29490) (#29607)Lunny Xiao2024-03-051-2/+2
| | | | | | When creating an issue, inserting issue, assign users and set project should be in the same transaction. Backport #29490
* Only use supported sort order for "explore/users" page (#29430) (#29443)wxiaoguang2024-03-031-0/+3
| | | | | | | | | | | | | | 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 relative/absolute URL usages (#29531) (#29547)Giteabot2024-03-021-3/+13
| | | | | | | | 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-022-6/+21
| | | | | | | | | | 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>
* Users with `read` permission of pull requests can be assigned too (#27263) ↵Giteabot2024-02-242-3/+5
| | | | | | | | | | (#29372) Backport #27263 by @lunny This PR will also keep the consistent between list assigned users and check assigned users. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix gitea-action user avatar broken on edited menu (#29190) (#29307)yp053272024-02-221-1/+5
| | | | | Backport #29190 Fix #29178
* Workaround to clean up old reviews on creating a new one (#28554) (#29264)65432024-02-192-9/+39
| | | | | | | | close #28542 backport #28554 --- *Sponsored by Kithara Software GmbH*
* Fix bug when the linked account was disactived and list the linked accounts ↵Lunny Xiao2024-02-191-3/+7
| | | | | | | | | (#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
* Use ghost user if user was not found (#29161) (#29169)KN4CK3R2024-02-142-0/+12
| | | Backport #29161
* Dont load Review if Comment is CommentTypeReviewRequest (#28551) (#29160)65432024-02-133-1/+12
| | | | | | Backport #28551 RequestReview get deleted on review. So we don't have to try to load them on comments.
* Revert "Speed up loading the dashboard on mysql/mariadb (#28546)" (#29006) ↵Giteabot2024-02-011-6/+3
| | | | | | | | | | (#29007) Backport #29006 by @lunny This reverts commit fa8c3beb26acfcc7e732038c947225857ebcbf31. #28546 Because it seems performance become worse. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Don't remove all mirror repository's releases when mirroring (#28817) (#28939)Giteabot2024-01-311-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #28817 by @lunny Fix #22066 # Purpose This PR fix the releases will be deleted when mirror repository sync the tags. # The problem In the previous implementation of #19125. All releases record in databases of one mirror repository will be deleted before sync. Ref: https://github.com/go-gitea/gitea/pull/19125/files#diff-2aa04998a791c30e5a02b49a97c07fcd93d50e8b31640ce2ddb1afeebf605d02R481 # The Pros This PR introduced a new method which will load all releases from databases and all tags on git data into memory. And detect which tags needs to be inserted, which tags need to be updated or deleted. Only tags releases(IsTag=true) which are not included in git data will be deleted, only tags which sha1 changed will be updated. So it will not delete any real releases include drafts. # The Cons The drawback is the memory usage will be higher than before if there are many tags on this repository. This PR defined a special release struct to reduce columns loaded from database to memory. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix reverting a merge commit failing (#28794) (#28825)Mihir Joshi2024-01-213-1/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport https://github.com/go-gitea/gitea/pull/28794 Fixes #22236 --- Error occurring currently while trying to revert commit using read-tree -m approach: > 2022/12/26 16:04:43 ...rvices/pull/patch.go:240:AttemptThreeWayMerge() [E] [63a9c61a] Unable to run read-tree -m! Error: exit status 128 - fatal: this operation must be run in a work tree > - fatal: this operation must be run in a work tree We need to clone a non-bare repository for `git read-tree -m` to work. https://github.com/go-gitea/gitea/commit/bb371aee6ecf5e570cdf7b5f7f0d6f47a607a325 adds support to create a non-bare cloned temporary upload repository. After cloning a non-bare temporary upload repository, we [set default index](https://github.com/go-gitea/gitea/blob/main/services/repository/files/cherry_pick.go#L37) (`git read-tree HEAD`). This operation ends up resetting the git index file (see investigation details below), due to which, we need to call `git update-index --refresh` afterward. Here's the diff of the index file before and after we execute SetDefaultIndex: https://www.diffchecker.com/hyOP3eJy/ Notice the **ctime**, **mtime** are set to 0 after SetDefaultIndex. You can reproduce the same behavior using these steps: ```bash $ git clone https://try.gitea.io/me-heer/test.git -s -b main $ cd test $ git read-tree HEAD $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 error: Entry '1' not uptodate. Cannot merge. ``` After which, we can fix like this: ```bash $ git update-index --refresh $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 ```
* Rework markup link rendering (#26745) (#28803)KN4CK3R2024-01-162-5/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-4/+40
| | | | | | Backport #28337 by @yp05327 Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix `GetCommitStatuses` (#28787) (#28804)KN4CK3R2024-01-152-36/+46
| | | | | Backport #28787 Replaces #28802
* Fix when private user following user, private user will not be counted in ↵Giteabot2024-01-151-0/+2
| | | | | | | | | | | | | | | | | | | | | | | his own view (#28037) (#28792) Backport #28037 by @yp05327 Doer: asdasasdasasdasasdasasdasasdasasdasasdas (private user) Followed: TestUser (public user) Before: (From doer's view) ![image](https://github.com/go-gitea/gitea/assets/18380374/9ba16b3b-068c-43c5-a3dd-e3343b5b32f2) (From followed user's view, can see doer) ![image](https://github.com/go-gitea/gitea/assets/18380374/dfd1b564-d689-4393-b3d3-1e6bf52c94ba) After: (From doer's view) ![image](https://github.com/go-gitea/gitea/assets/18380374/1c85c1d1-c9f7-40c8-948c-145f7cae9a04) Co-authored-by: yp05327 <576951401@qq.com>
* Speed up loading the dashboard on mysql/mariadb (#28546) (#28784)Giteabot2024-01-151-3/+6
| | | | | | | Backport #28546 by @lunny Fixes #28155 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix schedule tasks bugs (#28691) (#28780)Lunny Xiao2024-01-146-34/+35
| | | | | | | | | | | | | | 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.
* Upgrade xorm to new version which supported update join for all supported ↵Giteabot2023-12-311-8/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | databases (#28590) (#28668) Backport #28590 by @lunny Fix https://github.com/go-gitea/gitea/pull/28547#issuecomment-1867740842 Since https://gitea.com/xorm/xorm/pulls/2383 merged, xorm now supports UPDATE JOIN. To keep consistent from different databases, xorm use `engine.Join().Update`, but the actural generated SQL are different between different databases. For MySQL, it's `UPDATE talbe1 JOIN table2 ON join_conditions SET xxx Where xxx`. For MSSQL, it's `UPDATE table1 SET xxx FROM TABLE1, TABLE2 WHERE join_conditions`. For SQLITE per https://www.sqlite.org/lang_update.html, sqlite support `UPDATE table1 SET xxx FROM table2 WHERE join conditions` from 3.33.0(2020-8-14). POSTGRES is the same as SQLITE. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Avoid cycle-redirecting user/login page (#28636) (#28658)wxiaoguang2023-12-302-6/+0
| | | | | Backport #28636 Fix #28231, and remove some unused code.
* Revert "improve possible performance bottleneck (#28547)" (#28593) (#28608)Giteabot2023-12-251-3/+8
| | | | | | | | | | | | Backport #28593 by @lunny This reverts commit b35d3fddfac389a7be401a63b4e1283dd74af681. This is totally wrong. I think `Update join` hasn't been supported well by xorm. I just revert the PR and will try to send another one. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* improve possible performance bottleneck (#28547) (#28578)Giteabot2023-12-211-8/+3
| | | | | | | Backport #28547 by @lunny Replace #28500 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix inperformant query on retrifing review from database. (#28552) (#28562)Giteabot2023-12-201-8/+10
| | | | | | | | | | | Backport #28552 by @6543 can we please PLEAS PLEASE only use raw SQL statements if it is relay needed!!! source is https://github.com/go-gitea/gitea/pull/28544 (before refactoring) Co-authored-by: 6543 <m.huber@kithara.com>
* Only check online runner when detecting matching runners in workflows ↵Giteabot2023-12-191-2/+15
| | | | | | | | | | | | | | | | | (#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>
* Refactor SSH clone URL generation code (#28421) (#28480)Giteabot2023-12-152-13/+42
| | | | | | | Backport #28421 by wxiaoguang Refactor the code and add tests, keep the old logic. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Retry SSH key verification with additional CRLF if it failed (#28392) (#28464)Giteabot2023-12-141-4/+9
| | | | | | | | | | | Backport #28392 by @nekrondev Windows-based shells will add a CRLF when piping the token into ssh-keygen command resulting in verification error. This resolves #21527. Co-authored-by: nekrondev <heiko@noordsee.de> Co-authored-by: Heiko Besemann <heiko.besemann@qbeyond.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Also sync DB branches on push if necessary (#28361) (#28403)Lunny Xiao2023-12-116-24/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* enable system users search via the API (#28013) (#28018)Giteabot2023-12-081-0/+1
| | | | | | | | | | | | Backport #28013 by @earl-warren Refs: https://codeberg.org/forgejo/forgejo/issues/1403 (cherry picked from commit dd4d17c159eaf8b642aa9e6105b0532e25972bb7) --------- Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* handle repository.size column being NULL in migration v263 (#28336) (#28363)Giteabot2023-12-051-1/+6
| | | | Co-authored-by: Nate Levesque <nate@thenaterhood.com>
* Increase "version" when update the setting value to a same value as before ↵Giteabot2023-11-282-1/+13
| | | | | | | | | | (#28243) (#28244) Backport #28243 Setting the same value should not trigger DuplicateKey error, and the "version" should be increased Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix comment permissions (#28213) (#28216)Lunny Xiao2023-11-2510-61/+96
| | | | | | | backport #28213 This PR will fix some missed checks for private repositories' data on web routes and API routes.
* Fix no ActionTaskOutput table waring (#28149) (#28152)Giteabot2023-11-211-0/+4
| | | | | | | | | | | | | | | | | | | Backport #28149 by @yp05327 Reproduce: - Create a new Gitea instance - Register a runner - Create a repo and add a workflow - Check the log, you will see warnings: ![image](https://github.com/go-gitea/gitea/assets/18380374/5f1278e0-114b-48bc-8113-8ba1404d9975) It comes from: ![image](https://github.com/go-gitea/gitea/assets/18380374/c2807831-e137-4229-9536-87f6114c8a5b) The reason is that we forgot registering `ActionTaskOutput` model. So `action_table_output` table will be missing in your db. Co-authored-by: yp05327 <576951401@qq.com>
* Fix system config cache expiration timing (#28072) (#28090)Giteabot2023-11-161-8/+10
| | | | | | | | | | Backport #28072 To avoid unnecessary database access, the `cacheTime` should always be set if the revision has been checked. Fix #28057 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Restricted users only see repos in orgs which their team was assigned to ↵Giteabot2023-11-141-5/+5
| | | | | | | | | | | (#28025) (#28051) Backport #28025 by @6543 --- *Sponsored by Kithara Software GmbH* Co-authored-by: 6543 <m.huber@kithara.com>
* enable system users for comment.LoadPoster (#28014) (#28032)Giteabot2023-11-141-1/+1
| | | | | | | | | | | | | | | | Backport #28014 by @earl-warren System users (Ghost, ActionsUser, etc) have a negative id and may be the author of a comment, either because it was created by a now deleted user or via an action using a transient token. The GetPossibleUserByID function has special cases related to system users and will not fail if given a negative id. Refs: https://codeberg.org/forgejo/forgejo/issues/1425 (cherry picked from commit 6a2d2fa24390116d31ae2507c0a93d423f690b7b) Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com>
* Fix wrong xorm Delete usage(backport for 1.21) (#28002)Nanguan Lin2023-11-121-1/+1
| | | | | manually backport for https://github.com/go-gitea/gitea/pull/27995 The conflict is `ctx` and `db.Defaultctx`.
* Fix 500 when deleting a dismissed review (#27903) (#27910)Giteabot2023-11-052-0/+40
| | | | | | | | Backport #27903 by @lng2020 Fix #27767 Add a test to ensure its behavior Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* Remove action runners on user deletion (#27902) (#27908)Giteabot2023-11-051-0/+24
| | | | | | | | | | | | | Backport #27902 by @earl-warren - On user deletion, delete action runners that the user has created. - Add a database consistency check to remove action runners that have nonexistent belonging owner. - Resolves https://codeberg.org/forgejo/forgejo/issues/1720 (cherry picked from commit 009ca7223dab054f7f760b7ccae69e745eebfabb) Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Delete repos of org when purge delete user (#27273) (#27728)65432023-11-011-2/+2
| | | | | | | | | Fixes https://codeberg.org/forgejo/forgejo/issues/1514 Backports #27273 --------- Co-authored-by: JakobDev <jakobdev@gmx.de>
* Upgrade xorm to 1.3.4 (#27807) (#27813)Giteabot2023-10-271-1/+1
| | | | | | | | | | | Backport #27807 by @lng2020 Noticeable change: Remove the `OrderBy("1") ` [patch](https://github.com/go-gitea/gitea/pull/27673#issuecomment-1768570142) for mssql since xorm has [fixed it](https://gitea.com/xorm/xorm/commit/0f085408afd85707635eadb2294ab52be04f3c0f). Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* Upgrade xorm (#27673) (#27691)Giteabot2023-10-192-2/+10
| | | | | | | Backport #27673 by @lng2020 Related to https://gitea.com/xorm/xorm/pulls/2341 Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* Respect SSH.KeygenPath option when calculating ssh key fingerprints (#27536) ↵Giteabot2023-10-101-1/+1
| | | | | | | | | (#27551) Backport #27536 by @picsel2 Fixes #27535 Co-authored-by: Sebastian Grabowski <sebastian@grabel.de>