summaryrefslogtreecommitdiffstats
path: root/routers/api/v1
Commit message (Collapse)AuthorAgeFilesLines
* Fix get reviewers' bug (#32415) (#32616)Lunny Xiao2024-11-231-1/+9
| | | | | | | | | | This PR rewrites `GetReviewer` function and move it to service layer. Reviewers should not be watchers, so that this PR removed all watchers from reviewers. When the repository is under an organization, the pull request unit read permission will be checked to resolve the bug of Fix #32394 Backport #32415
* Fix PR creation on forked repositories (#31863) (#32591)Lunny Xiao2024-11-221-3/+14
| | | | | | Resolves #20475 Backport #31863 Co-authored-by: Job <LordChunk@users.noreply.github.com>
* Refactor find forks and fix possible bugs that weak permissions check ↵Lunny Xiao2024-11-191-3/+12
| | | | | | | | | | | | | | | (#32528) (#32547) Backport #32528 - Move models/GetForks to services/FindForks - Add doer as a parameter of FindForks to check permissions - Slight performance optimization for get forks API with batch loading of repository units - Add tests for forking repository to organizations --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix `missing signature key` error when pulling Docker images with ↵Zettat1232024-11-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `SERVE_DIRECT` enabled (#32365) (#32397) Backport #32365 Fix #28121 I did some tests and found that the `missing signature key` error is caused by an incorrect `Content-Type` header. Gitea correctly sets the `Content-Type` header when serving files. https://github.com/go-gitea/gitea/blob/348d1d0f322ca57c459acd902f54821d687ca804/routers/api/packages/container/container.go#L712-L717 However, when `SERVE_DIRECT` is enabled, the `Content-Type` header may be set to an incorrect value by the storage service. To fix this issue, we can use query parameters to override response header values. https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html <img width="600px" src="https://github.com/user-attachments/assets/f2ff90f0-f1df-46f9-9680-b8120222c555" /> In this PR, I introduced a new parameter to the `URL` method to support additional parameters. ``` URL(path, name string, reqParams url.Values) (*url.URL, error) ```
* Fix the permission check for user search API and limit the number of ↵Zettat1232024-10-231-2/+10
| | | | | | | | | returned users for `/user/search` (#32310) Partially backport #32288 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* API: enhance SearchIssues swagger docs (#32208) (#32298)65432024-10-211-19/+32
| | | | | | | | Backport #32208 This will result in better api clients generated out of the openapi docs for SearchIssues --- *Sponsored by Kithara Software GmbH*
* Fix bug when a token is given public only (#32204) (#32218)Lunny Xiao2024-10-095-51/+97
| | | Backport #32204
* Fix the logic of finding the latest pull review commit ID (#32139) (#32165)Giteabot2024-10-011-1/+0
| | | | | | | Backport #32139 by @Zettat123 Fix #31423 Co-authored-by: Zettat123 <zettat123@gmail.com>
* Fix bug in getting merged pull request by commit (#32079) (#32117)Zettat1232024-09-252-3/+5
| | | | | Backport #32079 Fix #32027
* Fix incorrect `/tokens` api (#32085) (#32092)Giteabot2024-09-221-0/+5
| | | | | | | | | | Backport #32085 by @KN4CK3R Fixes #32078 - Add missing scopes output. - Disallow empty scope. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Handle invalid target when creating releases using API (#31841) (#32043)Giteabot2024-09-171-0/+3
| | | | | | | | | | | Backport #31841 by @kemzeb A 500 status code was thrown when passing a non-existent target to the create release API. This snapshot handles this error and instead throws a 404 status code. Discovered while working on #31840. Co-authored-by: Kemal Zebari <60799661+kemzeb@users.noreply.github.com>
* Check if the `due_date` is nil when editing issues (#32035) (#32042)Giteabot2024-09-151-4/+10
| | | | | | | Backport #32035 by @Zettat123 Fix #32030 Co-authored-by: Zettat123 <zettat123@gmail.com>
* Fix 500 error when `state` params is set when editing issue/PR by API ↵Giteabot2024-09-012-10/+38
| | | | | | | | | (#31880) (#31952) Backport #31880 by @yp05327 A quick fix for #31871 Co-authored-by: yp05327 <576951401@qq.com>
* fix(api): owner ID should be zero when created repo secret (#31715) (#31811)Bo-Yi Wu2024-08-101-4/+2
| | | | | | | | - Change condition to include `RepoID` equal to 0 for organization secrets Backport https://github.com/go-gitea/gitea/pull/31715 by @appleboy Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* Set owner id to zero when GetRegistrationToken for repo (#31725) (#31729)Giteabot2024-07-301-1/+1
| | | | | | | | | | | | Backport #31725 by @wolfogre Fix #31707. It's split from #31724. Although #31724 could also fix #31707, it has change a lot so it's not a good idea to backport it. Co-authored-by: Jason Song <i@wolfogre.com>
* Fix API endpoint for registration-token (#31722) (#31728)Giteabot2024-07-291-1/+1
| | | | | | | Backport #31722 by @wolfogre Partially fix #31707. Related to #30656. Co-authored-by: Jason Song <i@wolfogre.com>
* Add permission check when creating PR (#31033) (#31720)yp053272024-07-291-0/+2
| | | | | Backport #31033 user should be a collaborator of the base repo to create a PR
* Fix missing images in editor preview due to wrong links (#31299) (#31393)wxiaoguang2024-06-171-39/+61
| | | | | | | | | | | | Backport #31299 Parse base path and tree path so that media links can be correctly created with /media/. Resolves #31294 --------- Co-authored-by: Brecht Van Lommel <brecht@blender.org>
* Add an immutable tarball link to archive download headers for Nix (#31139) ↵Giteabot2024-05-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#31145) Backport #31139 by @Mic92 This allows `nix flake metadata` and nix in general to lock a *branch* tarball link in a manner that causes it to fetch the correct commit even if the branch is updated with a newer version. For further context, Nix flakes are a feature that, among other things, allows for "inputs" that are "github:someuser/somerepo", "https://some-tarball-service/some-tarball.tar.gz", "sourcehut:~meow/nya" or similar. This feature allows our users to fetch tarballs of git-based inputs to their builds rather than using git to fetch them, saving significant download time. There is presently no gitea or forgejo specific fetcher in Nix, and we don't particularly wish to have one. Ideally (as a developer on a Nix implementation myself) we could just use the generic tarball fetcher and not add specific forgejo support, but to do so, we need additional metadata to know which commit a given *branch* tarball represents, which is the purpose of the Link header added here. The result of this patch is that a Nix user can specify `inputs.something.url = "https://forgejo-host/some/project/archive/main.tar.gz"` in flake.nix and get a link to some concrete tarball for the actual commit in the lock file, then when they run `nix flake update` in the future, they will get the latest commit in that branch. Example of it working locally: » nix flake metadata --refresh 'http://localhost:3000/api/v1/repos/jade/cats/archive/main.tar.gz?dir=configs/nix' Resolved URL: http://localhost:3000/api/v1/repos/jade/cats/archive/main.tar.gz?dir=configs/nix Locked URL: http://localhost:3000/api/v1/repos/jade/cats/archive/804ede182b6b66469b23ea4d21eece52766b7a06.tar.gz?dir=configs /nix&narHash=sha256-yP7KkDVfuixZzs0fsqhSETXFC0y8m6nmPLw2GrAMxKQ%3D Description: Computers with the nixos Path: /nix/store/s856c6yqghyan4v0zy6jj19ksv0q22nx-source Revision: 804ede182b6b66469b23ea4d21eece52766b7a06 Last modified: 2024-05-02 00:48:32 For details on the header value, see: https://github.com/nixos/nix/blob/56763ff918eb308db23080e560ed2ea3e00c80a7/doc/manual/src/protocols/tarball-fetcher.md Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com> Co-authored-by: Jade Lovelace <software@lfcode.ca> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add missed return after `ctx.ServerError` (#31130) (#31133)Giteabot2024-05-281-0/+1
| | | | | Backport #31130 by @lunny Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix bug on avatar (#31008) (#31019)Giteabot2024-05-202-0/+4
| | | | | | | | Backport #31008 by @lunny Extract from #30995 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io>
* Fix "force private" logic (#31012) (#31021)Giteabot2024-05-202-3/+3
| | | | | Backport #31012 by wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Simplify mirror repository API logic (#30963) (#31009)Giteabot2024-05-181-9/+3
| | | | | | | Backport #30963 by wxiaoguang Fix #30921 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Protected tag is no internal server error (#30962) (#30970)Giteabot2024-05-143-8/+17
| | | | | | | | | | Backport #30962 by @KN4CK3R Fixes #30959 Adds an API test for protected tags. Fix existing tag in combination with fixtures. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Support using label names when changing issue labels (#30943) (#30958)Giteabot2024-05-131-1/+28
| | | | | | | | | | | | | | | | Backport #30943 by @Zettat123 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" /> Co-authored-by: Zettat123 <zettat123@gmail.com>
* Fix misspelling of mergable (#30896) (#30905)Giteabot2024-05-081-2/+2
| | | | | | | | Backport #30896 by @yp05327 https://github.com/go-gitea/gitea/pull/25812#issuecomment-2099833692 Follow #30573 Co-authored-by: yp05327 <576951401@qq.com>
* Fix no edit history after editing issue's title and content (#30814) (#30845)Giteabot2024-05-032-40/+33
| | | | | | | | | Backport #30814 by @yp05327 Fix #30807 reuse functions in services Co-authored-by: yp05327 <576951401@qq.com>
* Don't only list code-enabled repositories when using repository API (#30817) ↵Giteabot2024-05-031-3/+1
| | | | | | | | | | | (#30848) Backport #30817 by kemzeb We should be listing all repositories by default. Fixes #28483. Co-authored-by: Kemal Zebari <60799661+kemzeb@users.noreply.github.com>
* Catch and handle unallowed file type errors in issue attachment API (#30791) ↵Giteabot2024-05-032-2/+17
| | | | | | | | | | | (#30834) Backport #30791 by kemzeb 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. Co-authored-by: Kemal Zebari <60799661+kemzeb@users.noreply.github.com>
* Prevent allow/reject reviews on merged/closed PRs (#30686)Kemal Zebari2024-04-271-2/+11
| | | Resolves #30675.
* Update misspell to 0.5.1 and add `misspellings.csv` (#30573)silverwind2024-04-271-1/+1
| | | | | | 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 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-226-7/+0
| | | | | | | | | | | 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>
* Clarify permission "HasAccess" behavior (#30585)wxiaoguang2024-04-202-3/+3
| | | | | | | | | | | | | | | 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>
* Allow everyone to read or write a wiki by a repo unit setting (#30495)wxiaoguang2024-04-171-5/+1
| | | | | Replace #6312 Help #5833 Wiki solution for #639
* 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>
* 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-163-0/+107
| | | | | | | | | | | | | | | | | | | | | | | | | - 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>
* Refactor cache and disable go-chi cache (#30417)wxiaoguang2024-04-131-4/+2
| | | use built-in cache package to wrap external go-chi cache package
* Fix missed doer (#30231)Lunny Xiao2024-04-085-18/+18
| | | | | Fix #29879 Co-authored-by: Giteabot <teabot@gitea.io>
* Clean up log messages (#30313)wxiaoguang2024-04-071-2/+0
| | | | | | `log.Xxx("%v")` is not ideal, this PR adds necessary context messages. Remove some unnecessary logs. Co-authored-by: Giteabot <teabot@gitea.io>
* Remove scheduled action tasks if the repo is archived (#30224)Zettat1232024-04-011-0/+10
| | | Fix #30220
* Add setting to disable user features when user login type is not plain (#29615)Jack Hay2024-03-292-4/+5
| | | | | | | | | ## Changes - Adds setting `EXTERNAL_USER_DISABLE_FEATURES` to disable any supported user features when login type is not plain - In general, this is necessary for SSO implementations to avoid inconsistencies between the external account management and the linked account - Adds helper functions to encourage correct use
* Refactor topic Find functions and add more tests for pagination (#30127)Lunny Xiao2024-03-291-3/+4
| | | This also fixed #22238
* Add API for `Variables` (#29520)sillyguodong2024-03-286-0/+884
| | | | | | | close #27801 --------- Co-authored-by: silverwind <me@silverwind.io>
* Prevent re-review and dismiss review actions on closed and merged PRs (#30065)Kemal Zebari2024-03-281-6/+11
| | | | | | | | | | | | | | | | | | | Resolves #29965. --- Manually tested this by: - Following the [installation](https://docs.gitea.com/next/installation/install-with-docker#basics) guide (but built a local Docker image instead) - Creating 2 users, one who is the `Owner` of a newly-created repository and the other a `Collaborator` - Had the `Collaborator` create a PR that the `Owner` reviews - `Collaborator` resolves conversation and `Owner` merges PR And with this change we see that we can no longer see re-request review button for the `Owner`: <img width="1351" alt="Screenshot 2024-03-25 at 12 39 18 AM" src="https://github.com/go-gitea/gitea/assets/60799661/bcd9c579-3cf7-474f-a51e-b436fe1a39a4">
* Remove repetitive words (#30091)crazeteam2024-03-261-1/+1
| | | | | remove repetitive words Signed-off-by: crazeteam <lilujing@outlook.com>
* Refactor StringsToInt64s (#29967)wxiaoguang2024-03-211-2/+7
| | | And close #27176