aboutsummaryrefslogtreecommitdiffstats
path: root/modules
Commit message (Collapse)AuthorAgeFilesLines
* Refactor sha1 and time-limited code (#31023)wxiaoguang2024-05-204-87/+116
| | | | | | | Remove "EncodeSha1", it shouldn't be used as a general purpose hasher (just like we have removed "EncodeMD5" in #28622) Rewrite the "time-limited code" related code and write better tests, the old code doesn't seem quite right.
* Fix project column title overflow (#31011)wxiaoguang2024-05-201-4/+5
| | | | | | By the way: * Re-format the "color.go" to Golang code style * Remove unused `overflow-y: scroll;` from `.project-column` because there is `overflow: visible`
* Improve reverse proxy documents and clarify the AppURL guessing behavior ↵wxiaoguang2024-05-192-17/+26
| | | | | | | | | | | | (#31003) Fix #31002 1. Mention Make sure `Host` and `X-Fowarded-Proto` headers are correctly passed to Gitea 2. Clarify the basic requirements and move the "general configuration" to the top 3. Add a comment for the "container registry" 4. Use 1.21 behavior if the reverse proxy is not correctly configured Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Simplify mirror repository API logic (#30963)wxiaoguang2024-05-171-1/+1
| | | Fix #30921
* Supports forced use of S3 virtual-hosted style (#30969)dicarne2024-05-152-4/+18
| | | | | Add a configuration item to enable S3 virtual-hosted style (V2) to solve the problem caused by some S3 service providers not supporting path style (V1).
* Always load or generate oauth2 jwt secret (#30942)wxiaoguang2024-05-142-12/+33
| | | Fix #30923
* Support using label names when changing issue labels (#30943)Zettat1232024-05-131-2/+3
| | | | | | | | | | | | Resolve #30917 Make the APIs for adding labels and replacing labels support both label IDs and label names so the [`actions/labeler`](https://github.com/actions/labeler) action can work in Gitea. <img width="600px" src="https://github.com/go-gitea/gitea/assets/15528715/7835c771-f637-4c57-9ce5-e4fbf56fa0d3" />
* Refactor AppURL usage (#30885)wxiaoguang2024-05-073-9/+112
| | | | | | | | Fix #30883 Fix #29591 --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Move database operations of merging a pull request to post receive hook and ↵Lunny Xiao2024-05-072-0/+10
| | | | | | | | | | | | | | | | | | | | add a transaction (#30805) Merging PR may fail because of various problems. The pull request may have a dirty state because there is no transaction when merging a pull request. ref https://github.com/go-gitea/gitea/pull/25741#issuecomment-2074126393 This PR moves all database update operations to post-receive handler for merging a pull request and having a database transaction. That means if database operations fail, then the git merging will fail, the git client will get a fail result. There are already many tests for pull request merging, so we don't need to add a new one. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Make "sync branch" also sync object format and add tests (#30878)wxiaoguang2024-05-063-27/+41
|
* Make sure git version&feature are always prepared (#30877)wxiaoguang2024-05-0613-125/+94
| | | Otherwise there would be more similar issues like #29287
* Fix markdown URL parsing for commit ID (#30812)wxiaoguang2024-05-044-74/+115
|
* Improve grep search (#30843)wxiaoguang2024-05-034-7/+59
| | | | Reduce the context line number to 1, make "git grep" search respect the include/exclude patter, and fix #30785
* Fix no edit history after editing issue's title and content (#30814)yp053272024-05-031-1/+1
| | | | | Fix #30807 reuse functions in services
* Remove external API calls in `TestPassword` (#30716)silverwind2024-05-021-76/+23
| | | | | | | | | | | The test had a dependency on `https://api.pwnedpasswords.com` which caused many failures on CI recently: ``` --- FAIL: TestPassword (2.37s) pwn_test.go:41: Get "https://api.pwnedpasswords.com/range/e6b6a": context deadline exceeded (Client.Timeout exceeded while awaiting headers) FAIL coverage: 82.9% of statements ```
* Skip gzip for some well-known compressed file types (#30796)wxiaoguang2024-05-021-0/+8
| | | Co-authored-by: silverwind <me@silverwind.io>
* Fix markdown rendering when mentioning users (#30795)wxiaoguang2024-05-024-10/+14
|
* Fix bleve fuzziness (#30799)wxiaoguang2024-05-013-9/+15
| | | | Fix #30797 Fix #30317
* Add API endpoints for getting action jobs status (#26673)Chester2024-05-011-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sample of response, it is similar to Github actions ref https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository ``` json { "workflow_runs": [ { "id": 3, "name": "Explore-Gitea-Actions", "head_branch": "main", "head_sha": "6d8d29a9f7a01ded8f8aeb64341cb31ee1ab5f19", "run_number": 3, "event": "push", "display_title": "More job", "status": "success", "workflow_id": "demo2.yaml", "url": "/chester/test/actions/runs/3", "created_at": "2023-08-22T13:41:33-04:00", "updated_at": "2023-08-22T13:41:37-04:00", "run_started_at": "2023-08-22T13:41:33-04:00" }, { "id": 2, "name": "Explore-Gitea-Actions", "head_branch": "main", "head_sha": "6d8d29a9f7a01ded8f8aeb64341cb31ee1ab5f19", "run_number": 2, "event": "push", "display_title": "More job", "status": "success", "workflow_id": "demo.yaml", "url": "/chester/test/actions/runs/2", "created_at": "2023-08-22T13:41:30-04:00", "updated_at": "2023-08-22T13:41:33-04:00", "run_started_at": "2023-08-22T13:41:30-04:00" }, { "id": 1, "name": "Explore-Gitea-Actions", "head_branch": "main", "head_sha": "e5369ab054cae79899ba36e45ee82811a6e0acd5", "run_number": 1, "event": "push", "display_title": "Add job", "status": "failure", "workflow_id": "demo.yaml", "url": "/chester/test/actions/runs/1", "created_at": "2023-08-22T13:15:21-04:00", "updated_at": "2023-08-22T13:18:10-04:00", "run_started_at": "2023-08-22T13:15:21-04:00" } ], "total_count": 3 } ``` --------- Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: puni9869 <80308335+puni9869@users.noreply.github.com>
* Fix tautological conditions (#30735)silverwind2024-04-301-6/+0
| | | | | | | As discovered by https://github.com/go-gitea/gitea/pull/30729. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix issue label rendering in the issue popup (#30763)wxiaoguang2024-04-301-22/+17
|
* Resolve lint for unused parameter and unnecessary type arguments (#30750)Chongyi Zheng2024-04-2918-62/+45
| | | | | | | | | | Resolve all cases for `unused parameter` and `unnecessary type arguments` Related: #30729 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Add support for npm bundleDependencies (#30751)Micash2024-04-292-0/+3
|
* Replace deprecated `math/rand` functions (#30733)v1.23.0-devChongyi Zheng2024-04-271-11/+5
| | | | | | | | | | | | Suggested by logs in #30729 - Remove `math/rand.Seed` `rand.Seed is deprecated: As of Go 1.20 there is no reason to call Seed with a random value.` - Replace `math/rand.Read` `rand.Read is deprecated: For almost all use cases, [crypto/rand.Read] is more appropriate.` - Replace `math/rand` with `math/rand/v2`, which is available since Go 1.22
* Add some tests to clarify the "must-change-password" behavior (#30693)wxiaoguang2024-04-271-1/+3
| | | | | | | | | | Follow #30472: When a user is created by command line `./gitea admin user create`: Old behavior before #30472: the first user (admin or non-admin) doesn't need to change password. Revert to the old behavior before #30472
* Update misspell to 0.5.1 and add `misspellings.csv` (#30573)silverwind2024-04-273-6/+6
| | | | | | Misspell 0.5.0 supports passing a csv file to extend the list of misspellings, so I added some common ones from the codebase. There is at least one typo in a API response so we need to decided whether to revert that and then likely remove the dict entry.
* Fix incorrect object id hash function (#30708)wxiaoguang2024-04-263-15/+8
| | | | | | | | | | | | | Great thanks to @oliverpool for figuring out the problem and proposing a fix. Regression of #28138 Incorrect hash causes the user's LFS files get all deleted when running `doctor fix all` (by the way, remove unused/non-standard comments) Co-authored-by: Giteabot <teabot@gitea.io>
* Deduplicate lfs common code (#30704)wxiaoguang2024-04-263-48/+42
|
* Improve oauth2 client "preferred username field" logic and the error ↵wxiaoguang2024-04-253-11/+52
| | | | | | | | | | | | | handling (#30622) Follow #30454 And fix #24957 When using "preferred_username", if no such field, `extractUserNameFromOAuth2` (old `getUserName`) shouldn't return an error. All other USERNAME options do not return such error. And fine tune some logic and error messages, make code more stable and more friendly to end users.
* Initial support for colorblindness-friendly themes (#30625)wxiaoguang2024-04-245-12/+17
| | | | | | | Initial support for #25680 This PR only adds some simple styles from GitHub, it is big enough and it focuses on adding the necessary framework-level supports. More styles could be fine-tuned later.
* Perform Newest sort type correctly when sorting issues (#30644)Kemal Zebari2024-04-231-2/+2
| | | | | | | | | | | | | Should resolve #30642. Before this commit, we were treating an empty `?sort=` query parameter as the correct sorting type (which is to sort issues in descending order by their created UNIX time). But when we perform `sort=latest`, we did not include this as a type so we would sort by the most recently updated when reaching the `default` switch statement block. This commit fixes this by considering the empty string, "latest", and just any other string that is not mentioned in the switch statement as sorting by newest.
* Fix queue test (#30646)wxiaoguang2024-04-223-19/+34
| | | | | | | | Fix #30643 The old test code is not stable due to the data-race described in the TODO added at that time. Make it stable, and remove a debug-only field from old test code.
* Enable more `revive` linter rules (#30608)silverwind2024-04-2217-51/+37
| | | | | | | | | | | Noteable additions: - `redefines-builtin-id` forbid variable names that shadow go builtins - `empty-lines` remove unnecessary empty lines that `gofumpt` does not remove for some reason - `superfluous-else` eliminate more superfluous `else` branches Rules are also sorted alphabetically and I cleaned up various parts of `.golangci.yml`.
* Use maintained gziphandler (#30592)Lunny Xiao2024-04-211-7/+13
| | | | | | | | Replace #27894 --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix commit file status parser (#30602)wxiaoguang2024-04-191-1/+1
| | | Try to fix #30492
* Avoid importing `modules/web/middleware` in `modules/session` (#30584)Jason Song2024-04-192-10/+18
| | | | | | | | | | | | Related to #30375. It doesn't make sense to import `modules/web/middleware` and `modules/setting` in `modules/web/session` since the last one is more low-level. And it looks like a workaround to call `DeleteLegacySiteCookie` in `RegenerateSession`, so maybe we could reverse the importing by registering hook functions.
* Mock queue backoff duration (#30553)wxiaoguang2024-04-182-1/+10
| | | | During testing, the backoff duration shouldn't be longer than other durations
* Allow everyone to read or write a wiki by a repo unit setting (#30495)wxiaoguang2024-04-171-0/+12
| | | | | Replace #6312 Help #5833 Wiki solution for #639
* Support nuspec manifest download for nuget packages (#28921)Michael Kriese2024-04-171-9/+12
| | | | | | | | | | | | | | | | Support downloading nuget nuspec manifest[^1]. This is useful for renovate because it uses this api to find the corresponding repository - Store nuspec along with nupkg on upload - allow downloading nuspec - add doctor command to add missing nuspec files [^1]: https://learn.microsoft.com/en-us/nuget/api/package-base-address-resource#download-package-manifest-nuspec --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Update API to return 'source_id' for users (#29718)Tobias Balle-Petersen2024-04-161-0/+2
| | | | | | | Using the API, a user's _source_id_ can be set in the _CreateUserOption_ model, but the field is not returned in the _User_ model. This PR updates the _User_ model to include the field _source_id_ (The ID of the Authentication Source).
* Allow `preferred_username` as username source for OIDC (#30454)SimonErm2024-04-161-1/+3
| | | | | | This PR adds the preferred_username claim as a possible username source for the oauth2_client. Closes #21518
* feat(api): implement branch/commit comparison API (#30349)Bo-Yi Wu2024-04-161-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | - Add new `Compare` struct to represent comparison between two commits - Introduce new API endpoint `/compare/*` to get commit comparison information - Create new file `repo_compare.go` with the `Compare` struct definition - Add new file `compare.go` in `routers/api/v1/repo` to handle comparison logic - Add new file `compare.go` in `routers/common` to define `CompareInfo` struct - Refactor `ParseCompareInfo` function to use `common.CompareInfo` struct - Update Swagger documentation to include the new API endpoint for commit comparison - Remove duplicate `CompareInfo` struct from `routers/web/repo/compare.go` - Adjust base path in Swagger template to be relative (`/api/v1`) GitHub API https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#compare-two-commits --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* fix: Fix to delete cookie when AppSubURL is non-empty (#30375)Jonathan Tran2024-04-142-5/+34
| | | | | | | | Cookies may exist on "/subpath" and "/subpath/" for some legacy reasons (eg: changed CookiePath behavior in code). The legacy cookie should be removed correctly. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Kyle D <kdumontnu@gmail.com>
* Add `interface{}` to `any` replacement to `make fmt`, exclude `*.pb.go` (#30461)silverwind2024-04-131-1/+1
| | | | | | | Since https://github.com/go-gitea/gitea/pull/25686, a few `interface{}` have sneaked into the codebase. Add this replacement to `make fmt` to prevent this from happening again. Ideally a linter would do this, but I haven't found any suitable.
* Avoid losing token when updating mirror settings (#30429)Jason Song2024-04-131-17/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #30416. Before (it shows as "Unset" while there's a token): <img width="980" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/d7148e3e-62c9-4d2e-942d-3d795b79515a"> After: <img width="977" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/24aaa1db-5baa-4204-9081-470b15ea72b5"> The username shows as "oauth2" because of https://github.com/go-gitea/gitea/blob/f9fdac9809335729b2ac3227b2a5f71a62fc64ad/services/migrations/dump.go#L99 I have checked that all usage of `MirrorRemoteAddress` has been updated. <img width="1806" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/2f042501-2824-4511-9203-c84a6731a02d"> However, it needs to be checked again when backporting. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix label rendering (#30456)wxiaoguang2024-04-132-12/+35
| | | | | | 1. Check whether the label is for an issue or a pull request. 2. Don't use space to layout 3. Make sure the test strings have trailing spaces explicitly, to avoid some IDE removing the trailing spaces automatically.
* Refactor cache and disable go-chi cache (#30417)wxiaoguang2024-04-136-157/+160
| | | use built-in cache package to wrap external go-chi cache package
* Limit the max line length when parsing git grep output (#30418)wxiaoguang2024-04-122-4/+26
|
* Use raw Wiki links for non-renderable Wiki files (#30273)Rafael2024-04-104-16/+55
| | | | | | | | | | | | | | | | | | | In Wiki pages, short-links created to local Wiki files were always expanded as regular Wiki Links. In particular, if a link wanted to point to a file that Gitea doesn't know how to render (e.g, a .zip file), a user following the link would be silently redirected to the Wiki's home page. This change makes short-links* in Wiki pages be expanded to raw wiki links, so these local wiki files may be accessed without manually accessing their URL. * only short-links ending in a file extension that isn't renderable are affected. Closes #27121. Signed-off-by: Rafael Girão <rafael.s.girao@tecnico.ulisboa.pt> Co-authored-by: silverwind <me@silverwind.io>
* Add container.FilterSlice function (#30339)oliverpool2024-04-092-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | Many places have the following logic: ```go func (jobs ActionJobList) GetRunIDs() []int64 { ids := make(container.Set[int64], len(jobs)) for _, j := range jobs { if j.RunID == 0 { continue } ids.Add(j.RunID) } return ids.Values() } ``` this introduces a `container.FilterMapUnique` function, which reduces the code above to: ```go func (jobs ActionJobList) GetRunIDs() []int64 { return container.FilterMapUnique(jobs, func(j *ActionRunJob) (int64, bool) { return j.RunID, j.RunID != 0 }) } ```