aboutsummaryrefslogtreecommitdiffstats
path: root/routers
Commit message (Collapse)AuthorAgeFilesLines
* Fix misspelling of mergable (#30896)yp053272024-05-082-4/+4
| | | | https://github.com/go-gitea/gitea/pull/25812#issuecomment-2099833692 Follow #30573
* Fix various problems around projects board view (#30696)Lunny Xiao2024-05-085-83/+68
| | | | | | | | | | | | | | | | | | | | | | | | | | | # The problem The previous implementation will start multiple POST requests from the frontend when moving a column and another bug is moving the default column will never be remembered in fact. # What's changed - [x] This PR will allow the default column to move to a non-first position - [x] And it also uses one request instead of multiple requests when moving the columns - [x] Use a star instead of a pin as the icon for setting the default column action - [x] Inserted new column will be append to the end - [x] Fix #30701 the newly added issue will be append to the end of the default column - [x] Fix when deleting a column, all issues in it will be displayed from UI but database records exist. - [x] Add a limitation for columns in a project to 20. So the sorting will not be overflow because it's int8. --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix wrong transfer hint (#30889)Lunny Xiao2024-05-081-2/+8
| | | Fix #30187
* Refactor AppURL usage (#30885)wxiaoguang2024-05-076-12/+18
| | | | | | | | 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-1/+112
| | | | | | | | | | | | | | | | | | | | 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 sure git version&feature are always prepared (#30877)wxiaoguang2024-05-068-8/+12
| | | Otherwise there would be more similar issues like #29287
* Improve grep search (#30843)wxiaoguang2024-05-032-1/+36
| | | | Reduce the context line number to 1, make "git grep" search respect the include/exclude patter, and fix #30785
* Don't only list code-enabled repositories when using repository API (#30817)Kemal Zebari2024-05-031-3/+1
| | | | | We should be listing all repositories by default. Fixes #28483.
* Fix no edit history after editing issue's title and content (#30814)yp053272024-05-032-40/+33
| | | | | Fix #30807 reuse functions in services
* Ignore useless error message "broken pipe" (#30801)wxiaoguang2024-05-031-3/+1
| | | Fix #30792
* refactor: merge ListActionTasks func to action.go file (#30811)Bo-Yi Wu2024-05-022-80/+66
| | | | | Just merge actions.go file to action.go Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* Prevent automatic OAuth grants for public clients (#30790)Archer2024-05-021-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | This commit forces the resource owner (user) to always approve OAuth 2.0 authorization requests if the client is public (e.g. native applications). As detailed in [RFC 6749 Section 10.2](https://www.rfc-editor.org/rfc/rfc6749.html#section-10.2), > The authorization server SHOULD NOT process repeated authorization requests automatically (without active resource owner interaction) without authenticating the client or relying on other measures to ensure that the repeated request comes from the original client and not an impersonator. With the implementation prior to this patch, attackers with access to the redirect URI (e.g., the loopback interface for `git-credential-oauth`) can get access to the user account without any user interaction if they can redirect the user to the `/login/oauth/authorize` endpoint somehow (e.g., with `xdg-open` on Linux). Fixes #25061. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Catch and handle unallowed file type errors in issue attachment API (#30791)Kemal Zebari2024-05-022-2/+17
| | | | | Before, we would just throw 500 if a user passes an attachment that is not an allowed type. This commit catches this error and throws a 422 instead since this should be considered a validation error.
* Skip gzip for some well-known compressed file types (#30796)wxiaoguang2024-05-021-1/+1
| | | Co-authored-by: silverwind <me@silverwind.io>
* Fix bleve fuzziness (#30799)wxiaoguang2024-05-011-1/+1
| | | | Fix #30797 Fix #30317
* Add API endpoints for getting action jobs status (#26673)Chester2024-05-013-0/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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-10/+8
| | | | | | | 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-1/+4
|
* Fix all rounded borders, change affected tab menus to pills (#30707)silverwind2024-04-291-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes https://github.com/go-gitea/gitea/issues/30673, all 23 issues. Notes: - Tab bar menus had to change to pills because of unsolvable issue with the border-radius as tab bar renders a overlapping border onto the box below. And I think pills look better. - Added padding to code editor empty preview message - Hide monaco's built-in blue focus border, we don't need it and it never showed before either. - Label add menu is simplified, removing the nested segment. <img width="1322" alt="Screenshot 2024-04-25 at 22 26 19" src="https://github.com/go-gitea/gitea/assets/115237/7e394e0c-b7ad-417d-8e9f-12f1dea93ed1"> <img width="1326" alt="Screenshot 2024-04-25 at 22 28 00" src="https://github.com/go-gitea/gitea/assets/115237/66c8499f-aa9f-4d95-8cca-ef13dfa82c65"> <img width="997" alt="Screenshot 2024-04-25 at 22 36 53" src="https://github.com/go-gitea/gitea/assets/115237/07896102-c71d-4246-8173-c2bc2e1d3cae"> <img width="832" alt="Screenshot 2024-04-25 at 22 56 09" src="https://github.com/go-gitea/gitea/assets/115237/d83afc96-08ca-4adc-baf4-3d02804be57c"> <img width="361" alt="Screenshot 2024-04-25 at 22 57 12" src="https://github.com/go-gitea/gitea/assets/115237/c7371a68-00b5-47d8-84d0-ddc5268b2b2c"> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Rename CodeIndexerEnabled to IsRepoIndexerEnabled (#30762)wxiaoguang2024-04-292-3/+3
| | | | | | Fix #30761 Most places use `IsRepoIndexerEnabled` but not `CodeIndexerEnabled`, so it should always use `IsRepoIndexerEnabled` for consistency.
* Resolve lint for unused parameter and unnecessary type arguments (#30750)Chongyi Zheng2024-04-296-13/+13
| | | | | | | | | | 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-291-0/+1
|
* Fix nil dereference on error (#30740)Chongyi Zheng2024-04-282-4/+5
| | | | | In both cases, the `err` is nil because of `if` checks before Reference: #30729
* Prevent allow/reject reviews on merged/closed PRs (#30686)Kemal Zebari2024-04-272-2/+13
| | | Resolves #30675.
* Update misspell to 0.5.1 and add `misspellings.csv` (#30573)silverwind2024-04-279-11/+11
| | | | | | 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.
* feat(api): enhance Actions Secrets Management API for repository (#30656)Bo-Yi Wu2024-04-266-284/+327
| | | | | | | | | | | | | | | | | | | | | | | | | | - Add endpoint to list repository action secrets in API routes - Implement `ListActionsSecrets` function to retrieve action secrets from the database - Update Swagger documentation to include the new `/repos/{owner}/{repo}/actions/secrets` endpoint - Add `actions` package import and define new routes for actions, secrets, variables, and runners in `api.go`. - Refactor action-related API functions into `Action` struct methods in `org/action.go` and `repo/action.go`. - Remove `actionAPI` struct and related functions, replacing them with `NewAction()` calls. - Rename `variables.go` to `action.go` in `org` directory. - Delete `runners.go` and `secrets.go` in both `org` and `repo` directories, consolidating their content into `action.go`. - Update copyright year and add new imports in `org/action.go`. - Implement `API` interface in `services/actions/interface.go` for action-related methods. - Remove individual action-related functions and replace them with methods on the `Action` struct in `repo/action.go`. --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Signed-off-by: appleboy <appleboy.tw@gmail.com>
* Fix code search input for different views (#30678)wxiaoguang2024-04-263-4/+0
| | | | | | Now only show the "code search" on the repo home page, because it only does global search. So do not show it when viewing file or directory to avoid misleading users (it doesn't search in a directory)
* Add route handler info for debugging purpose (#30705)wxiaoguang2024-04-262-1/+7
| | | Follow #30519
* Improve job commit description (#30579)yp053272024-04-261-12/+14
| | | | | | | | | | | | | | | | | | | | | Fix https://github.com/go-gitea/gitea/issues/30567 When job is a schedule: ![image](https://github.com/go-gitea/gitea/assets/18380374/b07e9d43-e8b7-4ee2-87b3-a7050c3a8ca5) When it is a normal one: ![image](https://github.com/go-gitea/gitea/assets/18380374/0d58dab9-74bb-421b-8952-0578cdf21a52) also add a 'space' behind `:` ![image](https://github.com/go-gitea/gitea/assets/18380374/4cebece0-bfe6-4ad9-b806-e5c49bb9be43) ![image](https://github.com/go-gitea/gitea/assets/18380374/02da7681-474b-4c0f-9dad-b6558f6cb484) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Allow to save empty comment (#30706)wxiaoguang2024-04-261-19/+22
| | | Fix #29986
* Improve oauth2 client "preferred username field" logic and the error ↵wxiaoguang2024-04-254-28/+81
| | | | | | | | | | | | | 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.
* Fix a panic bug when head repository deleting (#30674)Lunny Xiao2024-04-241-13/+13
| | | | When visiting a pull request files which head repository has been deleted, it will panic because headrepo is nil.
* Initial support for colorblindness-friendly themes (#30625)wxiaoguang2024-04-242-2/+11
| | | | | | | 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.
* Fix compare api swagger (#30648)Lunny Xiao2024-04-231-1/+1
| | | The swagger format on #30349 is not right. This PR will fix it.
* Enable more `revive` linter rules (#30608)silverwind2024-04-2224-42/+23
| | | | | | | | | | | 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`.
* fix(api): refactor branch and tag existence checks (#30618)Bo-Yi Wu2024-04-221-5/+4
| | | | | | | | | | | | - Update branch existence check to also include tag existence check - Adjust error message for branch/tag existence check ref: https://github.com/go-gitea/gitea/pull/30349 --------- Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Use maintained gziphandler (#30592)Lunny Xiao2024-04-211-4/+6
| | | | | | | | Replace #27894 --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Clarify permission "HasAccess" behavior (#30585)wxiaoguang2024-04-203-5/+5
| | | | | | | | | | | | | | | Follow #30495 "HasAccess" behavior wasn't clear, to make it clear: * Use a new name `HasAnyUnitAccess`, it will be easier to review related code and permission problems. * Separate everyone access mode to a separate field, then all calls to HasAccess are reverted to old behavior before #30495. * Add new tests. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix HEAD method for robots.txt (#30603)wxiaoguang2024-04-191-1/+1
| | | Fix #30601
* Fix project description rendering for org (#30587)wxiaoguang2024-04-191-2/+2
| | | | | | | | Fix #30263 ![image](https://github.com/go-gitea/gitea/assets/2114189/41cabe6c-f94a-4874-a26f-d01bb89bb28c) Co-authored-by: Giteabot <teabot@gitea.io>
* Some following up changes for routes (#30550)wxiaoguang2024-04-181-5/+3
| | | | 1. Switch back to the old order for `reqRepoAdmin, context.RepoRef()` 2. Add a routing function info for global NotFound
* Expose fuzzy search for issues/pulls (#29701)65432024-04-181-2/+10
| | | | | | | | close #29685 --------- Signed-off-by: 6543 <6543@obermui.de> Co-authored-by: silverwind <me@silverwind.io>
* Allow everyone to read or write a wiki by a repo unit setting (#30495)wxiaoguang2024-04-174-14/+9
| | | | | Replace #6312 Help #5833 Wiki solution for #639
* Support nuspec manifest download for nuget packages (#28921)Michael Kriese2024-04-171-2/+30
| | | | | | | | | | | | | | | | 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>
* Fix branch_protection api shows users/teams who has no readAccess (#30291)Edward Zhang2024-04-171-4/+4
| | | | | | | | | | | | Add some logic in `convert.ToBranchProtection` to return only the names associated with readAccess instead of returning all names. This will ensure consistency in behavior between the frontend and backend. Fixes: #27694 --------- Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wenzhuo.zhang <wenzhuo.zhang@geely.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor web routes (#30519)wxiaoguang2024-04-172-264/+276
| | | | | | | Re-organize the routes in web.go and use ctx constants instead of `context.UnitTypes()` --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Allow `preferred_username` as username source for OIDC (#30454)SimonErm2024-04-161-0/+7
| | | | | | This PR adds the preferred_username claim as a possible username source for the oauth2_client. Closes #21518
* Fix empty field `login_name` in API response JSON when creating user (#30511)yp053272024-04-161-3/+3
| | | | | Fix #30508 ps: if `sourceID` is not set, `LoginName` will be ignored
* feat(api): implement branch/commit comparison API (#30349)Bo-Yi Wu2024-04-165-14/+132
| | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* Rewrite and restyle reaction selector and enable no-sizzle eslint rule (#30453)silverwind2024-04-141-2/+0
| | | | | | | | | | | Enable `no-sizzle` lint rule, there was only one use in `initCompReactionSelector` and: - Remove all jQuery except the necessary fomantic dropdown init - Remove the recursion, instead bind event listeners to common parent container nodes --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>