]> source.dussan.org Git - gitea.git/log
gitea.git
17 months agoImprove template helper functions: string/slice (#24266)
wxiaoguang [Sat, 22 Apr 2023 18:16:22 +0000 (02:16 +0800)]
Improve template helper functions: string/slice (#24266)

Follow #23328

The improvements:

1. The `contains` functions are covered by tests
2. The inconsistent behavior of `containGeneric` is replaced by
`StringUtils.Contains` and `SliceUtils.Contains`
3. In the future we can move more help functions into XxxUtils to
simplify the `helper.go` and reduce unnecessary global functions.

FAQ:

1. Why it's called `StringUtils.Contains` but not `strings.Contains`
like Golang?

Because our `StringUtils` is not Golang's `strings` package. There will
be our own string functions.

---------

Co-authored-by: silverwind <me@silverwind.io>
17 months agoAdd `DumpVar` helper function to help debugging templates (#24262)
wxiaoguang [Sat, 22 Apr 2023 17:28:20 +0000 (01:28 +0800)]
Add `DumpVar` helper function to help debugging templates (#24262)

I guess many contributors might agree that it's really difficult to
write Golang template. The dot syntax `.` confuses everyone: what
variable it is ....

So, we can use a `{{DumpVar .ContextUser}}` to look into every variable
now.

![image](https://user-images.githubusercontent.com/2114189/233692383-f3c8f24d-4465-45f8-839b-b63e00731559.png)

And it can even dump the whole `ctx.Data` by `{{DumpVar .}}`:

```
dumpVar: templates.Vars
{
  "AllLangs": [
    {
      "Lang": "id-ID",
      "Name": "Bahasa Indonesia"
    },
...
      "Context": "[dumped]",
      "ContextUser": {
        "AllowCreateOrganization": true,
        "AllowGitHook": false,
        "AllowImportLocal": false,
...
  "TemplateLoadTimes": "[func() string]",
  "TemplateName": "user/profile",
  "Title": "Full'\u003cspan\u003e Name",
  "Total": 7,
  "UnitActionsGlobalDisabled": false,
  "UnitIssuesGlobalDisabled": false,
  "UnitProjectsGlobalDisabled": false,
  "UnitPullsGlobalDisabled": false,
  "UnitWikiGlobalDisabled": false,
  "locale": {
    "Lang": "en-US",
    "LangName": "English",
    "Locale": {}
  }
...

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
17 months agoImprove emoji and mention matching (#24255)
Yarden Shoham [Sat, 22 Apr 2023 15:32:34 +0000 (18:32 +0300)]
Improve emoji and mention matching (#24255)

Prioritize matches that start with the given text, then matches that
contain the given text.

I wanted to add a heart emoji on a pull request comment so I started
writing `:`, `h`, `e`, `a`, `r` (at this point I still couldn't find the
heart), `t`... The heart was not on the list, that's weird - it feels
like I made a typo or a mistake. This fixes that.

This also feels more like GitHub's emoji auto-complete.

# Before

![image](https://user-images.githubusercontent.com/20454870/233630750-bd0a1b76-33d0-41d4-9218-a37b670c42b0.png)

# After

![image](https://user-images.githubusercontent.com/20454870/233775128-05e67fc1-e092-4025-b6f7-1fd8e5f71e87.png)

---------

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: silverwind <me@silverwind.io>
17 months agoRemove git sample files and ignore them (#24271)
wxiaoguang [Sat, 22 Apr 2023 12:29:29 +0000 (20:29 +0800)]
Remove git sample files and ignore them (#24271)

17 months agoFix footer display (#24251)
wxiaoguang [Sat, 22 Apr 2023 05:58:59 +0000 (13:58 +0800)]
Fix footer display (#24251)

Fix #24249

Diff with ignoring spaces:
https://github.com/go-gitea/gitea/pull/24251/files?diff=split&w=1

Screenshots:

<details>

<img width="1440" alt="image"
src="https://user-images.githubusercontent.com/2114189/233592840-d9ef7296-64eb-4e48-a598-300807a7c2f9.png">

<img width="923" alt="image"
src="https://user-images.githubusercontent.com/2114189/233593015-16edc531-43c2-4ff0-b27e-ca75dbadce0c.png">

</details>

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
17 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Sat, 22 Apr 2023 00:07:44 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

17 months agoLimit avatar upload to valid image files (#24258)
JakobDev [Fri, 21 Apr 2023 21:58:59 +0000 (23:58 +0200)]
Limit avatar upload to valid image files (#24258)

This causes the browser to allow only valid images in the file picker by
default.

---------

Co-authored-by: silverwind <me@silverwind.io>
17 months agoAdd project type descriptions in issue badge and improve project icons (#23437)
yp05327 [Fri, 21 Apr 2023 21:15:17 +0000 (06:15 +0900)]
Add project type descriptions in issue badge and improve project icons (#23437)

Changes:

- ~~Add project icons to issue badge~~
~~After:~~

![image](https://user-images.githubusercontent.com/18380374/224633165-9d899176-03dc-4c36-94f8-b2fd9583856c.png)
Use `tooltip` to add a description of project type to the project name.

![image](https://user-images.githubusercontent.com/18380374/224923685-77201b5a-1c1f-4d37-b867-23299649df3f.png)

- improve project icons
we can use `project.icon` to get the svg name, which looks better and is
easy to change all of them in templates.

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
17 months agoImprove test logger (#24235)
wxiaoguang [Fri, 21 Apr 2023 20:32:25 +0000 (04:32 +0800)]
Improve test logger (#24235)

Before, there was a `log/buffer.go`, but that design is not general, and
it introduces a lot of irrelevant `Content() (string, error) ` and
`return "", fmt.Errorf("not supported")` .

And the old `log/buffer.go` is difficult to use, developers have to
write a lot of `Contains` and `Sleep` code.

The new `LogChecker` is designed to be a general approach to help to
assert some messages appearing or not appearing in logs.

17 months agoAllow `webp` images as avatars (#24248)
JakobDev [Fri, 21 Apr 2023 17:15:49 +0000 (19:15 +0200)]
Allow `webp` images as avatars (#24248)

Users can now upload `webp` images.
Browsers supporting webp images then display this as the avatar of this
user (every major browser except IE).

---------

Co-authored-by: silverwind <me@silverwind.io>
17 months agoShow commit history for closed/merged PRs (#24238)
wxiaoguang [Fri, 21 Apr 2023 16:36:37 +0000 (00:36 +0800)]
Show commit history for closed/merged PRs (#24238)

Close #24237

Before:

<details>

![image](https://user-images.githubusercontent.com/2114189/233424875-a69c6dad-df4a-483e-b796-36c6459af2d6.png)

</details>

After:

![image](https://user-images.githubusercontent.com/2114189/233424712-60a296de-017b-49a8-89b2-5925ff452646.png)

Co-authored-by: Giteabot <teabot@gitea.io>
17 months agoFix access token issue on some public endpoints (#24194)
harryzcy [Fri, 21 Apr 2023 15:39:03 +0000 (11:39 -0400)]
Fix access token issue on some public endpoints (#24194)

- [x] Identify endpoints that should be public
- [x] Update integration tests

Fix #24159

17 months agoFix comment for EmailNotificationsAndYourOwn constant (#24236)
Infinoid [Fri, 21 Apr 2023 14:27:32 +0000 (10:27 -0400)]
Fix comment for EmailNotificationsAndYourOwn constant (#24236)

This fixes some copypasta in the constant definitions for the
`User.EmailNotificationsPreference` field. No code changes.

17 months agoApply to become maintainer (#24254)
wxiaoguang [Fri, 21 Apr 2023 13:23:16 +0000 (21:23 +0800)]
Apply to become maintainer (#24254)

PRs:
https://github.com/go-gitea/gitea/pulls?q=is%3Apr+is%3Aclosed+author%3Awxiaoguang

17 months agoFix label color, fix divider in dropdown (#24215)
silverwind [Fri, 21 Apr 2023 01:53:17 +0000 (03:53 +0200)]
Fix label color, fix divider in dropdown (#24215)

Two small CSS fixes:

1. Fix basic primary label hover
2. Fix border color of divider in dropdown and remove margin so it looks
better with hover effect, as discussed in
https://github.com/go-gitea/gitea/pull/24143:

17 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 21 Apr 2023 00:08:19 +0000 (00:08 +0000)]
[skip ci] Updated translations via Crowdin

17 months agoRefactor web route (#24080)
wxiaoguang [Thu, 20 Apr 2023 18:49:06 +0000 (02:49 +0800)]
Refactor web route (#24080)

The old code is unnecessarily complex, and has many misuses.

Old code "wraps" a lot, wrap wrap wrap, it's difficult to understand
which kind of handler is used.

The new code uses a general approach, we do not need to write all kinds
of handlers into the "wrapper", do not need to wrap them again and
again.

New code, there are only 2 concepts:

1. HandlerProvider: `func (h any) (handlerProvider func (next)
http.Handler)`, it can be used as middleware
2. Use HandlerProvider to get the final HandlerFunc, and use it for
`r.Get()`

And we can decouple the route package from context package (see the
TODO).

# FAQ

## Is `reflect` safe?

Yes, all handlers are checked during startup, see the `preCheckHandler`
comment. If any handler is wrong, developers could know it in the first
time.

## Does `reflect` affect performance?

No. https://github.com/go-gitea/gitea/pull/24080#discussion_r1164825901

1. This reflect code only runs for each web handler call, handler is far
more slower: 10ms-50ms
2. The reflect is pretty fast (comparing to other code): 0.000265ms
3. XORM has more reflect operations already

17 months agoFix unclear "Owner" concept (#24233)
wxiaoguang [Thu, 20 Apr 2023 17:33:30 +0000 (01:33 +0800)]
Fix unclear "Owner" concept (#24233)

Some user/org pages use `Owner` variable. It's an incorrect concept
since year 2016: what is a user's owner?

Actually, new code is right: use `ContextUser`.

This PR cleans all legacy "Owner" variables.

## Screenshots for related pages and test results

All pages are as before:

### `web/org/home.go`

![image](https://user-images.githubusercontent.com/2114189/233366687-a3643025-1f78-474d-a901-deea35b72f4d.png)

### `web/user/profile.go`

![image](https://user-images.githubusercontent.com/2114189/233366812-2e5c2fbc-3f78-44e7-88c1-ec2f612c241e.png)

### `web/user/setting/profile.go`

![image](https://user-images.githubusercontent.com/2114189/233366928-7a1e52c9-b400-4379-a4be-af06a853c5fa.png)

17 months agoIntroduce eslint-plugin-no-jquery/no-event-shorthand (#24198)
yp05327 [Thu, 20 Apr 2023 09:28:27 +0000 (18:28 +0900)]
Introduce eslint-plugin-no-jquery/no-event-shorthand (#24198)

https://github.com/go-gitea/gitea/pull/24098#issuecomment-1514010690

---------

Co-authored-by: silverwind <me@silverwind.io>
17 months agoUse secondary pointing menu for tabs on user/organization home page (#24162)
Hester Gong [Thu, 20 Apr 2023 08:58:26 +0000 (16:58 +0800)]
Use secondary pointing menu for tabs on user/organization home page (#24162)

Close #24108

Use secondary pointing menu for tabs on user/organization home page so
the tabs look the same.
Main changes:
1. modified a part of dom structure in
`templates/user/overview/header.tmpl` to make it the same as
`templates/org/header.tmpl` in order to produce the same ui.
2. Move some css to `web_src/css/shared/repoorgshared.css` to make them
shareable between `templates/user/overview/header.tmpl` and
`templates/org/header.tmpl`

After:

https://user-images.githubusercontent.com/17645053/232400617-2add5bec-d483-4ab1-b48d-eaee157f7b09.mov

For further improvements. Need some thoughts:

For [this
TODO](https://github.com/HesterG/gitea/blob/729ad294cbec7a77623b2e3eab750ea7a20e8ee0/templates/user/overview/header.tmpl#L1),
it is viable to make it a shared template for [this
part](https://github.com/HesterG/gitea/blob/729ad294cbec7a77623b2e3eab750ea7a20e8ee0/templates/user/overview/header.tmpl#L2-L17)
and [this
part](https://github.com/HesterG/gitea/blob/729ad294cbec7a77623b2e3eab750ea7a20e8ee0/templates/org/header.tmpl#L1-L16)
because they are the same except for the variable. But for the menu
parts, they are quite different so might not be suitable to use a shared
template. So need some thoughts and advice about extracting the shared
template from these two headers.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
17 months agoMake HTML template functions support context (#24056)
wxiaoguang [Thu, 20 Apr 2023 08:08:58 +0000 (16:08 +0800)]
Make HTML template functions support context (#24056)

# Background

Golang template is not friendly for large projects, and Golang template
team is quite slow, related:
* `https://github.com/golang/go/issues/54450`

Without upstream support, we can also have our solution to make HTML
template functions support context.

It helps a lot, the above Golang template issue `#54450` explains a lot:

1. It makes `{{Locale.Tr}}` could be used in any template, without
passing unclear `(dict "root" . )` anymore.
2. More and more functions need `context`, like `avatar`, etc, we do not
need to do `(dict "Context" $.Context)` anymore.
3. Many request-related functions could be shared by parent&children
templates, like "user setting" / "system setting"

See the test `TestScopedTemplateSetFuncMap`, one template set, two
`Execute` calls with different `CtxFunc`.

# The Solution

Instead of waiting for upstream, this PR re-uses the escaped HTML
template trees, use `AddParseTree` to add related templates/trees to a
new template instance, then the new template instance can have its own
FuncMap , the function calls in the template trees will always use the
new template's FuncMap.

`template.New` / `template.AddParseTree` / `adding-FuncMap` are all
quite fast, so the performance is not affected.

The details:

1. Make a new `html/template/Template` for `all` templates
2. Add template code to the `all` template
3. Freeze the `all` template, reset its exec func map, it shouldn't
execute any template.
4. When a router wants to render a template by its `name`
    1. Find the `name` in `all`
    2. Find all its related sub templates
3. Escape all related templates (just like what the html template
package does)
4. Add the escaped parse-trees of related templates into a new (scoped)
`text/template/Template`
    5. Add context-related func map into the new (scoped) text template
    6. Execute the new (scoped) text template
7. To improve performance, the escaped templates are cached to `template
sets`

# FAQ

## There is a `unsafe` call, is this PR unsafe?

This PR is safe. Golang has strict language definition, it's safe to do
so: https://pkg.go.dev/unsafe#Pointer (1) Conversion of a *T1 to Pointer
to *T2

## What if Golang template supports such feature in the future?

The public structs/interfaces/functions introduced by this PR is quite
simple, the code of `HTMLRender` is not changed too much. It's very easy
to switch to the official mechanism if there would be one.

## Does this PR change the template execution behavior?

No, see the tests (welcome to design more tests if it's necessary)

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Giteabot <teabot@gitea.io>
17 months agoFix issue attachment handling (#24202)
wxiaoguang [Thu, 20 Apr 2023 06:39:44 +0000 (14:39 +0800)]
Fix issue attachment handling (#24202)

Close #24195

Some of the changes are taken from my another fix
https://github.com/go-gitea/gitea/pull/20147/commits/f07b0de997125c9b79cc5af27966a7cdd1803a4d
in #20147 (although that PR was discarded ....)

The bug is:

1. The old code doesn't handle `removedfile` event correctly
2. The old code doesn't provide attachments for type=CommentTypeReview

This PR doesn't intend to refactor the "upload" code to a perfect state
(to avoid making the review difficult), so some legacy styles are kept.

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
17 months agoUpdate JS dependencies (#24218)
silverwind [Thu, 20 Apr 2023 02:36:41 +0000 (04:36 +0200)]
Update JS dependencies (#24218)

- Update all js dependencies, update playwright image to jammy
- Adjust eslint and vitest config
- Tested build, monaco, mermaid, katex

17 months agoRemove most path-based golangci exclusions (#24214)
silverwind [Thu, 20 Apr 2023 02:08:01 +0000 (04:08 +0200)]
Remove most path-based golangci exclusions (#24214)

They are non-obvious and do not survive refactor.

Will replace with `//nolint` comments after CI results are in.

17 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 20 Apr 2023 00:07:41 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

17 months agoFix internal sever error when visiting a PR that bound to the deleted team (#24127)
sillyguodong [Wed, 19 Apr 2023 23:50:00 +0000 (07:50 +0800)]
Fix internal sever error when visiting a PR that bound to the deleted team (#24127)

Close: #23738

The actual cause of `500 Internal Server Error` in the issue is not what
is descirbed in the issue.

The actual cause is that after deleting team, if there is a PR which has
requested reivew from the deleted team, the comment could not match with
the deleted team by `assgin_team_id`. So the value of `.AssigneeTeam`
(see below code block) is `nil` which cause `500 error`.

https://github.com/go-gitea/gitea/blob/1c8bc4081a4f4d0d921ac218cb724ce97924d410/templates/repo/issue/view_content/comments.tmpl#L691-L695

To fix this bug, there are the following problems to be resolved:

- [x] 1. ~~Stroe the name of the team in `content` column when inserting
`comment` into DB in case that we cannot get the name of team after it
is deleted. But for comments that already exist, just display "Unknown
Team"~~ Just display "Ghost Team" in the comment if the assgined team is
deleted.
- [x] 2. Delete the PR&team binding (the row of which `review_team_id =
${team_id} ` in table `review`) when deleting team.
- [x] 3.For already exist and undeleted binding rows in in table
`review`, ~~we can delete these rows when executing migrations.~~ they
do not affect the function, so won't delete them.

17 months agoAdd owner team permission check test (#24096)
yp05327 [Wed, 19 Apr 2023 23:19:13 +0000 (08:19 +0900)]
Add owner team permission check test (#24096)

Add test for https://github.com/go-gitea/gitea/pull/23675

Should be merged after #24117

---------

Co-authored-by: silverwind <me@silverwind.io>
17 months agoFix incorrect CORS default values (#24206)
wxiaoguang [Wed, 19 Apr 2023 19:30:10 +0000 (03:30 +0800)]
Fix incorrect CORS default values (#24206)

Document:

```
;ALLOW_DOMAIN = *
;METHODS = GET,HEAD,POST,PUT,PATCH,DELETE,OPTIONS
```

Co-authored-by: Giteabot <teabot@gitea.io>
17 months agoAdd repository counter badge to repository tab (#24205)
Jakob [Wed, 19 Apr 2023 18:58:36 +0000 (20:58 +0200)]
Add repository counter badge to repository tab (#24205)

Add a new badge to the repository tab for users and organizations.
The badge is only visible if a repo exists.

Change the badge color of existing "Starred Repositories". (from primary to small)

Closes #24188

17 months agoFix template error in pull request with deleted head repo (#24192)
Brecht Van Lommel [Wed, 19 Apr 2023 18:21:48 +0000 (20:21 +0200)]
Fix template error in pull request with deleted head repo (#24192)

Rendering of Allow Edits from Maintainers did not check if the head repo
exists, while other parts of the page handle it gracefully.

17 months agoMake wiki title supports dashes and improve wiki name related features (#24143)
wxiaoguang [Wed, 19 Apr 2023 17:50:10 +0000 (01:50 +0800)]
Make wiki title supports dashes and improve wiki name related features (#24143)

Close #7570

1. Clearly define the wiki path behaviors, see
`services/wiki/wiki_path.go` and tests
2. Keep compatibility with old contents
3. Allow to use dashes in titles, eg: "2000-01-02 Meeting record"
4. Add a "Pages" link in the dropdown, otherwise users can't go to the
Pages page easily.
5. Add a "View original git file" link in the Pages list, even if some
file names are broken, users still have a chance to edit or remove it,
without cloning the wiki repo to local.
6. Fix 500 error when the name contains prefix spaces.

This PR also introduces the ability to support sub-directories, but it
can't be done at the moment due to there are a lot of legacy wiki data,
which use "%2F" in file names.

![image](https://user-images.githubusercontent.com/2114189/232239004-3359d7b9-7bf3-4ff3-8446-bfb0e79645dd.png)

![image](https://user-images.githubusercontent.com/2114189/232239020-74b92c72-bf73-4377-a319-1c85609f82b1.png)

Co-authored-by: Giteabot <teabot@gitea.io>
17 months agoFix Resolve Conversation not working in Conversation view (#24191)
Brecht Van Lommel [Wed, 19 Apr 2023 17:05:25 +0000 (19:05 +0200)]
Fix Resolve Conversation not working in Conversation view (#24191)

It only worked in the Files Changed view.

Caused by #23639.

17 months agoVertical widths of containers removed (#24184)
Krzysztof Jeziorny [Wed, 19 Apr 2023 16:13:00 +0000 (18:13 +0200)]
Vertical widths of containers removed (#24184)

A vertical overflow appears in Firefox 112/MacOS 12.6 when the system
setting for scrollbars is to "Always" show them.
---
Here, the fixed 100vw container widths are removed, which removes the
overflow. It is, however, only simulated in Developer Tools in latest
Firefox and Chromium, so please test on a Gitea installation.

17 months agoDon't list root repository on compare page if pulls not allowed (#24183)
Lunny Xiao [Wed, 19 Apr 2023 15:16:46 +0000 (23:16 +0800)]
Don't list root repository on compare page if pulls not allowed (#24183)

Fix #24165

17 months agoAdd unset default project column (#23531)
yp05327 [Wed, 19 Apr 2023 14:28:28 +0000 (23:28 +0900)]
Add unset default project column (#23531)

Close: https://github.com/go-gitea/gitea/issues/23401

17 months agoAllow adding new files to an empty repo (#24164)
wxiaoguang [Wed, 19 Apr 2023 13:40:42 +0000 (21:40 +0800)]
Allow adding new files to an empty repo (#24164)

![image](https://user-images.githubusercontent.com/2114189/232561612-2bfcfd0a-fc04-47ba-965f-5d0bcea46c54.png)

17 months agoAdd runner check in repo action page (#24124)
yp05327 [Wed, 19 Apr 2023 12:51:20 +0000 (21:51 +0900)]
Add runner check in repo action page (#24124)

![image](https://user-images.githubusercontent.com/18380374/232996647-13c2b9f1-c9e9-42d9-acbf-8a6e16b175a6.png)

Maybe we can also add online runner check? e.g. : Target runner is
offline.

17 months agoUse same action status svg icons on actions list as on action page (#24178)
Hester Gong [Wed, 19 Apr 2023 05:42:53 +0000 (13:42 +0800)]
Use same action status svg icons on actions list as on action page (#24178)

Close #24020

After:

These icons are the same now:

<img width="1287" alt="截屏2023-04-18 13 52 11"
src="https://user-images.githubusercontent.com/17645053/232684252-05ddc101-dc5b-41b5-b374-132c3d853a41.png">

<img width="1141" alt="截屏2023-04-18 13 54 48"
src="https://user-images.githubusercontent.com/17645053/232684261-6ebd864a-a9aa-4982-af32-2cea91c35be8.png">

In this PR, didn't use `ActionRunStatus.vue` because the mounting of the
component will cause flash of the icons like below:

https://user-images.githubusercontent.com/17645053/232682646-713202dc-9023-4b9c-a849-c3a1ae6dd155.mov

Instead, modified and used `status.tmpl` to make it the same as
`ActionRunStatus.vue` to avoid the ui flash (Welcomed to show how to use
`ActionRunStatus.vue` without flashing if there is a way).
Added comments to both of them for reminding synchronization of these
two files.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
17 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 19 Apr 2023 00:07:39 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

17 months agofix calReleaseNumCommitsBehind (#24148)
oliverpool [Tue, 18 Apr 2023 19:11:17 +0000 (21:11 +0200)]
fix calReleaseNumCommitsBehind (#24148)

`repoCtx.CommitsCount` is not reliably the commit count of the default
branch (Repository.GetCommitsCount depends on what is currently
displayed).

For instance on the releases page the commit count is correct:
https://codeberg.org/Codeberg/pages-server/releases

![2023-04-15-215027](https://user-images.githubusercontent.com/3864879/232250500-6c05dc00-7030-4ec9-87f1-18c7797d36bf.png)

However it is not on the single page:
https://codeberg.org/Codeberg/pages-server/releases/tag/v4.6.2

![2023-04-15-215036](https://user-images.githubusercontent.com/3864879/232250503-620c8038-7c2c-45a1-b99d-cb994ef955a6.png)

This PR fixes this by removing a "fast branch" which was using this
field (I think this field should be removed, since it is a bit
unpredictable - but this would mean a larger refactoring PR).

_contributed in the context of @forgejo_

---------

Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
17 months agoMark `public/img/svg/*.svg` as generated files (#24193)
Yarden Shoham [Tue, 18 Apr 2023 17:52:18 +0000 (20:52 +0300)]
Mark `public/img/svg/*.svg` as generated files (#24193)

These files are generated using `make svg`

17 months agoMake mention autocomplete case insensitive in new markdown editor (#24190)
Brecht Van Lommel [Tue, 18 Apr 2023 17:25:11 +0000 (19:25 +0200)]
Make mention autocomplete case insensitive in new markdown editor (#24190)

This matches EasyMDE, and makes it easier to find the right user without
having to remember the exact name.

---------

Co-authored-by: silverwind <me@silverwind.io>
17 months agoFix duplicate modals when clicking on "remove all" repository button (#24129)
Hester Gong [Tue, 18 Apr 2023 16:49:49 +0000 (00:49 +0800)]
Fix duplicate modals when clicking on "remove all" repository button (#24129)

Under Team tab of an organization, click on "remove all" repositories
button will trigger two modals. Because `data-modal-id` is not proerly
added.

Before:

https://user-images.githubusercontent.com/17645053/231988545-ac690b86-e3fe-4bf5-81c6-5ef09302e849.mov

After:

https://user-images.githubusercontent.com/17645053/231989678-53be4f91-fdc9-4bc5-ba11-a08aa4548e37.mov

17 months agoBump GitHub's `relative-time-element` to `v4.3.0` (#24187)
Yarden Shoham [Tue, 18 Apr 2023 16:00:01 +0000 (19:00 +0300)]
Bump GitHub's `relative-time-element` to `v4.3.0` (#24187)

https://github.com/github/relative-time-element/releases/tag/v4.3.0

I checked and everything still works

17 months agoFix wrong scopes of locale.PrettyNumber (#24181)
Hester Gong [Tue, 18 Apr 2023 11:26:57 +0000 (19:26 +0800)]
Fix wrong scopes of locale.PrettyNumber (#24181)

18 months agoFix incorrect internal response type (#24173)
wxiaoguang [Tue, 18 Apr 2023 03:10:40 +0000 (11:10 +0800)]
Fix incorrect internal response type (#24173)

Close #24167

The endpoint "set-default-branch" returns `success`, so just decode it
as `responseText`

18 months agozh-cn support on doc pages (#24166)
Kroytz [Tue, 18 Apr 2023 00:23:35 +0000 (08:23 +0800)]
zh-cn support on doc pages (#24166)

+ Add zh-cn support for upgrade-from-gitea page
+ Fix typo error on https-support.zh-cn page

18 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 18 Apr 2023 00:07:34 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

18 months agoUse double quotes consistently in en-US (#24141)
Panagiotis "Ivory" Vasilopoulos [Mon, 17 Apr 2023 22:04:26 +0000 (22:04 +0000)]
Use double quotes consistently in en-US (#24141)

Also removes quotes in commit messages related to file modifications
made in the Web UI.

18 months agoUse correct locale key for forks page (#24172)
John Olheiser [Mon, 17 Apr 2023 20:41:06 +0000 (15:41 -0500)]
Use correct locale key for forks page (#24172)

https://github.com/go-gitea/gitea/blob/4014200021a1997283c779a815fe9e5febf1fda1/options/locale/locale_en-US.ini#L873

https://github.com/go-gitea/gitea/blob/4014200021a1997283c779a815fe9e5febf1fda1/options/locale/locale_en-US.ini#L943

18 months agoImprove Wiki TOC (#24137)
wxiaoguang [Mon, 17 Apr 2023 19:05:19 +0000 (03:05 +0800)]
Improve Wiki TOC (#24137)

The old code has a lot of technical debts, eg: `repo/wiki/view.tmpl` /
`Iterate`

This PR improves the Wiki TOC display and improves the code.

---------

Co-authored-by: delvh <dev.lh@web.de>
18 months agoLocalize activity heatmap (except tooltip) (#24131)
Yarden Shoham [Mon, 17 Apr 2023 18:26:01 +0000 (21:26 +0300)]
Localize activity heatmap (except tooltip) (#24131)

The calculation of the total sum is moved to the backend so a full HTML
string could be sent.

![image](https://user-images.githubusercontent.com/20454870/232112381-c11d896b-ba47-40f8-b2a3-71cf4b3208de.png)

- Closes #10669
- 2nd attempt (the first was in #21570)

---------

Signed-off-by: Yarden Shoham <git@yardenshoham.com>
Co-authored-by: Giteabot <teabot@gitea.io>
18 months agoSupport triggering workflows by wiki related events (#24119)
Zettat123 [Mon, 17 Apr 2023 17:49:47 +0000 (01:49 +0800)]
Support triggering workflows by wiki related events (#24119)

This PR is to support triggering workflows by wiki related events like
creating, editing or deleting wiki pages. In GitHub, this event is
called
[gollum](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#gollum)

18 months agoadd CLI command to register runner tokens (#23762)
techknowlogick [Mon, 17 Apr 2023 17:07:13 +0000 (13:07 -0400)]
add CLI command to register runner tokens (#23762)

This is a CLI command to generate new tokens for the runners to register
with

Fix https://github.com/go-gitea/gitea/issues/23643

---------

Co-authored-by: delvh <dev.lh@web.de>
18 months agoAdd new user types `reserved`, `bot`, and `remote` (#24026)
techknowlogick [Mon, 17 Apr 2023 16:36:50 +0000 (12:36 -0400)]
Add new user types `reserved`, `bot`, and `remote` (#24026)

This allows for usernames, and emails connected to them to be reserved
and not reused.

Use case, I manage an instance with open registration, and sometimes
when users are deleted for spam (or other purposes), their usernames are
freed up and they sign up again with the same information.

This could also be used to reserve usernames, and block them from being
registered (in case an instance would like to block certain things
without hardcoding the list in code and compiling from scratch).

This is an MVP, that will allow for future work where you can set
something as reserved via the interface.

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
18 months agoFix Org edit page bugs: renaming detection, maxlength (#24161)
wxiaoguang [Mon, 17 Apr 2023 15:35:57 +0000 (23:35 +0800)]
Fix Org edit page bugs: renaming detection, maxlength (#24161)

## Before

* The renaming detection is wrong (eg: pasting a new name into the input
doesn't trigger the detection)
* The renaming prompt layout is not good
* Some MaxSize/maxlength rules is missing

![image](https://user-images.githubusercontent.com/2114189/232379191-5d0f6d10-56ca-4cec-ac52-7f77b9cb4a8a.png)

![image](https://user-images.githubusercontent.com/2114189/232379234-3289373b-9ddb-4627-ae86-f4d74589fa0c.png)

## After

* Fix these problems

![image](https://user-images.githubusercontent.com/2114189/232379098-31c6fa21-c210-4e7f-a337-b38b99670835.png)

18 months agoMake HAS_GO a simply expanded variable (#24169)
silverwind [Mon, 17 Apr 2023 14:46:25 +0000 (16:46 +0200)]
Make HAS_GO a simply expanded variable (#24169)

Avoid recursive expansion on this variable and simplify the value.
[Reference](https://www.gnu.org/software/make/manual/html_node/Setting.html).

18 months agoSupport converting varchar to nvarchar for mssql database (#24105)
Lunny Xiao [Mon, 17 Apr 2023 13:22:10 +0000 (21:22 +0800)]
Support converting varchar to nvarchar for mssql database (#24105)

18 months agoFix math and mermaid rendering bugs (#24049)
silverwind [Mon, 17 Apr 2023 10:10:22 +0000 (12:10 +0200)]
Fix math and mermaid rendering bugs (#24049)

1. Fix multiple error display for math and mermaid:

![err](https://user-images.githubusercontent.com/115237/231126411-8a21a777-cd53-4b7e-ac67-5332623106e8.gif)

2. Fix height calculation of certain mermaid diagrams by reading the
iframe inner height from it's document instead of parsing it from SVG:

Before:
<img width="866" alt="Screenshot 2023-04-11 at 11 56 27"
src="https://user-images.githubusercontent.com/115237/231126480-b194e02b-ea8c-4ddf-8c79-50c525815d92.png">

After:
<img width="855" alt="Screenshot 2023-04-11 at 11 56 35"
src="https://user-images.githubusercontent.com/115237/231126494-5fe86a48-8d21-455a-8b95-79b6ee27a16f.png">

3. Refactor error handling to a common function
4. Rename to `renderAsciicast` for consistency
5. Improve mermaid loading sequence

Note: I did try `securityLevel: 'sandbox'` to make mermaid output a
iframe directly, but that showed a bug in mermaid where the iframe style
height was set incorrectly. Opened
https://github.com/mermaid-js/mermaid/issues/4289 for this.

---------

Co-authored-by: Giteabot <teabot@gitea.io>
18 months agoRefactor locale number (#24134)
wxiaoguang [Mon, 17 Apr 2023 03:37:23 +0000 (11:37 +0800)]
Refactor locale number (#24134)

Before, the `GiteaLocaleNumber.js` was just written as a a drop-in
replacement for old `js-pretty-number`.

Actually, we can use Golang's `text` package to format.

This PR partially completes the TODOs in `GiteaLocaleNumber.js`:

> if we have complete backend locale support (eg: Golang "x/text"
package), we can drop this component.
> tooltip: only 2 usages of this, we can replace it with Golang's
"x/text/number" package in the future.

This PR also helps #24131

Screenshots:

<details>

![image](https://user-images.githubusercontent.com/2114189/232179420-b1b9974b-9d96-4408-b209-b80182c8b359.png)

![image](https://user-images.githubusercontent.com/2114189/232179416-14f36aa0-3f3e-4ac9-b366-7bd3a4464a11.png)

</details>

18 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 17 Apr 2023 00:07:34 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

18 months agoUse 1.18's aria role for dropdown menus (#24144)
wxiaoguang [Sun, 16 Apr 2023 13:58:22 +0000 (21:58 +0800)]
Use 1.18's aria role for dropdown menus (#24144)

According to erion's feedback, the 1.18 approach works with Safari
(`role=menu` on the parent container), while the 1.19's approach doesn't
work well with Safari+VoiceOver (although I tested it worked with Chrome
a little better).

I have tested this 1.18 approach could work for all
Safari/Chrome+VoiceOver and Chrome+Talkback.

Let's try to make it on try.gitea.io to see whether it helps Safari
users.

18 months agoSet EasyMDE heading font-size to the same size as the resulting markdown (#24151)
wxiaoguang [Sun, 16 Apr 2023 12:01:08 +0000 (20:01 +0800)]
Set EasyMDE heading font-size to the same size as the resulting markdown (#24151)

Fix #23816

According to my personal experience, the EasyMDE is still useful when
writing a lot of contents, eg: the wiki page.

It's not difficult to improve its heading styles, so let's make it.

Before:

<img width="815" alt="image"
src="https://user-images.githubusercontent.com/2114189/232280943-9177f0bc-e380-426f-8588-20ff8d8e5293.png">

After:

<img width="538" alt="image"
src="https://user-images.githubusercontent.com/2114189/232280903-e8c476ee-f5b1-48fe-8a93-86fcd79680c3.png">

18 months agoFix 2-dot direct compare to use the right base commit (#24133)
Jonathan Tran [Sun, 16 Apr 2023 07:27:23 +0000 (03:27 -0400)]
Fix 2-dot direct compare to use the right base commit (#24133)

For 2-dot direct compare, we should use the base commit in the title and
templates, as is used elsewhere, not the common ancestor which is used
for 3-dot compare. I believe that this change should have been included
in #22949.

18 months agoAdd migration to fix external unit access mode of owner/admin team (#24117)
yp05327 [Sat, 15 Apr 2023 13:52:44 +0000 (22:52 +0900)]
Add migration to fix external unit access mode of owner/admin team (#24117)

Fix the incorrect migration in #23675 and #24012

External Unit (Tracker and Wiki) access mode should be `read` in
owner/admin team.

18 months agoRemove untranslatable `on_date` key (#24106)
Yarden Shoham [Sat, 15 Apr 2023 11:01:54 +0000 (14:01 +0300)]
Remove untranslatable `on_date` key (#24106)

- Follows #23988
- Fixes: #24074 by removing this key

GitHub's `relative-time` elements allow us to force their rendering to
`auto`, `past`, or `future` tense. We will never show an absolute date
`on ...` in `TimeSince`

## Before

![image](https://user-images.githubusercontent.com/20454870/231735872-048c7bf3-6aa1-4113-929d-75a985c9922c.png)

## After

![image](https://user-images.githubusercontent.com/20454870/231736116-6ad47b63-77f4-4d3f-82a2-ee9a46ba2bd1.png)

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
18 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Sat, 15 Apr 2023 00:07:26 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

18 months agoSort repo topic labels by name (#24123)
wxiaoguang [Fri, 14 Apr 2023 19:29:05 +0000 (03:29 +0800)]
Sort repo topic labels by name (#24123)

Close #24077

18 months agoAdd option to search for users is active join a team (#24093)
Tyrone Yeh [Fri, 14 Apr 2023 18:48:36 +0000 (02:48 +0800)]
Add option to search for users is active join a team (#24093)

Adding a user in a team to enter a username gives a list of no active
users

---------

Co-authored-by: Jason Song <i@wolfogre.com>
18 months agoMake more functions use ctx instead of db.DefaultContext (#24068)
wxiaoguang [Fri, 14 Apr 2023 18:18:28 +0000 (02:18 +0800)]
Make more functions use ctx instead of db.DefaultContext (#24068)

Continue the "ctx refactoring" work.

There are still a lot db.DefaultContext, incorrect context could cause
database deadlock errors.

18 months agoFix meilisearch not working when searching across multiple repositories (#24109)
Brecht Van Lommel [Fri, 14 Apr 2023 17:27:11 +0000 (19:27 +0200)]
Fix meilisearch not working when searching across multiple repositories (#24109)

This would happen in the issue and pull request dashboards, while the
per repository lists worked fine.

Use OR instead of AND for repo IDs.

18 months agoShow friendly 500 error page to users and developers (#24110)
wxiaoguang [Fri, 14 Apr 2023 05:19:11 +0000 (13:19 +0800)]
Show friendly 500 error page to users and developers (#24110)

Close #24104

This also introduces many tests to cover many complex error handling
functions.

### Before

The details are never shown in production.

<details>

![image](https://user-images.githubusercontent.com/2114189/231805004-13214579-4fbe-465a-821c-be75c2749097.png)

</details>

### After

The details could be shown to site admin users. It is safe.

![image](https://user-images.githubusercontent.com/2114189/231803912-d5660994-416f-4b27-a4f1-a4cc962091d4.png)

18 months agoFix incorrect server error content in RunnersList (#24118)
yp05327 [Fri, 14 Apr 2023 03:34:10 +0000 (12:34 +0900)]
Fix incorrect server error content in RunnersList (#24118)

18 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 14 Apr 2023 00:07:25 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

18 months agoImprove git log for debugging (#24095)
wxiaoguang [Thu, 13 Apr 2023 23:17:27 +0000 (07:17 +0800)]
Improve git log for debugging (#24095)

18 months agoUpdate redis library to support redis v7 (#24114)
techknowlogick [Thu, 13 Apr 2023 22:41:04 +0000 (18:41 -0400)]
Update redis library to support redis v7 (#24114)

18 months agoRefactor cookie (#24107)
wxiaoguang [Thu, 13 Apr 2023 19:45:33 +0000 (03:45 +0800)]
Refactor cookie (#24107)

Close #24062

At the beginning, I just wanted to fix the warning mentioned by #24062

But, the cookie code really doesn't look good to me, so clean up them.

Complete the TODO on `SetCookie`:

> TODO: Copied from gitea.com/macaron/macaron and should be improved
after macaron removed.

18 months agoFix admin team access mode value in team_unit table (#24012)
yp05327 [Thu, 13 Apr 2023 19:06:10 +0000 (04:06 +0900)]
Fix admin team access mode value in team_unit table (#24012)

Same as https://github.com/go-gitea/gitea/pull/23675
Feedback:
https://github.com/go-gitea/gitea/pull/23879#issuecomment-1500923636

18 months agoAdd monospace toggle button to textarea (#24034)
silverwind [Thu, 13 Apr 2023 19:05:06 +0000 (21:05 +0200)]
Add monospace toggle button to textarea (#24034)

- Add new button to textarea to switch font. State is persisted in
localStorage.
- Change markdown-switch-easymde button from `<span>` to `<button>`
- Slightly increased monospace font globally by 5% as I think it fits
better.

For hover effect on these buttons I'm deferring to
https://github.com/go-gitea/gitea/pull/23896.

![](https://user-images.githubusercontent.com/115237/230948526-ecf8d730-0c69-4a8e-a1a5-1e5e079c754d.gif)

---------

Co-authored-by: delvh <dev.lh@web.de>
18 months agoCorrect the access log format (#24085)
Gary Moon [Thu, 13 Apr 2023 13:14:06 +0000 (09:14 -0400)]
Correct the access log format (#24085)

The default access log format has been unnecessarily escaped, leading to
spurious backslashes appearing in log lines.

Additionally, the `RemoteAddr` field includes the port, which breaks
most log parsers attempting to process it. I've added a call to
`net.SplitHostPort()` attempting to isolate the address alone, with a
fallback to the original address if it errs.

Signed-off-by: Gary Moon <gary@garymoon.net>
18 months agoChangelog v1.19.1 (#24079) (#24092)
6543 [Thu, 13 Apr 2023 08:45:54 +0000 (10:45 +0200)]
Changelog v1.19.1 (#24079) (#24092)

Frontport #24079

18 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 13 Apr 2023 00:07:24 +0000 (00:07 +0000)]
[skip ci] Updated translations via Crowdin

18 months agoBump vm2 from 3.9.15 to 3.9.16 (#24089)
dependabot[bot] [Wed, 12 Apr 2023 21:45:39 +0000 (17:45 -0400)]
Bump vm2 from 3.9.15 to 3.9.16 (#24089)

Bumps [vm2](https://github.com/patriksimek/vm2) from 3.9.15 to 3.9.16.

Signed-off-by: dependabot[bot] <support@github.com>
18 months agoFix difficult translation for other languages (#24070)
Lunny Xiao [Wed, 12 Apr 2023 17:05:53 +0000 (01:05 +0800)]
Fix difficult translation for other languages (#24070)

Fix https://github.com/go-gitea/gitea/pull/24051#discussion_r1163697643

---------

Co-authored-by: silverwind <me@silverwind.io>
18 months agoFix mismatch between hook events and github event types (#24048)
Zettat123 [Wed, 12 Apr 2023 16:16:47 +0000 (00:16 +0800)]
Fix mismatch between hook events and github event types (#24048)

Some workflow trigger events can have multiple activity types, such as
`issues` and `pull_request`, and user can specify which types can
trigger the workflow. See GitHub documentation:
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

Now some hook events cannot match the workflow trigger events correctly
because we don't check the activity types. For example,
`pull_request_label` is an individual hook event. But there isn't a
`pull_request_label` workflow trigger event, we can only use
`pull_request` event's `label` activity type. If we don't check the
activity types, the workflows without the `label` activity type may be
triggered by the `pull_request_label` event by mistake. We need to
improve the match logic.

- [x] [`issues`
](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issues)
- [x]
[`issue_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#issue_comment)
- [x]
[`pull_request`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request)
- [x]
[`pull_request_review`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review)
- [x]
[`pull_request_review_comment`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_review_comment)
- [x]
[`release`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release)
- [x]
[`registry_package`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#registry_package)

18 months agoImprove LFS error logs (#24072)
wxiaoguang [Wed, 12 Apr 2023 15:01:41 +0000 (23:01 +0800)]
Improve LFS error logs (#24072)

The error logs were not clear.

Help (but not fix) #24053

18 months agoUpdate the value of the `diffEnd` when click `Show More` btn in the DiffFileTree...
sillyguodong [Wed, 12 Apr 2023 13:11:23 +0000 (21:11 +0800)]
Update the value of the `diffEnd` when click `Show More` btn in the DiffFileTree (#24069)

In the component `DiffFileTree`,if don't update the value of the
`diffEnd` in the callback of ajax request, click `Show More` btn will
always return the same response, duplicate files are appended to the
file list.

Before:

https://user-images.githubusercontent.com/33891828/231371188-82d169af-10bb-47e2-8aca-83ced2597f2d.mov

After:

https://user-images.githubusercontent.com/33891828/231369805-39a5a4d0-662c-4f08-bc5a-7d31e8782453.mov

---------

Co-authored-by: Giteabot <teabot@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
18 months agoAdd tooltips to `Hide comment type` settings where necessary (#21306)
delvh [Wed, 12 Apr 2023 11:59:17 +0000 (13:59 +0200)]
Add tooltips to `Hide comment type` settings where necessary (#21306)

Previously, this setting was pretty confusing for users, especially the
difference between "reference" and "issue reference".
Related: #21321.

18 months agoUse a general approach to access custom/static/builtin assets (#24022)
wxiaoguang [Wed, 12 Apr 2023 10:16:45 +0000 (18:16 +0800)]
Use a general approach to access custom/static/builtin assets (#24022)

The idea is to use a Layered Asset File-system (modules/assetfs/layered.go)

For example: when there are 2 layers: "custom", "builtin", when access
to asset "my/page.tmpl", the Layered Asset File-system will first try to
use "custom" assets, if not found, then use "builtin" assets.

This approach will hugely simplify a lot of code, make them testable.

Other changes:

* Simplify the AssetsHandlerFunc code
* Simplify the `gitea embedded` sub-command code

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
18 months agoMake Release Download URLs predictable (#23891)
JakobDev [Wed, 12 Apr 2023 09:05:23 +0000 (11:05 +0200)]
Make Release Download URLs predictable (#23891)

As promised in #23817, I have this made a PR to make Release Download
URLs predictable. It currently follows the schema
`<repo>/releases/download/<tag>/<filename>`. this already works, but it
is nowhere shown in the UI or the API. The Problem is, that it is
currently possible to have multiple files with the same name (why do we
even allow this) for a release. I had written some Code to check, if a
Release has 2 or more files with the same Name. If yes, it uses the old
`attachments/<uuid>` URlL if no it uses the new fancy URL.

I had also changed `<repo>/releases/download/<tag>/<filename>` to
directly serve the File instead of redirecting, so people who who use
automatic update checker don't end up with the `attachments/<uuid>` URL.

Fixes #10919

---------

Co-authored-by: a1012112796 <1012112796@qq.com>
18 months agoExpand selected file when clicking file tree (#24041)
sillyguodong [Wed, 12 Apr 2023 07:06:39 +0000 (15:06 +0800)]
Expand selected file when clicking file tree (#24041)

Auto expand the selected file when clicking the file item of the file
tree.
This is consistent with Github's behavior.

https://user-images.githubusercontent.com/33891828/231048124-61f180af-adba-42d7-9ffa-626e1de04aed.mov

18 months agoLocalize milestone related time strings (#24051)
Yarden Shoham [Wed, 12 Apr 2023 06:29:49 +0000 (09:29 +0300)]
Localize milestone related time strings (#24051)

- With #23988 in place, we can improve these timestamps

---------

Co-authored-by: silverwind <me@silverwind.io>
18 months agoupdate BSDmakefile to latest version from upstream (#24063)
techknowlogick [Wed, 12 Apr 2023 03:42:22 +0000 (23:42 -0400)]
update BSDmakefile to latest version from upstream (#24063)

from https://github.com/neosmart/gmake-proxy

18 months agoAdd popup to hashed comments/pull requests/issues in file editing/adding preview...
Hester Gong [Wed, 12 Apr 2023 03:03:23 +0000 (11:03 +0800)]
Add popup to hashed comments/pull requests/issues in file editing/adding preview tab (#24040)

#23734 didn't add popups(tippy) to ref issues for the preview tab when
adding/editing a file

The location of the preview tab:
<img width="1214" alt="截屏2023-04-10 13 55 38"
src="https://user-images.githubusercontent.com/17645053/230836213-a73f0cee-378c-4a21-93db-583ba2c72f77.png">

This PR resues the logic in `ComboMarkdownEditor.js` to also add popup
to hashed comments/pull requests/issues in file editing/adding preview
tab.

After - On hover:
<img width="1222" alt="截屏2023-04-10 13 55 42"
src="https://user-images.githubusercontent.com/17645053/230836250-527ca7d0-6ec4-4c68-89ab-4f1b57b09239.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
18 months agoUse reactive store to share data between components (#23996)
wxiaoguang [Wed, 12 Apr 2023 00:44:26 +0000 (08:44 +0800)]
Use reactive store to share data between components (#23996)

Follow #23947

* Use reactive store to share data between components
* Remove no-op `this.hashListener = window.addEventListener()` because
`addEventListener` returns void/undefined.

Reference:

https://vuejs.org/guide/scaling-up/state-management.html#simple-state-management-with-reactivity-api

Screenshot (the same as before):

<details>

<img width="565" alt="image"
src="https://user-images.githubusercontent.com/2114189/230701282-bd61bfa3-7786-433b-9ad8-a88591112a02.png">

</details>

---------

Co-authored-by: silverwind <me@silverwind.io>
18 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 12 Apr 2023 00:08:36 +0000 (00:08 +0000)]
[skip ci] Updated translations via Crowdin

18 months agoFix accidental overwriting of LDAP team memberships (#24050)
sillyguodong [Tue, 11 Apr 2023 23:54:26 +0000 (07:54 +0800)]
Fix accidental overwriting of LDAP team memberships (#24050)

In the `for` loop, the value of `membershipsToAdd[org]` and
`membershipsToRemove[org]` is a slice that should be appended instead of
overwritten.
Due to the current overwrite, the LDAP group sync only matches the last
group at the moment.

## Example reproduction
- an LDAP user is both a member of
`cn=admin_staff,ou=people,dc=planetexpress,dc=com` and
`cn=ship_crew,ou=people,dc=planetexpress,dc=com`.
- configuration of `Map LDAP groups to Organization teams ` in
`Authentication Sources`:
```json
{
    "cn=admin_staff,ou=people,dc=planetexpress,dc=com":{
        "test_organization":[
            "admin_staff",
            "test_add"
        ]
    },
    "cn=ship_crew,ou=people,dc=planetexpress,dc=com":{
        "test_organization":[
            "ship_crew"
        ]
}
```
- start `Synchronize external user data` task in the `Dashboard`.
- the user was only added for the team `test_organization.ship_crew`

18 months agoAdd cardtype to org/user level project on creation, edit and view (#24043)
Hester Gong [Tue, 11 Apr 2023 18:28:40 +0000 (02:28 +0800)]
Add cardtype to org/user level project on creation, edit and view (#24043)

Part of #23318

The way to fix the missing cardtype for user/org level projects in this
PR is to port the cardtype related part from #22112 to org/user level
projects' template and router functions.

Before:
<img width="1135" alt="截屏2023-04-11 13 55 49"
src="https://user-images.githubusercontent.com/17645053/231069068-ba897129-ae90-4aa0-9b0f-468bf5c65375.png">

<img width="1131" alt="截屏2023-04-11 13 55 59"
src="https://user-images.githubusercontent.com/17645053/231069084-279f6681-5a10-42da-b5a8-2b0ba47c7078.png">

After:
Create
<img width="835" alt="截屏2023-04-11 13 27 16"
src="https://user-images.githubusercontent.com/17645053/231064445-0d6e12bd-5725-48db-a102-80e7472757c2.png">

Edit
<img width="852" alt="截屏2023-04-11 13 27 05"
src="https://user-images.githubusercontent.com/17645053/231064503-c70525cd-1038-43ec-8d93-8b8d95d183d4.png">

View
<img width="1329" alt="截屏2023-04-11 13 26 56"
src="https://user-images.githubusercontent.com/17645053/231064529-26023c85-698b-4b2e-af02-45f9820c77ec.png">

Co-authored-by: Giteabot <teabot@gitea.io>
18 months agoFix branch protection priority (#24045)
Lunny Xiao [Tue, 11 Apr 2023 17:22:49 +0000 (01:22 +0800)]
Fix branch protection priority (#24045)

Fix #24044

18 months agoUpdate documentation to explain which projects allow Gitea to host static pages ...
6543 [Tue, 11 Apr 2023 16:36:58 +0000 (18:36 +0200)]
Update documentation to explain which projects allow Gitea to host static pages (#23993)

close  #23521

---------

Signed-off-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>