Commit Graph

4294 Commits

Author SHA1 Message Date
Giteabot 6c235f4959
Perform Newest sort type correctly when sorting issues (#30644) (#30847)
Backport #30644 by kemzeb

Should resolve #30642.

Co-authored-by: Kemal Zebari <60799661+kemzeb@users.noreply.github.com>
2024-05-03 16:52:18 +08:00
Zettat123 ddf64b84e4
Add a db consistency check to remove runners that do not belong to a repository (#30614) (#30653)
Backport #30614
2024-04-24 00:08:06 +00:00
wxiaoguang 32f895f2d7
Fix queue test (#30646) (#30650)
Backport #30553 and #30646
2024-04-23 08:30:32 +00:00
Lunny Xiao d95408bd5d
Use maintained gziphandler (#30592) (#30638)
Replace #27894
Backport #30592

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-04-23 02:39:27 +00:00
Giteabot 08822651a6
Fix commit file status parser (#30602) (#30606)
Backport #30602 by wxiaoguang

Try to fix  #30492

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-04-19 15:16:02 +00:00
Giteabot 944f1ec54c
Avoid importing `modules/web/middleware` in `modules/session` (#30584) (#30588)
Backport #30584 by @wolfogre

Related to #30375.

It doesn't make sense to import `modules/web/middleware` and
`modules/setting` in `modules/web/session` since the last one is more
low-level.

And it looks like a workaround to call `DeleteLegacySiteCookie` in
`RegenerateSession`, so maybe we could reverse the importing by
registering hook functions.

Co-authored-by: Jason Song <i@wolfogre.com>
2024-04-19 09:18:11 +02:00
Lunny Xiao 430fe6c0c1
Avoid losing token when updating mirror settings (#30429) (#30466)
Fix #30416.
Backport #30429 

Before (it shows as "Unset" while there's a token):

<img width="980" alt="image"

src="https://github.com/go-gitea/gitea/assets/9418365/d7148e3e-62c9-4d2e-942d-3d795b79515a">

After:

<img width="977" alt="image"

src="https://github.com/go-gitea/gitea/assets/9418365/24aaa1db-5baa-4204-9081-470b15ea72b5">

The username shows as "oauth2" because of

f9fdac9809/services/migrations/dump.go (L99)

I have checked that all usage of `MirrorRemoteAddress` has been updated.

<img width="1806" alt="image"

src="https://github.com/go-gitea/gitea/assets/9418365/2f042501-2824-4511-9203-c84a6731a02d">

However, it needs to be checked again when backporting.

Co-authored-by: Jason Song <i@wolfogre.com>
2024-04-15 11:29:42 +08:00
Giteabot 222d16e6ea
fix: Fix to delete cookie when AppSubURL is non-empty (#30375) (#30468)
Backport #30375 by @jtran

Cookies may exist on "/subpath" and "/subpath/" for some legacy reasons
(eg: changed CookiePath behavior in code). The legacy cookie should be
removed correctly.

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
2024-04-14 13:45:51 +02:00
Lunny Xiao 09df5c9c7d
Use db.ListOptions directly instead of Paginator interface to make iteasier to use and fix performance of /pulls and /issues (#29990) (#30447)
backport #29990

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

- Inline math blocks couldn't be preceeded or succeeded by
alphanumerical characters due to changes introduced in PR #21171.
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 (#30174) (#30181)
Backport #30174 by @KN4CK3R

Fixes #30119

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 (#30094) (#30120)
backport #30094
2024-03-27 10:09:17 +08:00
yp05327 6d47b63be2
Fix panic for fixBrokenRepoUnits16961 (#30068) (#30100)
backport #30068
2024-03-26 18:20:03 +08:00
Lunny Xiao 6ef986d474
Performance improvements for pull request list page (#29900) (#29972)
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 #29585
Backport #29900
2024-03-22 09:58:04 +08:00
wxiaoguang b4a6c6fd7a
Fix loadOneBranch panic (#29938) (#29939)
Backport #29938

Try to fix #29936

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 (#29926) (#29928)
Backport #29926 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 (#29740 & #29671) (#29846)
Backport https://github.com/go-gitea/gitea/pull/29740 (based on #29671
...)
2024-03-16 17:01:40 +01:00
Giteabot e0a9a921af
Support GITEA_I_AM_BEING_UNSAFE_RUNNING_AS_ROOT env (#29788) (#29791)
Backport #29788 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>` (#29725) (#29747)
Backport #29725 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 (#29677) (#29711)
Backport #29677 by @yp05327

Fix #28735

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 (#29669) (#29705)
Backport #29669 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 #29668

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 (#29653) (#29663)
Backport #29653 by @yp05327

Fix #29506

Co-authored-by: yp05327 <576951401@qq.com>
2024-03-08 09:13:58 +00:00
Giteabot 0b5a4e7db4
Use strict protocol check when redirect (#29642) (#29644)
Backport #29642 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 (#29629) (#29630)
Backport #29629
2024-03-06 11:00:21 +00:00
Giteabot 9db426ad8c
Fix wrong line number in code search result (#29260) (#29623)
Backport #29260 by @yp05327

Fix #29136

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 (#29583) (#29599)
Backport #29583
2024-03-05 21:03:45 +08:00
wxiaoguang 4ef7e496b8
Add a trailing slash to dashboard links (#29555) (#29573)
Backport #29555
2024-03-04 13:50:55 +08:00
Giteabot 5ca2971ccb
Fix incorrect cookie path for AppSubURL (#29534) (#29552)
Backport #29534
Regression of #24107

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 (#29532) (#29546)
Backport #29532

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 (#29484) (#29487) (#29536)
Backport #29487 by @charles7668

Close #29484

![圖片](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 (#29489) (#29523)
Backport #29489 by @sillyguodong

close #27496
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` (#29459) (#29488)
Backport #29459 by @KN4CK3R

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

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2024-02-29 14:40:35 +08:00
Giteabot b43ce53a23
Fix workflow trigger event bugs (#29467) (#29475)
Backport #29467 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 (#29354) (#29370)
Backport #29354 by @KN4CK3R

Fixes #29346

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 (#27893) (#29332)
Backport #27893

- 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 (#29295) (#29327)
Backport #29295 by @lunny

Fix #28843

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 (#29205) (#29325)
Backport #29205 (including #29172)

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 (#29277) (#29322)
Backport #29277 by @Zettat123

Fix #29175
Replace #29207

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` (#29297) (#29310)
Backport #29297 by @KN4CK3R

Fixes #29101
Related #29298

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 (#29173) (#29308)
Backport #29173

Fix #29166

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. (#29298) (#29301)
Backport #29298
Fixes the reason why #29101 is hard to replicate.
Related #29297

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 (#29287) (#29291)
Backport #29287
2024-02-21 12:08:34 +01:00
wxiaoguang 906a722fca
Refactor git version functions and check compatibility (#29155) (#29157)
Backport #29155 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 (#29054) (#29108)
Backport #29054. Fix #28840

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 (#29050) (#29086)
Backport #29050 by wxiaoguang

Try to improve #28949

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 (#29024) (#29076)
Backport #29024
Also backport #27968 (remove unnecessary titles)

Fix #28974

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 #28117 (#29062) (#29075)
Backport #29062 by @inferno-umar

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

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 (#28942) (#28999)
Backport #28942 by @Zettat123

In #28691, 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