0
0
mirror of https://github.com/go-gitea/gitea.git synced 2025-04-15 08:32:44 +02:00

4345 Commits

Author SHA1 Message Date
KN4CK3R
a2651c14ce
Add cache for common package queries (#22491)
This adds a cache for common package queries in `GetPackageDescriptor`.
Code which needs to process a list of packages benefits from this
change. This skips 350 queries in the package integration tests for
example.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-13 09:40:36 +00:00
hiifong
aada0370e7
fix webhook url (#34186)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-13 02:24:32 +00:00
Thomas E Lackey
fa49cd719f
feat: Add sorting by exclusive labels (issue priority) (#33206)
Fix #2616

This PR adds a new sort option for exclusive labels.

For exclusive labels, a new property is exposed called "order", while in
the UI options are populated automatically in the `Sort` column (see
screenshot below) for each exclusive label scope.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-10 17:18:07 +00:00
Lunny Xiao
4a5af4edca
Cache GPG keys, emails and users when list commits (#34086)
When list commits, some of the commits authors are the same at many
situations. But current logic will always fetch the same GPG keys from
database. This PR will cache the GPG keys, emails and users for the
context so that reducing the database queries.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-09 16:34:38 +00:00
Lunny Xiao
32b97b3ce8
Uniform all temporary directories and allow customizing temp path (#32352)
This PR uniform all temporary directory usage so that it will be easier
to manage.

Relate to #31792 

- [x] Added a new setting to allow users to configure the global
temporary directory.
- [x] Move all temporary files and directories to be placed under
os.Temp()/gitea.
- [x] `setting.Repository.Local.LocalCopyPath` now will be
`setting.TempPath/local-repo` and the customized path is removed.
```diff
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;[repository.local]
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;
-;; Path for local repository copy. Defaults to  TEMP_PATH + `local-repo`, this is deprecated and cannot be changed
-;LOCAL_COPY_PATH = local-repo
```

- [x] `setting.Repository.Upload.TempPath` now will be
`settting.TempPath/uploads` and the customized path is removed.
```diff
;[repository.upload]
-;;
-;; Path for uploads. Defaults to TEMP_PATH + `uploads`
-;TEMP_PATH = uploads
```

- [x] `setting.Packages.ChunkedUploadPath` now will be
`settting.TempPath/package-upload` and the customized path is removed.
```diff
;[packages]
-;;
-;; Path for chunked uploads. Defaults it's `package-upload` under `TEMP_PATH` unless it's an absolute path.
-;CHUNKED_UPLOAD_PATH = package-upload
```

- [x] `setting.SSH.KeyTestPath` now will be
`settting.TempPath/ssh_key_test` and the customized path is removed.
```diff
[server]
-;;
-;; Directory to create temporary files in when testing public keys using ssh-keygen,
-;; default is the system temporary directory.
-;SSH_KEY_TEST_PATH =
```

TODO:
- [ ] setting.PprofDataPath haven't been changed because it may need to
be kept until somebody read it but temp path may be clean up any time.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-08 16:15:28 +00:00
DrMaxNix
fd7c364ca6
Check user/org repo limit instead of doer (#34147)
This PR tries to finally fix the bug mentioned in #30011 and #15504,
where the user repo limit is checked when creating a repo in an
organization.

Fix #30011

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: TheFox0x7 <thefox0x7@gmail.com>
2025-04-07 23:45:31 -07:00
Lunny Xiao
a100ac3306
Rework create/fork/adopt/generate repository to make sure resources will be cleanup once failed (#31035)
Fix #28144 

To make the resources will be cleanup once failed. All repository
operations now follow a consistent pattern:

- 1. Create a database record for the repository with the status
being_migrated.
- 2. Register a deferred cleanup function to delete the repository and
its related data if the operation fails.
- 3.	Perform the actual Git and database operations step by step.
- 4. Upon successful completion, update the repository’s status to
ready.

The adopt operation is a special case — if it fails, the repository on
disk should not be deleted.
2025-04-07 22:12:54 -07: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
wxiaoguang
e1c2d05bde
Fix markdown render behaviors (#34122)
* Fix #27645
* Add config options `MATH_CODE_BLOCK_DETECTION`, problematic syntaxes
are disabled by default
* Fix #33639
    * Add config options `RENDER_OPTIONS_*`, old behaviors are kept
2025-04-05 11:56:48 +08: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
Kemal Zebari
55a69ae4c6
Add new CLI flags to set name and scopes when creating a user with access token (#34080)
Resolves #33474.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-02 22:00:54 +08:00
Lunny Xiao
88352e0b25
Return default avatar url when user id is zero rather than updating database (#34094) 2025-04-02 01:03:27 +00:00
Lunny Xiao
92dfec704f
Move ParseCommitWithSSHSignature to service layer (#34087)
No code change.
2025-04-01 16:30:53 +00: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
Lunny Xiao
a2e8a289b2
Improve pull request list api (#34052)
The pull request list API is slow, for every pull request, it needs to
open a git repository. Assume it has 30 records, there will be 30 sub
processes back because every repository will open a git cat-file --batch
sub process. This PR use base git repository to get the head commit id
rather than read it from head repository to avoid open any head git
repository.
2025-03-31 12:54:31 -07: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
TheFox0x7
2a59dfbd47
enable staticcheck QFxxxx rules (#34064) 2025-03-29 17:32:28 -04:00
wxiaoguang
cddd19efc8
Add anonymous access support for private/unlisted repositories (#34051)
Follow #33127

Fix #8649, fix #639

This is a complete solution. A repo unit could be set to:

* Anonymous read (non-signed-in user)
* Everyone read (signed-in user)
* Everyone write (wiki-only)
2025-03-29 13:26:41 +08:00
wxiaoguang
0d2607a303
Add anonymous access support for private repositories (backend) (#33257)
Follow #33127

This PR add backend logic and test for "anonymous access", it shares the
same logic as "everyone access", so not too much change.

By the way, split `SettingsPost` into small functions to make it easier
to make frontend-related changes in the future.

Next PR will add frontend support for "anonymous access"
2025-03-28 22:42:29 +08: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
wxiaoguang
51d86adb6d
Fix some migration and repo name problems (#33986)
1. Ignore empty inputs in `UnmarshalHandleDoubleEncode`
2. Ignore non-existing `stateEvent.User` in gitlab migration
3. Enable `release` and `wiki` units when they are selected in migration
4. Sanitize repo name for migration and new repo
2025-03-24 20:26:58 -07:00
Lunny Xiao
3fe449c21a
Use filepath.Join instead of path.Join for file system file operations (#33978) 2025-03-24 14:50:28 -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
a4df01b580
Optimize total count of feed when loading activities in user dashboard. (#33841)
Two SQLs are very slow when `action` table have over 5M records.

```
database duration=1.8881s db.sql="SELECT created_unix DIV 900 * 900 AS timestamp, count(user_id) as contributions FROM `action` WHERE user_id=? AND act_user_id=? AND (created_unix > ?) GROUP BY timestamp ORDER BY timestamp"

database duration=1.5408s db.sql="SELECT count(*) FROM `action` WHERE (user_id = ?) AND (is_deleted = ?)"
```

This will cache the count for the first loading or when the activities
changed.
2025-03-20 10:46:18 -07:00
Lunny Xiao
4a7ab0abf0
Optimize heatmap query (#33853)
When there are over 5M records on `action` table, the heatmap on
dashboard is very slow as below SQL.
```
database duration=1.8881s db.sql="SELECT created_unix DIV 900 * 900 AS timestamp, count(user_id) as contributions FROM `action` WHERE user_id=? AND act_user_id=? AND (created_unix > ?) GROUP BY timestamp ORDER BY timestamp"
```

This PR add a new index for `action` table with columns `user_id`,
`act_user_id` and `created_unix` so that this query will become about 6
times faster than before.
2025-03-20 09:30:45 -07: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
Lunny Xiao
c88e71c1d2
Refactor functions to reduce repopath expose (#33892) 2025-03-16 03:14:56 +00:00
Job
30b13942f0
Give organisation members access to organisation feeds (#33508)
Currently the organisation feed only includes items for public
repositories (for non-administrators). This pull requests adds
notifications from private repositories to the organisation-feed (for
accounts that have access to the organisation).

Feed-items only get shown for repositories where the users team(s)
should have access to, this filtering seems to get done by some existing
code.

Needs some tests, but am unsure where/how to add them.

Before:

![image](https://github.com/user-attachments/assets/8b63f430-227a-4b19-ad1a-f6f5175de301)

After:

![image](https://github.com/user-attachments/assets/b439ce0e-4946-421c-a399-421806c7a6d8)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-15 17:49:06 +00:00
Kerwin Bryant
92f997ce6b
Add file tree to file view page (#32721)
Resolve #29328

This pull request introduces a file tree on the left side when reviewing
files of a repository.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-15 16:26:49 +08:00
ChristopherHX
65e2411394
Feature: Ephemeral action runners (#33570)
* This includes a runner mock test for hardend PickTask behavior like
described in my proposal
* Runner register ephemeral flag introduced in
https://gitea.com/gitea/act_runner/pulls/649

Closes #32461
2025-03-14 12:27:24 -07:00
ChristopherHX
651ef66966
Add workflow_job webhook (#33694)
Provide external Integration information about the Queue lossly based on
https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=completed#workflow_job

Naming conflicts between GitHub & Gitea are here, Blocked => Waiting,
Waiting => Queued

Rationale Enhancement for ephemeral runners management #33570
2025-03-11 10:40:38 -07:00
ChristopherHX
a92d5f65ce
Fix auto concurrency cancellation skips commit status updates (#33764)
* add missing commit status
* conflicts with concurrency support

Closes #33763

Co-authored-by: Giteabot <teabot@gitea.io>
2025-03-10 15:58:48 -07:00
Lunny Xiao
ae63568ce3
Move notifywatch to service layer (#33825)
No logic change.
2025-03-10 00:54:25 +00:00
TheFox0x7
4c4c56c7cd
Decouple context from repository related structs (#33823)
Calls that required context implicitly are made to pass it as argument
2025-03-08 13:12:46 -08:00
wxiaoguang
4ed71eb754
Improve log format (#33814) 2025-03-08 21:47:11 +08:00
Lunny Xiao
1b2dffff8e
Add global lock for migrations to make upgrade more safe with multiple replications (#33706) 2025-03-07 21:08:53 +00:00
TheFox0x7
ae3a18e01a
Remove context from git struct (#33793)
Argument is moved from struct init in command run, which lets us remove
context from struct.
2025-03-04 11:56:11 -08:00
Lunny Xiao
6c8fb8d455
Small refactor to reduce unnecessary database queries and remove duplicated functions (#33779) 2025-03-04 18:25:20 +00:00
wxiaoguang
216243eee2
Refactor error system (#33771)
It should not expose `util.SilentWrap` or construct it manually.
2025-03-03 05:36:10 +00:00
Lunny Xiao
dbed39d632
Add migrations and doctor fixes (#33556)
Fix #33535
2025-03-02 21:01:28 -08:00
Lunny Xiao
5cbdf83f70
Use pullrequestlist instead of []*pullrequest (#33765)
Just renames no code changed.
2025-03-02 10:14:49 -08:00
Lunny Xiao
aca21549f2
Add composor source field (#33502)
Fix #33066
2025-02-28 16:29:21 +00:00
Guillaume
303af554c9
Improve "generate new access token" form (#33730)
Fix: https://github.com/go-gitea/gitea/issues/33519

As discussed in [PR
#33614](https://github.com/go-gitea/gitea/pull/33614), the
ScopedAccessTokenSelector Vue component is not particularly useful.

This PR removes the component and reverts to using HTML templates. It
also introduces some (hopefully) useful refactoring.

The Vue component was causing the UX bug reported in the linked issue.
Required form fields are now properly working, as expected (see
screenshot).

![Screenshot from 2025-02-25
22-00-28](https://github.com/user-attachments/assets/41167854-0718-48b0-a3ee-75ca3a7b8b20)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-02-27 19:40:12 +00:00
Quentin
f52e31f5ce
Clone repository with Tea CLI (#33725)
This PR adds "Tea CLI" as a clone method.

<img width="350" alt="Capture d’écran 2025-02-25 à 23 38 47"
src="https://github.com/user-attachments/assets/8e86e54a-998b-45d1-9f20-167b449e79b6"
/>

---------

Signed-off-by: Quentin Guidée <quentin.guidee@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-02-27 18:18:02 +00:00
Royce Remer
b7aac5ef9a
allow filtering /repos/{owner}/{repo}/pulls by target base branch queryparam (#33684)
Co-authored-by: Royce Remer <rremer@salesforce.com>
Co-authored-by: delvh <dev.lh@web.de>
2025-02-27 17:50:44 +00:00
Lunny Xiao
76b7f95a27
Optimize user dashboard loading (#33686)
Fix #33582
Fix #31698

When a user login, the dashboard should load all feed belongs to him
with no any conditions. The complicated conditions should be applied
only for another user view this user's profile.
2025-02-24 11:29:32 -08:00
wxiaoguang
8ae46d9684
Fix some user name usages (#33689)
1. GetUserOrgsList should "order by" lower_name
2. GetIssuePostersWithSearch should search in-case-sensitive-ly
3. LoginName should not be used as username

By the way, remove unnecessary "onGiteaRun"
2025-02-23 12:33:43 +00:00