]> source.dussan.org Git - gitea.git/log
gitea.git
19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Sat, 11 Mar 2023 00:15:59 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoHide target selector if tag exists when creating new release (#23171)
Zettat123 [Fri, 10 Mar 2023 16:42:38 +0000 (00:42 +0800)]
Hide target selector if tag exists when creating new release (#23171)

Close #22649.

|status|screenshot|
|-|-|
|empty tag name|<img
src="https://user-images.githubusercontent.com/15528715/221490165-fd3abd2e-6dc5-4562-bece-d1d6a305479e.png"
width="300px"/>|
|new tag|<img
src="https://user-images.githubusercontent.com/15528715/221490450-49b2a48e-b206-49f4-bd79-34b1ea64156f.png"
width="300px"/>|
|existing tag|<img
src="https://user-images.githubusercontent.com/15528715/221490301-4d1879dd-4947-4abc-9b9a-e77be1806981.png"
width="300px"/>|

19 months agoParse external request id from request headers, and print it in access log (#22906)
sillyguodong [Fri, 10 Mar 2023 15:54:32 +0000 (23:54 +0800)]
Parse external request id from request headers, and print it in access log (#22906)

Close: #22890.

---
### Configure in .ini file:
```ini
[log]
REQUEST_ID_HEADERS = X-Request-ID, X-Trace-Id
```

### Params in Request Header
```
X-Trace-ID: trace-id-1q2w3e4r
```

![image](https://user-images.githubusercontent.com/33891828/218665296-8fd19a0f-ada6-4236-8bdb-f99201c703e8.png)

### Log output:

![image](https://user-images.githubusercontent.com/33891828/218665225-cc242a57-4ffc-449a-a1f6-f45ded0ead60.png)

19 months agoAdd missing tabs to org projects page (#22705)
yp05327 [Fri, 10 Mar 2023 15:18:20 +0000 (00:18 +0900)]
Add missing tabs to org projects page (#22705)

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

Context Data `IsOrganizationMember` and `IsOrganizationOwner` is used to
control the visibility of `people` and `team` tab.

https://github.com/go-gitea/gitea/blob/2871ea08096cba15546f357d0ec473734ee9d8be/templates/org/menu.tmpl#L19-L40

And because of the reuse of user projects page, User Context is changed
to Organization Context. But the value of `IsOrganizationMember` and
`IsOrganizationOwner` are not being given.

I reused func `HandleOrgAssignment` to add them to the ctx, but may have
some unnecessary variables, idk whether it is ok.

I found there is a missing `PageIsViewProjects` at create project page.

19 months agoAdd user webhooks (#21563)
KN4CK3R [Fri, 10 Mar 2023 14:28:32 +0000 (15:28 +0100)]
Add user webhooks (#21563)

Currently we can add webhooks for organizations but not for users. This
PR adds the latter. You can access it from the current users settings.

![grafik](https://user-images.githubusercontent.com/1666336/197391408-15dfdc23-b476-4d0c-82f7-9bc9b065988f.png)

19 months agoHandle OpenID discovery URL errors a little nicer when creating/editing sources ...
zeripath [Fri, 10 Mar 2023 06:14:43 +0000 (06:14 +0000)]
Handle OpenID discovery URL errors a little nicer when creating/editing sources (#23397)

When there is an error creating a new openIDConnect authentication
source try to handle the error a little better.

Close #23283

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoSplit CI pipelines (#23385)
John Olheiser [Fri, 10 Mar 2023 06:13:17 +0000 (00:13 -0600)]
Split CI pipelines (#23385)

- This PR attempts to split our various DB tests into separate
pipelines.
- It splits up some of the extra feature-related tests rather than
having most of them in the MySQL test.
- It disables the race detector for some of the pipelines as well, as it
can cause slower runs and is mostly redundant when the pipelines just
swap DBs.
- It builds without SQLite support for any of the non-SQLite pipelines.
- It moves the e2e test to using SQLite rather than PG (partially
because I moved the minio tests to PG and that mucked up the test
config, and partially because it avoids another running service)
- It splits up the `go mod download` task in the Makefile from the tool
installation, as the tools are only needed in the compliance pipeline.
(Arguably even some of the tools aren't needed there, but that could be
a follow-up PR)
- SQLite is now the only arm64 pipeline, moving PG back to amd64 which
can leverage autoscaler

Should resolve #22010 - one thing that wasn't changed here but is
mentioned in that issue, unit tests are needed in the same pipeline as
an integration test in order to form a complete coverage report (at
least as far as I could tell), so for now it remains in a pipeline with
a DB integration test.

Please let me know if I've inadvertently changed something that was how
it was on purpose.

---

I will say sometimes it's hard to pin down the average time, as a
pipeline could be waiting for a runner for X minutes and that brings the
total up by X minutes as well, but overall this does seem to be faster
on average.

---------

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoImprove squash merge commit author and co-author with private emails (#22977)
Brecht Van Lommel [Fri, 10 Mar 2023 03:17:04 +0000 (04:17 +0100)]
Improve squash merge commit author and co-author with private emails (#22977)

When emails addresses are private, squash merges always use
`@noreply.localhost` for the author of the squash commit. And the author
is redundantly added as a co-author in the commit message.

Also without private mails, the redundant co-author is possible when
committing with a signature that's different than the user full name and
primary email.

Now try to find a commit by the same user in the list of commits, and
prefer the signature from that over one constructed from the account
settings.

19 months agoFix broken Chroma CSS styles (#23174)
wxiaoguang [Fri, 10 Mar 2023 03:16:16 +0000 (11:16 +0800)]
Fix broken Chroma CSS styles (#23174)

The CSS styles in Gitea themes are out-of-sync of Chroma's styles.

This PR introduces a `chroma-style-diff.go` tool to compare the diff.
The missing CSS styles have been added manually. They are left as empty
to reduce arguments because there was no color for them before.

And this PR fixes #22348, with just 2 lines changed: `.chroma .kt & .n`,
these colors are taken from GitHub.

It's good enough for #22348

![image](https://user-images.githubusercontent.com/2114189/221551941-0d27d11d-e71e-498f-8e88-92b558fe4a18.png)

---------

Co-authored-by: silverwind <me@silverwind.io>
19 months agoAdd gradle samples in maven doc of packages (#23374)
InsanusMokrassar [Fri, 10 Mar 2023 03:14:59 +0000 (09:14 +0600)]
Add gradle samples in maven doc of packages (#23374)

Samples for gitea.io docs to help to use maven packages with
gradle-oriented projects

---------

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
19 months agoFix and move "Use this template" button (#23398)
silverwind [Fri, 10 Mar 2023 03:14:45 +0000 (04:14 +0100)]
Fix and move "Use this template" button (#23398)

Before:
<img width="1157" alt="Screenshot 2023-03-09 at 23 21 25"
src="https://user-images.githubusercontent.com/115237/224174168-869966cc-fa59-4231-b449-23bd9db12862.png">

After:
<img width="1145" alt="Screenshot 2023-03-09 at 23 24 34"
src="https://user-images.githubusercontent.com/115237/224174173-7f5b9c22-44c4-4eed-990c-da49d749eb0e.png">

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 10 Mar 2023 00:15:59 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoAdd init file for Ubuntu (#23362)
Lycolia Rizzim [Thu, 9 Mar 2023 22:54:37 +0000 (07:54 +0900)]
Add init file for Ubuntu (#23362)

Created an init file for Ubuntu that will be useful when running it on
WSL.

19 months agoRename `canWriteUnit` to `canWriteProjects` (#23386)
yp05327 [Thu, 9 Mar 2023 19:57:20 +0000 (04:57 +0900)]
Rename `canWriteUnit` to `canWriteProjects` (#23386)

A part of https://github.com/go-gitea/gitea/pull/22865

19 months agoFix pull request update showing too many commits with multiple branches (#22856)
Brecht Van Lommel [Thu, 9 Mar 2023 18:14:22 +0000 (19:14 +0100)]
Fix pull request update showing too many commits with multiple branches (#22856)

When the base repository contains multiple branches with the same
commits as the base branch, pull requests can show a long list of
commits already in the base branch as having been added.

What this is supposed to do is exclude commits already in the base
branch. But the mechansim to do so assumed a commit only exists in a
single branch. Now use `git rev-list A B --not branchName` instead of
filtering commits afterwards.

The logic to detect if there was a force push also was wrong for
multiple branches. If the old commit existed in any branch in the base
repository it would assume there was no force push. Instead check if the
old commit is an ancestor of the new commit.

19 months agoFix incorrect NotFound conditions in org/projects.go (#23384)
yp05327 [Thu, 9 Mar 2023 16:59:50 +0000 (01:59 +0900)]
Fix incorrect NotFound conditions in org/projects.go (#23384)

A part of https://github.com/go-gitea/gitea/pull/22865

user/org project's `RepoID` is always 0, we need to check `OwnerID`

19 months agoRefactor merge/update git command calls (#23366)
wxiaoguang [Thu, 9 Mar 2023 15:48:52 +0000 (23:48 +0800)]
Refactor merge/update git command calls (#23366)

Follow #22568

* Remove unnecessary ToTrustedCmdArgs calls
    * the FAQ in  #22678
* Quote: When using ToTrustedCmdArgs, the code will be very complex (see
the changes for examples). Then developers and reviewers can know that
something might be unreasonable.
* The `signArg` couldn't be empty, it's either `-S{keyID}` or
`--no-gpg-sign`.
* Use `signKeyID` instead, add comment "empty for no-sign, non-empty to
sign"
* 5-line code could be extracted to a common `NewGitCommandCommit()` to
handle the `signKeyID`, but I think it's not a must, current code is
clear enough.

19 months agoRedirect to project again after editing it (#23326)
yp05327 [Thu, 9 Mar 2023 14:38:29 +0000 (23:38 +0900)]
Redirect to project again after editing it (#23326)

A part of https://github.com/go-gitea/gitea/pull/22865

We have edit buttons in projects list page and project view page.
But after user edit a project, it will always redirect to the projects
list page.

19 months agoAdd Gitea Community Code of Conduct (#23188)
Jason Song [Thu, 9 Mar 2023 02:49:34 +0000 (10:49 +0800)]
Add Gitea Community Code of Conduct (#23188)

The Gitea Community Code of Conduct.

Authored by lunny. Slightly modified from [Go
CoC](https://go.dev/conduct)

---

CC all TOCs:

@go-gitea/technical-oversight-committee

And we welcome suggestions from everyone.

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Nick <nick@kousu.ca>
Co-authored-by: Lauris BH <lauris@nix.lv>
19 months agoTest renderReadmeFile (#23185)
Nick [Thu, 9 Mar 2023 01:24:23 +0000 (20:24 -0500)]
Test renderReadmeFile (#23185)

Add test coverage to the important features of
[`routers.web.repo.renderReadmeFile`](https://github.com/go-gitea/gitea/blob/067b0c2664d127c552ccdfd264257caca4907a77/routers/web/repo/view.go#L273);
namely that:

- it can handle looking in docs/, .gitea/, and .github/
- it can handle choosing between multiple competing READMEs
- it prefers the localized README to the markdown README to the
plaintext README
- it can handle broken symlinks when processing all the options
- it uses the name of the symlink, not the name of the target of the
symlink

19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 9 Mar 2023 00:15:57 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoSet `X-Gitea-Debug` header once (#23361)
Yarden Shoham [Wed, 8 Mar 2023 20:40:04 +0000 (22:40 +0200)]
Set `X-Gitea-Debug` header once (#23361)

Instead of adding it

# Before
On the raw commit page:

![image](https://user-images.githubusercontent.com/20454870/223470744-cdf11898-e023-4198-8c8b-c294e5d78b73.png)

# After

![image](https://user-images.githubusercontent.com/20454870/223470596-af898d66-bd5b-4ddb-b220-ceb1f149bfec.png)

Fixes #23308

---------

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
19 months agoImprove cache context (#23330)
Jason Song [Wed, 8 Mar 2023 17:57:05 +0000 (01:57 +0800)]
Improve cache context (#23330)

Related to: #22294 #23186 #23054

Replace: #23218

Some discussion is in the comments of #23218.

Highlights:
- Add Expiration for cache context. If a cache context has been used for
more than 10s, the cache data will be ignored, and warning logs will be
printed.
- Add `discard` field to `cacheContext`, a `cacheContext` with `discard`
true will drop all cached data and won't store any new one.
- Introduce `WithNoCacheContext`, if one wants to run long-life tasks,
but the parent context is a cache context,
`WithNoCacheContext(perentCtx)` will discard the cache data, so it will
be safe to keep the context for a long time.
- It will be fine to treat an original context as a cache context, like
`GetContextData(context.Backgraud())`, no warning logs will be printed.

Some cases about nesting:

When:
- *A*, *B* or *C* means a cache context.
- ~*A*~, ~*B*~ or ~*C*~ means a discard cache context.
- `ctx` means `context.Backgrand()`
- *A(ctx)* means a cache context with `ctx` as the parent context.
- *B(A(ctx))* means a cache context with `A(ctx)` as the parent context.
- `With` means `WithCacheContext`
- `WithNo` means `WithNoCacheContext`

So:
- `With(ctx)` -> *A(ctx)*
- `With(With(ctx))` -> *A(ctx)*, not *B(A(ctx))*
- `With(With(With(ctx)))` -> *A(ctx)*, not *C(B(A(ctx)))*
- `WithNo(ctx)` -> *ctx*, not *~A~(ctx)*
- `WithNo(With(ctx))` -> *~A~(ctx)*
- `WithNo(WithNo(With(ctx)))` -> *~A~(ctx)*, not *~B~(~A~(ctx))*
- `With(WithNo(With(ctx)))` -> *B(~A~(ctx))*
- `WithNo(With(WithNo(With(ctx))))` -> *~B~(~A~(ctx))*
- `With(WithNo(With(WithNo(With(ctx)))))` -> *C(~B~(~A~(ctx)))*

19 months agoadd user visibility in dashboard navbar (#22747)
yp05327 [Wed, 8 Mar 2023 15:18:10 +0000 (00:18 +0900)]
add user visibility in dashboard navbar (#22747)

Add private/limited tag to dashboard user/org list dropdown menu

![image](https://user-images.githubusercontent.com/18380374/216752207-5beb5281-1b0b-4e2b-adfc-b39c192c5032.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix panic when getting notes by ref (#23372)
Zettat123 [Wed, 8 Mar 2023 12:21:23 +0000 (20:21 +0800)]
Fix panic when getting notes by ref (#23372)

Fix #23357 .

Now the `/repos/{owner}/{repo}/git/notes/{sha}` API supports getting
notes by a ref or sha
(https://try.gitea.io/api/swagger#/repository/repoGetNote). But the
`GetNote` func can only accept commit ID.

https://github.com/go-gitea/gitea/blob/a12f5757372f751d25f9e5ca1f168f6920ded894/modules/git/notes_nogogit.go#L18

So we need to convert the query parameter to commit ID before calling
`GetNote`.

19 months agoUse CleanPath instead of path.Clean (#23371)
Lunny Xiao [Wed, 8 Mar 2023 12:17:39 +0000 (20:17 +0800)]
Use CleanPath instead of path.Clean (#23371)

As title.

19 months agoReduce duplicate and useless code in options (#23369)
Jason Song [Wed, 8 Mar 2023 09:31:27 +0000 (17:31 +0800)]
Reduce duplicate and useless code in options (#23369)

Avoid maintaining two copies of code, some functions can be used with
both `bindata` and `no bindata`.

And removed `GetRepoInitFile`, it's useless now.
`Readme`/`Gitignore`/`License`/`Labels` will clean the name and use
custom files when available.

19 months agoClean Path in Options (#23006)
JakobDev [Wed, 8 Mar 2023 07:07:58 +0000 (08:07 +0100)]
Clean Path in Options (#23006)

At the Moment it is possible to read files in another Directory as
supposed using the Options functions. e.g.
`options.Gitignore("../label/Default) `. This was discovered while
working on #22783, which exposes `options.Gitignore()` through the
public API. At the moment, this is not a security problem, as this
function is only used internal, but I thought it would be a good idea to
make a PR to fix this for all types of Options files, not only
Gitignore, to make it safe for the further. This PR should be merged
before the linked PR.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
19 months agoDo not recognize text files as audio (#23355)
wxiaoguang [Wed, 8 Mar 2023 03:40:41 +0000 (11:40 +0800)]
Do not recognize text files as audio (#23355)

Close #17108

This PR uses a trick (removing the ID3 tag) to detect the content again
to to see whether the content is text type.

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix incorrect display for comment context menu (#23343)
wxiaoguang [Wed, 8 Mar 2023 03:26:37 +0000 (11:26 +0800)]
Fix incorrect display for comment context menu  (#23343)

Replace #23342

Fix a regression of #23014: the `a` couldn't be used here because
Fomantic UI has style conflicts: `.ui.comments .comment .actions a {
display: inline-block; }`

And complete one more of my TODOs: "in the future there could be a
special CSS class for it"

19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 8 Mar 2023 00:15:50 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoPass context to avatar for projects view (#23359)
delvh [Tue, 7 Mar 2023 23:17:35 +0000 (00:17 +0100)]
Pass context to avatar for projects view (#23359)

Previously, a 500 response was returned when
- an issue had assignees
- the issue was assigned to a project
- you tried to view this project

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoRefactor and tidy-up the merge/update branch code (#22568)
zeripath [Tue, 7 Mar 2023 20:07:35 +0000 (20:07 +0000)]
Refactor and tidy-up the merge/update branch code (#22568)

The merge and update branch code was previously a little tangled and had
some very long functions. The functions were not very clear in their
reasoning and there were deficiencies in their logging and at least one
bug in the handling of LFS for update by rebase.

This PR substantially refactors this code and splits things out to into
separate functions. It also attempts to tidy up the calls by wrapping
things in "context"s. There are also attempts to improve logging when
there are errors.

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: delvh <dev.lh@web.de>
19 months agoFix adding of empty class name (#23352)
Hester Gong [Tue, 7 Mar 2023 15:08:22 +0000 (23:08 +0800)]
Fix adding of empty class name (#23352)

This PR is to fix the error shown below. The reason is because
[`class-name`
prop](https://github.com/go-gitea/gitea/blob/main/web_src/js/components/ActionRunStatus.vue#L6)
given to `svg` component has a space, and classList cannot add empty
string.

https://user-images.githubusercontent.com/17645053/223346720-c7f9de43-5e69-4ecf-93c0-90bf04090693.mov

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix various ImageDiff/SVG bugs (#23312)
wxiaoguang [Tue, 7 Mar 2023 12:11:24 +0000 (20:11 +0800)]
Fix various ImageDiff/SVG bugs (#23312)

Replace #23310, Close #19733

And fix various UI problems, including regressions from #22959 #22950
and more.

## SVG Detection

The old regexp may mismatch non-SVG files. This PR adds new tests for
those cases.

## UI Changes

### Before

![image](https://user-images.githubusercontent.com/2114189/222967716-f6ad8721-f46a-4a3f-9eb0-a89e488d3436.png)

![image](https://user-images.githubusercontent.com/2114189/222967780-8af8981a-e69d-4304-9dc4-0235582fa4f4.png)

### After

![image](https://user-images.githubusercontent.com/2114189/222967575-c21c23d4-0200-4e09-aac3-57895e853000.png)

![image](https://user-images.githubusercontent.com/2114189/222967585-8b8da262-bc96-441a-9851-8d3845f2659d.png)

![image](https://user-images.githubusercontent.com/2114189/222967595-58d9bea5-6df4-41fa-bf8a-86704117959d.png)

![image](https://user-images.githubusercontent.com/2114189/222967608-38757c1a-b8bd-4ebf-b7a8-3b30edb7f303.png)

![image](https://user-images.githubusercontent.com/2114189/222967623-9849a339-6fae-4484-8fa5-939e2fdacbf5.png)

![image](https://user-images.githubusercontent.com/2114189/222967633-4383d7dd-62ba-47a3-8c10-86f7ca7757ae.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoRefactor `setting.Database.UseXXX` to methods (#23354)
Jason Song [Tue, 7 Mar 2023 10:51:06 +0000 (18:51 +0800)]
Refactor `setting.Database.UseXXX` to methods (#23354)

Replace #23350.

Refactor `setting.Database.UseMySQL` to
`setting.Database.Type.IsMySQL()`.

To avoid mismatching between `Type` and `UseXXX`.

This refactor can fix the bug mentioned in #23350, so it should be
backported.

19 months agoUpdate documentation for the new YAML label file format (#23020)
JonRB [Mon, 6 Mar 2023 23:39:07 +0000 (23:39 +0000)]
Update documentation for the new YAML label file format  (#23020)

update documentation to include an overview of the yaml label template that is part of PR #22976

Signed-off-by: Jon Roadley-Battin <jon.roadleybattin@gmail.com>
---------

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
19 months agoRemove unnecessary space on link (#23334)
Lunny Xiao [Mon, 6 Mar 2023 19:12:10 +0000 (03:12 +0800)]
Remove unnecessary space on link (#23334)

The action run title has a blank. This PR removes it.

19 months agoFix incorrect redirect link of delete org project (#23327)
yp05327 [Mon, 6 Mar 2023 18:05:26 +0000 (03:05 +0900)]
Fix incorrect redirect link of delete org project (#23327)

A part of https://github.com/go-gitea/gitea/pull/22865/commits

The old code will cause 500 error.

19 months agoFix incorrect project links and use symlink icon for org-wide projects (#23325)
yp05327 [Mon, 6 Mar 2023 16:32:56 +0000 (01:32 +0900)]
Fix incorrect project links and use symlink icon for org-wide projects (#23325)

Fix displaying same projects icons between user/repo projects.
And fix incorrect projects links.
A part of https://github.com/go-gitea/gitea/pull/22865.

![image](https://user-images.githubusercontent.com/18380374/223044279-7b620ff1-d88a-4146-97e6-531bbf269761.png)

![image](https://user-images.githubusercontent.com/18380374/223044390-42911e3f-1f6b-439f-8441-4f3ebf99ea13.png)

![image](https://user-images.githubusercontent.com/18380374/223044437-5cad5391-0f95-4c8b-b0a3-32e263e2854f.png)

19 months agoFix PR view misalignment caused by long name file (#23321)
Hester Gong [Mon, 6 Mar 2023 15:44:04 +0000 (23:44 +0800)]
Fix PR view misalignment caused by long name file (#23321)

Close #23248

The UI after this PR:

https://user-images.githubusercontent.com/17645053/223009758-7f0c9f12-d346-4cb2-a605-729fddce732f.mov

19 months agoAdd ActionRunStatus component (#23259)
yp05327 [Mon, 6 Mar 2023 14:35:24 +0000 (23:35 +0900)]
Add ActionRunStatus component (#23259)

Related to:
https://github.com/go-gitea/gitea/pull/23212#discussion_r1122856231

Decrease duplication of SvgIcon when display a run status svg.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoScoped labels: don't require holding alt key to remove (#23303)
Brecht Van Lommel [Mon, 6 Mar 2023 10:20:29 +0000 (11:20 +0100)]
Scoped labels: don't require holding alt key to remove (#23303)

Alt doesn't work on all browsers, the simplest solution for v1.19 is to
just not require it and toggle the label by just clicking.

Part of #22974

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoUpdate hacking-on-gitea-zh_cn documentation (#23315)
Lunny Xiao [Mon, 6 Mar 2023 07:14:00 +0000 (15:14 +0800)]
Update hacking-on-gitea-zh_cn documentation (#23315)

This PR fix outdated hacking-on-gitea-zh_cn documentation.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
19 months agoFix broken code editor diff preview (#23307)
wxiaoguang [Mon, 6 Mar 2023 01:37:58 +0000 (09:37 +0800)]
Fix broken code editor diff preview (#23307)

Close #23265, the code editor diff preview has been broken for long
time.

* Fix the regression for `data-line-num`
    * `.code-diff` is necessary to show the line number
* Fix the regression for #12434
* The diff:
[12434](https://github.com/go-gitea/gitea/pull/12434/files?diff=unified&w=1)
    * It hides the Type(4) (aka HunkHeader)  for unexpected cases.

Diff with ignoring whitespaces:
https://github.com/go-gitea/gitea/pull/23307/files?diff=unified&w=1

Before: see the issue #23265

After:

![image](https://user-images.githubusercontent.com/2114189/222942810-286dc9af-0b39-4e9d-8585-8c299b881241.png)

19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 6 Mar 2023 00:15:51 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoAdd context when rendering labels or emojis (#23281)
Jonathan Tran [Sun, 5 Mar 2023 21:59:05 +0000 (16:59 -0500)]
Add context when rendering labels or emojis (#23281)

This branch continues the work of #23092 and attempts to rid the
codebase of any `nil` contexts when using a `RenderContext`.

Anything that renders markdown or does post processing may call
`markup.sha1CurrentPatternProcessor()`, and this runs
`git.OpenRepository()`, which needs a context. It will panic if the
context is `nil`. This branch attempts to _always_ include a context
when creating a `RenderContext` to prevent future crashes.

Co-authored-by: Kyle D <kdumontnu@gmail.com>
19 months agoChange interactiveBorder to fix popup preview (#23169)
Hester Gong [Sun, 5 Mar 2023 15:40:50 +0000 (23:40 +0800)]
Change interactiveBorder to fix popup preview  (#23169)

Close #23073.
Used the solution as reference to the reply:
https://github.com/go-gitea/gitea/issues/23073#issuecomment-1440124609
Here made the change inside the `contextpopup.js` because this is where
the popup component is created and tippy configuration is given.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoImprove the frontend guideline (#23298)
wxiaoguang [Sun, 5 Mar 2023 14:23:42 +0000 (22:23 +0800)]
Improve the frontend guideline (#23298)

### The CustomEvent prefix

There was already `ce-quick-submit`, the `ce-` prefix seems better than
`us-`. Rename the only `us-` prefixed `us-load-context-popup` to `ce-`
prefixed.

### Styles and Attributes in Go HTML Template

https://github.com/go-gitea/gitea/pull/21855#issuecomment-1429643073

Suggest to stick to `class="c1 {{if $var}}c2{{end}}"`

The readability and maintainability should be applied to the code which
is read by developers, but not for the generated outputs.

The template code is the code for developers, while the generated HTML
are only for browsers.

The `class="c1 {{if $var}}c2{{end}}"` style is clearer for developers
and more intuitive, and the generated HTML also makes browsers happy (a
few spaces do not affect anything)

Think about a more complex case:

* `class="{{if $active}}active{{end}} menu item {{if $show}}show{{end}}
{{if $warn}}warn{{end}}"`
* --vs--
* `class="{{if $active}}active {{end}}menu item{{if $show}}
show{{end}}{{if $warn}} warn{{end}}"`

The first style make it clearer to see each CSS class name with its
`{{if}}` block.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoScoped labels: set aria-disabled on muted Exclusive option for a11y (#23306)
Brecht Van Lommel [Sun, 5 Mar 2023 13:25:25 +0000 (14:25 +0100)]
Scoped labels: set aria-disabled on muted Exclusive option for a11y (#23306)

It is convenient to be able to toggle off this option after removing /
from the name. This ensures the muted state is communicated to blind
users even when the input is not fully disabled.

Part of #22974

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoAdd basic documentation for labels, including scoped labels (#23304)
Brecht Van Lommel [Sun, 5 Mar 2023 12:35:12 +0000 (13:35 +0100)]
Add basic documentation for labels, including scoped labels (#23304)

Part of #22974

---------

Co-authored-by: delvh <dev.lh@web.de>
19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Sun, 5 Mar 2023 00:15:41 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoRe-add accidentally removed `hacking-on-gitea.zh-cn.md` (#23297)
Lunny Xiao [Sat, 4 Mar 2023 21:34:02 +0000 (05:34 +0800)]
Re-add accidentally removed `hacking-on-gitea.zh-cn.md` (#23297)

#21627 accidentally removed the docs file `hacking-on-gitea.zh-cn.md`.
This re-adds it and merges some changes from #23289

19 months agoAdd default owner team to privated_org and limited_org in unit test (#23109)
yp05327 [Sat, 4 Mar 2023 19:23:51 +0000 (04:23 +0900)]
Add default owner team to privated_org and limited_org in unit test (#23109)

Related to https://github.com/go-gitea/gitea/pull/22705 's CI result
[here](https://drone.gitea.io/go-gitea/gitea/68043/2/16)
> IsOrganizationOwner() [E] [63f61849-7] Organization does not have
owner team: 23

19 months agoImprove sed detection in update-locales.sh (#23254)
silverwind [Sat, 4 Mar 2023 14:29:28 +0000 (15:29 +0100)]
Improve sed detection in update-locales.sh (#23254)

- ~~Make scripts work from any directory~~
- Detect sed version just like Makefile does

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
19 months agoSupport sanitising the URL by removing extra slashes in the URL (#21333)
Sandeep Bhat [Sat, 4 Mar 2023 13:31:24 +0000 (19:01 +0530)]
Support sanitising the URL by removing extra slashes in the URL (#21333)

Changes in this PR :

Strips incoming request URL of additional slashes (/). For example an
input like

`https://git.data.coop//halfd/new-website.git` is translated to
`https://git.data.coop/halfd/new-website.git`

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

Fix #23242

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoMake Ctrl+Enter submit a pending comment (starting review) instead of submitting...
wxiaoguang [Sat, 4 Mar 2023 07:13:37 +0000 (15:13 +0800)]
Make Ctrl+Enter submit a pending comment (starting review) instead of submitting a single comment (#23245)

Close #23241

Before: press Ctrl+Enter in the Code Review Form, a single comment will
be added.

After: press Ctrl+Enter in the Code Review Form, start the review with
pending comments.

The old name `is_review` is not clear, so the new code use
`pending_review` as the new name.

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoAvoid panic caused by broken payload when creating commit status (#23216)
Jason Song [Sat, 4 Mar 2023 07:12:37 +0000 (15:12 +0800)]
Avoid panic caused by broken payload when creating commit status (#23216)

When creating commit status for Actons jobs, a payload with nil
`HeadCommit` will cause panic.

Reported at:
https://gitea.com/gitea/act_runner/issues/28#issuecomment-732166

Although the `HeadCommit` probably can not be nil after #23215,
`CreateCommitStatus` should protect itself, to avoid being broken in the
future.

In addition, it's enough to print error log instead of returning err
when `CreateCommitStatus` failed.

---------

Co-authored-by: delvh <dev.lh@web.de>
19 months agoAdd run status in action view page (#23212)
yp05327 [Sat, 4 Mar 2023 05:41:37 +0000 (14:41 +0900)]
Add run status in action view page (#23212)

Before:

![image](https://user-images.githubusercontent.com/18380374/222084932-a7643fbe-2d9f-48db-b25d-74ace49e03f4.png)

![image](https://user-images.githubusercontent.com/18380374/222084887-fde3500d-dad3-4902-9c82-c4f71f23f83b.png)

After:

![image](https://user-images.githubusercontent.com/18380374/222084565-eeef1110-9d9d-40b4-a26b-fbd5a307f14e.png)

![image](https://user-images.githubusercontent.com/18380374/222084728-6c96d7c1-a399-43d5-8369-392ad5017b7f.png)

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoupdate to mermaid v10 (#23178)
techknowlogick [Sat, 4 Mar 2023 05:39:07 +0000 (00:39 -0500)]
update to mermaid v10 (#23178)

fix #23153

---------

Co-authored-by: silverwind <me@silverwind.io>
19 months agoFix code wrap for unbroken lines (#23268)
wxiaoguang [Sat, 4 Mar 2023 04:48:59 +0000 (12:48 +0800)]
Fix code wrap for unbroken lines (#23268)

## The Problem

`overflow-wrap: break-word` doesn't work well for unbroken lines. Use
`overflow-wrap: anywhere` instead, and remove legacy alias `word-wrap`

## Before

![image](https://user-images.githubusercontent.com/2114189/222743939-5f38d9e4-18d8-4ae0-8078-4b3a59195a30.png)

## After

![image](https://user-images.githubusercontent.com/2114189/222743833-0e0cfdbb-7b2e-420d-99f9-b1b45dde521a.png)

---------

Co-authored-by: silverwind <me@silverwind.io>
19 months agoFix stray backticks appearing in pull request timeline (#23282)
Brecht Van Lommel [Sat, 4 Mar 2023 04:48:05 +0000 (05:48 +0100)]
Fix stray backticks appearing in pull request timeline (#23282)

Caused by #23189.

19 months agoFill head commit to in payload when notifying push commits for mirroring (#23215)
Jason Song [Sat, 4 Mar 2023 04:45:53 +0000 (12:45 +0800)]
Fill head commit to in payload when notifying push commits for mirroring (#23215)

Just like what has been done when pushing manually:

https://github.com/go-gitea/gitea/blob/7a5af25592003ddc3017fcd7b822a3e02fc40ef6/services/repository/push.go#L225-L226

Before:

<img width="448" alt="image"
src="https://user-images.githubusercontent.com/9418365/222100123-cd4839d1-2d4d-45f7-b7a0-0cbc73162b44.png">

After:

<img width="448" alt="image"
src="https://user-images.githubusercontent.com/9418365/222100225-f3c5bb65-7ab9-41e2-8e39-9d84c23c352d.png">

---------

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix various bugs for "install" page (#23194)
wxiaoguang [Sat, 4 Mar 2023 02:12:02 +0000 (10:12 +0800)]
Fix various bugs for "install" page (#23194)

## TLDR

* Fix the broken page / broken image problem when click "Install"
* Close #20089
* Fix the Password Hash Algorithm display problem for #22942
* Close #23183
* Close #23184

## Details

### The broken page / broken image problem when click "Install"
(Redirect failed after install gitea #23184)

Before: when click "install", all new requests will fail, because the
server has been restarted. Users just see a broken page with broken
images, sometimes the server is not ready but the user would have been
redirect to "/user/login" page, then the users see a new broken page
(connection refused or something wrong ...)

After: only check InstallLock=true for necessary handlers, and sleep for
a while before restarting the server, then the browser has enough time
to load the "post-install" page. And there is a script to check whether
"/user/login" is ready, the user will only be redirected to the login
page when the server is ready.

### During new instance setup make 'Gitea Base URL' filled from
window.location.origin #20089

If the "app_url" input contains `localhost` (the default value from
config), use current window's location href as the `app_url` (aka
ROOT_URL)

### Fix the Password Hash Algorithm display problem for "Provide the
ability to set password hash algorithm parameters #22942"

Before: the UI shows `pbkdf2$50000$50`

<details>

![image](https://user-images.githubusercontent.com/2114189/221917143-e1e54798-1698-4fee-a18d-00c48081fc39.png)

</details>

After: the UI shows `pbkdf2`

<details>

![image](https://user-images.githubusercontent.com/2114189/221916999-97a15be8-2ebb-4a01-bf93-dac18e354fcc.png)

</details>

### GET data: net::ERR_INVALID_URL #23183

Cause by empty `data:` in `<link rel="manifest"
href="data:{{.ManifestData}}">`

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoFix GetFilesChangedBetween if the file name may be escaped (#23272)
zeripath [Fri, 3 Mar 2023 22:28:38 +0000 (22:28 +0000)]
Fix GetFilesChangedBetween if the file name may be escaped (#23272)

The code for GetFilesChangedBetween uses `git diff --name-only
base..head` to get the names of files changed between base and head
however this forgets that git will escape certain values.

This PR simply switches to use `-z` which has the `NUL` character as the
separator.

Ref https://github.com/go-gitea/gitea/pull/22568#discussion_r1123138096

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoSupport paste treepath when creating a new file or updating the file name (#23209)
Hester Gong [Fri, 3 Mar 2023 22:28:20 +0000 (06:28 +0800)]
Support paste treepath when creating a new file or updating the file name (#23209)

Close #23204

Quick Demo:

https://user-images.githubusercontent.com/17645053/222058727-ad30a37c-f0ac-4184-9946-a71fcee473b5.mov

---------

Co-authored-by: delvh <leon@kske.dev>
19 months agoFix grammar in error message (#23273)
ChristianSch [Fri, 3 Mar 2023 20:53:46 +0000 (21:53 +0100)]
Fix grammar in error message (#23273)

Fixes the grammar in the error message in case a runner token has
already been activated

19 months agoRevert relative links to absolute links in mail templates (#23267)
wxiaoguang [Fri, 3 Mar 2023 14:43:30 +0000 (22:43 +0800)]
Revert relative links to absolute links in mail templates (#23267)

Follow #21986 , fix regression.

The mail templates should always use `AppURL` (the full absolute URL)

19 months agoFix cannot reopen after pushing commits to a closed PR (#23189)
sillyguodong [Fri, 3 Mar 2023 13:16:58 +0000 (21:16 +0800)]
Fix cannot reopen after pushing commits to a closed PR (#23189)

Close: #22784

1. On GH, we can reopen a PR which was closed before after pushing
commits. After reopening PR, we can see the commits that were pushed
after closing PR in the time line. So the case of
[issue](https://github.com/go-gitea/gitea/issues/22784) is a bug which
needs to be fixed.

2. After closing a PR and pushing commits, `headBranchSha` is not equal
to `sha`(which is the last commit ID string of reference). If the
judgement exists, the button of reopen will not display. So, skip the
judgement if the status of PR is closed.

![image](https://user-images.githubusercontent.com/33891828/222037529-651fccf9-0bba-433e-b2f0-79c17e0cc812.png)

3. Even if PR is already close, we should still insert comment record
into DB when we push commits.
So we should still call  function `CreatePushPullComment()`.

https://github.com/go-gitea/gitea/blob/067b0c2664d127c552ccdfd264257caca4907a77/services/pull/pull.go#L260-L282
So, I add a switch(`includeClosed`) to the
`GetUnmergedPullRequestsByHeadInfo` func to control whether the status
of PR must be open. In this case, by setting `includeClosed` to `true`,
we can query the closed PR.

![image](https://user-images.githubusercontent.com/33891828/222621045-bb80987c-10c5-4eac-aa0c-1fb9c6aefb51.png)

4. In the loop of comments, I use the`latestCloseCommentID` variable to
record the last occurrence of the close comment.
In the go template, if the status of PR is closed, the comments whose
type is `CommentTypePullRequestPush(29)` after `latestCloseCommentID`
won't be rendered.

![image](https://user-images.githubusercontent.com/33891828/222058913-c91cf3e3-819b-40c5-8015-654b31eeccff.png)
e.g.
1). The initial status of the PR is opened.

![image](https://user-images.githubusercontent.com/33891828/222453617-33c5093e-f712-4cd6-8489-9f87e2075869.png)
2). Then I click the button of `Close`.  PR is closed now.

![image](https://user-images.githubusercontent.com/33891828/222453694-25c588a9-c121-4897-9ae5-0b13cf33d20b.png)
3). I try to push a commit to this PR, even though its current status is
closed.

![image](https://user-images.githubusercontent.com/33891828/222453916-361678fb-7321-410d-9e37-5a26e8095638.png)
But in comments list, this commit do not display.This is as expected :)

![image](https://user-images.githubusercontent.com/33891828/222454169-7617a791-78d2-404e-be5e-77d555f93313.png)
4). Click the `Reopen` button, the commit which is pushed after closing
PR display now.

![image](https://user-images.githubusercontent.com/33891828/222454533-897893b6-b96e-4701-b5cb-b1800f382b8f.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoUse correct README link to render the README (#23152)
yp05327 [Fri, 3 Mar 2023 10:01:33 +0000 (19:01 +0900)]
Use correct README link to render the README (#23152)

`renderReadmeFile` needs `readmeTreelink` as parameter but gets
`treeLink`.
The values of them look like as following:
`treeLink`:  `/{OwnerName}/{RepoName}/src/branch/{BranchName}`
`readmeTreelink`:
`/{OwnerName}/{RepoName}/src/branch/{BranchName}/{ReadmeFileName}`

`path.Dir` in

https://github.com/go-gitea/gitea/blob/8540fc45b11eff9a73753ca139f8ea5c38509bf5/routers/web/repo/view.go#L316
should convert `readmeTreelink` into
`/{OwnerName}/{RepoName}/src/branch/{BranchName}` instead of the current
`/{OwnerName}/{RepoName}/src/branch`.

Fixes #23151

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
19 months agoAdd document for `webcomponents` (#23261)
wxiaoguang [Fri, 3 Mar 2023 09:45:19 +0000 (17:45 +0800)]
Add document for `webcomponents` (#23261)

19 months agoUse async await to fix empty quote reply at first time (#23168) 23287/head
HesterG [Thu, 2 Mar 2023 19:53:22 +0000 (03:53 +0800)]
Use async await to fix empty quote reply at first time (#23168)

The reason why quote reply is empty is when quote reply is clicked, it
triggers the click function on `.comment-form-reply` button, and when
the first time this function is triggered, easyMDE for the reply has not
yet initialized, so that click handler of `.quote-reply` button in
`repo-legacy.js` got an `undefined` as easyMDE, and the following lines
which put quoted reply into the easyMDE is not executed.
The workaround in this PR is to pass the replied content to
'.comment-form-reply' button if easyMDE is not yet initialized (quote
reply first clicked) and put the replied content into it the after
easyMDE is created.
Now quote reply on first click:

https://user-images.githubusercontent.com/17645053/221452823-fc699d50-1649-4af1-952e-f04fc8d2978e.mov

<br />

Update:
The above change is not appropriate as stated in the
[comment](https://github.com/go-gitea/gitea/pull/23168#issuecomment-1445562284)
Use await instead

Close #22075.
Close #23247.

19 months agoFix switched citation format (#23250)
Blender Defender [Thu, 2 Mar 2023 19:08:02 +0000 (20:08 +0100)]
Fix switched citation format (#23250)

Due to switched input parameters, the citation texts for Bibtex and Apa
were switched.
This pull request fixes #23244

19 months agoImprove update-locales script and fix locale processing bug (#23240)
wxiaoguang [Thu, 2 Mar 2023 18:33:36 +0000 (02:33 +0800)]
Improve update-locales script and fix locale processing bug (#23240)

The locales of Gitea has been broken for long time, till now, it's still
not fully fixed.

One of the root problems is that the `ini` library is quite quirky and
the `update-locales` script doesn't work well for all cases.

This PR fixes the `update-locales` script to make it satisfy `ini`
library and the crowdin.

See the comments for more details.

The `locale_zh-CN.ini` is an example, it comes from crowdin and is
processed by the new `update-locales.sh`. Especially see the `feed_of`:
https://github.com/go-gitea/gitea/pull/23240/files#diff-321f6ca4eae1096eba230e93c4740f9903708afe8d79cf2e57f4299786c4528bR268

19 months agoRefactor `ctx` in templates (#23105)
wxiaoguang [Thu, 2 Mar 2023 17:44:06 +0000 (01:44 +0800)]
Refactor `ctx` in templates (#23105)

Before, the `dict "ctx" ...` map is used to pass data between templates.

Now, more and more templates need to use real Go context:

* #22962
* #23092

`ctx` is a Go concept for `Context`, misusing it may cause problems, and
it makes it difficult to review or refactor.

This PR contains 2 major changes:

* In the top scope of a template, the `$` is the same as the `.`, so the
old labels_sidebar's `root` is the `ctx`. So this `ctx` could just be
removed.
https://github.com/go-gitea/gitea/commit/bd7f218dce01e0fb661b23b55995f5d51b4530e8
* Rename all other `ctx` to `ctxData`, and it perfectly matches how it
comes from backend: `"ctxData": ctx.Data`.
https://github.com/go-gitea/gitea/pull/23105/commits/7c01260e1df1dcb052e1cf86ebe982bf77c4407f

From now on, there is no `ctx` in templates. There are only:

* `ctxData` for passing data
* `Context` for Go context

19 months agoImprove frontend guideline (#23252)
wxiaoguang [Thu, 2 Mar 2023 16:46:47 +0000 (00:46 +0800)]
Improve frontend guideline (#23252)

If an event listener must be `async`, the `e.preventDefault()` should be
before any `await`,
it's recommended to put it at the beginning of the function.

19 months agoClose the temp file when dumping database to make the temp file can be deleted on...
wxiaoguang [Thu, 2 Mar 2023 15:57:31 +0000 (23:57 +0800)]
Close the temp file when dumping database to make the temp file can be deleted on Windows (#23249)

There was no `dbDump.Close()` before, Windows doesn't like to delete
opened files.

19 months agoFix commit retrieval by tag (#21804)
silverwind [Thu, 2 Mar 2023 05:32:21 +0000 (06:32 +0100)]
Fix commit retrieval by tag (#21804)

It is not correct to return tag data when commit data is requested, so
remove the hacky code that overwrote parts of a commit with parts of a
tag.

This fixes commit retrieval by tag for both the latest commit in the UI
and the commit info on tag webhook events.

Fixes: https://github.com/go-gitea/gitea/issues/21687
Replaces: https://github.com/go-gitea/gitea/pull/21693

<img width="324" alt="Screenshot 2022-11-13 at 15 26 37"
src="https://user-images.githubusercontent.com/115237/201526975-736c6ea7-ad6a-467a-a823-9a63d6ecb718.png">

<img width="789" alt="image"
src="https://user-images.githubusercontent.com/115237/201526876-90a13ffc-1e5c-4d76-911b-f1ae51e8eaab.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months agoFix missed `.hide` class (#23208)
yp05327 [Thu, 2 Mar 2023 04:22:04 +0000 (13:22 +0900)]
Fix missed `.hide` class (#23208)

https://github.com/go-gitea/gitea/pull/22950 removed `hide` class, and
use `gt-hidden`
But there are some missed `hide`....

---------

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 2 Mar 2023 00:23:09 +0000 (00:23 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoAdd loading yaml label template files (#22976)
Lauris BH [Wed, 1 Mar 2023 23:44:23 +0000 (01:44 +0200)]
Add loading yaml label template files (#22976)

Extract from #11669 and enhancement to #22585 to support exclusive
scoped labels in label templates

* Move label template functionality to label module
* Fix handling of color codes
* Add Advanced label template

19 months agoAllow `<video>` in MarkDown (#22892)
Sybren [Wed, 1 Mar 2023 21:30:51 +0000 (22:30 +0100)]
Allow `<video>` in MarkDown (#22892)

As you can imagine, for the Blender development process it is rather
nice to be able to include videos in issues, pull requests, etc.

This PR allows the `<video>` HTML tag to be used in MarkDown, with the
`src`, `autoplay`, and `controls` attributes.

## Help Needed

To have this fully functional, personally I feel the following things
are still missing, and would appreciate some help from the Gitea team.

### Styling

Some CSS is needed, but I couldn't figure out which of the LESS files
would work. I tried `web_src/less/markup/content.less` and
`web_src/less/_base.less`, but after running `make` the changes weren't
seen in the frontend.

This I would consider a minimal set of CSS rules to be applied:

```css
video {
  max-width: 100%;
  max-height: 100vh;
}
```

### Default Attributes

It would be fantastic if Gitea could add some default attributes to the
`<video>` tag. Basically `controls` should always be there, as there is
no point in disallowing scrolling through videos, looping them, etc.

### Integration with the attachments system

Another thing that could be added, but probably should be done in a
separate PR, is the integration with the attachments system. Dragging in
a video should attach it, then generate the appropriate MarkDown/HTML.

19 months agoPull Requests: add button to compare force pushed commits (#22857)
Brecht Van Lommel [Wed, 1 Mar 2023 19:19:47 +0000 (20:19 +0100)]
Pull Requests: add button to compare force pushed commits (#22857)

To quickly see what changed without having to re-read the whole diff.

19 months agoDo not create commit graph for temporary repos (#23219)
Brecht Van Lommel [Wed, 1 Mar 2023 19:19:04 +0000 (20:19 +0100)]
Do not create commit graph for temporary repos (#23219)

When fetching remotes for conflict checking, skip unnecessary and
potentially slow writing of commit graphs.

In a test with the Blender repository, this reduces conflict checking
time for one pull request from about 2s to 0.1s.

19 months agoUse the correct selector to hide the checkmark of selected labels on clear (#23224)
wxiaoguang [Wed, 1 Mar 2023 19:18:35 +0000 (03:18 +0800)]
Use the correct selector to hide the checkmark of selected labels on clear (#23224)

Regression of #10107
(https://github.com/go-gitea/gitea/pull/10107/files#diff-a15e36f2f9c13339f7fdd38bc2887db2ff2945cb8434464318ab9105fcc846bdR460)

Fix #22222

Before: the "clear" action couldn't remove these check marks.

![image](https://user-images.githubusercontent.com/2114189/222212998-c9f33459-b71d-4e80-8588-2935f3b7050c.png)

After: the "clear" action can remove these  check marks.

![image](https://user-images.githubusercontent.com/2114189/222213048-2be98ed0-cac0-4e27-b72c-1dd0ac2637d5.png)

19 months agoOrder pull request conflict checking by recently updated, for each push (#23220)
Brecht Van Lommel [Wed, 1 Mar 2023 19:14:02 +0000 (20:14 +0100)]
Order pull request conflict checking by recently updated, for each push (#23220)

When a change is pushed to the default branch and many pull requests are
open for that branch, conflict checking can take some time.

Previously it would go from oldest to newest pull request. Now
prioritize pull requests that are likely being actively worked on or
prepared for merging.

This only changes the order within one push to one repository, but the
change is trivial and can already be quite helpful for smaller Gitea
instances where a few repositories have most pull requests. A global
order would require deeper changes to queues.

19 months agoFix incorrect checkbox behaviors in the dashboard repolist's filter (#23147)
wxiaoguang [Wed, 1 Mar 2023 02:22:14 +0000 (10:22 +0800)]
Fix incorrect checkbox behaviors in the dashboard repolist's filter (#23147)

Co-author: yp05327 , this PR is based on yp05327's #22813.

The problems of the old DashboardRepoList / repolist.tmpl:

* It mixes many different frameworks together
* It "just works", bug on bug
* It uses many anti-pattern of Vue

This PR:

* Fix bugs and close #22800
* Decouple the "checkbox" elements from Fomantic UI (only use CSS
styles)
* Simplify the HTML layout
* Simplify JS logic
* Make it easier to refactor the DashboardRepoList into a pure Vue
component in the future.

### Screenshots

#### Default

![image](https://user-images.githubusercontent.com/2114189/221355768-a3eb5b23-85b4-4e3d-b906-844d8b15539d.png)

####  Click "Archived" to make it checked

![image](https://user-images.githubusercontent.com/2114189/221355777-9a104ddf-52a7-4504-869a-43a73827d802.png)

####  Click "Archived" to make it intermediate

![image](https://user-images.githubusercontent.com/2114189/221355802-0f67a073-67ad-4e92-84a6-558c432103a5.png)

####  Click "Archived" to make it unchecked

![image](https://user-images.githubusercontent.com/2114189/221355810-acf1d9d8-ccce-47fe-a02e-70cf4e666331.png)

---------

Co-authored-by: yp05327 <576951401@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 1 Mar 2023 00:16:03 +0000 (00:16 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoProperly flush unique queues on startup (#23154)
zeripath [Tue, 28 Feb 2023 22:55:43 +0000 (22:55 +0000)]
Properly flush unique queues on startup (#23154)

There have been a number of reports of PRs being blocked whilst being
checked which have been difficult to debug. In investigating #23050 I
have realised that whilst the Warn there is somewhat of a miscall there
was a real bug in the way that the LevelUniqueQueue was being restored
on start-up of the PersistableChannelUniqueQueue.

Next there is a conflict in the setting of the internal leveldb queue
name - This wasn't being set so it was being overridden by other unique
queues.

This PR fixes these bugs and adds a testcase.

Thanks to @brechtvl  for noticing the second issue.

Fix #23050
and others

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
19 months agoUse context parameter in services/repository (#23186)
Jason Song [Tue, 28 Feb 2023 22:17:51 +0000 (06:17 +0800)]
Use context parameter in services/repository (#23186)

Use context parameter in `services/repository`.

And use `cache.WithCacheContext(ctx)` to generate push action history
feeds.

Fix #23160

19 months agoPass `--global` when calling `git config --get`, for consistency with `git config...
Philip Peterson [Tue, 28 Feb 2023 21:26:19 +0000 (16:26 -0500)]
Pass `--global` when calling `git config --get`, for consistency with `git config --set` (#23157)

This arose out of #22451; it seems we are checking using non-global
settings to see if a config value is set, in order to decide whether to
call another global(-indeed) configuration command. This PR changes it
so that both the check and the set are for global configuration.

19 months agoMake `gitea serv` respect git binary home (#23138)
wxiaoguang [Tue, 28 Feb 2023 20:33:10 +0000 (04:33 +0800)]
Make `gitea serv` respect git binary home (#23138)

Close #23137

The old code is too old (8-9 years ago)

Let's try to execute the git commands from git bin home directly.

The verb has been checked above, it could only be:
* git-upload-pack
* git-upload-archive
* git-receive-pack
* git-lfs-authenticate

19 months agoWrite Gitpod `app.ini` only once (#23192)
Yarden Shoham [Tue, 28 Feb 2023 15:30:43 +0000 (17:30 +0200)]
Write Gitpod `app.ini` only once (#23192)

Before this change, the `app.ini` would get overwritten on each
workspace start, confusing Gitea. It asked for reinstallation each time.
This makes sure the file is written only once by checking it does not
exist before creating it.

---
[Review without whitespace
diff](https://github.com/go-gitea/gitea/pull/23192/files?w=1)

---------

Co-authored-by: delvh <dev.lh@web.de>
19 months agoAvoid too long names for actions (#23162)
Jason Song [Tue, 28 Feb 2023 10:20:36 +0000 (18:20 +0800)]
Avoid too long names for actions (#23162)

The name of the job or step comes from the workflow file, while the name
of the runner comes from its registration. If the strings used for these
names are too long, they could cause db issues.

19 months ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 28 Feb 2023 00:15:54 +0000 (00:15 +0000)]
[skip ci] Updated translations via Crowdin

19 months agoChange button text for commenting and closing an issue at the same time (#23135)
wxiaoguang [Mon, 27 Feb 2023 23:13:52 +0000 (07:13 +0800)]
Change button text for commenting and closing an issue at the same time (#23135)

Close  #10468

Without SimpleMDE/EasyMDE, using Simple Textarea, the button text could
be changed when content changes.

After introducing SimpleMDE/EasyMDE, there is no code for updating the
button text.

19 months agoDon't run unnecessary steps when only docs changed (#23103)
Lunny Xiao [Mon, 27 Feb 2023 22:20:42 +0000 (06:20 +0800)]
Don't run unnecessary steps when only docs changed (#23103)

Remove some unnecessary steps from drone when only docs changed.

ref: https://drone.gitea.io/go-gitea/gitea/68090/1/3

19 months agoAdd word-break to sidebar-item-link (#23146)
yp05327 [Mon, 27 Feb 2023 20:19:50 +0000 (05:19 +0900)]
Add word-break to sidebar-item-link (#23146)

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

![image](https://user-images.githubusercontent.com/18380374/221351117-1e4b8922-04ca-4717-8e3b-c338a61bc062.png)

Co-authored-by: delvh <leon@kske.dev>
19 months agoSpeed up HasUserStopwatch & GetActiveStopwatch (#23051)
zeripath [Mon, 27 Feb 2023 18:46:00 +0000 (18:46 +0000)]
Speed up HasUserStopwatch & GetActiveStopwatch (#23051)

GetActiveStopwatch & HasUserStopwatch is a hot piece of code that is
repeatedly called and on examination of the cpu profile for TestGit it
represents 0.44 seconds of CPU time. This PR reduces this time to 80ms.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
19 months agoAdd InsecureSkipVerify to Minio Client for Storage (#23166)
Yarden Shoham [Mon, 27 Feb 2023 16:26:13 +0000 (18:26 +0200)]
Add InsecureSkipVerify to Minio Client for Storage (#23166)

Allows using Minio with untrusted certificates

Closes #23128

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>