Commit Graph

1622 Commits (6cee3bfa9611a691584824ea23a75cc1ebcbb46b)

Author SHA1 Message Date
KN4CK3R 8fed70afdc
Fix invalid version in RPM package path (#34112) 2025-04-03 19:00:00 +00:00
Lunny Xiao 45c45934aa
Add `last_committer_date` and `last_author_date` for file contents API (#32921)
Fix #32886

Add `last_committer_date` and `last_author_date` in the content API
which is not implemented by Github API v3 at the moment.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-04-02 21:47:31 -07: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
wxiaoguang 6ed1b26c58
Do not show 500 error when default branch doesn't exist (#34096)
Fix #34090
2025-04-01 21:39:00 -07: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
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
JonRB d7a6133825
add additional ReplaceAll in pathsep to cater for different pathsep (#34061)
The doctor storage check reconstructs the lfs oid by producing a string
where the path separator is stripped
ab/dc/efg -> abdcefg. Windows however uses a backslash and thus the
ReplaceAll call doesn't produce the correct oid resulting in all lfs
objects being classed as orphaned.
This PR allows this to be more OS agnostic.

Closes #34039

---------

Co-authored-by: Giteabot <teabot@gitea.io>
2025-03-30 12:46:28 +08: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
Royce Remer e0ad72e223
Fail mirroring more gracefully (#34002)
* reuse recoverable error checks across mirror_pull
* add new cases for 'cannot lock ref/not our ref' (race condition in
fetch) and 'Unable to create/lock"
* move lfs sync right after commit graph write, and before other
maintenance which may fail
* try a prune for 'broken reference' as well as 'not our ref'
* always sync LFS right after commit graph write, and before other
maintenance which may fail

This handles a few cases where our very large and very active
repositories could serve mirrored git refs, but be missing lfs files:

## Case 1 (multiple variants): Race condition in git fetch
There was already a check for 'unable to resolve reference' on a failed
git fetch, after which a git prune and then subsequent fetch are
performed. This is to work around a race condition where the git remote
tells Gitea about a ref for some HEAD of a branch, then fails a few
seconds later because the remote branch was deleted, or the ref was
updated (force push).

There are two more variants to the error message you can get, but for
the same kind of race condition. These *may* be related to the git
binary version Gitea has access to (in my case, it was 2.48.1).

## Case 2: githttp.go can serve updated git refs before it's synced lfs
oids

There is probably a more aggressive refactor we could do here to have
the cat-file loop use FETCH_HEAD instead of relying on the commit graphs
to be committed locally (and thus serveable to clients of Gitea), but a
simple reduction in the occurrences of this for me was to move the lfs
sync block immediately after the commit-graph write and before any other
time-consuming (or potentially erroring/exiting) blocks.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-26 18:04:46 +00:00
Lunny Xiao 356b707dde
Git client will follow 301 but 307 (#34005)
Fix #28460

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-25 07:20:08 +00: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
Lunny Xiao 30ee082e48
Only use prev and next buttons for pagination on user dashboard (#33981)
The pagination on the user dashboard sounds unnecessary, this will
change it to a prev/next buttons. For instances with around `10 million`
records in the action table, this option affects how the user dashboard
is loaded on first visit.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Giteabot <teabot@gitea.io>
2025-03-23 19:52:43 +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 ef0970506f
Extract code to their own functions for push update (#33944) 2025-03-20 16:57:04 +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
wxiaoguang 9d7c02f9f7
Try to figure out attribute checker problem (#33901)
For #31600
2025-03-17 11:59:34 -07:00
Lunny Xiao 7fd44a85ca
Move hooks function to gitrepo and reduce expose repopath (#33890)
Extract from #28966 
Follow #33874
2025-03-16 16:12:55 +00:00
Lunny Xiao c88e71c1d2
Refactor functions to reduce repopath expose (#33892) 2025-03-16 03:14:56 +00:00
Lunny Xiao 0056fdb942
Move git references checking to gitrepo packages to reduce expose of repository path (#33891) 2025-03-15 19:48:59 -07:00
Lunny Xiao 3e2e7bf4e5
Add lock for a repository pull mirror (#33876)
Fix #33647

This PR add a global lock for repository pulling mirror.
2025-03-15 10:23:18 -07: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
Lunny Xiao 55cc649d3d
Add abstraction layer to delete repository from disk (#33879)
Extract from #28966 
Follow #33874
2025-03-14 18:38:55 +00:00
wxiaoguang cb6b33c9cd
Ignore trivial errors when updating push data (#33864)
Fix #23213
2025-03-14 08:36:39 +00:00
Lunny Xiao 9c673d066c
Add abstraction layer to check if the repository exists on disk (#33874)
Extract from #28966 

This PR uses `gitrepo.IsRepositoryExist` instead of `util.IsExist` to
detect whether the repository exist in disk. This will move `RepoPath`
detail behind of package `gitrepo` to make it easier to do possible
changes where storing the repositories.

No code change
2025-03-14 03:00:56 +00:00
Lunny Xiao 1e7248047c
Pull request updates will also trigger code owners review requests (#33744)
Fix #33490 

It will only read the changed file on the pushed commits but not all the
files of this PR.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-13 19:36:14 -07:00
TheFox0x7 5d65b9060b
remove context from retry downloader (#33871)
follow up to https://github.com/go-gitea/gitea/pull/33399 as I
apparently missed this one.
2025-03-14 00:28:57 +00:00
wxiaoguang 3996518ed4
Refactor cache-control (#33861)
And fix #21391
2025-03-13 07:04:50 +08: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
wxiaoguang 657239b480
Fix material icon & diff highlight (#33844) 2025-03-10 22:34:48 +08:00
Lunny Xiao ae63568ce3
Move notifywatch to service layer (#33825)
No logic change.
2025-03-10 00:54:25 +00:00
wxiaoguang 7290bfaccb
Only keep popular licenses (#33832)
Fix #33467
2025-03-10 06:40:37 +08:00
Dustin Firebaugh 3f1f808b9e
Full-file syntax highlighting for diff pages (#33766)
Fix #33358, fix #21970

This adds a step in the `GitDiffForRender` that does syntax highlighting for the
entire file and then only references lines from that syntax highlighted
code. This allows things like multi-line comments to be syntax
highlighted correctly.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-09 12:51:58 +08:00
wxiaoguang 6f13331754
Improve theme display (#30671)
Document: https://gitea.com/gitea/docs/pulls/180

![image](https://github.com/go-gitea/gitea/assets/2114189/68e38573-b911-45d9-b7aa-40d96d836ecb)
2025-03-08 21:38:11 +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
wxiaoguang 6422f05a4e
Decouple diff stats query from actual diffing (#33810)
The diff stats are no longer part of the diff generation.
Use `GetDiffShortStat` instead to get the total number of changed files,
added lines, and deleted lines.
As such, `gitdiff.GetDiff` can be simplified:
It should not do more than expected.

And do not run "git diff --shortstat" for pull list. Fix #31492
2025-03-08 17:36:08 +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 e7cf62f2f7
remove context from mail struct (#33811)
it can be passed by argument instead
2025-03-06 20:57:00 +00:00
Lunny Xiao 0453177b61
Refactor: move part of updating protected branch logic to service layer (#33742) 2025-03-05 19:15:40 +00:00
sommerf-lf 7cdde20c73
Email option to embed images as base64 instead of link (#32061)
ref: #15081
ref: #14037

Documentation: https://gitea.com/gitea/docs/pulls/69

# Example
Content:

![image](https://github.com/user-attachments/assets/e73ebfbe-e329-40f6-9c4a-f73832bbb181)
Result in Email:

![image](https://github.com/user-attachments/assets/55b7019f-e17a-46c3-a374-3b4769d5c2d6)
Result with source code:
(first image is external image, 2nd is now embedded)

![image](https://github.com/user-attachments/assets/8e2804a1-580f-4a69-adcb-cc5d16f7da81)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2025-03-05 16:29:29 +00:00