]> source.dussan.org Git - gitea.git/log
gitea.git
21 months agoFix blame view missing lines (#22826) (#22929)
zeripath [Fri, 17 Feb 2023 02:19:24 +0000 (02:19 +0000)]
Fix blame view missing lines (#22826) (#22929)

Backport #22826

Creating a new buffered reader for every part of the blame can miss
lines, as it will read and buffer bytes that the next buffered reader
will not get.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agosome refactor about code comments(#20821) (#22707)
Lunny Xiao [Thu, 16 Feb 2023 13:21:25 +0000 (21:21 +0800)]
some refactor about code comments(#20821) (#22707)

fix #22691
backport #20821

Co-authored-by: zeripath <art27@cantab.net>
21 months agoAdd command to bulk set must-change-password (#22823) (#22928)
zeripath [Thu, 16 Feb 2023 12:33:24 +0000 (12:33 +0000)]
Add command to bulk set must-change-password (#22823) (#22928)

Backport #22823

As part of administration sometimes it is appropriate to forcibly tell
users to update their passwords.

This PR creates a new command `gitea admin user must-change-password`
which will set the `MustChangePassword` flag on the provided users.
---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Jason Song <i@wolfogre.com>
21 months agofix incorrect role labels for migrated issues and comments (#22914) (#22923)
Yarden Shoham [Thu, 16 Feb 2023 03:19:46 +0000 (05:19 +0200)]
fix incorrect role labels for migrated issues and comments (#22914) (#22923)

Backport #22914

Fix #22797.

## Reason
If a comment was migrated from other platforms, this comment may have an
original author and its poster is always not the original author. When
the `roleDescriptor` func get the poster's role descriptor for a
comment, it does not check if the comment has an original author. So the
migrated comments' original authors might be marked as incorrect roles.

Co-authored-by: Zettat123 <zettat123@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoImprove trace logging for pulls and processes (#22633) (#22812)
zeripath [Mon, 13 Feb 2023 03:17:36 +0000 (03:17 +0000)]
Improve trace logging for pulls and processes (#22633) (#22812)

Backport #22633

Our trace logging is far from perfect and is difficult to follow.

This PR:

* Add trace logging for process manager add and remove.
* Fixes an errant read file for git refs in getMergeCommit
* Brings in the pullrequest `String` and `ColorFormat` methods
introduced in #22568
* Adds a lot more logging in to testPR etc.

Ref #22578

---------
Signed-off-by: Andrew Thornton <art27@cantab.net>
21 months agoFix PR file tree folders no longer collapsing (#22864) (#22872)
Yarden Shoham [Sun, 12 Feb 2023 11:14:19 +0000 (13:14 +0200)]
Fix PR file tree folders no longer collapsing (#22864) (#22872)

Backport #22864

Collapsing folders currently just throws a console error

```
index.js?v=1.19.0~dev-403-gb6b8feb3d:10 TypeError: this.$set is not a function
    at Proxy.handleClick (index.js?v=1.19.0~dev-403-gb6b8feb3d:58:7159)
    at index.js?v=1.19.0~dev-403-gb6b8feb3d:58:6466
    at index.js?v=1.19.0~dev-403-gb6b8feb3d:10:93922
    at ce (index.js?v=1.19.0~dev-403-gb6b8feb3d:10:1472)
    at Q (index.js?v=1.19.0~dev-403-gb6b8feb3d:10:1567)
    at HTMLDivElement.$e (index.js?v=1.19.0~dev-403-gb6b8feb3d:10:79198)
```

This PR fixes this and allows folders to be collapsed again.

Also:
- better cursor interaction with folders
- added some color to the diff detail stats
- remove green link color from all the file names

Screenshots:

![image](https://user-images.githubusercontent.com/9765622/218269712-2f3dda55-6d70-407f-8d34-2a5d9c8df548.png)

![image](https://user-images.githubusercontent.com/9765622/218269714-6ce8a954-daea-4ed6-9eea-8b2323db4d8f.png)

Co-authored-by: gempir <daniel.pasch.s@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoescape filename when assemble URL (#22850) (#22871)
Yarden Shoham [Sun, 12 Feb 2023 09:39:52 +0000 (11:39 +0200)]
escape filename when assemble URL (#22850) (#22871)

Backport #22850

Fixes: #22843
### Cause:

https://github.com/go-gitea/gitea/blob/affdd40296960a08a4223330ccbd1fb88c96ea1a/services/repository/files/content.go#L161

Previously, we did not escape the **"%"** that might be in "treePath"
when call "url.parse()".

![image](https://user-images.githubusercontent.com/33891828/218066318-5a909e50-2a17-46e6-b32f-684b2aa4b91f.png)

This function will check whether "%" is the beginning of an escape
character. Obviously, the "%" in the example (hello%mother.txt) is not
that. So, the function will return a error.

### Solution:
We can escape "treePath" by call "url.PathEscape()" function firstly.

### Screenshot:

![image](https://user-images.githubusercontent.com/33891828/218069781-1a030f8b-18d0-4804-b0f8-73997849ef43.png)

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: sillyguodong <33891828+sillyguodong@users.noreply.github.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
21 months agoUse proxy for pull mirror (#22771) (#22772)
Gusted [Sat, 11 Feb 2023 08:11:54 +0000 (09:11 +0100)]
Use proxy for pull mirror (#22771) (#22772)

- Backport #22771
  - Use the proxy (if one is specified) for pull mirrors syncs.
- Pulled the code from
https://github.com/go-gitea/gitea/blob/c2774d9e80d9a436d9c2044960369c4db227e3a0/modules/git/repo.go#L164-L170
  - Downstream issue: https://codeberg.org/forgejo/forgejo/issues/302

---------

Co-authored-by: zeripath <art27@cantab.net>
21 months agoFix isAllowed of escapeStreamer (#22814) (#22837)
Jason Song [Fri, 10 Feb 2023 03:36:58 +0000 (11:36 +0800)]
Fix isAllowed of escapeStreamer (#22814) (#22837)

Backport #22814.

The use of `sort.Search` is wrong: The slice should be sorted, and
`return >= 0` doen't mean it exists, see the
[manual](https://pkg.go.dev/sort#Search).

Could be fixed like this if we really need it:

```diff
diff --git a/modules/charset/escape_stream.go b/modules/charset/escape_stream.go
index 823b63513..fcf1ffbc1 100644
--- a/modules/charset/escape_stream.go
+++ b/modules/charset/escape_stream.go
@@ -20,6 +20,9 @@ import (
 var defaultWordRegexp = regexp.MustCompile(`(-?\d*\.\d\w*)|([^\` + "`" + `\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s\x00-\x1f]+)`)

 func NewEscapeStreamer(locale translation.Locale, next HTMLStreamer, allowed ...rune) HTMLStreamer {
+       sort.Slice(allowed, func(i, j int) bool {
+               return allowed[i] < allowed[j]
+       })
        return &escapeStreamer{
                escaped:                 &EscapeStatus{},
                PassthroughHTMLStreamer: *NewPassthroughStreamer(next),
@@ -284,14 +287,8 @@ func (e *escapeStreamer) runeTypes(runes ...rune) (types []runeType, confusables
 }

 func (e *escapeStreamer) isAllowed(r rune) bool {
-       if len(e.allowed) == 0 {
-               return false
-       }
-       if len(e.allowed) == 1 {
-               return e.allowed[0] == r
-       }
-
-       return sort.Search(len(e.allowed), func(i int) bool {
+       i := sort.Search(len(e.allowed), func(i int) bool {
                return e.allowed[i] >= r
-       }) >= 0
+       })
+       return i < len(e.allowed) && e.allowed[i] == r
 }
```

But I don't think so, a map is better to do it.

21 months agoLoad issue before accessing index in merge message (#22822) (#22830)
John Olheiser [Thu, 9 Feb 2023 21:53:14 +0000 (15:53 -0600)]
Load issue before accessing index in merge message (#22822) (#22830)

Backport #22822

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
21 months agoadd default user visibility to cli command "admin user create" (#22750) (#22760)
Yarden Shoham [Wed, 8 Feb 2023 17:04:38 +0000 (19:04 +0200)]
add default user visibility to cli command "admin user create" (#22750) (#22760)

Backport #22750

Fixes https://github.com/go-gitea/gitea/issues/22523

Co-authored-by: yp05327 <576951401@qq.com>
21 months agoFix color of tertiary button on dark theme (#22739) (#22744)
Yarden Shoham [Wed, 8 Feb 2023 15:44:40 +0000 (17:44 +0200)]
Fix color of tertiary button on dark theme (#22739) (#22744)

Backport #22739

Before:
<img width="266" alt="Screenshot 2023-02-03 at 14 07 34"
src="https://user-images.githubusercontent.com/115237/216611151-92e98305-c4b5-42f3-b2e2-8b1b805fa644.png">

After:
<img width="271" alt="Screenshot 2023-02-03 at 14 07 52"
src="https://user-images.githubusercontent.com/115237/216611156-878a8a75-39a1-415b-9b6d-4f035985444e.png">

This is the only instance of such a button in all templates.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix restore repo bug, clarify the problem of ForeignIndex (#22776) (#22794)
Yarden Shoham [Wed, 8 Feb 2023 08:39:42 +0000 (10:39 +0200)]
Fix restore repo bug, clarify the problem of ForeignIndex (#22776) (#22794)

Backport #22776

Fix #22581

TLDR: #18446 made a mess with ForeignIndex and triggered a design
flaw/bug of #16356, then a quick patch #21271 helped #18446, then the
the bug was re-triggered by #21721 .

Related:
* #16356
* BasicIssueContext
https://github.com/go-gitea/gitea/pull/16356/files#diff-7938eb670d42a5ead6b08121e16aa4537a4d716c1cf37923c70470020fb9d036R16-R27
* #18446
* If some issues were dumped without ForeignIndex, then they would be
imported as ForeignIndex=0
https://github.com/go-gitea/gitea/pull/18446/files#diff-1624a3e715d8fc70edf2db1630642b7d6517f8c359cc69d58c3958b34ba4ce5eR38-R39
* #21271
* It patched the above bug (somewhat), made the issues without
ForeignIndex could have the same value as LocalIndex
* #21721
    * It re-triggered the zero-ForeignIndex bug.

ps: I am not sure whether the changes in `GetForeignIndex` are ideal (at
least, now it has almost the same behavior as BasicIssueContext in
#16356), it's just a quick fix. Feel free to edit on this PR directly or
replace it.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
21 months agoUse import of OCI structs (#22765) (#22805)
KN4CK3R [Tue, 7 Feb 2023 23:50:19 +0000 (00:50 +0100)]
Use import of OCI structs (#22765) (#22805)

Backport of #22765

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
21 months agoupgrade golangcilint to v1.51.0 (#22764)
Lunny Xiao [Tue, 7 Feb 2023 19:28:25 +0000 (03:28 +0800)]
upgrade golangcilint to v1.51.0 (#22764)

With the upgrade to go 1.20 golangci-lint no longer correctly works. We must therefore upgrade to the latest golangci-lint.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
21 months agoEscape path for the file list (#22741) (#22757)
wxiaoguang [Mon, 6 Feb 2023 12:58:06 +0000 (20:58 +0800)]
Escape path for the file list (#22741) (#22757)

Backport #22741
Fix #22740

21 months agouse drone secrets for s3 config (#22770) (#22773)
Yarden Shoham [Sun, 5 Feb 2023 23:42:45 +0000 (01:42 +0200)]
use drone secrets for s3 config (#22770) (#22773)

21 months agoFix bugs with WebAuthn preventing sign in and registration. (#22651) (#22721)
zeripath [Thu, 2 Feb 2023 07:45:57 +0000 (07:45 +0000)]
Fix bugs with WebAuthn preventing sign in and registration. (#22651) (#22721)

Partial Backport #22651

This PR fixes a longstanding bug within webauthn due to the backend
using URLEncodedBase64 but the javascript using decoding using plain
base64. This causes intermittent issues with users reporting decoding
errors.

Fix #22507

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix line spacing for plaintext previews (#22699) (#22701)
crystal [Wed, 1 Feb 2023 22:06:58 +0000 (15:06 -0700)]
Fix line spacing for plaintext previews (#22699) (#22701)

Backport #22699

Adding `<br>` between each line is not necessary since the entire file
is rendered inside a `<pre>`

fixes https://codeberg.org/Codeberg/Community/issues/915

21 months agoAdd missing close bracket in imagediff (#22710) (#22712)
Yarden Shoham [Wed, 1 Feb 2023 12:30:52 +0000 (14:30 +0200)]
Add missing close bracket in imagediff (#22710) (#22712)

Backport #22710

There was a missing `]` in imagediff.js:

```
const $range = $container.find("input[type='range'");
```

This PR simply adds this.

Fix #22702

Co-authored-by: zeripath <art27@cantab.net>
21 months agoFix wrong hint when deleting a branch successfully from pull request UI (#22673)...
Yarden Shoham [Wed, 1 Feb 2023 01:35:38 +0000 (03:35 +0200)]
Fix wrong hint when deleting a branch successfully from pull request UI (#22673) (#22698)

Backport #22673

Fix #18785

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
21 months agoFix README TOC links (#22577) (#22677)
crystal [Tue, 31 Jan 2023 09:23:19 +0000 (02:23 -0700)]
Fix README TOC links (#22577) (#22677)

Backport #22577

Fixes anchored markup links by adding `user-content-` (which is
prepended to IDs)

Closes https://codeberg.org/Codeberg/Community/issues/894

21 months agoDon't return duplicated users who can create org repo (#22560) (#22562)
Gusted [Mon, 30 Jan 2023 16:59:20 +0000 (17:59 +0100)]
Don't return duplicated users who can create org repo (#22560) (#22562)

- Backport of #22560
- Currently the function `GetUsersWhoCanCreateOrgRepo` uses a query that
is able to have duplicated users in the result, this is can happen under
the condition that a user is in team that either is the owner team or
has permission to create organization repositories.
- Add test code to simulate the above condition for user 3,
[`TestGetUsersWhoCanCreateOrgRepo`](https://github.com/go-gitea/gitea/blob/a1fcb1cfb84fd6b36c8fe9fd56588119fa4377bc/models/organization/org_test.go#L435)
is the test function that tests for this.
  - The fix is quite trivial, use a map as a set to get distinct orgs.

21 months agoFix missing message in git hook when pull requests disabled on fork (#22625) (#22658)
John Olheiser [Mon, 30 Jan 2023 00:55:45 +0000 (18:55 -0600)]
Fix missing message in git hook when pull requests disabled on fork (#22625) (#22658)

Backport #22625

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
21 months agoImprove checkIfPRContentChanged (#22611) (#22644)
zeripath [Sat, 28 Jan 2023 17:56:16 +0000 (17:56 +0000)]
Improve checkIfPRContentChanged (#22611) (#22644)

Backport #22611

The code for checking if a commit has caused a change in a PR is
extremely inefficient and affects the head repository instead of using a
temporary repository.

This PR therefore makes several significant improvements:

* A temporary repo like that used in merging.
* The diff code is then significant improved to use a three-way diff
instead of comparing diffs (possibly binary) line-by-line - in memory...

Ref #22578

Signed-off-by: Andrew Thornton <art27@cantab.net>
21 months agoLink issue and pull requests status change in UI notifications directly to their...
Yarden Shoham [Sat, 28 Jan 2023 15:51:00 +0000 (17:51 +0200)]
Link issue and pull requests status change in UI notifications directly to their event in the timelined view. (#22627) (#22642)

Backport #22627

Adding the related comment to the issue and pull request status change
in the UI notifications allows to navigate directly to the specific
event in its dedicated view, easing the reading of last comments and to
the editor for additional comments if desired.

Co-authored-by: Felipe Leopoldo Sologuren GutiƩrrez <fsologureng@users.noreply.github.com>
21 months agoUse `--index-url` in PyPi description (#22620) (#22636)
Yarden Shoham [Sat, 28 Jan 2023 04:57:12 +0000 (06:57 +0200)]
Use `--index-url` in PyPi description (#22620) (#22636)

21 months agoPrevent duplicate labels when importing more than 99 (#22591) (#22598)
Yarden Shoham [Tue, 24 Jan 2023 20:48:21 +0000 (22:48 +0200)]
Prevent duplicate labels when importing more than 99 (#22591) (#22598)

Backport #22591

Importing labels (via `gitea restore-repo`) did not split them up into
batches properly. The first "batch" would create all labels, the second
"batch" would create all labels except those in the first "batch", etc.
This meant that when importing more than 99 labels (the batch size)
there would always be duplicate ones.

This is solved by actually passing `labels[:lbBatchSize]` to the
`CreateLabels()` function, instead of the entire list `labels`.

Co-authored-by: Sybren <122987084+drsybren@users.noreply.github.com>
22 months agoChangelog 1.18.3 (#22575) v1.18.3
John Olheiser [Mon, 23 Jan 2023 14:42:02 +0000 (08:42 -0600)]
Changelog 1.18.3 (#22575)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoPrevent multiple `To` recipients (#22566) (#22569)
Yarden Shoham [Sun, 22 Jan 2023 17:37:26 +0000 (19:37 +0200)]
Prevent multiple `To` recipients (#22566) (#22569)

Backport #22566

Change the mailer interface to prevent the leaking of possible hidden
email addresses when sending to multiple recipients.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
22 months agoTruncate commit summary on repo files table. (#22551) (#22552)
Yarden Shoham [Fri, 20 Jan 2023 15:34:52 +0000 (17:34 +0200)]
Truncate commit summary on repo files table. (#22551) (#22552)

Backport #22551
There was an unintended regression in #21124 which assumed that
.commits-list .message-wrapper would only match the commit summaries on
/{owner}/{name}/commits/*. This assumption is incorrect as the
directory/file view also uses a .commits-list wrapper.

Rather than completely restructure this page this PR simply adjusts the
styling to again use display: inline-block; for #repo-files-table
.commit-list .message-wrapper

Fix #22360

22 months agoMute all links in issue timeline (#22534)
silverwind [Fri, 20 Jan 2023 05:18:58 +0000 (06:18 +0100)]
Mute all links in issue timeline (#22534)

Backport of https://github.com/go-gitea/gitea/pull/22533.
https://github.com/go-gitea/gitea/pull/21799 introduced a regression
where some links in the issue timeline were not muted any more. Fix it
by replacing all `class="text grey"` with `class="text grey
muted-links"` in the file.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoWhen updating by rebase we need to set the environment for head repo (#22535) (#22536) v1.18.2
zeripath [Thu, 19 Jan 2023 22:31:20 +0000 (22:31 +0000)]
When updating by rebase we need to set the environment for head repo (#22535) (#22536)

Backport #22535

The update by rebase code reuses the merge code but shortcircuits and
pushes back up to the head. However, it doesn't set the correct pushing
environment - and just uses the same environment as the base repo. This
leads to the push update failing and thence the PR becomes out-of-sync
with the head.

This PR fixes this and adjusts the trace logging elsewhere to help make
this clearer.

Fix #18802

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agochore: changelog 1.18.2 (#22530)
John Olheiser [Thu, 19 Jan 2023 20:23:25 +0000 (14:23 -0600)]
chore: changelog 1.18.2 (#22530)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoFix issue not auto-closing when it includes a reference to a branch (#22514) (#22521)
John Olheiser [Thu, 19 Jan 2023 17:17:44 +0000 (11:17 -0600)]
Fix issue not auto-closing when it includes a reference to a branch (#22514) (#22521)

Backport #22514

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
22 months agoFix invalid issue branch reference if not specified in template (#22513) (#22520)
John Olheiser [Thu, 19 Jan 2023 15:39:30 +0000 (09:39 -0600)]
Fix invalid issue branch reference if not specified in template (#22513) (#22520)

Backport #22513

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
22 months agocgo cross-compile for freebsd (#22397) (#22519)
techknowlogick [Thu, 19 Jan 2023 03:06:17 +0000 (22:06 -0500)]
cgo cross-compile for freebsd (#22397) (#22519)

Provide pre-compiled cgo binaries for freebsd

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
22 months ago Fix 500 error viewing pull request when fork has pull requests disabled (#22512...
John Olheiser [Wed, 18 Jan 2023 21:50:51 +0000 (15:50 -0600)]
 Fix 500 error viewing pull request when fork has pull requests disabled (#22512) (#22515)

Backport #22512

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
22 months agoReliable selection of admin user (#22509) (#22511)
John Olheiser [Wed, 18 Jan 2023 17:47:23 +0000 (11:47 -0600)]
Reliable selection of admin user (#22509) (#22511)

Backport #22509

Co-authored-by: Sybren <122987084+drsybren@users.noreply.github.com>
22 months agoSet disable_gravatar/enable_federated_avatar when offline mode is true (#22479) ...
Jason Song [Wed, 18 Jan 2023 16:30:34 +0000 (00:30 +0800)]
Set disable_gravatar/enable_federated_avatar when offline mode is true (#22479) (#22496)

Backport #22479.

When offline mode is true, we should set `disable_gravatar` to `true`
and `enable_federated_avatar` to `false` in system settings.

22 months agochore: changelog 1.18.1 (#22471) v1.18.1
John Olheiser [Tue, 17 Jan 2023 16:40:47 +0000 (10:40 -0600)]
chore: changelog 1.18.1 (#22471)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoUpdate `github.com/zeripath/zapx/v15` (#22485)
KN4CK3R [Tue, 17 Jan 2023 14:51:24 +0000 (15:51 +0100)]
Update `github.com/zeripath/zapx/v15` (#22485)

Fixes #22481

_Originally posted by @zeripath in
https://github.com/go-gitea/gitea/issues/22481#issuecomment-1385188703_

22 months agoFix pull request API field `closed_at` always being `null` (#22482) (#22483)
Yarden Shoham [Tue, 17 Jan 2023 11:41:43 +0000 (13:41 +0200)]
Fix pull request API field `closed_at` always being `null` (#22482) (#22483)

Backport #22482

Fix #22480

22 months agoFix migration from GitBucket (#22465)
Haruo Kinoshita [Tue, 17 Jan 2023 08:57:17 +0000 (17:57 +0900)]
Fix migration from GitBucket (#22465)

Migration from GitBucket does not work due to a access for "Reviews" API
on GitBucket that makes 404 response.
This PR has following changes.
1. Made to stop access for Reviews API while migrating from GitBucket.
2. Added support for custom URL (e.g.
`http://example.com/gitbucket/owner/repository`)
3. Made to accept for git checkout URL
(`http://example.com/git/owner/repository.git`)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 months agoFix container blob mount (#22226) (#22476)
John Olheiser [Tue, 17 Jan 2023 06:50:45 +0000 (00:50 -0600)]
Fix container blob mount (#22226) (#22476)

Backport #22226

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoFix error when calculate the repository size (#22392) (#22474)
zeripath [Mon, 16 Jan 2023 22:07:06 +0000 (22:07 +0000)]
Fix error when calculate the repository size (#22392) (#22474)

Backport #22392

Fix #22386

`GetDirectorySize` moved as `getDirectorySize` because it becomes a
special function which should not be put in `util`.

Co-authored-by: Jason Song <i@wolfogre.com>
22 months agoFix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454...
zeripath [Mon, 16 Jan 2023 20:17:22 +0000 (20:17 +0000)]
Fix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454) (#22472)

Backport #22454

There is a mistake in the code for SearchRepositoryCondition where it
tests topics as a string. This is incorrect for postgres where topics is
cast and stored as json. topics needs to be cast to text for this to
work. (For some reason JSON_ARRAY_LENGTH does not work, so I have taken
the simplest solution of casting to text and doing a string comparison.)

Ref https://github.com/go-gitea/gitea/pull/21962#issuecomment-1379584057

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoFix environments for KaTeX and error reporting (#22453) (#22473)
zeripath [Mon, 16 Jan 2023 19:34:50 +0000 (19:34 +0000)]
Fix environments for KaTeX and error reporting (#22453) (#22473)

Backport #22453

In #22447 it was noticed that display environments were not working
correctly. This was due to the setting displayMode not being set.

Further it was noticed that the error was not being displayed correctly.

This PR fixes both of these issues by forcibly setting the displayMode
setting and corrects an error in displayError.

Fix #22447

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months ago Remove the netgo tag for Windows build (#22467) (#22468)
wxiaoguang [Mon, 16 Jan 2023 13:05:12 +0000 (21:05 +0800)]
 Remove the netgo tag for Windows build (#22467) (#22468)

Backport #22467

Fix #22370 and more.

Before Go 1.19, the `netgo` tag for Windows does nothing.

But Go 1.19 rewrite the net package code for Windows DNS, and there is a
bug:

* https://github.com/golang/go/issues/57757

This PR just removes the `netgo` tag for Windows build, then the Gitea
for Windows can have the old DNS behavior.

22 months agoFix leaving organization bug on user settings -> orgs (#21983) (#22438)
zeripath [Sun, 15 Jan 2023 23:29:27 +0000 (23:29 +0000)]
Fix leaving organization bug on user settings -> orgs (#21983) (#22438)

Backport #21983

Fix #21772

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 花å¢Ø <shanee@live.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoRestore previous official review when an official review is deleted (#22449) (#22460)
Jimmy Praet [Sun, 15 Jan 2023 19:47:54 +0000 (20:47 +0100)]
Restore previous official review when an official review is deleted (#22449) (#22460)

Backport #22449

Co-authored-by: Lauris BH <lauris@nix.lv>
22 months agoPrevent panic on looking at api "git" endpoints for empty repos (#22457) (#22458)
zeripath [Sun, 15 Jan 2023 14:35:56 +0000 (14:35 +0000)]
Prevent panic on looking at api "git" endpoints for empty repos (#22457) (#22458)

Backport #22457

The API endpoints for "git" can panic if they are called on an empty
repo. We can simply allow empty repos for these endpoints without worry
as they should just work.

Fix #22452

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoFixed colour transparency regex matching in project board sorting (#22092) (#22437)
zeripath [Sun, 15 Jan 2023 12:05:04 +0000 (12:05 +0000)]
Fixed colour transparency regex matching in project board sorting (#22092) (#22437)

Backport #22092

As described in the linked issue (#22091), semi-transparent UI elements
would result in JS errors due to the fact that the CSS `backgroundColor`
element was being matched by the pattern
`^rgb\((\d+),\s*(\d+),\s*(\d+)\)$`, which does not take the alpha
channel into account.

I changed the pattern to `^rgba?\((\d+),\s*(\d+),\s*(\d+).*\)$`. This
new pattern accepts both `rgb` and `rgba` tuples, and ignores the alpha
channel (that little `.*` at the end) from the sorting criteria. The
reason why I chose to ignore alpha is because when it comes to kanban
colour sorting, only the hue is important; the order of the panels
should stay the same, even if some of them are transparent.

Alternative solutions were discussed in the bug report and are included
here for completeness:
1. Change the regex from ^rgb\((\d+),\s*(\d+),\s*(\d+)\)$ to
^rgba?\((\d+),\s*(\d+),\s*(\d+)(,\s*(\d+(\.\d+)?))?\)$ (alpha channel is
a float or NaN on 5th group) and include the alpha channel in the
sorting criteria.
2. Rethink on why you're reading colours out of the CSS in the first
place, then reformat this sorting procedure.

Fix #22091

Co-authored-by: MisterCavespider <deler.urist@tutanota.de>
22 months agoLog STDERR of external renderer when it fails (#22442) (#22444)
Jonathan Tran [Sat, 14 Jan 2023 23:14:27 +0000 (18:14 -0500)]
Log STDERR of external renderer when it fails (#22442) (#22444)

Backport #22442.

22 months agofix: PR status layout on mobile (#21547) (#22441)
zeripath [Sat, 14 Jan 2023 08:56:44 +0000 (08:56 +0000)]
fix: PR status layout on mobile (#21547) (#22441)

Backport #21547

This PR fixes the layout of PR status layouts on mobile. For longer
status context names or on very small screens the text would overflow
and push the "Details" and "Required" badges out of the container.

Before:

![Screen Shot 2022-10-22 at 12 27

46](https://user-images.githubusercontent.com/13721712/197335454-e4decf09-4778-43e8-be88-9188fabbec23.png)

After:

![Screen Shot 2022-10-22 at 12 53

24](https://user-images.githubusercontent.com/13721712/197335449-2c731a6c-7fd6-4b97-be0e-704a99fd3d32.png)

Co-authored-by: kolaente <k@knt.li>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 months agoFix wechatwork webhook sends empty content in PR review (#21762) (#22440)
zeripath [Sat, 14 Jan 2023 03:37:18 +0000 (03:37 +0000)]
Fix wechatwork webhook sends empty content in PR review (#21762) (#22440)

Backport #21762

Wechatwork webhook is sending the following string for pull request
reviews:

``` markdown
>
```

This commit fixes this problem.

Co-authored-by: Jim Kirisame <jim@lotlab.org>
22 months agoRemove duplicate "Actions" label in mobile view (#21974) (#22439)
zeripath [Fri, 13 Jan 2023 23:23:39 +0000 (23:23 +0000)]
Remove duplicate "Actions" label in mobile view (#21974) (#22439)

Backport #21974

Closes #21973.

The "Actions" button on the commit view page is labelled twice in mobile
view. No other buttons on the page have a `mobile-only` extra label, so
this PR removes it.

Before:

![before](https://user-images.githubusercontent.com/6496999/204540002-75baa08a-6c06-4b39-847b-34272e09d71e.PNG)

After:

![after](https://user-images.githubusercontent.com/6496999/204539991-a0607765-d5e2-4b1a-84c9-a3e16cbc674e.PNG)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Mark Ormesher <me@markormesher.co.uk>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
22 months agoPrepend refs/heads/ to issue template refs (#20461) (#22427)
zeripath [Fri, 13 Jan 2023 22:33:35 +0000 (22:33 +0000)]
Prepend refs/heads/ to issue template refs (#20461) (#22427)

Backport #20461

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoContinue GCing other repos on error in one repo (#22422) (#22425)
zeripath [Fri, 13 Jan 2023 21:29:16 +0000 (21:29 +0000)]
Continue GCing other repos on error in one repo (#22422) (#22425)

Backport #22422

The current code propagates all errors up to the iteration step meaning
that a single malformed repo will prevent GC of other repos.

This PR simply stops that propagation.

Fix #21605

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoCorrectly handle select on multiple channels in Queues (#22146) (#22428)
zeripath [Fri, 13 Jan 2023 20:42:42 +0000 (20:42 +0000)]
Correctly handle select on multiple channels in Queues (#22146) (#22428)

Backport #22146

There are a few places in FlushQueueWithContext which make an incorrect
assumption about how `select` on multiple channels works.

The problem is best expressed by looking at the following example:

```go
package main

import "fmt"

func main() {
    closedChan := make(chan struct{})
    close(closedChan)
    toClose := make(chan struct{})
    count := 0

    for {
        select {
        case <-closedChan:
            count++
            fmt.Println(count)
            if count == 2 {
                close(toClose)
            }
        case <-toClose:
            return
        }
    }
}
```

This PR double-checks that the contexts are closed outside of checking
if there is data in the dataChan. It also rationalises the WorkerPool
FlushWithContext because the previous implementation failed to handle
pausing correctly. This will probably fix the underlying problem in
 #22145

Fix #22145

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoRemove test session cache to reduce possible concurrent problem (#22199) (#22429)
Lunny Xiao [Fri, 13 Jan 2023 18:54:58 +0000 (02:54 +0800)]
Remove test session cache to reduce possible concurrent problem (#22199) (#22429)

backport #22199

22 months agoRestore function to "Show more" buttons (#22399) (#22426)
zeripath [Fri, 13 Jan 2023 09:29:10 +0000 (09:29 +0000)]
Restore function to "Show more" buttons (#22399) (#22426)

Backport #22399

There was a serious regression in #21012 which broke the Show More
button on the diff page, and the show more button was also broken on the
file tree too.

This PR fixes this by resetting the pageData.diffFiles as the vue
watched value and reattachs a function to the show more button outside
of the file tree view.

Fix #22380

Signed-off-by: Andrew Thornton <art27@cantab.net>
22 months agoAllow HOST has no port (#22280) (#22409)
Lunny Xiao [Thu, 12 Jan 2023 01:57:03 +0000 (09:57 +0800)]
Allow HOST has no port (#22280) (#22409)

Fix #22274
Backport #22280

This PR will allow `HOST` without port. Then a default port will be
given in future steps.

22 months agofix: omit avatar_url in discord payload when empty (#22393) (#22394)
John Olheiser [Tue, 10 Jan 2023 19:44:18 +0000 (13:44 -0600)]
fix: omit avatar_url in discord payload when empty (#22393) (#22394)

Backport #22393

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoDon't display stop watch top bar icon when disabled and hidden when click other place...
Yarden Shoham [Tue, 10 Jan 2023 09:21:29 +0000 (11:21 +0200)]
Don't display stop watch top bar icon when disabled and hidden when click other place (#22374) (#22387)

Backport #22374

Fix #22286

When timetracking is disabled, the stop watch top bar icon should be
hidden. When the stop watch recording popup, it should be allowed to
hide with some operation. Now click any place on this page will hide the
popup window.

22 months agoDon't lookup mail server when using sendmail (#22300) (#22383)
Lunny Xiao [Mon, 9 Jan 2023 17:18:03 +0000 (01:18 +0800)]
Don't lookup mail server when using sendmail (#22300) (#22383)

Fix #22287
backport #22300

22 months agoFix set system setting failure once it cached (#22334)
Lunny Xiao [Mon, 9 Jan 2023 02:04:44 +0000 (10:04 +0800)]
Fix set system setting failure once it cached (#22334)

backport #22333

22 months agoUpdate Emoji dataset to Unicode 14 (#22342) (#22343)
isla w [Wed, 4 Jan 2023 18:45:18 +0000 (13:45 -0500)]
Update Emoji dataset to Unicode 14 (#22342) (#22343)

Backport of #22342 to release/v1.18 as requested

22 months agofix gravatar disable bug (#22337)
Lunny Xiao [Wed, 4 Jan 2023 13:17:59 +0000 (21:17 +0800)]
fix gravatar disable bug (#22337)

22 months agofix: update settings table on install (#22326) (#22327)
John Olheiser [Tue, 3 Jan 2023 22:19:57 +0000 (16:19 -0600)]
fix: update settings table on install (#22326) (#22327)

Backport #22326

Signed-off-by: jolheiser <john.olheiser@gmail.com>
22 months agoAdd deprecated warning for DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR (#22324)
Kyle D [Tue, 3 Jan 2023 16:11:00 +0000 (11:11 -0500)]
Add deprecated warning for DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR (#22324)

Backport https://github.com/go-gitea/gitea/pull/22318

22 months agoFix sitemap (#22272) (#22320)
Jason Song [Tue, 3 Jan 2023 14:03:56 +0000 (22:03 +0800)]
Fix sitemap (#22272) (#22320)

Backport #22272.

Fix #22270.

Related to #18407.

The old code treated both sitemap and sitemap index as the format like:

```xml
...
<url>
  <loc>http://localhost:3000/explore/users/sitemap-1.xml</loc>
</url>
...
```

Actually, it's incorrect for sitemap index, it should be:

```xml
...
<sitemap>
  <loc>http://localhost:3000/explore/users/sitemap-1.xml</loc>
</sitemap>
...
```

See https://www.sitemaps.org/protocol.html

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 months agoDisplay error log when a modified template has an error so that it could recovery...
Lunny Xiao [Tue, 3 Jan 2023 11:39:58 +0000 (19:39 +0800)]
Display error log when a modified template has an error so that it could recovery when the error fixed (#22261) (#22321)

backport #22261

A drawback is the previous generated template has been cached, so you
cannot get error in the UI but only from log

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: delvh <dev.lh@web.de>
22 months agofix: code search title translation (#22285) (#22316)
John Olheiser [Tue, 3 Jan 2023 03:33:55 +0000 (21:33 -0600)]
fix: code search title translation (#22285) (#22316)

Backport #22285

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
22 months agoFix due date rendering the wrong date in issue (#22302) (#22306)
Yarden Shoham [Mon, 2 Jan 2023 12:42:39 +0000 (14:42 +0200)]
Fix due date rendering the wrong date in issue (#22302) (#22306)

Backport #22302

Previously, the last minute of the chosen date caused bad timezone
rendering.

For example, I chose January 4th, 2023.

### Before
```html
<time data-format="date" datetime="Wed, 04 Jan 2023 23:59:59 +0000">January 5, 2023</time>
```

### After
```html
<time data-format="date" datetime="2023-01-04">January 4, 2023</time>
```

---

Closes #21999

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
22 months agoFix get system setting bug when enabled redis cache (#22298)
Lunny Xiao [Sun, 1 Jan 2023 15:24:01 +0000 (23:24 +0800)]
Fix get system setting bug when enabled redis cache (#22298)

backport #22295, fix #22281

Co-authored-by: Lauris BH <lauris@nix.lv>
22 months agoFix bug of DisableGravatar default value (#22297)
Lunny Xiao [Sun, 1 Jan 2023 12:20:04 +0000 (20:20 +0800)]
Fix bug of DisableGravatar default value (#22297)

backport #22296

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
22 months agoAdd `sync_on_commit` option for push mirrors api (#22271) (#22292)
Chongyi Zheng [Sat, 31 Dec 2022 11:46:14 +0000 (06:46 -0500)]
Add `sync_on_commit` option for push mirrors api (#22271) (#22292)

Backport of #22271

22 months agoFix key signature error page (#22229) (#22230)
Gusted [Fri, 30 Dec 2022 04:53:23 +0000 (05:53 +0100)]
Fix key signature error page (#22229) (#22230)

- Backport of #22229
- When the GPG key contains an error, such as an invalid signature or an
email address that does not match the user.A page will be shown that
says you must provide a signature for the token.
- This page had two errors: one had the wrong translation key and the
other tried to use an undefined variable
[`.PaddedKeyID`](https://github.com/go-gitea/gitea/blob/e81ccc406bf723a5a58d685e7782f281736affd4/models/asymkey/gpg_key.go#L65-L72),
which is a function implemented on the `GPGKey` struct, given that we
don't have that, we use
[`KeyID`](https://github.com/go-gitea/gitea/blob/e81ccc406bf723a5a58d685e7782f281736affd4/routers/web/user/setting/keys.go#L102)
which is [the fingerprint of the
publickey](https://pkg.go.dev/golang.org/x/crypto/openpgp/packet#PublicKey.KeyIdString)
and is a valid way for opengpg to refer to a key.

22 months agoFrontport 1.17.4 changelog and Add 1.18.0 changelog (#22215) v1.18.0
Lunny Xiao [Thu, 29 Dec 2022 19:08:57 +0000 (03:08 +0800)]
Frontport 1.17.4 changelog and Add 1.18.0 changelog (#22215)

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
22 months agoAdd more test directory to exclude dir of air, remove watching templates from air...
Lunny Xiao [Thu, 29 Dec 2022 15:12:10 +0000 (23:12 +0800)]
Add more test directory to exclude dir of air, remove watching templates from air include dir because gitea has internal mechanism (#22246) (#22247)

backport #22246

Since #20218 introduced internal watching template, template watching
should be removed from `air`. This will prevent restart the whole server
once the template files changed to speed up developing when using `make
watch`.

To ensure `make watch` will reuse template watching, this PR introduced
a new ENV `GITEA_RUN_MODE` to make sure `make watch` will always run in
a dev mode of Gitea so that template watching will open.

This PR also added more exclude testdata directories.

Co-authored-by: 6543 <6543@obermui.de>
22 months agorefactor auth interface to return error when verify failure (#22119) (#22259)
Lunny Xiao [Thu, 29 Dec 2022 05:50:09 +0000 (13:50 +0800)]
refactor auth interface to return error when verify failure (#22119) (#22259)

backport #22119

This PR changed the Auth interface signature from `Verify(http
*http.Request, w http.ResponseWriter, store DataStore, sess
SessionStore) *user_model.User`
to
`Verify(http *http.Request, w http.ResponseWriter, store DataStore, sess
SessionStore) (*user_model.User, error)`.

There is a new return argument `error` which means the verification
condition matched but verify process failed, we should stop the auth
process.

Before this PR, when return a `nil` user, we don't know the reason why
it returned `nil`. If the match condition is not satisfied or it
verified failure? For these two different results, we should have
different handler. If the match condition is not satisfied, we should
try next auth method and if there is no more auth method, it's an
anonymous user. If the condition matched but verify failed, the auth
process should be stop and return immediately.

This will fix #20563

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Jason Song <i@wolfogre.com>
22 months agoUse complete SHA to create and query commit status (#22244) (#22257)
Jason Song [Wed, 28 Dec 2022 10:03:21 +0000 (18:03 +0800)]
Use complete SHA to create and query commit status (#22244) (#22257)

Backport #22244.

Fix #13485.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
22 months agoRemove ReverseProxy authentication from the API (#22219) (#22251)
Lunny Xiao [Tue, 27 Dec 2022 19:24:43 +0000 (03:24 +0800)]
Remove ReverseProxy authentication from the API (#22219) (#22251)

backport from #22219

Since we changed the /api/v1/ routes to disallow session authentication
we also removed their reliance on CSRF. However, we left the
ReverseProxy authentication here - but this means that POSTs to the API
are no longer protected by CSRF.

Now, ReverseProxy authentication is a kind of session authentication,
and is therefore inconsistent with the removal of session from the API.

This PR proposes that we simply remove the ReverseProxy authentication
from the API and therefore users of the API must explicitly use tokens
or basic authentication.

Replace #22077
Close #22221
Close #22077

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
23 months agoUpdate bleve and zapx to fix unaligned atomic (#22031) (#22218)
zeripath [Thu, 22 Dec 2022 15:45:38 +0000 (15:45 +0000)]
Update bleve and zapx to fix unaligned atomic (#22031) (#22218)

Backport #22031

There is an unaligned atomic field in zapx 15.3.5 which should have been
fixed in a subsequent patch

This bug causes issues on 32bit builds.

Update bleve and zapx to account for this.

Fix #21957

Signed-off-by: Andrew Thornton <art27@cantab.net>
23 months agoFix container layer display overflow (#22208) (#22211)
Lauris BH [Thu, 22 Dec 2022 13:26:48 +0000 (15:26 +0200)]
Fix container layer display overflow (#22208) (#22211)

Backport #22208

23 months agoAllow empty assignees on pull request edit (#22150) (#22214)
KN4CK3R [Thu, 22 Dec 2022 12:40:07 +0000 (13:40 +0100)]
Allow empty assignees on pull request edit (#22150) (#22214)

Backport of #22150

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
23 months agoAdd setting to disable the git apply step in test patch (#22130) (#22170)
zeripath [Thu, 22 Dec 2022 10:59:10 +0000 (10:59 +0000)]
Add setting to disable the git apply step in test patch (#22130) (#22170)

Backport #22130

For a long time Gitea has tested PR patches using a git apply --check
method, and in fact prior to the introduction of a read-tree assisted
three-way merge in #18004, this was the only way of checking patches.

Since #18004, the git apply --check method has been a fallback method,
only used when the read-tree three-way merge method has detected a
conflict. The read-tree assisted three-way merge method is much faster
and less resource intensive method of detecting conflicts. #18004 kept
the git apply method around because it was thought possible that this
fallback might be able to rectify conflicts that the read-tree three-way
merge detected. I am not certain if this could ever be the case.

Given the uncertainty here and the now relative stability of the
read-tree method - this PR makes using this fallback optional but
enables it by default. A `log.Critical` has been added which will alert
if the `git apply --check` method was successful at checking a PR that
`read-tree` failed on.

The hope is that none of these log.Critical messages will be found and
there will be no significant difference in conflict detection. Thus we
will be able to remove the git apply fallback in future, and/or improve
the read-tree three-way merge method to catch any conflicts that git
apply method might have been able to fix.

An additional benefit for anyone who disables the check method is that
patch checking should be significantly less resource intensive and much
quicker.

(See
https://github.com/go-gitea/gitea/issues/22083\#issuecomment-1347961737)

Ref #22083

Signed-off-by: Andrew Thornton <art27@cantab.net>
<!--

Please check the following:

1. Make sure you are targeting the `main` branch, pull requests on
release branches are only allowed for bug fixes.
2. Read contributing guidelines:
https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md
3. Describe what your pull request does and which issue you're targeting
(if any)

-->

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
23 months agoNormalize NuGet package version on upload (#22186) (#22200)
KN4CK3R [Wed, 21 Dec 2022 20:50:17 +0000 (21:50 +0100)]
Normalize NuGet package version on upload (#22186) (#22200)

Backport of #22186

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
23 months agofix: update libcurl in docs pipeline (#22204)
John Olheiser [Wed, 21 Dec 2022 19:39:05 +0000 (13:39 -0600)]
fix: update libcurl in docs pipeline (#22204)

Backport https://github.com/go-gitea/gitea/pull/22203

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
23 months agoCheck for zero time instant in TimeStamp.IsZero() (#22171) (#22172)
Gusted [Tue, 20 Dec 2022 02:04:46 +0000 (03:04 +0100)]
Check for zero time instant in TimeStamp.IsZero() (#22171) (#22172)

- Backport of #22171
- Currently, the 'IsZero' function for 'TimeStamp' just checks if the
unix time is zero, which is not the behavior of 'Time.IsZero()', but
Gitea is using this method in accordance with the behavior of
'Time.IsZero()'.
  - Adds a new condition to check for the zero time instant.
- Fixes a bug where non-expiring GPG keys where shown as they expired on
Jan 01, 0001.
  - Related https://codeberg.org/Codeberg/Community/issues/791

23 months agoEnsure that plain files are rendered correctly even when containing ambiguous charact...
zeripath [Mon, 19 Dec 2022 15:51:21 +0000 (15:51 +0000)]
Ensure that plain files are rendered correctly even when containing ambiguous characters (#22017) (#22160)

Backport #22017

As recognised in #21841 the rendering of plain text files is somewhat
incorrect when there are ambiguous characters as the html code is double
escaped. In fact there are several more problems here.

We have a residual isRenderedHTML which is actually simply escaping the
file - not rendering it. This is badly named and gives the wrong
impression.

There is also unusual behaviour whether the file is called a Readme or
not and there is no way to get to the source code if the file is called
README.

In reality what should happen is different depending on whether the file
is being rendered a README at the bottom of the directory view or not.

1. If it is rendered as a README on a directory - it should simply be
escaped and rendered as `<pre>` text.
2. If it is rendered as a file then it should be rendered as source
code.

This PR therefore does:
1. Rename IsRenderedHTML to IsPlainText
2. Readme files rendered at the bottom of the directory are rendered
without line numbers
3. Otherwise plain text files are rendered as source code.

Replace #21841

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
23 months agoDo not list active repositories as unadopted (#22034) (#22166)
Christian Ullrich [Mon, 19 Dec 2022 12:48:38 +0000 (13:48 +0100)]
Do not list active repositories as unadopted (#22034) (#22166)

Backport #22034

This fixes a bug where, when searching unadopted repositories, active
repositories will be listed as well. This is because the size of the
array of repository names to check is larger by one than the
`IterateBufferSize`.

For an `IterateBufferSize` of 50, the original code will pass 51
repository names but set the query to `LIMIT 50`. If all repositories in
the query are active (i.e. not unadopted) one of them will be omitted
from the result. Due to the `ORDER BY` clause it will be the oldest (or
least recently modified) one.

Co-authored-by: Christian Ullrich <christian.ullrich@traditionsa.lu>
23 months agoLocal storage should not store files as executable (#22162) (#22163)
zeripath [Sun, 18 Dec 2022 23:12:25 +0000 (23:12 +0000)]
Local storage should not store files as executable (#22162) (#22163)

Backport #22162

The PR #21198 introduced a probable security vulnerability which
resulted in making all storage files be marked as executable.

This PR ensures that these are forcibly marked as non-executable.

Fix #22161

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
23 months agoFix heatmap first color being unused (#22158)
silverwind [Sun, 18 Dec 2022 13:18:07 +0000 (14:18 +0100)]
Fix heatmap first color being unused (#22158)

Backport #22157. vue3-calendar-heatmap has the behaviour that the first
and second colors are mapped to values null and 0, meaning the second
color was not used as intended for values > 0. I think this is a
behaviour change from previous vue2 version that was missed during the
upgrade.

This change makes first and second values the same, so the heatmap can
now use one additional color for meaningful values.

23 months agoFix margin and alignment in dashboard repolist (#22120) (#22122)
silverwind [Fri, 16 Dec 2022 19:57:22 +0000 (20:57 +0100)]
Fix margin and alignment in dashboard repolist (#22120) (#22122)

Backport #22120 to 1.18. Seems this has recently regressed, previously,
there was a significant whitespace between icon and text, but it seems
to be gone, so I added the margin.

23 months agoCorrectly handle moved files in apply patch (#22118) (#22135)
zeripath [Thu, 15 Dec 2022 00:59:16 +0000 (00:59 +0000)]
Correctly handle moved files in apply patch (#22118) (#22135)

Backport #22118

Moved files in a patch will result in git apply returning:

```
error: {filename}: No such file or directory
```

This wasn't handled by the git apply patch code. This PR adds handling
for this.

Fix #22083

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
23 months agoFix condition for is_internal (#22095) (#22132)
KN4CK3R [Wed, 14 Dec 2022 18:38:15 +0000 (19:38 +0100)]
Fix condition for is_internal (#22095) (#22132)

Backport of #22095

I changed it to a static condition because it needs a new version of
xorm which is only available in 1.19. This change is valid because
`SearchLatestVersions` is never called to list internal versions and
there will no change to this behaviour in <1.19.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
23 months agoMake gitea work using cmd.exe again (#22073) (#22133)
zeripath [Wed, 14 Dec 2022 13:13:16 +0000 (13:13 +0000)]
Make gitea work using cmd.exe again (#22073) (#22133)

Backport #22073

Gitea will attempt to lookup its location using LookPath however, this
fails on cmd.exe if gitea is in the current working directory.

exec.LookPath will return an exec.ErrDot error which we can test for and
then simply using filepath.Abs(os.Args[0]) to absolute gitea against the
current working directory.

Fix #22063

Signed-off-by: Andrew Thornton <art27@cantab.net>
23 months agoFix sorting admin user list by last login (#22081) (#22107)
aceArt-GmbH [Tue, 13 Dec 2022 22:37:33 +0000 (23:37 +0100)]
Fix sorting admin user list by last login (#22081) (#22107)