aboutsummaryrefslogtreecommitdiffstats
path: root/models
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade xorm (#27673)Nanguan Lin2023-10-192-2/+10
| | | Related to https://gitea.com/xorm/xorm/pulls/2341
* Add unit tests for action runner token (#27670)Nanguan Lin2023-10-193-0/+93
| | | In case the behavior of the register token changes.
* Fix typo "GetLatestRunnerToken" (#27680)Jason Song2023-10-181-2/+2
|
* Replace more db.DefaultContext (#27628)Lunny Xiao2023-10-1510-29/+33
| | | Target #27065
* Final round of `db.DefaultContext` refactor (#27587)JakobDev2023-10-1415-104/+110
| | | Last part of #27065
* Enhanced auth token / remember me (#27606)KN4CK3R2023-10-147-0/+83
| | | | | | | | | | | | | | | | | Closes #27455 > The mechanism responsible for long-term authentication (the 'remember me' cookie) uses a weak construction technique. It will hash the user's hashed password and the rands value; it will then call the secure cookie code, which will encrypt the user's name with the computed hash. If one were able to dump the database, they could extract those two values to rebuild that cookie and impersonate a user. That vulnerability exists from the date the dump was obtained until a user changed their password. > > To fix this security issue, the cookie could be created and verified using a different technique such as the one explained at https://paragonie.com/blog/2015/04/secure-authentication-php-with-long-term-persistence#secure-remember-me-cookies. The PR removes the now obsolete setting `COOKIE_USERNAME`.
* Replace assert.Fail with assert.FailNow (#27578)Nanguan Lin2023-10-112-4/+3
| | | | | | | | | assert.Fail() will continue to execute the code while assert.FailNow() not. I thought those uses of assert.Fail() should exit immediately. PS: perhaps it's a good idea to use [require](https://pkg.go.dev/github.com/stretchr/testify/require) somewhere because the assert package's default behavior does not exit when an error occurs, which makes it difficult to find the root error reason.
* Penultimate round of `db.DefaultContext` refactor (#27414)JakobDev2023-10-1132-180/+180
| | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Make actions default enabled for newly created repository if global ↵Lunny Xiao2023-10-102-1/+2
| | | | configuraion enabled (#27482)
* Respect SSH.KeygenPath option when calculating ssh key fingerprints (#27536)Sebastian Grabowski2023-10-101-1/+1
| | | Fixes #27535
* Restore warning commit status (#27504)silverwind2023-10-082-3/+4
| | | | | | | | | | | | | Partial revert of https://github.com/go-gitea/gitea/pull/25839. This commit status is used by a number of external integrations, so I think we should not remove it (See https://github.com/go-gitea/gitea/pull/25839#issuecomment-1729002077). This is a rare case where an existing migration needed to be alterted to avoid data loss. --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: Giteabot <teabot@gitea.io>
* Pre-register OAuth application for tea (#27509)M Hickford2023-10-081-0/+5
| | | | | | It remains to implement OAuth login in tea https://gitea.com/gitea/tea/issues/598 Fixes #27510
* Rename the default themes to gitea-light, gitea-dark, gitea-auto (#27419)silverwind2023-10-062-0/+35
| | | | | | | | | | | | | | | | | | | | | | | | | Part of https://github.com/go-gitea/gitea/issues/27097: - `gitea` theme is renamed to `gitea-light` - `arc-green` theme is renamed to `gitea-dark` - `auto` theme is renamed to `gitea-auto` I put both themes in separate CSS files, removing all colors from the base CSS. Existing users will be migrated to the new theme names. The dark theme recolor will follow in a separate PR. ## :warning: BREAKING :warning: 1. If there are existing custom themes with the names `gitea-light` or `gitea-dark`, rename them before this upgrade and update the `theme` column in the `user` table for each affected user. 2. The theme in `<html>` has moved from `class="theme-name"` to `data-theme="name"`, existing customizations that depend on should be updated. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Don't let API add 2 exclusive labels from same scope (#27433)JakobDev2023-10-052-0/+39
| | | Fixes #27380
* Refactor system setting (#27000)wxiaoguang2023-10-059-384/+174
| | | | | | | | | This PR reduces the complexity of the system setting system. It only needs one line to introduce a new option, and the option can be used anywhere out-of-box. It is still high-performant (and more performant) because the config values are cached in the config system.
* Add Index to `action.user_id` (#27403)JakobDev2023-10-033-1/+19
| | | | | | Another Column that needs a Index. Found at https://codeberg.org/forgejo/discussions/issues/61#issuecomment-1258744. Co-authored-by: Giteabot <teabot@gitea.io>
* Even more `db.DefaultContext` refactor (#27352)JakobDev2023-10-0324-135/+135
| | | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Don't use subselect in `DeleteIssuesByRepoID` (#27332)JakobDev2023-10-031-64/+79
| | | | | Part of https://codeberg.org/forgejo/discussions/issues/61 This is workaround for a bug in MariaDB
* fix: comment typo (#27388)246012023-10-021-1/+1
| | | fix a typo in the comment
* Test more templates for if they contain an error (#27367)Lunny Xiao2023-10-021-0/+20
|
* simplify issue deletion query (#27312)Earl Warren2023-10-021-11/+0
| | | | | | | | | | - There's no need for `In` to be used, as it's a single parameter that's being passed. Refs: https://codeberg.org/forgejo/forgejo/pulls/1521 (cherry picked from commit 4a4955f43ae7fc50cfe3b48409a0a10c82625a19) Co-authored-by: Gusted <postmaster@gusted.xyz>
* Allow get release download files and lfs files with oauth2 token format (#26430)Lunny Xiao2023-10-012-0/+27
| | | | Fix #26165 Fix #25257
* rename TotalTimes() to TotalTimesForEachUser() (#27261)65432023-09-292-7/+7
| | | | | | | make function name more descriptive as it would otherwise imply it could be used for e.g. #26672 too ... --- *Sponsored by Kithara Software GmbH*
* More `db.DefaultContext` refactor (#27265)JakobDev2023-09-2921-231/+230
| | | | | | | Part of #27065 This PR touches functions used in templates. As templates are not static typed, errors are harder to find, but I hope I catch it all. I think some tests from other persons do not hurt.
* Add logs for data broken of comment review (#27326)Lunny Xiao2023-09-291-27/+9
| | | Fix #27306
* Fix the approval count of PR when there is no protection branch rule (#27272)Nanguan Lin2023-09-281-8/+17
| | | | | As title ![ksnip_20230926-115158](https://github.com/go-gitea/gitea/assets/70063547/a60be44a-06ad-421e-ba27-e4e0adfa5db7)
* Add Index to `comment.dependent_issue_id` (#27325)JakobDev2023-09-283-1/+19
| | | | | | This Column is missing index. It is used by [issue_service.deleteIssue](https://github.com/go-gitea/gitea/blob/7ea2a910cebaf51cfd13c0941029c404e408ae54/services/issue/issue.go#L300). Co-authored-by: Giteabot <teabot@gitea.io>
* make writing main test easier (#27270)Lunny Xiao2023-09-2819-86/+47
| | | | | | | | | This PR removed `unittest.MainTest` the second parameter `TestOptions.GiteaRoot`. Now it detects the root directory by current working directory. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Redefine the meaning of column is_active to make Actions Registration Token ↵Lunny Xiao2023-09-271-8/+18
| | | | | | | | | | | | | | | generation easier (#27143) Partially Fix #25041 This PR redefined the meaning of column `is_active` in table `action_runner_token`. Before this PR, `is_active` means whether it has been used by any runner. If it's true, other runner cannot use it to register again. In this PR, `is_active` means whether it's validated to be used to register runner. And if it's true, then it can be used to register runners until it become false. When creating a new `is_active` register token, any previous tokens will be set `is_active` to false.
* Fix yaml test (#27297)Lunny Xiao2023-09-262-3/+6
|
* Fix more yaml lint errors (#27284)Lunny Xiao2023-09-2614-25/+21
| | | Fix #27268
* Another round of `db.DefaultContext` refactor (#27103)JakobDev2023-09-2523-105/+114
| | | | | | | Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Quote table `release` in sql queries (#27205)KN4CK3R2023-09-231-5/+5
| | | | | | | | | | Fixes #27174 `release` is a reserved keyword in MySql. I can't reproduce the issue on my setup and we have a test for that code but it seems there can be setups where it fails. https://github.com/go-gitea/gitea/blob/a101dbaa7952e359843c6d8303ca24a0e63c865c/tests/integration/repo_activity_test.go#L45-L46
* Updates to the API for archived repos (#27149)JakobDev2023-09-212-2/+28
|
* Fix review request number and add more tests (#27104)Nanguan Lin2023-09-218-4/+81
| | | | | | | | | | | | | | | | | | | | | fix #27019 ## testfixture yml 1. add issue20(a pr issue) in repo 23, org 17 2. add user15 to team 9 3. add four reviews about issue20 ## test case add two tests that are described with code comments the code before pr #26784 failed the first test <img width="479" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/1d9b5787-11b4-4c4d-931f-6a9869547f35"> current code failed the second test(as mentioned in #27019) <img width="484" alt="image" src="https://github.com/go-gitea/gitea/assets/70063547/05608055-7587-43d1-bae1-92c688270819"> Any advice is appreciated. --------- Co-authored-by: CaiCandong <50507092+CaiCandong@users.noreply.github.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Add index to `issue_user.issue_id` (#27154)JakobDev2023-09-213-1/+19
| | | | | | | | | | | | This fixes a performance bottleneck. It was discovered by Codeberg. Every where query on that table (which has grown big over time) uses this column, but there is no index on it. See this part of the log which was posted on Matrix: ``` 2023/09/10 00:52:01 ...rs/web/repo/issue.go:1446:ViewIssue() [W] [Slow SQL Query] UPDATE `issue_user` SET is_read=? WHERE uid=? AND issue_id=? [true x y] - 51.395434887s 2023/09/10 00:52:01 ...rs/web/repo/issue.go:1447:ViewIssue() [E] ReadBy: Error 1205 (HY000): Lock wait timeout exceeded; try restarting transaction 2023/09/10 00:52:01 ...eb/routing/logger.go:102:func1() [I] router: completed GET /Codeberg/Community/issues/1201 for [::ffff:xxx]:0, 500 Internal Server Error in 52384.2ms @ repo/issue.go:1256(repo.ViewIssue) ```
* Fix wrong xorm get usage on migration (#27111)Lunny Xiao2023-09-181-19/+14
| | | | | | | | | | | | | | | | | | Fix the bug on try.gitea.io ```log 2023/09/18 01:48:41 ...ations/migrations.go:635:Migrate() [I] Migration[276]: Add RemoteAddress to mirrors 2023/09/18 01:48:41 routers/common/db.go:34:InitDBEngine() [E] ORM engine initialization attempt #7/10 failed. Error: migrate: migration[276]: Add RemoteAddress to mirrors failed: exit status 128 - fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). - fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set). ``` Caused by #26952 --------- Co-authored-by: Jason Song <i@wolfogre.com>
* Search branches (#27055)Lunny Xiao2023-09-171-0/+4
| | | | | | | | | Resolve #25233 <img width="1315" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/3ba59b58-471a-4e1b-985c-87edac2268c0"> <img width="1297" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/b6caa12f-323b-4f70-9c44-ef91cb71a26c">
* Fix wrong migration for email address (#27106)Lunny Xiao2023-09-171-18/+70
| | | | | On Iterate, `sess` should not be used in the closure function body. Caused by #26952
* Add `RemoteAddress` to mirrors (#26952)KN4CK3R2023-09-165-11/+143
| | | | | This PR adds a new field `RemoteAddress` to both mirror types which contains the sanitized remote address for easier (database) access to that information. Will be used in the audit PR if merged.
* Next round of `db.DefaultContext` refactor (#27089)JakobDev2023-09-1627-273/+236
| | | Part of #27065
* Use db.WithTx for AddTeamMember to avoid ctx abuse (#27095)wxiaoguang2023-09-161-48/+48
| | | | Compare with ignoring spaces: https://github.com/go-gitea/gitea/pull/27095/files?diff=split&w=1
* More refactoring of `db.DefaultContext` (#27083)JakobDev2023-09-1517-149/+155
| | | Next step of #27065
* Reduce usage of `db.DefaultContext` (#27073)JakobDev2023-09-1419-177/+181
| | | | | | | | | | | | | | Part of #27065 This reduces the usage of `db.DefaultContext`. I think I've got enough files for the first PR. When this is merged, I will continue working on this. Considering how many files this PR affect, I hope it won't take to long to merge, so I don't end up in the merge conflict hell. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Remove the useless function `GetUserIssueStats` and move relevant tests to ↵Nanguan Lin2023-09-142-314/+0
| | | | | | | | | | | | | | | | | | | `indexer_test.go` (#27067) Since the issue indexer has been refactored, the issue overview webpage is built by the `buildIssueOverview` function and underlying `indexer.Search` function and `GetIssueStats` instead of `GetUserIssueStats`. So the function is no longer used. I moved the relevant tests to `indexer_test.go` and since the search option changed from `IssueOptions` to `SearchOptions`, most of the tests are useless now. We need more tests about the db indexer because those tests are highly connected with the issue overview webpage and now this page has several bugs. Any advice about those test cases is appreciated. --------- Co-authored-by: CaiCandong <50507092+CaiCandong@users.noreply.github.com>
* Display all user types and org types on admin management UI (#27050)Lunny Xiao2023-09-141-1/+15
| | | | | | | | | | Follow #24026 <img width="1049" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/d3fc5159-b5e7-411a-b6f8-4a111a027e6b"> --------- Co-authored-by: delvh <dev.lh@web.de>
* Replace 'userxx' with 'orgxx' in all test files when the user type is org ↵Nanguan Lin2023-09-1419-94/+94
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#27052) Currently 'userxx' and 'orgxx' are both used as username in test files when the user type is org, which is confusing. This PR replaces all 'userxx' with 'orgxx' when the user type is org(`user.type==1`). Some non-trivial changes 1. Rename `user3` dir to `org3` in `tests/git-repositories-meta` 2. Change `end` in `issue reference` because 'org3' is one char shorter than 'user3' ![ksnip_20230913-112819](https://github.com/go-gitea/gitea/assets/70063547/442988c5-4cf4-49b8-aa01-4dd6bf0ca954) 3. Change the search result number of `user/repo2` because `user3/repo21` can't be searched now ![ksnip_20230913-112931](https://github.com/go-gitea/gitea/assets/70063547/d9ebeba4-479f-4110-9a85-825efbc981fd) 4. Change the first org name getting from API because the result is ordered by alphabet asc and now `org 17` is before `org25` ![JW8U7NIO(J$H _YCRB36H)T](https://github.com/go-gitea/gitea/assets/70063547/f55a685c-cf24-40e5-a87f-3a2327319548) ![)KFD411O4I8RB5ZOH7E0 Z3](https://github.com/go-gitea/gitea/assets/70063547/a0dc3299-249c-46f6-91cb-d15d4ee88dd5) Other modifications are just find all and replace all. Unit tests with SQLite are all passed. --------- Co-authored-by: caicandong <1290147055@qq.com>
* Update status and code index after changing the default branch (#27018)Nanguan Lin2023-09-131-1/+3
| | | | | | | | | | | Fix #26723 Add `ChangeDefaultBranch` to the `notifier` interface and implement it in `indexerNotifier`. So when changing the default branch, `indexerNotifier` sends a message to the `indexer queue` to update the index. --------- Co-authored-by: techknowlogick <matti@mdranta.net>
* resolve issue with sort icons on admin/users and admin/runners (#24360)jladbrook2023-09-121-0/+6
| | | | Fixes #24327 to avoid the sort icon changing the table header over multiple lines and adds missing sort icons on the runners page.
* Fix context cache bug & enable context cache for dashabord commits' authors ↵Lunny Xiao2023-09-114-38/+40
| | | | | | | | | | | (#26991) Unfortunately, when a system setting hasn't been stored in the database, it cannot be cached. Meanwhile, this PR also uses context cache for push email avatar display which should avoid to read user table via email address again and again. According to my local test, this should reduce dashboard elapsed time from 150ms -> 80ms .