Commit Graph

5008 Commits (main)

Author SHA1 Message Date
wxiaoguang 6b8b580218
Refactor container and UI (#34736) 2025-06-16 16:27:01 +08:00
Kerwin Bryant bbee652e29
Prevent duplicate form submissions when creating forks (#34714)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2025-06-16 04:19:16 +00:00
wxiaoguang 637070e07b
Fix container range bug (#34725)
Fix #34724
2025-06-15 21:55:11 +03:00
Lunny Xiao d21ce9fa07
Improve the performance when detecting the file editable (#34653)
Noticed the SQL will be executed 4 times when visit the file render view
page. For a repository which have many pull requests, it maybe slow.
```SQL
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 2.004167ms
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 1.03975ms
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 881.583µs
2025/06/08 15:24:44 models/issues/pull_list.go:69:GetUnmergedPullRequestsByHeadInfo() [I] [SQL] SELECT * FROM `pull_request` INNER JOIN `issue` ON issue.id = pull_request.issue_id WHERE (head_repo_id = ? AND head_branch = ? AND has_merged = ? AND issue.is_closed = ? AND flow = ?) [393 main false false 0] - 935.084µs
```

This PR did a refactor to query it once only.
2025-06-12 18:12:45 +00:00
wxiaoguang 8fed27bf6a
Fix various problems (#34708)
* Fix #34707
* Fix dropdown filter handling
* Fix #27014
2025-06-12 09:19:24 -07: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
charles c6b2cbd75d
Fix footnote jump behavior on the issue page. (#34621)
Close #34511 
Close #34590 

Add comment ID to the footnote item's id attribute to ensure uniqueness.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-09 17:18:11 +00:00
Lunny Xiao 9165ea8713
Only activity tab needs heatmap data loading (#34652) 2025-06-09 21:02:16 +08:00
wxiaoguang 7a59f5a825
Ignore "Close" error when uploading container blob (#34620) 2025-06-09 07:06:21 +00:00
Lunny Xiao 6d0b24064a
Keeping consistent between UI and API about combined commit status state and fix some bugs (#34562)
Extract from #34531 

## Move Commit status state to a standalone package

Move the state from `structs` to `commitstatus` package. It also
introduce `CommitStatusStates` so that the combine function could be
used from UI and API logic.

## Combined commit status Changed

This PR will follow Github's combined commit status. Before this PR,
every commit status could be a combined one.
According to
https://docs.github.com/en/rest/commits/statuses?apiVersion=2022-11-28#get-the-combined-status-for-a-specific-reference
> Additionally, a combined state is returned. The state is one of:
> failure if any of the contexts report as error or failure
> pending if there are no statuses or a context is pending
> success if the latest status for all contexts is success

This PR will follow that rule and remove the `NoBetterThan` logic. This
also fixes the inconsistent between UI and API. In the API convert
package, it has implemented this which is different from the UI. It also
fixed the missing `URL` and `CommitURL` in the API.

## `CalcCommitStatus` return nil if there is no commit statuses

The behavior of `CalcCommitStatus` is changed. If the parameter commit
statuses is empty, it will return nil. The reference places should check
the returned value themselves.
2025-06-09 04:05:33 +00:00
wxiaoguang f6041441ee
Refactor FindOrgOptions to use enum instead of bool, fix membership visibility (#34629) 2025-06-09 03:30:34 +00:00
Kemal Zebari 47d69b7749
Validate hex colors when creating/editing labels (#34623)
Resolves #34618.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-06-07 11:25:08 +03: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
Lunny Xiao 4e471487fb
Remove unnecessary duplicate code (#34552)
`GetIssuesLastCommitStatus` will revoke `GetIssuesAllCommitStatus` but
it has been invoked. The `CommitStatus` template variable has never been
used in notification subscription page so that it could be removed.
2025-06-03 16:27:29 +00:00
wxiaoguang 2a1585b32e
Refactor some tests (#34580)
1. use `test.MockVariableValue` as much as possible
2. avoid `time.Sleep` as much as possible
2025-06-03 01:26:19 +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
NorthRealm 4cb0c641ce
Add "View workflow file" to Actions list page (#34538)
This PR adds "View workflow file" to Actions list page, and replaces the
redundant link.

Related #34530

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-05-28 20:30:00 +08: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 dd500ce559
Fix Workflow run Not Found page (#34459)
Related:
https://github.com/go-gitea/gitea/pull/34337#issuecomment-2863593738
https://github.com/go-gitea/gitea/pull/34337#discussion_r2086332493
2025-05-14 14:40:10 -07: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
wxiaoguang 5cb4cbf044
Fix repo broken check (#34444)
Fix #34424
2025-05-13 08:18:45 +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 780e92ea99
Only git operations should update `last changed` of a repository (#34388)
Try to fix #32046
2025-05-11 19:18:46 +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 ad271444e9
Fix a bug when uploading file via lfs ssh command (#34408)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-05-09 16:17:08 +00:00
wxiaoguang 179068fddb
Refactor commit message rendering and fix bugs (#34412)
Fix #34398, fix #33308

Remove all `repo.ComposeCommentMetas` from templates,
only use `repo` to render commit message.
2025-05-09 20:42:35 +08:00
NorthRealm 4c611bf280
Add a button editing action secret (#34348)
Add a button editing action secret
Closes #34190

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-05-08 17:11:43 +00:00
NorthRealm 6b2c506e05
Grey out expired artifact on Artifacts list (#34314)
Grey out expired artifact on Artifacts list.

![1](https://github.com/user-attachments/assets/79c00e39-29f5-4264-b7b2-7ed638ab71c1)

![2](https://github.com/user-attachments/assets/686b745f-d6d7-4921-8e1b-3472ac8b6c17)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-05-05 21:53:17 -07:00
bytedream 12bf0b8e42
Fix only text/* being viewable in web UI (#34374)
Regression from #34356, files like SVGs should be editable too
(https://github.com/go-gitea/gitea/pull/34356#discussion_r2072766240).
2025-05-06 00:15:22 +03: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
Lunny Xiao 41f3d062a2
Fix bug when visiting comparation page (#34334)
The `ci.HeadGitRepo` was opened and closed in the function
`ParseCompareInfo` but reused in the function `PrepareCompareDiff`.
2025-05-04 18:52:00 +00:00
bytedream 180aa00abf
Fix LFS files being editable in web UI (#34356)
It's possible to edit "raw" lfs files in the web UI when accessing the path manually.

![image](https://github.com/user-attachments/assets/62610e9e-24db-45ec-ad04-28062073164c)
2025-05-04 11:23:28 -07: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
Kerwin Bryant 2b76993415
support the open-icon of folder (#34168)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-28 19:51:32 -07: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
wxiaoguang 9705adb27f
Make public URL generation configurable (#34250)
Follow up #32564

Co-authored-by: Jannis Pohl <838818+jannispl@users.noreply.github.com>
Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
2025-04-22 06:49:37 +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