aboutsummaryrefslogtreecommitdiffstats
path: root/routers/api/v1
Commit message (Collapse)AuthorAgeFilesLines
* Fix ListWorkflowRuns OpenAPI response model. (#35026)Scion9 hours1-1/+1
| | | | | | | | | Change the OpenAPI response of `ListWorkflowRuns` to `WorkflowRunsList` like it is supposed to be. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix the response format for `actions/workflows`. (#35009)Scion25 hours1-1/+1
| | | | | | | | This PR fixes the response format for the OpenAPI Spec of `ActionsListRepositoryWorkflows`. It was specified in the OpenAPI spec as returning a `[]*ActionWorkflow`, but it actually should return a `api.ActionWorkflowResponse`. The test already expects an `api.ActionWorkflowResponse` like expected.
* Enable gocritic `equalFold` and fix issues (#34952)silverwind4 days3-3/+3
| | | | | | | Continuation of https://github.com/go-gitea/gitea/pull/34678. --------- Signed-off-by: silverwind <me@silverwind.io>
* Support getting last commit message using contents-ext API (#34904)RickyMa8 days1-3/+16
| | | | | | | | Fix #34870 Fix #34929 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add a `login`/`login-name`/`username` disambiguation to affected endpoint ↵AlexMaryW10 days20-51/+51
| | | | | | | | | | | | parameters and response/request models (#34901) Issue: [link](https://github.com/go-gitea/gitea/issues/9637) Changes introduced: I have clarified the problematic terms (`login`, `login_name`, and `username`) in all affected endpoints. The changes were made to relevant: - HTTP endpoint parameters' descriptions - response/request models' fields
* enforce explanation for necessary nolints and fix bugs (#34883)TheFox0x713 days1-2/+2
| | | | | | | Follows up https://github.com/go-gitea/gitea/pull/34851 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* enforce nolint scope (#34851)TheFox0x713 days1-4/+4
| | | | | | | | | | | | | | | enable nolintlint scope requirement add comments to new directives so it's more obvious why they are in place --- I can also toggle the mandatory comments on if that's something of interest. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Refactor "change file" API (#34855)wxiaoguang2025-06-253-294/+134
| | | | | | | | | Follow up the "editor" refactor, use the same approach to simplify code, and fix some docs & comments --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* Fix archive API (#34853)wxiaoguang2025-06-251-3/+3
| | | Fix #34852
* Refactor repo contents API and add "contents-ext" API (#34822)wxiaoguang2025-06-255-12/+88
| | | See the updated swagger document for details.
* fix(issue): Replace stopwatch toggle with explicit start/stop actions (#34818)Junsik Kong2025-06-251-31/+25
| | | | | | | | | | | | | | | | This PR fixes a state de-synchronization bug with the issue stopwatch, it resolves the issue by replacing the ambiguous `/toggle` endpoint with two explicit endpoints: `/start` and `/stop`. - The "Start timer" button now exclusively calls the `/start` endpoint. - The "Stop timer" button now exclusively calls the `/stop` endpoint. This ensures the user's intent is clearly communicated to the server, eliminating the state inconsistency and fixing the bug. --------- Signed-off-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor editor (#34780)wxiaoguang2025-06-211-0/+3
| | | A complete rewrite
* Add workflow_run api + webhook (#33964)ChristopherHX2025-06-208-10/+766
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implements - https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#list-jobs-for-a-workflow-run--code-samples - https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#get-a-job-for-a-workflow-run--code-samples - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#list-workflow-runs-for-a-repository - https://docs.github.com/en/rest/actions/workflow-runs?apiVersion=2022-11-28#get-a-workflow-run - `/actions/runs` for global + user + org (Gitea only) - `/actions/jobs` for global + user + org + repository (Gitea only) - workflow_run webhook + action trigger - limitations - workflow id is assigned to a string, this may result into problems in strongly typed clients Fixes - workflow_job webhook url to no longer contain the `runs/<run>` part to align with api - workflow instance does now use it's name inside the file instead of filename if set Refactoring - Moved a lot of logic from workflows/workflow_job into a shared module used by both webhook and api TODO - [x] Verify Keda Compatibility - [x] Edit Webhook API bug is resolved Closes https://github.com/go-gitea/gitea/issues/23670 Closes https://github.com/go-gitea/gitea/issues/23796 Closes https://github.com/go-gitea/gitea/issues/24898 Replaces https://github.com/go-gitea/gitea/pull/28047 and is much more complete --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add ff_only parameter to POST /repos/{owner}/{repo}/merge-upstream (#34770)Dan Čermák2025-06-191-1/+1
| | | | | | | | | The merge-upstream route was so far performing any kind of merge, even those that would create merge commits and thus make your branch diverge from upstream, requiring manual intervention via the git cli to undo the damage. With the new optional parameter ff_only, we can instruct gitea to error out, if a non-fast-forward merge would be performed.
* Support annotated tags when using create release API (#31840)Kemal Zebari2025-06-181-1/+3
| | | | | | | | | | This adds a new field, "tag_message", that represents the message of the annotated tag. Resolves #31835. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Remove unused param `doer` (#34545)Philip Peterson2025-06-181-1/+1
|
* Run `gopls modernize` on codebase (#34751)silverwind2025-06-182-16/+4
| | | | Recent modernize fixes: https://github.com/golang/tools/commits/master/gopls/internal/analysis/modernize
* Improve instance wide ssh commit signing (#34341)ChristopherHX2025-06-112-19/+65
| | | | | | | | | | | | | | | | | * Signed SSH commits can look in the UI like on GitHub, just like gpg keys today in Gitea * SSH format can be added in gitea config * SSH Signing worked before with DEFAULT_TRUST_MODEL=committer `TRUSTED_SSH_KEYS` can be a list of additional ssh public key contents to trust for every user of this instance Closes #34329 Related #31392 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: techknowlogick <techknowlogick@gitea.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix last admin check when syncing users (#34649)wxiaoguang2025-06-091-1/+1
| | | Fix #34358
* Refactor FindOrgOptions to use enum instead of bool, fix membership ↵wxiaoguang2025-06-091-5/+3
| | | | visibility (#34629)
* Fix possible pull request broken when leave the page immediately after ↵Lunny Xiao2025-06-041-1/+2
| | | | | | | | | | clicking the update button (#34509) If user leaves the page, the context will become cancelled, so that the update process maybe terminal in an unexpected status. This PR haven't resolve the problem totally. It uses a background context to not cancel the update process even if the user leaved the pull request view page. Fix #31779
* Do not mutate incoming options to SearchRepositoryByName (#34553)Philip Peterson2025-06-023-4/+4
| | | | | | | | | | | | | | Similar to #34544, this PR changes the `opts` argument in `SearchRepositoryByName()` to be passed by value instead of by pointer, as its mutations do not escape the function scope and are not used elsewhere. This simplifies reasoning about the function and avoids unnecessary pointer usage. This insight emerged during an initial attempt to refactor `RenderUserSearch()`, which currently intermixes multiple concerns. --------- Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
* Do not mutate incoming options to RenderUserSearch and SearchUsers (#34544)Philip Peterson2025-05-274-4/+4
| | | | | | | | | | | This PR changes the `opts` argument in `SearchUsers()` to be passed by value instead of by pointer, as its mutations do not escape the function scope and are not used elsewhere. This simplifies reasoning about the function and avoids unnecessary pointer usage. This insight emerged during an initial attempt to refactor `RenderUserSearch()`, which currently intermixes multiple concerns. Co-authored-by: Philip Peterson <philip-peterson@users.noreply.github.com>
* Split GetLatestCommitStatus as two functions (#34535)Lunny Xiao2025-05-261-3/+8
| | | | | | | | Extract from #34531. This will reduce unnecessary count operation in databases. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add sort option recentclose for issues and pulls (#34525)Markus Amshove2025-05-261-1/+1
| | | | | | closes #34171 Adds a new sort option `recentclose` for issues and pull requests which will return items in a descending order of when they were closed
* fix: return 201 Created for CreateVariable API responses (#34517)Bo-Yi Wu2025-05-263-17/+15
| | | | | | | | | | | | | | | | | | | - Change CreateVariable API response status from 204 No Content to 201 Created - Update related integration tests to expect 201 Created instead of 204 No Content ## :warning: BREAKING :warning: Change the response status code of the Create Variable API under both Org and Repo levels to `201` instead of 204. API SDK: https://gitea.com/gitea/go-sdk/pulls/713 --------- Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com> Signed-off-by: appleboy <appleboy.tw@gmail.com> Co-authored-by: delvh <dev.lh@web.de>
* feat(api): add date range filtering to commit retrieval endpoints (#34497)Bo-Yi Wu2025-05-191-1/+35
| | | | | | | | | | | | | | | - Add support for filtering commits by date range via new "since" and "until" parameters - Update API endpoints and command logic to handle the new parameters for fetching commits within given dates - Extend API documentation and Swagger specs to describe the new "since" and "until" query parameters - Refactor related function signatures and implementations to accept and pass "since" and "until" values --------- Signed-off-by: appleboy <appleboy.tw@gmail.com> Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* Fix edithook api can not update package, status and workflow_job events (#34495)ChristopherHX2025-05-181-55/+37
| | | * the origin of this problem is duplicated code
* Fix url validation in webhook add/edit API (#34492)Lunny Xiao2025-05-173-0/+112
|
* Fix get / delete runner to use consistent http 404 and 500 status (#34480)ChristopherHX2025-05-161-18/+27
| | | | * previously deleting an already deleted runner returned http 500 * previously any database error for the get endpoint was http 404 and never 500
* Add endpoint deleting workflow run (#34337)NorthRealm2025-05-132-1/+56
| | | | | | | | | | | Add endpoint deleting workflow run Resolves #26219 /claim #26219 --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix bug webhook milestone is not right. (#34419)Lunny Xiao2025-05-112-0/+14
| | | | | | | Fix #34400 --------- Co-authored-by: silverwind <me@silverwind.io>
* When updating comment, if the content is the same, just return and not ↵Lunny Xiao2025-05-111-8/+10
| | | | | update the databse (#34422) Fix #34318
* Fix bug when API get pull changed files for deleted head repository (#34333)Lunny Xiao2025-05-041-1/+3
|
* feat: return time of last usage for public keys and access tokens in the api ↵Tobias Balle-Petersen2025-05-011-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | (#34323) In the Gitea GUI, the user can see the time that _AccessTokens_ and _PublicKeys_ were last used. This information is not returned by the _/users/{username}/tokens_ and _/user/keys_ endpoints in the API. This PR adds the missing data. The time of last usage for for _tokens_ & _keys_ seem to be stored in the _Updated_ field of the structs internally. For consistency, I have used the name _updated_at_ for the new field returned by the _API_. However, for the _API_ user, I don't think that name reflects the data returned, as I believe it is the time of last usage. I propose that we use the name _last_used_at_ instead. Let's hear reviewers opinion on that. * PublicKey 1. _last_used_at_: string($date-time) * AccessToken 1. _created_at_: string($date-time) (for parity with public keys) 2. _last_used_at_: string($date-time) Fix #34313
* Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)wxiaoguang2025-04-281-1/+25
| | | | | | | | | | | | | | | | | | | | | Fix #880 Design: 1. A global setting `security.TWO_FACTOR_AUTH`. * To support org-level config, we need to introduce a better "owner setting" system first (in the future) 2. A user without 2FA can login and may explore, but can NOT read or write to any repositories via API/web. 3. Keep things as simple as possible. * This option only aggressively suggest users to enable their 2FA at the moment, it does NOT guarantee that users must have 2FA before all other operations, it should be good enough for real world use cases. * Some details and tests could be improved in the future since this change only adds a check and seems won't affect too much. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Option to delay conflict checking of old pull requests until page view (#27779)Brecht Van Lommel2025-04-241-2/+10
| | | | | | | | | | | | | | | | | | | | | | `[repository.pull-request] DELAY_CHECK_FOR_INACTIVE_DAYS` is a new setting to delay the mergeable check for pull requests that have been inactive for the specified number of days. This avoids potentially long delays for big repositories with many pull requests. and reduces system load overall when there are many repositories or pull requests. When viewing the PR, checking will start immediately and the PR merge box will automatically reload when complete. Accessing the PR through the API will also start checking immediately. The default value of `7` provides a balance between system load, and keeping behavior similar to what it was before both for users and API access. With `0` all conflict checking will be delayed, while `-1` always checks immediately to restore the previous behavior. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Improve "not found" error messages for API (#34267)wxiaoguang2025-04-234-6/+5
| | | Make the message clear, for example: #34266
* Add API endpoint to request contents of multiple files simultaniously (#34139)Denys Konovalov2025-04-226-104/+168
| | | | | | | | | | | | | | | | Adds an API POST endpoint under `/repos/{owner}/{repo}/file-contents` which receives a list of paths and returns a list of the contents of these files. This API endpoint will be helpful for applications like headless CMS (reference: https://github.com/sveltia/sveltia-cms/issues/198) which need to retrieve a large number of files by reducing the amount of needed API calls. Close #33495 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add API routes to lock and unlock issues (#34165)YaFou2025-04-213-0/+160
| | | | | | | | | | | | | | | This pull request adds a GitHub-compatible API endpoint to lock and unlock an issue. The following routes exist now: - `PUT /api/v1/repos/{owner}/{repo}/issues/{id}/lock` to lock an issue - `DELETE /api/v1/repos/{owner}/{repo}/issues/{id}/lock` to unlock an issue Fixes #33677 Fixes #20012 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Don't assume the default wiki branch is master in the wiki API (#34244)Kemal Zebari2025-04-191-4/+4
| | | | | | Resolves #34218. In the recent past, the default wiki branch was made to be changeable. This change reflects this.
* Actions Runner rest api (#33873)ChristopherHX2025-04-187-1/+490
| | | | | | | | | | | | | | | | | | | | | | | | | Implements runner apis based on https://docs.github.com/en/rest/actions/self-hosted-runners?apiVersion=2022-11-28#list-self-hosted-runners-for-an-organization - Add Post endpoints for registration-token, google/go-github revealed this as problem - We should deprecate Get Endpoints, leaving them for compatibility - Get endpoint of admin has api path /admin/runners/registration-token that feels wrong, /admin/actions/runners/registration-token seems more consistent with user/org/repo api - Get Runner Api - List Runner Api - Delete Runner Api - Tests admin / user / org / repo level endpoints Related to #33750 (implements point 1 and 2) Via needs discovered in #32461, this runner api is needed to allow cleanup of runners that are deallocated without user interaction. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix bug when migrating repository (#34182)Lunny Xiao2025-04-141-1/+1
| | | This PR fixed a bug which is a regression from #31035
* Add package version api endpoints (#34173)KN4CK3R2025-04-132-24/+148
| | | | | | | | | Fixes #33544 Adds two new api endpoints to list a versions of a package and to get the latest version of a package by API. ⚠️ BREAKING ⚠️ the `size` field for this endpoint changes from `Size` to `size`.
* Allow admins and org owners to change org member public status (#28294)Tomeamis2025-04-131-4/+19
| | | | | | | | | | | | | | Allows admins and org owners to change org member public status. Before, this would return `Error 403: Cannot publicize another member` despite the fact that the same user could make the same change through the GUI. Fixes #28372 --------- Co-authored-by: Tomáš Ženčák <zencak@ica.cz> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix team permission (#34128)wxiaoguang2025-04-082-26/+12
| | | | The `team.access_mode` should be either `none` or `admin/owner`. For non-admin team, the real permissions are provided by `team_unit`.
* Avoid creating unnecessary temporary cat file sub process (#33942)Lunny Xiao2025-04-041-1/+1
| | | | | | | | | | | | | Extract from #33934 In the same goroutine, we should reuse the exist cat file sub process which exist in `git.Repository` to avoid creating a unnecessary temporary subprocess. This PR reuse the exist cate file writer and reader in `getCommitFromBatchReader`. It also move `prepareLatestCommitInfo` before creating dataRc which will hold the writer so other git operation will create a temporary cat file subprocess.
* Refactor markup render to fix various path problems (#34114)wxiaoguang2025-04-041-5/+5
| | | | | | | | | | | * Fix #33972 * Use consistent path resolving for links and medias. * No need to make the markup renders to resolve the paths, instead, the paths are all correctly resolved in the "post process" step. * Fix #33274 * Since 1.23, all paths starting with "/" are relative to current render context (for example: the current repo branch) * Introduce `/:root/path-relative-to-root`, then the path will be rendered as relative to "ROOT_URL"
* Refactor Branch struct in package modules/git (#33980)Lunny Xiao2025-04-022-24/+11
| | | | The `Branch` struct in `modules/git` package is unnecessary. We can just use a `string` to represent a branch
* Fix return bug (#34093)Lunny Xiao2025-04-011-1/+1
| | | Fix https://github.com/go-gitea/gitea/pull/34031/files#r2021927997