aboutsummaryrefslogtreecommitdiffstats
path: root/modules
Commit message (Collapse)AuthorAgeFilesLines
* Upgrade to golangci-lint@v1.55.0 (#27756)silverwind2023-10-247-96/+91
| | | https://github.com/golangci/golangci-lint/releases/tag/v1.55.0
* Fix label render containing invalid HTML (#27752)Earl Warren2023-10-231-1/+1
| | | | | | | | | - The label HTML contained a quote that wasn't being closed. Refs: https://codeberg.org/forgejo/forgejo/pulls/1651 (cherry picked from commit e2bc2c9a1fff482c49dbeb3a51e4e1c698bf506c) Co-authored-by: Gusted <postmaster@gusted.xyz>
* refactor: make db iterate context aware (#27710)65432023-10-211-15/+20
| | | | | | | | | the iteration will run until finished atm. this changes it by checking if if the context got canceled before each run of a loop sequence is executed [View this pull with now whitespace](https://github.com/go-gitea/gitea/pull/27710/files?diff=unified&w=1)
* Clean some functions about project issue (#27705)Nanguan Lin2023-10-201-1/+0
| | | | | | | | | 1. remove unused function `MoveIssueAcrossProjectBoards` 2. extract the project board condition into a function 3. use db.NoCondition instead of -1. (BTW, the usage of db.NoCondition is too confusing. Is there any way to avoid that?) 4. remove the unnecessary comment since the ctx refactor is completed. 5. Change `b.ID != 0` to `b.ID > 0`. It's more intuitive but I think they're the same since board ID can't be negative.
* Add doctor dbconsistency fix to delete repos with no owner (#27290)65432023-10-191-0/+70
| | | | to address #27273 replace #24873
* Support allowed hosts for webhook to work with proxy (#27655)Jason Song2023-10-181-3/+15
| | | | | | | | | | | | | | | | | When `webhook.PROXY_URL` has been set, the old code will check if the proxy host is in `ALLOWED_HOST_LIST` or reject requests through the proxy. It requires users to add the proxy host to `ALLOWED_HOST_LIST`. However, it actually allows all requests to any port on the host, when the proxy host is probably an internal address. But things may be even worse. `ALLOWED_HOST_LIST` doesn't really work when requests are sent to the allowed proxy, and the proxy could forward them to any hosts. This PR fixes it by: - If the proxy has been set, always allow connectioins to the host and port. - Check `ALLOWED_HOST_LIST` before forwarding.
* Improve retrying index issues (#27554)Jason Song2023-10-152-30/+41
| | | Fix #27540
* Replace more db.DefaultContext (#27628)Lunny Xiao2023-10-154-18/+24
| | | Target #27065
* Final round of `db.DefaultContext` refactor (#27587)JakobDev2023-10-142-7/+7
| | | Last part of #27065
* Enhanced auth token / remember me (#27606)KN4CK3R2023-10-142-46/+0
| | | | | | | | | | | | | | | | | 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-115-18/+11
| | | | | | | | | 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-118-12/+14
| | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Increase queue length (#27555)Jason Song2023-10-102-2/+2
|
* Fix `environment-to-ini` inherited key bug (#27543)wxiaoguang2023-10-102-1/+28
| | | | | | | Fix #27541 The INI package has a quirk: by default, the keys are inherited. When maintaining the keys, the newly added sub key should not be affected by the parent key.
* Restore warning commit status (#27504)silverwind2023-10-081-3/+11
| | | | | | | | | | | | | 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-1/+1
| | | | | | It remains to implement OAuth login in tea https://gitea.com/gitea/tea/issues/598 Fixes #27510
* Improve feed icons and feed merge text color (#27498)silverwind2023-10-071-10/+14
| | | | | | | | | | | | | | 1. Improve various feed icons 2. Fix merge message color <img width="763" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/3f5bcb23-6d90-4c63-85f2-46bd7e1c96d6"> <img width="769" alt="image" src="https://github.com/go-gitea/gitea/assets/115237/466c37b4-e2f4-42bb-922d-b86596cdc6d0"> Fixes: https://github.com/go-gitea/gitea/issues/27495 Continues: https://github.com/go-gitea/gitea/pull/27356
* Rename the default themes to gitea-light, gitea-dark, gitea-auto (#27419)silverwind2023-10-062-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Remove redundant `len` check around loop (#27464)Eng Zer Jun2023-10-062-35/+25
| | | | | | | | | | | | | | | | | | | | This pull request is a minor code cleanup. From the Go specification (https://go.dev/ref/spec#For_range): > "1. For a nil slice, the number of iterations is 0." > "3. If the map is nil, the number of iterations is 0." `len` returns 0 if the slice or map is nil (https://pkg.go.dev/builtin#len). Therefore, checking `len(v) > 0` before a loop is unnecessary. --- At the time of writing this pull request, there wasn't a lint rule that catches these issues. The closest I could find is https://staticcheck.dev/docs/checks/#S103 Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
* Refactor system setting (#27000)wxiaoguang2023-10-054-8/+186
| | | | | | | | | 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.
* Even more `db.DefaultContext` refactor (#27352)JakobDev2023-10-035-12/+12
| | | | | | | | Part of #27065 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Add support for HEAD ref in /src/branch and /src/commit routes (#27384)Kirill Sorokin2023-10-031-0/+20
| | | | | | | | | Add support for HEAD in paths: ``` /src/branch/HEAD/README.md /src/commit/HEAD/README.md ``` Closes #26920
* Make Actions tasks/jobs timeouts configurable by the user (#27400)Francesco Antognazza2023-10-021-0/+8
| | | | | | | | | | | | | | | | | | | With this PR we added the possibility to configure the Actions timeouts values for killing tasks/jobs. Particularly this enhancement is closely related to the `act_runner` configuration reported below: ``` # The timeout for a job to be finished. # Please note that the Gitea instance also has a timeout (3h by default) for the job. # So the job could be stopped by the Gitea instance if it's timeout is shorter than this. timeout: 3h ``` --- Setting the corresponding key in the INI configuration file, it is possible to let jobs run for more than 3 hours. Signed-off-by: Francesco Antognazza <francesco.antognazza@gmail.com>
* Fix git 2.11 error when checking IsEmpty (again) (#27399)wxiaoguang2023-10-021-1/+1
| | | | | | Follow #27393 Sorry that I made a mistake in #27393. The `errbuf` is not empty when the err is `exit status 129`.
* Fix git 2.11 error when checking IsEmpty (#27393)wxiaoguang2023-10-021-1/+2
| | | Fix #27389
* More `db.DefaultContext` refactor (#27265)JakobDev2023-09-293-7/+7
| | | | | | | 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.
* Improvements of releases list and tags list (#25859)Zettat1232023-09-281-1/+4
| | | | | | | | | | | | | | | | | | Follow #23465 and #25624 This PR introduces the following improvements: - We do not need to call `GetTags` to get tags because tags have been loaded by `RepoAssignment` https://github.com/go-gitea/gitea/blob/ef90fdbd1d7e1f62ed5bf18757e00e97817eb602/modules/context/repo.go#L663-L668 - Similarly, the number of tags and releases also have been loaded by `RepoAssignment`, so the related code has been removed from the handlers. The query condition of `GetReleaseCountByRepoID` in `RepoAssignment` has been changed to include draft releases. https://github.com/go-gitea/gitea/blob/ef90fdbd1d7e1f62ed5bf18757e00e97817eb602/modules/context/repo.go#L538-L551 - `releasesOrTags` function has been removed. The code for rendering releases list and tags list moved to `Releases` and `TagList` respectively.
* doctor: delete action entries without existing user (#27292)65432023-09-281-0/+3
| | | | | just extend doctor with a usefully check :) Co-authored-by: techknowlogick <techknowlogick@gitea.com>
* fix orphan check for deleted branch (#27310)Earl Warren2023-09-281-3/+3
| | | | | | | | | | - Modify the deleted branch orphan check to check for the new table instead. - Regression from 6e19484f4d3bf372212f2da462110a1a8c10cbf2 - Resolves https://codeberg.org/forgejo/forgejo/issues/1522 (cherry picked from commit c1d888686fe445e4edecb9d835c5b3893b574b75) Co-authored-by: Gusted <postmaster@gusted.xyz>
* make writing main test easier (#27270)Lunny Xiao2023-09-286-23/+6
| | | | | | | | | 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>
* Document the queue item's marshaling behavior (#27271)wxiaoguang2023-09-261-0/+2
| | | Close #26843
* Another round of `db.DefaultContext` refactor (#27103)JakobDev2023-09-256-16/+17
| | | | | | | Part of #27065 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix PushEvent NullPointerException jenkinsci/github-plugin (#27203)Nabapadma-sarker2023-09-241-0/+1
| | | Fixes #27202
* Quote table `release` in sql queries (#27205)KN4CK3R2023-09-231-1/+1
| | | | | | | | | | 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
* Fix push mirror, wrong timestamp format (#27153)Daniel Kilimnik2023-09-231-8/+12
| | | | | | | | | | | | | | | | | I noticed, that the push mirrors endpoint, is the only endpoint which returns the times in long format rather than as time.Time(). I think the behavior should be consistent across the project. ---- ## ⚠️ BREAKING ⚠️ This PR changes the time format used in API responses for all push_mirror endpoints which return a push mirror. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Remove some dead code (#27196)wxiaoguang2023-09-222-4/+0
| | | Some code is not in use any more, remove them.
* Updates to the API for archived repos (#27149)JakobDev2023-09-211-0/+6
|
* Fix review request number and add more tests (#27104)Nanguan Lin2023-09-211-6/+21
| | | | | | | | | | | | | | | | | | | | | 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>
* Refactor lfs requests (#26783)Chongyi Zheng2023-09-186-135/+124
| | | | | | | | | | | | | | - Refactor lfs request code - The original code uses `performRequest` function to create the request, uses a callback to modify the request, and then send the request. - Now it's replaced with `createRequest` that only creates request and `performRequest` that only sends the request. - Reuse `createRequest` and `performRequest` in `http_client.go` and `transferadapter.go` --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Support `.git-blame-ignore-revs` file (#26395)KN4CK3R2023-09-1614-30/+184
| | | | | | | | | | | | | | | | | Closes #26329 This PR adds the ability to ignore revisions specified in the `.git-blame-ignore-revs` file in the root of the repository. ![grafik](https://github.com/go-gitea/gitea/assets/1666336/9e91be0c-6e9c-431c-bbe9-5f80154251c8) The banner is displayed in this case. I intentionally did not add a UI way to bypass the ignore file (same behaviour as Github) but you can add `?bypass-blame-ignore=true` to the url manually. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add `RemoteAddress` to mirrors (#26952)KN4CK3R2023-09-162-0/+14
| | | | | 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-165-11/+12
| | | Part of #27065
* Add tests for db indexer in indexer_test.go (#27087)Nanguan Lin2023-09-161-131/+324
| | | | | | | | | | | | | | | | | | | | As described in the title. Some points: 1. Why need those tests? Because `buildIssueOverview` is not well tested, there are several continuous bugs in the issue overview webpage. 2. Why in indexer_test.go? It's hard to put those tests in `./modules/indexer/issue/db/db_test.go` because those tests need 'real' data in db mocked by fixtures instead of random data in `./modules/indexer/issue/internal/tests`. When using 'real' data(`unittest.PrepareTestDatabase`), `InitIssueIndexer` and the package `init()` function of `indexer` are required to init indexer. 3. Why only db? The other three indexer engines are well tested by random data and it's okay to also test them with 'real' data in db mocked by fixtures. Any follow-up PR is welcome. 4. Those tests are really basic, any more complicated tests are welcome. 5. I think it's also necessary to add tests in `TestAPISearchIssues` in`api_test_issue.go` and `TestIssues` in `home_test.go`
* Actions are no longer experimental, so enable them by default (#27054)Lunny Xiao2023-09-151-1/+1
| | | | This PR makes the actions enabled by default, so people will find it easier to enable actions in repository setting.
* More refactoring of `db.DefaultContext` (#27083)JakobDev2023-09-156-16/+21
| | | Next step of #27065
* Reduce usage of `db.DefaultContext` (#27073)JakobDev2023-09-145-10/+13
| | | | | | | | | | | | | | 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-141-1/+82
| | | | | | | | | | | | | | | | | | | `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>
* Replace 'userxx' with 'orgxx' in all test files when the user type is org ↵Nanguan Lin2023-09-141-15/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#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>
* fix media description render for orgmode (#26895)Earl Warren2023-09-132-9/+34
| | | | | | | | | | | | | | | - In org mode you can specify an description for media via the following syntax `[[description][media link]]`. The description is then used as title or alt. - This patch fixes the rendering of the description by seperating the description and non-description cases and using `org.String()`. - Added unit tests. - Inspired by https://github.com/niklasfasching/go-org/blob/6eb20dbda93cb88c3503f7508dc78cbbc639378f/org/html_writer.go#L406-L427 - Resolves https://codeberg.org/Codeberg/Community/issues/848 (cherry picked from commit 8b8aab83113b34bade61964e2097ed497abc39e9) Co-authored-by: Gusted <postmaster@gusted.xyz>
* Update status and code index after changing the default branch (#27018)Nanguan Lin2023-09-131-1/+8
| | | | | | | | | | | 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>