Commit Graph

1580 Commits (main)

Author SHA1 Message Date
wxiaoguang 6b8b580218
Refactor container and UI (#34736) 2025-06-16 16:27:01 +08:00
wxiaoguang 637070e07b
Fix container range bug (#34725)
Fix #34724
2025-06-15 21:55:11 +03:00
ChristopherHX c9505a26b9
Improve instance wide ssh commit signing (#34341)
* 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>
2025-06-11 10:32:55 +00:00
wxiaoguang 0082cb51fa
Fix last admin check when syncing users (#34649)
Fix #34358
2025-06-09 20:57:45 +00:00
wxiaoguang 7b39c82587
Fix "oras" OCI client compatibility (#34666)
Fix #25846

1. the ImageConfig can be empty, fall back to default
2. the blob size can be empty, it still needs "Content-Length" header
2025-06-09 18:51:05 +00:00
wxiaoguang 7a59f5a825
Ignore "Close" error when uploading container blob (#34620) 2025-06-09 07:06:21 +00:00
wxiaoguang f6041441ee
Refactor FindOrgOptions to use enum instead of bool, fix membership visibility (#34629) 2025-06-09 03:30:34 +00:00
Lunny Xiao 108db0b04f
Fix possible pull request broken when leave the page immediately after 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
2025-06-04 17:09:08 +00:00
Philip Peterson c5e78fc7ad
Do not mutate incoming options to SearchRepositoryByName (#34553)
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>
2025-06-02 17:33:25 +00:00
wxiaoguang e8d8984f7c
Fix some trivial problems (#34579) 2025-06-02 15:22:43 +00:00
Philip Peterson b0936f4f41
Do not mutate incoming options to RenderUserSearch and SearchUsers (#34544)
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>
2025-05-27 19:36:02 +00:00
Lunny Xiao 688da55f54
Split GetLatestCommitStatus as two functions (#34535)
Extract from #34531. This will reduce unnecessary count operation in
databases.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-05-26 19:00:22 +00:00
Markus Amshove 50d9565088
Add sort option recentclose for issues and pulls (#34525)
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
2025-05-26 16:37:38 +00:00
Bo-Yi Wu 11ee7ff3bf
fix: return 201 Created for CreateVariable API responses (#34517)
- 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

## ⚠️ BREAKING ⚠️

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>
2025-05-26 12:12:49 -04:00
Bo-Yi Wu d06eb8d801
feat(api): add date range filtering to commit retrieval endpoints (#34497)
- 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>
2025-05-19 18:57:58 -07:00
ChristopherHX d89eed998f
Fix edithook api can not update package, status and workflow_job events (#34495)
* the origin of this problem is duplicated code
2025-05-18 09:43:56 -07:00
Lunny Xiao 972381097c
Fix url validation in webhook add/edit API (#34492) 2025-05-17 20:05:55 +00:00
ChristopherHX 59df03b554
Fix get / delete runner to use consistent http 404 and 500 status (#34480)
* previously deleting an already deleted runner returned http 500
* previously any database error for the get endpoint was http 404 and never 500
2025-05-16 06:44:29 +00:00
NorthRealm 1e2f3514b9
Add endpoint deleting workflow run (#34337)
Add endpoint deleting workflow run
Resolves #26219

/claim #26219

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-05-13 19:18:13 +00:00
Lunny Xiao 34281bc198
Fix bug webhook milestone is not right. (#34419)
Fix #34400

---------

Co-authored-by: silverwind <me@silverwind.io>
2025-05-11 23:56:24 +00:00
Lunny Xiao b07e03956a
When updating comment, if the content is the same, just return and not update the databse (#34422)
Fix #34318
2025-05-11 18:53:23 +00:00
Lunny Xiao 51aafb4278
Fix bug when API get pull changed files for deleted head repository (#34333) 2025-05-04 19:17:17 +00:00
Tobias Balle-Petersen 3e49fba578
feat: return time of last usage for public keys and access tokens in the api (#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
2025-05-01 21:42:17 +03:00
wxiaoguang 0148d03f21
Enforce two-factor auth (2FA: TOTP or WebAuthn) (#34187)
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>
2025-04-28 15:31:59 -07:00
ChristopherHX 4ed07244b9
actions artifacts api list/download check status upload confirmed (#34273)
* fixes a fixture status to upload confirmed
* add another fixture as noise to break tests as soon they are exposed
to api
* v4 delete test added check that artifact is no longer visible in
internal api with status pending delete
* removal of http 404 on empty list: actions/upload-artifact@v4 now
backoff on http 404 of ListArtifacts endpoint
* fixes artifacts with pending delete etc. are able to be found and
downloaded if the storage is not freed
2025-04-28 16:31:53 +00:00
Brecht Van Lommel a9343896f4
Option to delay conflict checking of old pull requests until page view (#27779)
`[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>
2025-04-24 19:26:57 +00:00
wxiaoguang 8aee07a064
Improve "not found" error messages for API (#34267)
Make the message clear, for example: #34266
2025-04-23 17:42:50 +08:00
Denys Konovalov 9a071a596f
Add API endpoint to request contents of multiple files simultaniously (#34139)
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>
2025-04-22 01:20:11 +08:00
YaFou e947f309b1
Add API routes to lock and unlock issues (#34165)
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>
2025-04-21 00:43:43 +00:00
Kemal Zebari f0544dbfca
Don't assume the default wiki branch is master in the wiki API (#34244)
Resolves #34218.

In the recent past, the default wiki branch was made to be changeable.
This change reflects this.
2025-04-19 03:13:00 +00:00
ChristopherHX 21b43fce08
Actions Runner rest api (#33873)
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>
2025-04-18 15:22:41 +00:00
wxiaoguang ba0deab616
Fix some trivial problems (#34237)
1. Using existing "content" variable in `swift.go`
2. Do not report 500 server error in `GetPullDiffStats` middleware,
otherwise a PR missing ref won't be able to view.
3. Fix the abused "label button" when listing commits, there was too
much padding space, see the screenshot below.
2025-04-18 22:56:50 +08:00
Wolfgang Reithmeier 2683adfcb4
Swift files can be passed either as file or as form value (#34068)
Fix #33990

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-18 20:09:56 +08:00
Lunny Xiao f6474cf2e9
Fix bug when migrating repository (#34182)
This PR fixed a bug which is a regression from #31035
2025-04-14 04:48:03 +00:00
KN4CK3R bec9233c29
Add package version api endpoints (#34173)
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`.
2025-04-13 20:00:44 +00:00
Tomeamis 4dca869ed1
Allow admins and org owners to change org member public status (#28294)
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>
2025-04-13 08:07:29 +00:00
wxiaoguang 07c6087878
Fix team permission (#34128)
The `team.access_mode` should be either `none` or `admin/owner`.
For non-admin team, the real permissions are provided by `team_unit`.
2025-04-08 04:15:15 +00:00
Lunny Xiao 7a09bc904a
Avoid creating unnecessary temporary cat file sub process (#33942)
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.
2025-04-04 16:19:19 -07:00
wxiaoguang 6cee3bfa96
Refactor markup render to fix various path problems (#34114)
* 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"
2025-04-04 23:45:23 +08:00
Lunny Xiao c27d87a9ac
Refactor Branch struct in package modules/git (#33980)
The `Branch` struct in `modules/git` package is unnecessary. We can just
use a `string` to represent a branch
2025-04-02 17:31:32 +00:00
Lunny Xiao 0668cce4e8
Fix return bug (#34093)
Fix https://github.com/go-gitea/gitea/pull/34031/files#r2021927997
2025-04-01 17:36:46 -04:00
TheFox0x7 ee3c82f874
Enable addtional linters (#34085)
enable mirror, usestdlibbars and perfsprint 
part of: https://github.com/go-gitea/gitea/issues/34083

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-01 10:14:01 +00:00
TheFox0x7 4d2323183d
fix users being able bypass limits with repo transfers (#34031)
prevent user from being able to transfer repo to user who cannot have
more repositories
2025-03-31 20:19:32 +00:00
TheFox0x7 0fde8ecd55
Enable testifylint rules (#34075)
enable testifylint rules disabled in:
https://github.com/go-gitea/gitea/pull/34054
2025-03-31 01:53:48 -04:00
wxiaoguang b59705fa34
Add a config option to block "expensive" pages for anonymous users (#34024)
Fix #33966

```
;; User must sign in to view anything.
;; It could be set to "expensive" to block anonymous users accessing some pages which consume a lot of resources,
;; for example: block anonymous AI crawlers from accessing repo code pages.
;; The "expensive" mode is experimental and subject to change.
;REQUIRE_SIGNIN_VIEW = false
```
2025-03-30 05:26:19 +00:00
TheFox0x7 2a59dfbd47
enable staticcheck QFxxxx rules (#34064) 2025-03-29 17:32:28 -04:00
Lunny Xiao 0c6957ef8d
Download actions job logs from API (#33858)
Related to #33709, #31416

It's similar with
https://docs.github.com/en/rest/actions/workflow-jobs?apiVersion=2022-11-28#download-job-logs-for-a-workflow-run--code-samples.

This use `job_id` as path parameter which is consistent with Github's
APIs.

---------

Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-26 11:30:52 -07:00
Andreas Svanberg 0da7318cf3
Allow filtering issues by any assignee (#33343)
This is the opposite of the "No assignee" filter, it will match all
issues that have at least one assignee.

Before
![Before
change](https://github.com/user-attachments/assets/4aea194b-9add-4a84-8d6b-61bfd8d9e58e)

After
![After change with any
filter](https://github.com/user-attachments/assets/99f1205d-ba9f-4a0a-a60b-cc1a0c0823fe)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-21 04:25:36 +00:00
Lunny Xiao a9e8ac0fe0
Don't create duplicated functions for code repositories and wiki repositories (#33924)
Fix
https://github.com/go-gitea/gitea/pull/33910#pullrequestreview-2688913865

This PR changed the Repositroy interface in `gitrepo` package which
makes it only focus the relative path in the disk and abstract whether
it's a wiki repository or not.
2025-03-19 11:17:19 -07:00
John Smith 8f051d598c
Added Description Field for Secrets and Variables (#33526)
Fixes #33484

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-17 19:24:54 +00:00