4286 Commits

Author SHA1 Message Date
Lunny Xiao
09df5c9c7d
Use db.ListOptions directly instead of Paginator interface to make iteasier to use and fix performance of /pulls and /issues () ()
backport 

This PR uses `db.ListOptions` instead of `Paginor` to make the code
simpler.
And it also fixed the performance problem when viewing /pulls or
/issues. Before the counting in fact will also do the search.

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: silverwind <me@silverwind.io>
2024-04-13 17:44:57 +00:00
Lunny Xiao
6e3aaa9975
Performance optimization for git push () ()
Agit returned result should be from `ProcReceive` hook but not
`PostReceive` hook. Then for all non-agit pull requests, it will not
check the pull requests for every pushing `refs/pull/%d/head`.

Backport 
2024-04-10 14:12:19 +08:00
Giteabot
4588c7b705
Close file in the Upload func () ()
Co-authored-by: guangwu <guoguangwu@magic-shield.com>
2024-04-03 15:20:18 +00:00
Giteabot
5123ed3191
Fixes : inline math blocks can't be preceeded/followed by alphanumerical characters () ()
Backport  by @jmlt2002

- Inline math blocks couldn't be preceeded or succeeded by
alphanumerical characters due to changes introduced in PR .
Removed the condition that caused this (precedingCharacter condition)
and added a new exit condition of the for-loop that checks if a specific
'$' was escaped using '\' so that the math expression can be rendered as
intended.
- Additionally this PR fixes another bug where math blocks of the type
'$xyz$abc$' where the dollar sign was not escaped by the user, generated
an error (shown in the screenshots below)
- Altered the tests to accomodate for the changes

Former behaviour (from try.gitea.io):

![image](https://github.com/go-gitea/gitea/assets/114936010/8f0cbb21-321d-451c-b871-c67a8e1e9235)

Fixed behaviour (from my local build):

![image](https://github.com/go-gitea/gitea/assets/114936010/5c22687c-6f11-4407-b5e7-c14b838bc20d)

(Edit) Source code for the README.md file:
```
$x$ -$x$ $x$-

a$xa$ $xa$a 1$xb$ $xb$1

$a a$b b$

a$b $a a$b b$

$a a\$b b$
```

Signed-off-by: João Tiago <joao.leal.tintas@tecnico.ulisboa.pt>
Co-authored-by: João Tiago <114936010+jmlt2002@users.noreply.github.com>
2024-04-03 06:06:39 +00:00
Giteabot
2ac78c75d0
Include encoding in signature payload () ()
Backport  by @KN4CK3R

Fixes 

Include the encoding in the signature payload.

before

![grafik](https://github.com/go-gitea/gitea/assets/1666336/01ab94a3-8af5-4d6f-be73-a10b65a15421)

after

![grafik](https://github.com/go-gitea/gitea/assets/1666336/3a37d438-c70d-4d69-b178-d170e74aa683)

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-04-01 09:47:11 +08:00
yp05327
0c10c3a282
Fix gitea doctor will remove repo-avatar files when execute command storage-archives () ()
backport 
2024-03-27 10:09:17 +08:00
yp05327
6d47b63be2
Fix panic for fixBrokenRepoUnits16961 () ()
backport 
2024-03-26 18:20:03 +08:00
Lunny Xiao
6ef986d474
Performance improvements for pull request list page () ()
This PR will avoid load pullrequest.Issue twice in pull request list
page. It will reduce x times database queries for those WIP pull
requests.

Partially fix 
Backport 
2024-03-22 09:58:04 +08:00
wxiaoguang
b4a6c6fd7a
Fix loadOneBranch panic () ()
Backport 

Try to fix 

Far from ideal, but still better than panic.
2024-03-20 22:31:32 +08:00
Giteabot
0873088223
Show Actions post step when it's running () ()
Backport  by @wolfogre

The post step was always waiting, even if all steps were done. Then,
once the task was done, the post step became success immediately.

Before:

<img width="915" alt="xnip_240320_120228"
src="https://github.com/go-gitea/gitea/assets/9418365/00347430-f998-4c43-917a-bf6dd6d0e333">

After:

<img width="905" alt="xnip_240320_120443"
src="https://github.com/go-gitea/gitea/assets/9418365/a419b111-17c2-4029-a022-c761cc419091">

Co-authored-by: Jason Song <i@wolfogre.com>
2024-03-20 06:25:11 +00:00
6543
0cbbcf20e3
Make meilisearch do exact search for issues ( & ) ()
Backport https://github.com/go-gitea/gitea/pull/29740 (based on 
...)
2024-03-16 17:01:40 +01:00
Giteabot
e0a9a921af
Support GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT env () ()
Backport  by @wolfogre

I was trying to run unit tests for Gitea on act runner, by using `make
test`.

It failed with log:

```
2024/03/14 03:09:26 ...s/setting/setting.go:180:loadRunModeFrom() [F] Gitea is not supposed to be run as root. Sorry. If you need to use privileged TCP ports please instead use setcap and the `cap_net_bind_service` permission
```

So it will be convenient to skip by setting environment, since it's OK
to use root user in job containers.

It's not a bug, but I want to backport it to v1.21 since it doesn't
break anything.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-03-14 10:02:37 +00:00
Giteabot
6124c78de0
Fix date rendering by adding <gitea-absolute-date> () ()
Backport  by @silverwind

Alternative to: https://github.com/go-gitea/gitea/pull/29698
Fixes: https://github.com/go-gitea/gitea/issues/29034

<img width="278" alt="image"
src="https://github.com/go-gitea/gitea/assets/115237/12ecd967-2723-410d-8a28-a1b0f41b7bba">

It also fixes a secondary issue that we were showing timestamp tooltips
over date, which makes no sense, so these are now gone as well:

<img width="284" alt="image"
src="https://github.com/go-gitea/gitea/assets/115237/a70432f3-97b6-41e6-b202-b53b76924a66">

Co-authored-by: silverwind <me@silverwind.io>
2024-03-13 01:04:58 +01:00
Giteabot
4bfc43ef8d
Fix inconsistent rendering of block mathematical expressions () ()
Backport  by @yp05327

Fix 

GitHub render `\```math\``` ` as a block now.
Add `display` class will render it as a block.

After:

![image](https://github.com/go-gitea/gitea/assets/18380374/2a1c20c7-438e-4ab1-8c66-cf91c8343087)

![image](https://github.com/go-gitea/gitea/assets/18380374/b81b8a93-8bca-46a5-b7db-e0d2f53e1342)

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-03-11 10:10:07 +01:00
Giteabot
93e105a228
fix: rendering internal file links in org () ()
Backport  by @ankitrgadiya

The internal links to other files in the repository were not rendering
with the Src Prefix (/src/branch-name/file-path). This commit fixes that
by using the `SrcLink` as base if available.

Resolves 

Co-authored-by: Ankit R Gadiya <git@argp.in>
2024-03-10 18:29:17 +01:00
Giteabot
6651d2d87a
Fix incorrect rendering csv file when file size is larger than UI.CSV.MaxFileSize () ()
Backport  by @yp05327

Fix 

Co-authored-by: yp05327 <576951401@qq.com>
2024-03-08 09:13:58 +00:00
Giteabot
0b5a4e7db4
Use strict protocol check when redirect () ()
Backport  by wxiaoguang

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-03-07 03:53:33 +00:00
wxiaoguang
2f1eb619bc
Avoid unexpected panic in graceful manager () ()
Backport 
2024-03-06 11:00:21 +00:00
Giteabot
9db426ad8c
Fix wrong line number in code search result () ()
Backport  by @yp05327

Fix 

Before:
The result is a table and all line numbers are all in one row.

![image](https://github.com/go-gitea/gitea/assets/18380374/7a18b354-e257-4f57-a5ca-f6d37378edf6)

![image](https://github.com/go-gitea/gitea/assets/18380374/98416e11-89b5-4b4f-920b-91bcf041a87f)

After:

![image](https://github.com/go-gitea/gitea/assets/18380374/f189e436-9046-4431-926a-cd0deb58e8f1)

![image](https://github.com/go-gitea/gitea/assets/18380374/07d213ed-2401-4b7f-b951-5df7dc776af4)

~~Updated:~~
~~added `active` class to the target line.~~

![image](https://github.com/go-gitea/gitea/assets/18380374/0b274e48-048a-4c66-ba95-df515212ec08)

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-03-06 10:05:41 +01:00
wxiaoguang
02df269d24
Make "/user/login" page redirect if the current user has signed in () ()
Backport 
2024-03-05 21:03:45 +08:00
wxiaoguang
4ef7e496b8
Add a trailing slash to dashboard links () ()
Backport 
2024-03-04 13:50:55 +08:00
Giteabot
5ca2971ccb
Fix incorrect cookie path for AppSubURL () ()
Backport 
Regression of 

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-03-03 08:54:33 +08:00
Giteabot
86cd94cba6
Fix queue worker incorrectly stopped when there are still more items in the queue () ()
Backport 

Without `case <-t.C`, the workers would stop incorrectly, the test won't
pass. For the worse case, there might be only one running worker
processing the queue items for long time because other workers are
stopped. The root cause is related to the logic of doDispatchBatchToWorker.
It isn't a serious problem at the moment, so keep it as-is.
2024-03-02 19:40:06 +00:00
Giteabot
3a8877c058
Fix issue link does not support quotes () () ()
Backport  by @charles7668

Close 

![圖片](https://github.com/go-gitea/gitea/assets/30816317/b27e6e16-67e0-469c-8e04-30180c585890)

Co-authored-by: charles <30816317+charles7668@users.noreply.github.com>
2024-03-02 19:37:45 +08:00
Giteabot
8d08558783
Set pre-step status to skipped if job is skipped () ()
Backport  by @sillyguodong

close 
1. Set pre-step (Set up job) status to `skipped` if job is skipped.
2. Apart from pre-step, the other steps should also be set to `skipped`.
The status of other steps are reported from the runner side. This will
be completed by this PR: https://gitea.com/gitea/act_runner/pulls/500

before:

![image](https://github.com/go-gitea/gitea/assets/33891828/4bac2ba9-66de-4679-b7ed-fbae459c0c54)

after:

![image](https://github.com/go-gitea/gitea/assets/33891828/ead4871a-4e0f-4bb1-9fb4-37f4fdb78dfc)

Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
2024-03-01 14:51:54 +01:00
Giteabot
c293e34df0
Fix wrong test usage of AppSubURL () ()
Backport  by @KN4CK3R

The tests use an invalid `setting.AppSubURL`. The wrong behaviour
disturbs other PRs like  and .

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-02-29 14:40:35 +08:00
Giteabot
b43ce53a23
Fix workflow trigger event bugs () ()
Backport  by @Zettat123

1. Fix incorrect `HookEventType` for issue-related events in
`IssueChangeAssignee`
2. Add `case "types"` in the `switch` block in `matchPullRequestEvent`
to avoid warning logs

Co-authored-by: Zettat123 <zettat123@gmail.com>
2024-02-28 21:24:51 +01:00
Giteabot
e75594f7a6
Do not double close reader () ()
Backport  by @KN4CK3R

Fixes 

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-02-24 12:08:06 +00:00
6543
65e2811859
Remove SSH workaround () ()
Backport 

- Update github.com/gliderlabs/ssh to include
02f9d57300.
- Resolves https://codeberg.org/forgejo/forgejo/issues/1230

Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com>
2024-02-22 21:45:31 +01:00
Giteabot
b78f5fc60f
Only log error when tag sync fails () ()
Backport  by @lunny

Fix 

This PR will bypass the pushUpdateTag to database failure when
syncAllTags. An error log will be recorded.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-02-22 20:52:54 +01:00
wxiaoguang
511298e452
Use general token signing secret () ()
Backport  (including )

Use a clearly defined "signing secret" for token signing.
2024-02-22 17:07:41 +00:00
Giteabot
fdb0d03083
Improve the issue_comment workflow trigger event () ()
Backport  by @Zettat123

Fix 
Replace 

This PR makes some improvements to the `issue_comment` workflow trigger
event.

1. Fix the bug that pull requests cannot trigger `issue_comment`
workflows
2. Previously the `issue_comment` event only supported the `created`
activity type. This PR adds support for the missing `edited` and
`deleted` activity types.
3. Some events (including `issue_comment`, `issues`, etc. ) only trigger
workflows that belong to the workflow file on the default branch. This
PR introduces the `IsDefaultBranchWorkflow` function to check for these
events.

Co-authored-by: Zettat123 <zettat123@gmail.com>
2024-02-22 17:19:48 +01:00
Giteabot
ed5e0c8c27
Discard unread data of git cat-file () ()
Backport  by @KN4CK3R

Fixes 
Related 

Discard all read data to prevent misinterpreting existing data. Some
discard calls were missing in error cases.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: yp05327 <576951401@qq.com>
2024-02-22 04:23:38 +00:00
yp05327
0870e0bc9b
Implement some action notifier functions () ()
Backport 

Fix 

Add support for the following activity types of `pull_request`
- assigned
- unassigned
- review_requested
- review_request_removed
- milestoned
- demilestoned
2024-02-22 03:55:03 +00:00
KN4CK3R
c0b97d0485
Prevent double use of git cat-file session. () ()
Backport 
Fixes the reason why  is hard to replicate.
Related 

Create a repo with a file with minimum size 4097 bytes (I use 10000) and
execute the following code:
```go
gitRepo, err := gitrepo.OpenRepository(db.DefaultContext, <repo>)
assert.NoError(t, err)

commit, err := gitRepo.GetCommit(<sha>)
assert.NoError(t, err)

entry, err := commit.GetTreeEntryByPath(<file>)
assert.NoError(t, err)

b := entry.Blob()

// Create a reader
r, err := b.DataAsync()
assert.NoError(t, err)
defer r.Close()

// Create a second reader
r2, err := b.DataAsync()
assert.NoError(t, err) // Should be no error but is ErrNotExist
defer r2.Close()
```

The problem is the check in `CatFileBatch`:


79217ea63c/modules/git/repo_base_nogogit.go (L81-L87)
`Buffered() > 0` is used to check if there is a "operation" in progress
at the moment. This is a problem because we can't control the internal
buffer in the `bufio.Reader`. The code above demonstrates a sequence
which initiates an operation for which the code thinks there is no
active processing. The second call to `DataAsync()` therefore reuses the
existing instances instead of creating a new batch reader.
2024-02-22 03:20:20 +00:00
wxiaoguang
9379352db6
Always write proc-receive hook for all git versions () ()
Backport 
2024-02-21 12:08:34 +01:00
wxiaoguang
906a722fca
Refactor git version functions and check compatibility () ()
Backport  with an extra change: tolerate the git 2.43.1 GIT_FLUSH
bug in Gitea 1.21.x, more details in the comment of repo_attribute.go

Manually tested with git 2.43.1 and an old git (2.39.2)
2024-02-17 02:47:18 +00:00
wxiaoguang
732d511e04
Refactor parseSignatureFromCommitLine () ()
Backport . Fix 

This backport is for 1.21 only and it is different from the change in
1.22: this backport still accept the legacy date format to avoid
breaking.
2024-02-09 10:26:43 +01:00
Giteabot
c9b2aaed0e
Improve user experience for outdated comments () ()
Backport  by wxiaoguang

Try to improve 

1. Make `ctx.Data["ShowOutdatedComments"] = true` by default: it brings
consistent user experience, and sometimes the "outdated (source
changed)" comments are still valuable.
2. Show a friendly message if the comment won't show, then the end users
won't fell that "the comment disappears" (it is the special case when
`ShowOutdatedComments = false`)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-02-08 10:29:54 +08:00
wxiaoguang
19a08c7fe2
Fix orgmode link resolving () ()
Backport 
Also backport  (remove unnecessary titles)

Fix 

Add some new tests and fix some legacy unclear tests.
2024-02-07 17:24:28 +00:00
Giteabot
f0d34cd3b9
fix: Elasticsearch: Request Entity Too Large () ()
Backport  by @inferno-umar

Fix for gitea putting everything into one request without batching and
sending it to Elasticsearch for indexing as issued in 

This issue occured in large repositories while Gitea tries to 
index the code using ElasticSearch.

Co-authored-by: dark-angel <70754989+inferno-umar@users.noreply.github.com>
2024-02-07 17:21:28 +08:00
Giteabot
c398c25b18
Fix an actions schedule bug () ()
Backport  by @Zettat123

In , schedule plans will be deleted when a repo's actions unit is
disabled. But when the unit is enabled, the schedule plans won't be
created again.

This PR fixes the bug. The schedule plans will be created again when the
actions unit is re-enabled

---------

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2024-01-31 15:52:31 +00:00
Giteabot
2048363f9e
Don't remove all mirror repository's releases when mirroring () ()
Backport  by @lunny

Fix 

# Purpose

This PR fix the releases will be deleted when mirror repository sync the
tags.

# The problem

In the previous implementation of . All releases record in
databases of one mirror repository will be deleted before sync.
Ref:
https://github.com/go-gitea/gitea/pull/19125/files#diff-2aa04998a791c30e5a02b49a97c07fcd93d50e8b31640ce2ddb1afeebf605d02R481

# The Pros

This PR introduced a new method which will load all releases from
databases and all tags on git data into memory. And detect which tags
needs to be inserted, which tags need to be updated or deleted. Only
tags releases(IsTag=true) which are not included in git data will be
deleted, only tags which sha1 changed will be updated. So it will not
delete any real releases include drafts.

# The Cons

The drawback is the memory usage will be higher than before if there are
many tags on this repository. This PR defined a special release struct
to reduce columns loaded from database to memory.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2024-01-31 04:23:26 +00:00
Giteabot
b8e6cffd31
Preserve BOM in web editor () ()
Backport  by @silverwind

The `ToUTF8*` functions were stripping BOM, while BOM is actually valid
in UTF8, so the stripping must be optional depending on use case. This
does:

- Add a options struct to all `ToUTF8*` functions, that by default will
strip BOM to preserve existing behaviour
- Remove `ToUTF8` function, it was dead code
- Rename `ToUTF8WithErr` to `ToUTF8`
- Preserve BOM in Monaco Editor
- Remove a unnecessary newline in the textarea value. Browsers did
ignore it, it seems but it's better not to rely on this behaviour.

Fixes: https://github.com/go-gitea/gitea/issues/28743
Related: https://github.com/go-gitea/gitea/issues/6716 which seems to
have once introduced a mechanism that strips and re-adds the BOM, but
from what I can tell, this mechanism was removed at some point after
that PR.

Co-authored-by: silverwind <me@silverwind.io>
2024-01-27 23:23:31 +01:00
Giteabot
1ddcaedb88
Strip / from relative links () ()
Backport  by @KN4CK3R

Fixes 

Restores the old behaviour:

https://github.com/go-gitea/gitea/pull/26745/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59L96

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-01-27 15:14:36 +00:00
6543
c33886b710
Update go dependencies and fix go-git () ()
Backport 
2024-01-26 15:08:43 +08:00
Giteabot
8766f65add
Respect branch info for relative links () ()
Backport  by @KN4CK3R

Fix 

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-01-25 10:40:29 +01:00
Giteabot
b508813fe4
Fix sort bug on repository issues list () ()
Backport  by @lunny

Fix 

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2024-01-23 08:00:52 +01:00
Giteabot
b7c944b9e4
Prevent anonymous container access if RequireSignInView is enabled () ()
Backport  by @KN4CK3R

Fixes 

If `RequireSignInView` is enabled, the ghost user has no access rights.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-01-22 01:44:38 +08:00
Giteabot
8c7bda8755
Fix incorrect PostgreSQL connection string for Unix sockets () ()
Backport  by @sdvcrx

Fix 

Co-authored-by: sdvcrx <memory.silentvoyage@gmail.com>
2024-01-21 16:06:34 +00:00