summaryrefslogtreecommitdiffstats
path: root/routers/api/v1
Commit message (Collapse)AuthorAgeFilesLines
* 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
* Performance improvements for pull request list page (#29900)Lunny Xiao2024-03-212-13/+8
| | | | | | | | | | | This PR will avoid load pullrequest.Issue twice in pull request list page. It will reduce x times database queries for those WIP pull requests. Partially fix #29585 --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix PR creation via api between branches of same repo with head field ↵norohind2024-03-171-0/+2
| | | | | | | | | | | | | | | | | | | | | | namespaced (#26986) Fix #20175 Current implementation of API does not allow creating pull requests between branches of the same repo when you specify *namespace* (owner of the repo) in `head` field in http request body. --- Although GitHub implementation of API allows performing such action and since Gitea targeting compatibility with GitHub API I see it as an appropriate change. I'm proposing a fix to the described problem and test case which covers this logic. My use-case just in case: https://github.com/go-gitea/gitea/issues/20175#issuecomment-1711283022
* Fix lint-swagger warning (#29787)sillyguodong2024-03-142-3/+7
| | | | | | | | | | | Caused by: #23106 Fix: https://github.com/go-gitea/gitea/actions/runs/8274650046/job/22640335697 1. Delete `UserBadgeList` in `options.go`, because it wasn't used. (The struct defined in `options.go` is the struct used to parse the request body) 2. Move `BadgeList` struct under `routers/api/v1/swagger` folder which response should be defined in.
* Refactor to use optional.Option for issue index search option (#29739)65432024-03-131-12/+12
| | | Signed-off-by: 6543 <6543@obermui.de>
* Do some performance optimize for issues list and view issue/pull (#29515)Lunny Xiao2024-03-121-4/+0
| | | | | | | | | | | | | | This PR do some performance optimzations. - [x] Add `index` for the column `comment_id` of `Attachment` table to accelerate query from the database. - [x] Remove unnecessary database queries when viewing issues. Before some conditions which id = 0 will be sent to the database - [x] Remove duplicated load posters - [x] Batch loading attachements, isread of comments on viewing issue --------- Co-authored-by: Zettat123 <zettat123@gmail.com>
* remove repetitive words (#29695)pengqiseven2024-03-112-2/+2
| | | Signed-off-by: pengqiseven <912170095@qq.com>
* Add a warning for disallowed email domains (#29658)Zettat1232024-03-111-0/+9
| | | | | | | | | | | | | Resolve #29660 Follow #29522 and #29609 Add a warning for disallowed email domains when admins manually add/edit users. Thanks @yp05327 for the [comment](https://github.com/go-gitea/gitea/pull/29605#issuecomment-1980105119) ![image](https://github.com/go-gitea/gitea/assets/15528715/6737b221-a3a2-4180-9ef8-b846c10f96e0)
* Move get/set default branch from git package to gitrepo package to hide ↵Lunny Xiao2024-03-081-2/+2
| | | | repopath (#29126)
* Cache repository default branch commit status to reduce query on commit ↵Lunny Xiao2024-03-061-2/+2
| | | | | | | | | | | | | status table (#29444) After repository commit status has been introduced on dashaboard, the most top SQL comes from `GetLatestCommitStatusForPairs`. This PR adds a cache for the repository's default branch's latest combined commit status. When a new commit status updated, the cache will be marked as invalid. <img width="998" alt="image" src="https://github.com/go-gitea/gitea/assets/81045/76759de7-3a83-4d54-8571-278f5422aed3">
* Skip email domain check when admins edit user emails (#29609)Zettat1232024-03-051-1/+1
| | | | | | Follow #29522 Administrators should be able to set a user's email address even if the email address is not in `EMAIL_DOMAIN_ALLOWLIST`
* Skip email domain check when admin users adds user manually (#29522)Zettat1232024-03-051-1/+1
| | | | | | Fix #27457 Administrators should be able to manually create any user even if the user's email address is not in `EMAIL_DOMAIN_ALLOWLIST`.
* Add missing database transaction for new issue (#29490)Lunny Xiao2024-03-041-1/+1
| | | | When creating an issue, inserting issue, assign users and set project should be in the same transaction.
* Add user blocking (#29028)KN4CK3R2024-03-0417-51/+452
| | | | | | | | | | | | | | | | | | | | | | Fixes #17453 This PR adds the abbility to block a user from a personal account or organization to restrict how the blocked user can interact with the blocker. The docs explain what's the consequence of blocking a user. Screenshots: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/4ed884f3-e06a-4862-afd3-3b8aa2488dc6) ![grafik](https://github.com/go-gitea/gitea/assets/1666336/ae6d4981-f252-4f50-a429-04f0f9f1cdf1) ![grafik](https://github.com/go-gitea/gitea/assets/1666336/ca153599-5b0f-4b4a-90fe-18bdfd6f0b6b) --------- Co-authored-by: Lauris BH <lauris@nix.lv>
* Allow options to disable user ssh keys configuration from the interface on ↵Lunny Xiao2024-03-041-0/+11
| | | | | | | | | | | app.ini (#29447) Follow #29275 Extract from #20549 Fix #24716 --------- Co-authored-by: delvh <dev.lh@web.de>
* Enable/disable owner and repo projects independently (#28805)Denys Konovalov2024-03-041-3/+23
| | | | | | | | | | | | | | | Part of #23318 Add menu in repo settings to allow for repo admin to decide not just if projects are enabled or disabled per repo, but also which kind of projects (repo-level/owner-level) are enabled. If repo projects disabled, don't show the projects tab. ![grafik](https://github.com/go-gitea/gitea/assets/47871822/b9b43fb4-824b-47f9-b8e2-12004313647c) --------- Co-authored-by: delvh <dev.lh@web.de>
* Fix 500 when pushing release to an empty repo (#29554)Nanguan Lin2024-03-031-0/+5
| | | | | | As title. The former code directly used `ctx.Repo.GitRepo`, causing 500. https://github.com/go-gitea/gitea/blob/22b4f0c09f1de5e581929bd10f39833d30d2c482/routers/api/v1/repo/release.go#L241
* Add support for API blob upload of release attachments (#29507)KN4CK3R2024-03-021-10/+29
| | | | | | | | | | | | Fixes #29502 Our endpoint is not Github compatible. https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset --------- Co-authored-by: Giteabot <teabot@gitea.io>
* remove util.OptionalBool and related functions (#29513)65432024-03-025-33/+31
| | | | | | and migrate affected code _last refactoring bits to replace **util.OptionalBool** with **optional.Option[bool]**_
* Allow options to disable user gpg keys configuration from the interface on ↵Lunny Xiao2024-03-021-0/+11
| | | | | | | | app.ini (#29486) Follow #29447 Fix #29454 Extract from #20549
* Add admin API route for managing user's badges (#23106)techknowlogick2024-03-013-0/+133
| | | | | | | Fix #22785 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* migrate some more "OptionalBool" to "Option[bool]" (#29479)65432024-02-292-15/+16
| | | | | | | | just some refactoring bits towards replacing **util.OptionalBool** with **optional.Option[bool]** --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix wrong test usage of `AppSubURL` (#29459)KN4CK3R2024-02-291-9/+9
| | | | The tests use an invalid `setting.AppSubURL`. The wrong behaviour disturbs other PRs like #29222 and #29427.
* Move generate from module to service (#29465)Lunny Xiao2024-02-281-1/+1
|
* Fix missed return (#29450)Lunny Xiao2024-02-271-0/+1
|
* Move context from modules to services (#29440)Lunny Xiao2024-02-27100-110/+109
| | | | | | | | | | | | | | | Since `modules/context` has to depend on `models` and many other packages, it should be moved from `modules/context` to `services/context` according to design principles. There is no logic code change on this PR, only move packages. - Move `code.gitea.io/gitea/modules/context` to `code.gitea.io/gitea/services/context` - Move `code.gitea.io/gitea/modules/contexttest` to `code.gitea.io/gitea/services/contexttest` because of depending on context - Move `code.gitea.io/gitea/modules/upload` to `code.gitea.io/gitea/services/context/upload` because of depending on context
* Add API to get PR by base/head (#29242)qwerty2872024-02-262-0/+86
| | | | | | | Closes https://github.com/go-gitea/gitea/issues/16289 Add a new API `/repos/{owner}/{repo}/pulls/{base}/{head}` to get a PR by its base and head branch.
* Add attachment support for code review comments (#29220)Jimmy Praet2024-02-251-0/+1
| | | | | | | Fixes #27960, #24411, #12183 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add API to get merged PR of a commit (#29243)qwerty2872024-02-242-0/+52
| | | | | | | | Adds a new API `/repos/{owner}/{repo}/commits/{sha}/pull` that allows you to get the merged PR associated to a commit. --------- Co-authored-by: 6543 <6543@obermui.de>
* Use the database object format name but not read from git repoisitory ↵Lunny Xiao2024-02-241-1/+1
| | | | | | | | | | | | | everytime and fix possible migration wrong objectformat when migrating a sha256 repository (#29294) Now we can get object format name from git command line or from the database repository table. Assume the column is right, we don't need to read from git command line every time. This also fixed a possible bug that the object format is wrong when migrating a sha256 repository from external. <img width="658" alt="image" src="https://github.com/go-gitea/gitea/assets/81045/6e9a9dcf-13bf-4267-928b-6bf2c2560423">