Compare commits

...
This repository has been archived on 2024-01-11. You can view files and clone it, but cannot push or open issues or pull requests.

6200 commits

Author SHA1 Message Date
b990484b03
make fmt 2023-03-16 01:34:48 +00:00
3b547c695e
Fix some annoying segfaults 2023-03-15 20:14:00 +00:00
dbc3eb7fa0
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-03-12 23:19:57 +00:00
yp05327
e72290fd9a
Sync the class change of Edit Column Button to JS code (#23400)
In #22767, we changed the class of `Edit Column` button from `red` to
`primary`
But `red` is used to find this button in js.....

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2023-03-12 19:09:20 +08:00
Peter
c6f5029708
Preserve file size when creating attachments (#23406)
When creating attachments (issue, release, repo) the file size (being
part of the multipart file header) is passed through the chain of
creating an attachment to ensure the MinIO client can stream the file
directly instead of having to read it to memory completely at first.

Fixes #23393

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-12 03:48:07 -04:00
GiteaBot
023521b016 [skip ci] Updated translations via Crowdin 2023-03-12 00:16:02 +00:00
techknowlogick
ab5bcdf98f
Use buildkit for docker builds (#23415)
This switches Docker builds to use build kit which is less prone to
error than legacy docker-in-docker building. It also switches back to
using the upstream docker image again now that it has been updated to a
version that supports alpine 3.14+

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-03-11 23:08:56 +02:00
wxiaoguang
75022f8b1a
Refactor branch/tag selector dropdown (first step) (#23394)
Follow: 
* #23345

The branch/tag selector dropdown mixes jQuery/Fomantic UI/Vue together,
it's very diffcult to maintain and causes unfixable a11y problems. It
also causes problems like #19851 #21314 #21952

This PR is the first step for the refactoring, move `data-` attributes
to JS object and use Vue data as much as possible.

The old selector `'.choose.reference .dropdown'` was also wrong, it hits
`<div class="choose reference"><svg class="dropdown icon">` and would
cause undefined behaviors.

I have done some quick tests and it works. After this PR gets merged, I
will move the code into a Vue SFC in next PR.



![image](https://user-images.githubusercontent.com/2114189/224099638-378a8a86-0865-47d1-bcba-f972506374c7.png)


![image](https://user-images.githubusercontent.com/2114189/224099690-70276cf5-b1e4-404a-b0c6-582448abf40e.png)

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-03-11 12:47:09 +02:00
GiteaBot
f20bf2fe3b [skip ci] Updated translations via Crowdin 2023-03-11 00:15:59 +00:00
Zettat123
3de9e63fd0
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"/>|
2023-03-10 10:42:38 -06:00
sillyguodong
5155ec35c5
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)
2023-03-10 09:54:32 -06:00
yp05327
cf29ee6dd2
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.

2871ea0809/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.
2023-03-10 09:18:20 -06:00
KN4CK3R
2173f14708
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)
2023-03-10 08:28:32 -06:00
zeripath
dad057b639
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>
2023-03-10 01:14:43 -05:00
John Olheiser
f92e0a4018
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>
2023-03-10 01:13:17 -05:00
Brecht Van Lommel
d647e74502
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.
2023-03-09 22:17:04 -05:00
wxiaoguang
0141d1667d
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>
2023-03-09 22:16:16 -05:00
InsanusMokrassar
92d3e2a6f8
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>
2023-03-09 22:14:59 -05:00
silverwind
17c8a0523a
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>
2023-03-09 22:14:45 -05:00
GiteaBot
c775053476 [skip ci] Updated translations via Crowdin 2023-03-10 00:15:59 +00:00
Lycolia Rizzim
79af6e367c
Add init file for Ubuntu (#23362)
Created an init file for Ubuntu that will be useful when running it on
WSL.
2023-03-09 16:54:37 -06:00
yp05327
e6df743eca
Rename canWriteUnit to canWriteProjects (#23386)
A part of https://github.com/go-gitea/gitea/pull/22865
2023-03-09 13:57:20 -06:00
Brecht Van Lommel
8bdc0acf97
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.
2023-03-09 12:14:22 -06:00
yp05327
689770c928
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`
2023-03-09 10:59:50 -06:00
wxiaoguang
542cec98f8
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.
2023-03-09 09:48:52 -06:00
yp05327
e52ac62d8e
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.
2023-03-09 08:38:29 -06:00
Jason Song
8cadd51bf2
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>
2023-03-09 10:49:34 +08:00
Nick
52e24167e5
Test renderReadmeFile (#23185)
Add test coverage to the important features of
[`routers.web.repo.renderReadmeFile`](067b0c2664/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
2023-03-09 09:24:23 +08:00
GiteaBot
c5573dbc0f [skip ci] Updated translations via Crowdin 2023-03-09 00:15:57 +00:00
Yarden Shoham
af0468ed8d
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>
2023-03-08 15:40:04 -05:00
Jason Song
1960ad5c90
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)))*
2023-03-08 11:57:05 -06:00
yp05327
d949d8e074
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>
2023-03-08 23:18:10 +08:00
Zettat123
15a1c2d7ef
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.

a12f575737/modules/git/notes_nogogit.go (L18)

So we need to convert the query parameter to commit ID before calling
`GetNote`.
2023-03-08 20:21:23 +08:00
Lunny Xiao
b116418f05
Use CleanPath instead of path.Clean (#23371)
As title.
2023-03-08 20:17:39 +08:00
Jason Song
090e753923
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.
2023-03-08 17:31:27 +08:00
JakobDev
a12f575737
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>
2023-03-08 15:07:58 +08:00
wxiaoguang
7e3b7c2346
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>
2023-03-07 22:40:41 -05:00
wxiaoguang
b70c7f8660
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"
2023-03-08 11:26:37 +08:00
GiteaBot
2dc4f80af0 [skip ci] Updated translations via Crowdin 2023-03-08 00:15:50 +00:00
delvh
608a3eeb59
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>
2023-03-07 18:17:35 -05:00
zeripath
8598356df1
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>
2023-03-07 15:07:35 -05:00
Hester Gong
a2f44463f0
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>
2023-03-07 23:08:22 +08:00
wxiaoguang
4c59c8c768
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>
2023-03-07 20:11:24 +08:00
Jason Song
c84238800b
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.
2023-03-07 18:51:06 +08:00
JonRB
84a299310d
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>
2023-03-07 00:39:07 +01:00
Lunny Xiao
27ba7fff6d
Remove unnecessary space on link (#23334)
The action run title has a blank. This PR removes it.
2023-03-06 13:12:10 -06:00
yp05327
e7b89888e1
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.
2023-03-06 12:05:26 -06:00
yp05327
3f547c7afb
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)
2023-03-06 10:32:56 -06:00
Hester Gong
471b6d24b4
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
2023-03-06 09:44:04 -06:00
yp05327
f0b0f22aed
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>
2023-03-06 22:35:24 +08:00
Brecht Van Lommel
68d7d772eb
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>
2023-03-06 18:20:29 +08:00
Lunny Xiao
e0800133dc
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>
2023-03-06 15:14:00 +08:00
wxiaoguang
6886706f5a
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)
2023-03-06 09:37:58 +08:00
GiteaBot
ce43208c6a [skip ci] Updated translations via Crowdin 2023-03-06 00:15:51 +00:00
Jonathan Tran
4de80392bc
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>
2023-03-05 22:59:05 +01:00
Hester Gong
ea7f0d6fcf
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>
2023-03-05 23:40:50 +08:00
wxiaoguang
21a1d76911
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>
2023-03-05 22:23:42 +08:00
Brecht Van Lommel
e8935606f5
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>
2023-03-05 21:25:25 +08:00
Brecht Van Lommel
5d621fe9a7
Add basic documentation for labels, including scoped labels (#23304)
Part of #22974

---------

Co-authored-by: delvh <dev.lh@web.de>
2023-03-05 20:35:12 +08:00
GiteaBot
390d270064 [skip ci] Updated translations via Crowdin 2023-03-05 00:15:41 +00:00
Lunny Xiao
8d6e9bc819
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
2023-03-04 22:34:02 +01:00
yp05327
6864583957
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
2023-03-04 19:23:51 +00:00
silverwind
b6d2c94966
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>
2023-03-04 14:29:28 +00:00
Sandeep Bhat
547c173dab
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>
2023-03-04 21:31:24 +08:00
wxiaoguang
188c8c12c2
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>
2023-03-04 02:13:37 -05:00
Jason Song
47b912cd52
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>
2023-03-04 02:12:37 -05:00
yp05327
ca84a61761
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>
2023-03-04 00:41:37 -05:00
techknowlogick
af4b00c283
update to mermaid v10 (#23178)
fix #23153

---------

Co-authored-by: silverwind <me@silverwind.io>
2023-03-04 00:39:07 -05:00
wxiaoguang
787a05a3a2
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>
2023-03-03 23:48:59 -05:00
Brecht Van Lommel
47bb5f11cb
Fix stray backticks appearing in pull request timeline (#23282)
Caused by #23189.
2023-03-03 23:48:05 -05:00
Jason Song
7b9e23cc1d
Fill head commit to in payload when notifying push commits for mirroring (#23215)
Just like what has been done when pushing manually:

7a5af25592/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>
2023-03-03 23:45:53 -05:00
wxiaoguang
b2359f3df6
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>
2023-03-04 10:12:02 +08:00
b4640101f3
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-03-04 00:03:38 +00:00
zeripath
5c4075e16d
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>
2023-03-03 17:28:38 -05:00
Hester Gong
7f9d58fab8
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>
2023-03-03 17:28:20 -05:00
ChristianSch
79acf7acc4
Fix grammar in error message (#23273)
Fixes the grammar in the error message in case a runner token has
already been activated
2023-03-03 14:53:46 -06:00
wxiaoguang
807e8e280c
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)
2023-03-03 22:43:30 +08:00
sillyguodong
2f49b55c19
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()`.

067b0c2664/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>
2023-03-03 21:16:58 +08:00
yp05327
699f20234b
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

8540fc45b1/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>
2023-03-03 18:01:33 +08:00
wxiaoguang
0bfcbcc5e7
Add document for webcomponents (#23261) 2023-03-03 17:45:19 +08:00
HesterG
ffce336f18
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.
2023-03-02 13:53:22 -06:00
Blender Defender
a14e6af236
Fix switched citation format (#23250)
Due to switched input parameters, the citation texts for Bibtex and Apa
were switched.
This pull request fixes #23244
2023-03-02 13:08:02 -06:00
wxiaoguang
d72462dae6
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
2023-03-02 12:33:36 -06:00
wxiaoguang
ce73492d6f
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.
bd7f218dce
* Rename all other `ctx` to `ctxData`, and it perfectly matches how it
comes from backend: `"ctxData": ctx.Data`.
7c01260e1d



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

* `ctxData` for passing data
* `Context` for Go context
2023-03-02 11:44:06 -06:00
wxiaoguang
0a9a3c2a6d
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.
2023-03-02 11:46:47 -05:00
wxiaoguang
294124d129
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.
2023-03-02 23:57:31 +08:00
silverwind
ea1d09718c
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>
2023-03-02 13:32:21 +08:00
yp05327
0945bf63d3
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>
2023-03-02 12:22:04 +08:00
GiteaBot
785a3e6e92 [skip ci] Updated translations via Crowdin 2023-03-02 00:23:09 +00:00
Lauris BH
58b4143803
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
2023-03-02 01:44:23 +02:00
Sybren
de6c718b46
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.
2023-03-01 16:30:51 -05:00
Brecht Van Lommel
545495dcb0
Pull Requests: add button to compare force pushed commits (#22857)
To quickly see what changed without having to re-read the whole diff.
2023-03-01 14:19:47 -05:00
Brecht Van Lommel
0268ee5c37
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.
2023-03-01 14:19:04 -05:00
wxiaoguang
403f3e9208
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)
2023-03-01 14:18:35 -05:00
Brecht Van Lommel
df48af2229
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.
2023-03-01 14:14:02 -05:00
wxiaoguang
7a5af25592
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>
2023-03-01 10:22:14 +08:00
GiteaBot
3e426bba78 [skip ci] Updated translations via Crowdin 2023-03-01 00:16:03 +00:00
zeripath
27e49cd01c
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>
2023-02-28 17:55:43 -05:00
Jason Song
04347eb810
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
2023-02-28 16:17:51 -06:00
Philip Peterson
cbbd3726b4
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.
2023-02-28 15:26:19 -06:00
wxiaoguang
f5987c24e2
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
2023-02-28 14:33:10 -06:00
Yarden Shoham
443dcc2db0
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>
2023-02-28 23:30:43 +08:00
Jason Song
cbc9a0fe47
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.
2023-02-28 18:20:36 +08:00
GiteaBot
067b0c2664 [skip ci] Updated translations via Crowdin 2023-02-28 00:15:54 +00:00
wxiaoguang
8b86ccbee1
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.
2023-02-27 17:13:52 -06:00
Lunny Xiao
725a97c6c9
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
2023-02-27 16:20:42 -06:00
yp05327
6e90a1459b
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>
2023-02-27 15:19:50 -05:00
zeripath
ef4fc30246
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>
2023-02-27 13:46:00 -05:00
Yarden Shoham
0e7bec1849
Add InsecureSkipVerify to Minio Client for Storage (#23166)
Allows using Minio with untrusted certificates

Closes #23128

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-02-27 16:26:13 +00:00
wxiaoguang
303b72c2d1
Fix Fomantic UI's touchstart fastclick, always use click for click events (#23065)
Using `touchstart` for `click` events is a black magic for mobile
browsers (Google: `fastclick`).

However, it causes many UX problems if the fastclick is used without
careful design.

Fomantic UI uses this fastclick for its `dimmer` and `dropdown`, it
makes mobile users feel strange when they "touch" the dropdown menu.


This PR uses a simple patch to fix that behavior. Then the Fomantic
dropdown only uses `click` for click events.

This PR is simple enough and won't cause hidden bugs even if the patch
doesn't work. In the future, if there are more patches for Fomantic UI,
the patches could be placed in a directory like
`web_src/fomantic/patches/001-fix-click-touchstart`, etc.


![image](https://user-images.githubusercontent.com/2114189/220551915-bd28e8cc-507f-43c7-bb4a-b24f7ff3934d.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-27 22:43:04 +08:00
Zettat123
611705888f
Remove useless comment in #23114 (#23173)
The `isAdmin` param is no longer used so the comment should be removed.


d27d36f2f4/routers/web/explore/repo.go (L36-L37)
2023-02-27 13:24:33 +01:00
xin-u
d27d36f2f4
Remove xin-u from maintainers (#23170) 2023-02-27 03:20:57 -05:00
Lunny Xiao
b9a9b8e469
Revert "[skip ci] Updated translations via Crowdin" (#23167) 2023-02-27 08:58:38 +08:00
GiteaBot
07ced728b3 [skip ci] Updated translations via Crowdin 2023-02-27 00:15:23 +00:00
yp05327
f1bde2fe00
Return 404 instead of 403 if user can not access the repo (#23155)
Fixes https://github.com/go-gitea/gitea/issues/23150

Before:

![image](https://user-images.githubusercontent.com/18380374/221390802-2317c6bc-d163-4def-b68b-6bb297143fe2.png)

After:

![image](https://user-images.githubusercontent.com/18380374/221390823-87490351-39c3-4a40-b1d2-11fc5b85fa24.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-26 18:22:42 +08:00
GiteaBot
357042279b [skip ci] Updated licenses and gitignores 2023-02-26 00:15:26 +00:00
Yarden Shoham
8540fc45b1
Fix secrets overview page missing from docs sidebar (#23143)
There was a warning while building the docs: `Building sites … WARN
2023/02/25 08:56:37
"/workspace/gitea/docs/content/doc/secrets/overview.en-us.md:1:1":
duplicate menu entry with identifier "overview" in menu "sidebar"`.

### Before

![image](https://user-images.githubusercontent.com/20454870/221348741-55cef254-f2ac-4507-9a66-818b406c668f.png)

### After

![image](https://user-images.githubusercontent.com/20454870/221348757-42066303-e1b7-43fe-9c4f-e05182fbabdd.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-02-25 10:56:02 +01:00
Brecht Van Lommel
10cdcb9ea8
Add "Reviewed by you" filter for pull requests (#22927)
This includes pull requests that you approved, requested changes or
commented on. Currently such pull requests are not visible in any of the
filters on /pulls, while they may need further action like merging, or
prodding the author or reviewers.

Especially when working with a large team on a repository it's helpful
to get a full overview of pull requests that may need your attention,
without having to sift through the complete list.
2023-02-24 21:55:50 -05:00
Brecht Van Lommel
843f81113e
Projects: rename Board to Column in interface and improve consistency (#22767) 2023-02-24 18:10:50 -05:00
zeripath
d827215011
Fix DBConsistency checks on MSSQL (#23132)
Unfortunately xorm's `builder.Select(...).From(...)` does not escape the
table names. This is mostly not a problem but is a problem with the
`user` table.

This PR simply escapes the user table. No other uses of `From("user")`
where found in the codebase so I think this should be all that is
needed.

Fix #23064

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-02-24 16:45:55 -05:00
Brecht Van Lommel
f4920c9c7f
Add pagination for dashboard and user activity feeds (#22937)
Previously only the last few activities where available. This works for
all activity and for activity on a date chosen on the heatmap.
2023-02-24 16:15:10 -05:00
zeripath
740a5ecdd9
Update go.mod dependencies (#23126)
This PR does a bulk update of a lot of our go deps.

I have not included nektos/act and xorm for the following reasons:
* Xorm updates can sometimes be complex and I'd rather do that in a
separate PR
* I think people more update with the actions code should double check
that the latest nektos/act library works correctly.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-24 20:18:49 +00:00
Zettat123
347df0cbf0
Show empty repos in Admin Repository Management page (#23114)
The **Admin Repository Management** page and the **Explore Repository**
page both use the `RenderRepoSearch` function. In this function, the
`OnlyShowRelevant` search option is `true` when querying repositories
for admin page.


edf98a2dc3/routers/web/explore/repo.go (L99-L115)

Refer to
[#19361](https://github.com/go-gitea/gitea/pull/19361/files#diff-8058dfb85557010e0592d586675ec62ce406af7068e6311f39c160deac37f149R497),
the repositories with `is_empty=true` will be hidden if
`OnlyShowRelevant` is `true`.

Administrators should be able to see all repositories. So
`OnlyShowRelevant` shouldn't be set to `true` .

---------

Co-authored-by: Andrew Thornton <art27@cantab.net>
2023-02-24 19:11:31 +00:00
yp05327
9eb61b77ac
Redirect to the commit page after applying patch (#23056)
Fixes https://github.com/go-gitea/gitea/issues/22621
2023-02-24 16:56:41 +00:00
WÁNG Xuěruì
e77528baed
Bump go.etcd.io/bbolt and blevesearch deps (#23062)
This notably brings support for GOARCH=loong64, among other fixes.

---------

Signed-off-by: WANG Xuerui <xen0n@gentoo.org>
Co-authored-by: zeripath <art27@cantab.net>
2023-02-24 15:45:28 +00:00
HesterG
d20b29d7ce
Fix height for sticky head on large screen on PR page (#23111)
Right now on the PR 'File Change' Tab, the file title header sticky to
the top on large screens has wrong height, resulting in wrong ui
behavior when scrolling down. This PR is to fix this.

Before:

<img width="964" alt="截屏2023-02-24 17 12 29"
src="https://user-images.githubusercontent.com/17645053/221140409-025c4a84-6bbe-4b5b-a13f-bd2b79063522.png">

After:
<img width="1430" alt="截屏2023-02-24 21 10 12"
src="https://user-images.githubusercontent.com/17645053/221186750-0344d652-4610-4a90-a4c0-7f6269f950d6.png">
2023-02-24 14:29:49 +00:00
Lunny Xiao
a8c4f8cebc
Fix db.Find bug (#23115)
Caused by #20821 

Fix #23110
2023-02-24 21:17:09 +08:00
Lunny Xiao
91fa0eb9d7
Avoid warning for system setting when start up (#23054)
Partially fix #23050

After #22294 merged, it always has a warning log like `cannot get
context cache` when starting up. This should not affect any real life
but it's annoying. This PR will fix the problem. That means when
starting up, getting the system settings will not try from the cache but
will read from the database directly.

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-24 18:23:13 +08:00
Jason Song
edf98a2dc3
Require approval to run actions for fork pull request (#22803)
Currently, Gitea will run actions automatically which are triggered by
fork pull request. It's a security risk, people can create a PR and
modify the workflow yamls to execute a malicious script.

So we should require approval for first-time contributors, which is the
default strategy of a public repo on GitHub, see [Approving workflow
runs from public
forks](https://docs.github.com/en/actions/managing-workflow-runs/approving-workflow-runs-from-public-forks).

Current strategy:

- don't need approval if it's not a fork PR;
- always need approval if the user is restricted;
- don't need approval if the user can write;
- don't need approval if the user has been approved before;
- otherwise, need approval.

https://user-images.githubusercontent.com/9418365/217207121-badf50a8-826c-4425-bef1-d82d1979bc81.mov

GitHub has an option for that, you can see that at
`/<owner>/<repo>/settings/actions`, and we can support that later.

<img width="835" alt="image"
src="https://user-images.githubusercontent.com/9418365/217199990-2967e68b-e693-4e59-8186-ab33a1314a16.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 15:58:49 +08:00
Zettat123
a6175b01d9
Fix nil context in RenderMarkdownToHtml (#23092)
Fix #23082.

This bug is caused by a nil context in
https://github.com/go-gitea/gitea/issues/23082#issuecomment-1441276546 .

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 14:36:07 +08:00
HesterG
045becf9aa
Add HesterG to maintainers (#23104)
[List of mine merged
PR](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3AHesterG+is%3Amerged+)
2023-02-24 14:31:02 +08:00
yp05327
5b87c05a95
improve FindProjects (#23085)
I found `FindAndCount` which can `Find` and `Count` in the same time
Maybe it is better to use it in `FindProjects`

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 13:18:52 +08:00
wxiaoguang
0bc8bb3cc4
Make issue meta dropdown support Enter, confirm before reloading (#23014)
As the title. Label/assignee share the same code.

* Close #22607
* Close #20727

Also:

* partially fix for #21742, now the comment reaction and menu work with
keyboard.
* partially fix for #17705, in most cases the comment won't be lost.
* partially fix for #21539
* partially fix for #20347
* partially fix for #7329

### The `Enter` support

Before, if user presses Enter, the dropdown just disappears and nothing
happens or the window reloads.

After, Enter can be used to select/deselect labels, and press Esc to
hide the dropdown to update the labels (still no way to cancel ....
maybe you can do a Cmd+R or F5 to refresh the window to discard the
changes .....)


This is only a quick patch, the UX is still not perfect, but it's much
better than before.


### The `confirm` before reloading

And more fixes for the `reload` problem, the new behaviors:

* If nothing changes (just show/hide the dropdown), then the page won't
be reloaded.
* If there are draft comments, show a confirm dialog before reloading,
to avoid losing comments.

That's the best effect can be done at the moment, unless completely
refactor these dropdown related code.

Screenshot of the confirm dialog:

<details>


![image](https://user-images.githubusercontent.com/2114189/220538288-e2da8459-6a4e-43cb-8596-74057f8a03a2.png)

</details>

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-24 09:26:27 +08:00
sillyguodong
1f09051f2b
Fix SyncOnCommit always return false in API of push_mirrors (#23088)
Fix: #22990

---
Before, the return value of the api is always false,regrardless of
whether the entry of `sync_on_commit` is true or false.
I have confirmed that the value of `sync_on_commit` dropped into the
database is correct.
So, I think it is enough to make some small changes.
2023-02-23 15:50:33 -06:00
yp05327
ed954b070d
Fix commit name in Apply Patch page (#23086)
Fixes
https://github.com/go-gitea/gitea/issues/22621#issuecomment-1439309200
2023-02-23 15:14:07 -06:00
HesterG
8ed6096158
Add wrapper to author to avoid long name ui problem (#23030)
This PR is a possible solution for issue #22866. Main change is to add a
`author-wrapper` class around author name, like the wrapper added to
message. The `max-width` is set to 200px on PC, and 100px on mobile
device for now.
2023-02-23 14:28:18 -06:00
Sven
659cf30b69
Avoid Hugo from adding quote to actions url (#23097) 2023-02-23 12:19:52 -05:00
KN4CK3R
0ae1ed749d
Remove all package data after tests (#22984)
Fixes #21020

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2023-02-23 22:11:56 +08:00
HesterG
3adfc0f02d
Change style to improve whitespaces trimming inside inline markdown code (#23093)
Given mardown source
```
x ` a` y
x `a ` y
x ` a ` y
```

Render

<img width="1421" alt="2023-02-23 15 33 14"
src="https://user-images.githubusercontent.com/17645053/220844280-a304c788-ac79-4a26-a55a-0db00f2fb3f3.png">

Fixes #23080.
2023-02-23 20:57:03 +08:00
techknowlogick
dd7d6e3ad0
Nest metadata in refactoring docs (#23087)
Whitespace was missing from refactoring docs metadata.

backport label applied so it is included in versioned docs.
2023-02-23 16:25:18 +08:00
Joakim Pettersen
0ce79bb9f6
Improve reverse proxies documentation (#23068)
Add "Traefik with a sub-path" documentation

closes #23047

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-23 15:34:09 +08:00
Andre Polykanine
6c35454654
Improve accessibility for issue comments (#22612)
Currently in Gitea issue comments are not marked up with headings. I'm
trying to fix this by adding an appropriate
[ARIA](https://www.w3.org/WAI/standards-guidelines/aria/) role for
comment header and also by enclosing the comment itself in a semantical
article element.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-23 10:24:24 +08:00
John Olheiser
a084e182b0
Wrap unless-check in docker manifests (#23079)
Should fix the following:
> failed to render template: Evaluation error: Helper 'unless' called
with wrong number of arguments, needed 2 but got 3

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-02-22 16:33:31 -06:00
HesterG
a78e0b7dad
Add accessibility to the menu on the navbar (#23059)
This PR is trying to add accessibility to the menu as mentioned in
#23053 so the menu can be accessed using keyboard (A quick demo is added
below), with a reference to
[PR2612](https://github.com/go-gitea/gitea/pull/22612). The goal is to
make the menu accessible merely using keyboard like shown below. And
this PR might need confirmation from developers using screen readers.
2023-02-22 15:58:07 -06:00
zeripath
1319ba6742
Use minio/sha256-simd for accelerated SHA256 (#23052)
minio/sha256-simd provides additional acceleration for SHA256 using
AVX512, SHA Extensions for x86 and ARM64 for ARM.

It provides a drop-in replacement for crypto/sha256 and if the
extensions are not available it falls back to standard crypto/sha256.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-22 14:21:46 -05:00
wxiaoguang
eb5a55785d
Fix some more hidden problems (#23074)
Follows #22950
2023-02-22 15:26:02 +00:00
sillyguodong
90a7bba1f2
Add sillyguodong to maintainers (#23067)
[List of mine merged
PR](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3Asillyguodong+is%3Amerged+)
2023-02-22 18:32:00 +08:00
wxiaoguang
33e556e67a
Improving CONTRIBUTING.md for backport details (#23057)
See the changes.

Two key points:
* Necessary enhancements could be backported.
* The backports shouldn't break downgrade  between minor releases.
2023-02-22 11:49:52 +08:00
John Olheiser
4d2d3bd65d
Changelog 1.18.5 (#23045) (#23049)
Frontport #23045
2023-02-21 13:36:19 -06:00
zeripath
43405c35f0
Add Bash and Zsh completion scripts (#22646)
This PR adds contrib scripts for bash and zsh completion.

Simply call:

```bash
source contrib/autocompletion/bash_autocomplete
```

or for Zsh:

```bash
source contrib/autocompletion/zsh_autocomplete
```

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

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-21 12:32:24 -05:00
Zettat123
4de5cd9f36
Return empty url for submodule tree entries (#23043)
Close #22614.

Refer to [Github's
API](https://docs.github.com/en/rest/git/trees?apiVersion=2022-11-28#get-a-tree),
if a tree entry is a submodule, its url will be an empty string.

---------

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-21 12:31:17 -05:00
wxiaoguang
a7e98d70b6
Fix the show/hide methods for string selector (#23042)
At that moment I made a mistake (failed to detect a JS variable type
correctly)

Close #23040
2023-02-21 11:09:03 -06:00
sillyguodong
09d7377090
display attachments of review comment when comment content is blank (#23035)
fix: #22647
2023-02-21 10:08:20 -06:00
silverwind
77f70bd5a3
Upgrade to stylelint 15 (#22944)
- Upgrade stylelint and plugin
- Change ruleset to a explicit one, with all deprecated rules removed
- Fix new issues detected by value validation

For `overflow: overlay` see
https://github.com/stylelint/stylelint/issues/6667
2023-02-21 09:23:45 -06:00
Jason Song
c8c2a31818
Add force_merge to merge request and fix checking mergable (#23010)
Fix #23000.
2023-02-21 08:42:07 -06:00
wxiaoguang
1fcf96ad01
Improve PR Review Box UI (#22986)
This PR follows: 
* #22950

### Before

The Review Box has many problems:

* It doesn't work for small screens.
* It has an anonying animation which makes the UI laggy.
* It uses "custom dropdown menu" which is very difficult to fine tune.
* `$().toggle('visible')` is not a correct call 
* jQuery just accepts any invalid `duration` argument:
`$().toggle('anyting')`
* The button is not a button.

<details>

![image](https://user-images.githubusercontent.com/2114189/219948865-6da3f39c-6fde-4c86-9e42-da5020f3d0c3.png)

</details>

### After

These problems are fixed, and eliminate many `!important` games.

<details>

![image](https://user-images.githubusercontent.com/2114189/219952744-8862fe1a-7ef1-49e4-bf92-2d0c1f104ee4.png)

![image](https://user-images.githubusercontent.com/2114189/219952771-be169a76-45fd-47a8-8f9c-b447d064f4ca.png)

![image](https://user-images.githubusercontent.com/2114189/219952784-3f52e9b7-64ce-4ad1-9553-64c33fb83042.png)

</details>

And most dropdown icons still looks good:

<details>

![image](https://user-images.githubusercontent.com/2114189/219952942-52866a00-e0f9-4af7-8fb5-eb1a8cad1ff3.png)

![image](https://user-images.githubusercontent.com/2114189/219948909-b3bfb844-f84e-4b79-ab1f-382ec66dec31.png)

</details>

Co-authored-by: delvh <leon@kske.dev>
2023-02-21 21:36:53 +08:00
HesterG
9ebf6424ee
Remove dashes between organization member avatars on hover (#23034)
On the home page of an organization, there are unexpected dashes between
the avatars of the members when hovering over the avatars, as shown in
below:

![hover including title](https://user-images.githubusercontent.com/17645053/220271470-4f49e16f-87eb-4ffa-b38e-23feae1ff92d.png)

![hover without title](https://user-images.githubusercontent.com/17645053/220271512-e4a67685-6b72-4742-a34f-e01ed248c1de.png)

This is because in `fomantic/build/semantic.css` there is a
rule `text-decoration: underline;` when hovering over the `<a>` tag.
Here, the `<a>` tag has width and height because of the avatar image inside,
leading to the unexpected underlines.

This PR overrides the `a:hover` rule so the underline does not exist anymore.

Co-authored-by: delvh <leon@kske.dev>
2023-02-21 12:28:31 +01:00
wxiaoguang
e7b560f3fe
Fix the Manually Merged form (#23015)
Regression bug of #19650

Close #20983
Close #21912

### The "Manually Merged" form

![image](https://user-images.githubusercontent.com/2114189/220170503-32638994-b509-4251-8aa1-d8393dda7184.png)

### Mark a PR as Manually Merged and close it

![image](https://user-images.githubusercontent.com/2114189/220170537-25c91b2c-7a9a-44d1-9e6a-ebe3f1dfc26a.png)

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-21 18:03:41 +08:00
Zettat123
7f790c70b9
Remove delete button for review comment (#23036)
Fix #23031.

Currently, only comments with type `CommentTypeComment` or
`CommentTypeCode` can be deleted. If user create a review comment, the
type of the comment will be `CommentTypeReview` so the comment cannot be
deleted.

e7be610d57/routers/web/repo/issue.go (L2860-L2868)

And in Github, user also cannot delete a review comment. There isn't a
delete button in the menu.

<img
src="https://user-images.githubusercontent.com/15528715/220275166-5ae2dc10-4003-4857-b14e-d7b02644345f.png"
width="640px" />

So we should remove the delete button from the menu when the comment's
type is `CommentTypeReview`.
2023-02-21 16:25:47 +08:00
wxiaoguang
e7be610d57
Improve frontend guidelines (#23007)
Some were out-dated, some are added.
2023-02-21 14:13:37 +08:00
wxiaoguang
dc9cebdf45
Use --message=%s for git commit message (#23028)
Close  #23027

`git commit` message option _only_ supports 4 formats (well, only ....):
* `"commit", "-m", msg`
* `"commit", "-m{msg}"`  (no space)
* `"commit", "--message", msg`
* `"commit", "--message={msg}"`

The long format with `=` is the best choice, and it's documented in `man
git-commit`:

`-m <msg>, --message=<msg> ...`

ps: I would suggest always use long format option for git command, as
much as possible.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-21 14:12:57 +08:00
HesterG
e3cffa70f9
add margin top to the top of branches (#23002)
add margin top as mentioned in #22973

---------

Co-authored-by: jidi <jidi@jidideMacBook-Pro.local>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-21 13:03:44 +08:00
yp05327
4fcf3a3f90
Add me to maintainers (#23026)
Add me to maintainers.

[My PRs
list](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3Ayp05327+is%3Amerged+)
2023-02-21 10:56:13 +08:00
Lunny Xiao
34ae184622
Render access log template as text instead of HTML (#23013)
Fix https://github.com/go-gitea/gitea/pull/22906#discussion_r1112106675
2023-02-21 10:22:13 +08:00
wxiaoguang
1b950b98cf
Use gt-relative class instead of the ambiguous gt-pr class (#23008)
`.gt-relative` is also `position: relative !important;`

There are `gt-pr-?` styles below (line 140) for `padding-right`, which
makes `.gt-pr` ambiguous

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-20 19:16:56 -05:00
zeripath
35d2fa744a
Fix intermittent panic in notify issue change content (#23019)
Ensure that issue pullrequests are loaded before trying to set the
self-reference.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-20 19:15:49 -05:00
Jason Song
97aacc3ea1
Improve pull_request_template.md (#22888)
Update `pull_request_template.md` because:

- It's a kind idea to hide the tips. However, it's easier to include
them in the commit message by mistake when you cannot see them. Check
`git log | grep 'Please check the following:'`. So don't hide it, expose
it and help fix it.
- "for backports" is much clearer than "for bug fixes". I saw someone
post a PR to a release branch because they believed it was the right way
for a bugfix.
- "Allow edits by maintainers", or we have to ask the contributor to
update the branch and they could be confused.
- Remind the contributor that the words could be included in the commit
message, to avoid some words like "Hello", "Sorry". If they really need
them, they can separate them with a line, like:

```markdown
Close #xxxx
Because ... Then ... Finally ...
---
Hello, this is my first time opening a pull request. Sorry for any mistakes.
```
And the merger should be careful, check and delete the extra content
before merging.

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-20 19:14:02 -05:00
Brecht Van Lommel
a82b9016c3
Hide 2FA status from other members in organization members list (#22999)
This is rather private information that should not be given to all
members in the same organization. Only show it to organization owners.
2023-02-20 17:16:29 -06:00
dc20c28328
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-02-20 22:21:24 +00:00
Lunny Xiao
d845be661f
handle deprecated settings (#22992)
Fix #22736
2023-02-20 16:18:26 -06:00
zeripath
d2128b44f7
Add scopes to API to create token and display them (#22989)
The API to create tokens is missing the ability to set the required
scopes for tokens, and to show them on the API and on the UI.

This PR adds this functionality.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-02-20 15:28:44 -06:00
wxiaoguang
330b166423
Remove unnecessary and incorrect find('.menu').toggle() (#22987)
Follows:
* #22950

The dropdown menu works well without these codes.

The reason is that the event bubbling still works for the dropdown menu,
the Fomantic UI dropdown menu module will hide the menu correctly if an
item is clicked.
2023-02-20 14:44:32 -06:00
yp05327
f4ce8c73fb
Improve issues.LoadProject (#22982)
issues.LoadProject() is no use
change `issues.loadProject(ctx)` to issues.LoadProject(ctx)
2023-02-20 13:21:56 -06:00
Lunny Xiao
cfc7a4efdb
Add 1.18.4 changelog (#22991) (#22995)
Frontport from #22991
2023-02-20 12:09:02 -06:00
Brecht Van Lommel
9aaf6998b7
Fix pull request branch selector visible without clicking Edit (#23012)
Caused by #22950
2023-02-21 00:08:32 +08:00
dependabot[bot]
018815215f
Bump golang.org/x/net from 0.4.0 to 0.7.0 (#22980)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.4.0 to
0.7.0.
<details>
<summary>Commits</summary>
<ul>
<li><a
href="8e2b117aee"><code>8e2b117</code></a>
http2/hpack: avoid quadratic complexity in hpack decoding</li>
<li><a
href="547e7edf38"><code>547e7ed</code></a>
http2: avoid referencing ResponseWrite.Write parameter after
returning</li>
<li><a
href="39940adcaa"><code>39940ad</code></a>
html: parse comments per HTML spec</li>
<li><a
href="87ce33ecb4"><code>87ce33e</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="415cb6d518"><code>415cb6d</code></a>
all: fix some comments</li>
<li><a
href="7e3c19ca52"><code>7e3c19c</code></a>
all: correct typos in comments</li>
<li><a
href="296f09aa38"><code>296f09a</code></a>
http2: case insensitive handling for 100-continue</li>
<li><a
href="f8411da775"><code>f8411da</code></a>
nettest: fix tests on dragonfly and js/wasm</li>
<li><a
href="8e0e7d8d38"><code>8e0e7d8</code></a>
go.mod: update golang.org/x dependencies</li>
<li><a
href="7805fdc37d"><code>7805fdc</code></a>
http2: rewrite inbound flow control tracking</li>
<li>Additional commits viewable in <a
href="https://github.com/golang/net/compare/v0.4.0...v0.7.0">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=golang.org/x/net&package-manager=go_modules&previous-version=0.4.0&new-version=0.7.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 23:52:21 +08:00
sillyguodong
36d1d5fb78
Fix panic when call api (/repos/{owner}/{repo}/pulls/{index}/files) (#22921)
Close: #22910 

---
I'm confused about that why does the api (`GET
/repos/{owner}/{repo}/pulls/{index}/files`) require caller to pass the
parameters `limit` and `page`.
In my case, the caller only needs to pass a `skip-to` to paging. This is
consistent with the api `GET /{owner}/{repo}/pulls/{index}/files`
So, I deleted the code related to `listOptions`

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 22:22:34 +08:00
Lunny Xiao
c3d9a70d0a
only trigger docs build and publish when docs changed (#22968)
Since drone plugin
https://github.com/meltwater/drone-convert-pathschanged/ enabled, we can
filter event with path in drone.

Building docs will now only be triggered when documentations changed.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-20 21:08:41 +08:00
Zettat123
9a83aa28a3
Get rules by id when editing branch protection rule (#22932)
When users rename an existing branch protection rule, a new rule with
the new name will be created and the old rule will still exist.

![image](https://user-images.githubusercontent.com/15528715/219276442-d3c001ad-e693-44ec-9ad2-b33f2666b49b.png)

---

![image](https://user-images.githubusercontent.com/15528715/219276478-547c3b93-b3f1-4292-a1ef-c1b7747fe1bb.png)

The reason is that the `SettingsProtectedBranchPost` function only get
branch protection rule by name before updating or creating a rule. When
the rule name changes, the function cannot find the existing rule so it
will create a new rule rather than update the existing rule. To fix the
bug, the function should get rule by id first.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 19:30:41 +08:00
oliverpool
3596df52c0
Fix hidden commit status on multiple checks (#22889)
Since #22632, when a commit status has multiple checks, no check is
shown at all (hence no way to see the other checks).

This PR fixes this by always adding a tag with the
`.commit-statuses-trigger` to the DOM (the `.vm` is for vertical
alignment).

![2023-02-13-120528](https://user-images.githubusercontent.com/3864879/218441846-1a79c169-2efd-46bb-9e75-d8b45d7cc8e3.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 16:43:04 +08:00
Zettat123
1d64eafe8f
Add me to maintainers (#22998)
Add me to maintainers.

[List of merged
PRs](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3AZettat123+is%3Amerged)

Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-20 16:42:02 +08:00
yp05327
b811ab48e5
Add all units to the units permission list in org team members sidebar (#22971)
Add all units to the units permission list in org team members sidebar.

Before:

![BQF448EIHEYKY62XGG(5101](https://user-images.githubusercontent.com/18380374/219877772-b57df8fb-2b82-4b1a-85c8-3809f8751cab.png)
After:

![image](https://user-images.githubusercontent.com/18380374/219877762-f69482b8-abf9-4333-978e-6a3f52039a16.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 15:08:33 +08:00
zeripath
ef11d41639
Make CI use a dummy password hasher for all tests (#22983)
During the recent hash algorithm change it became clear that the choice
of password hash algorithm plays a role in the time taken for CI to run.

Therefore as attempt to improve CI we should consider using a dummy
hashing algorithm instead of a real hashing algorithm.

This PR creates a dummy algorithm which is then set as the default
hashing algorithm during tests that use the fixtures. This hopefully
will cause a reduction in the time it takes for CI to run.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 13:20:30 +08:00
Kyle D
2b3f12f6fd
Use beforeCommit instead of baseCommit (#22949)
Replaces: https://github.com/go-gitea/gitea/pull/22947
Fixes https://github.com/go-gitea/gitea/issues/22946
Probably related to https://github.com/go-gitea/gitea/issues/19530

Basically, many of the diffs were broken because they were comparing to
the base commit, where a 3-dot diff should be comparing to the [last
common
ancestor](https://matthew-brett.github.io/pydagogue/git_diff_dots.html).

This should have an integration test so that we don’t run into this
issue again.

---------

Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
2023-02-20 11:56:07 +08:00
Yarden Shoham
6840a8ccfc
Add comment marking the end of database migrations in 1.19.0 (#22975)
There will be no more migrations in `1.19.0`

---------

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-02-20 10:30:36 +08:00
Lunny Xiao
8e9814c346
Fix broken pull request files (#22962)
Fix #22961
2023-02-20 09:57:16 +08:00
Zettat123
65fc2d1b83
Fix avatar misalignment (#22955)
Fix #22818.

|  Before   | After  |
|  ----  | ----  |
| <img
src="https://user-images.githubusercontent.com/15528715/219617504-d86e7a90-d4ac-4a92-bd8a-100dddc693d5.png"
width="200px" /> | <img
src="https://user-images.githubusercontent.com/15528715/219618645-a4045f65-bda6-49ce-a676-f03a9817bb70.png"
width="200px" />|
| <img
src="https://user-images.githubusercontent.com/15528715/219618013-844ef208-853b-44bd-a67c-36e360f0ffa7.png"
width="200px" /> | <img
src="https://user-images.githubusercontent.com/15528715/219618361-cb13c369-852e-47bf-ae30-e429d348823d.png"
width="200px" /> |

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-20 07:07:46 +08:00
Lunny Xiao
c53ad052d8
Refactor the setting to make unit test easier (#22405)
Some bugs caused by less unit tests in fundamental packages. This PR
refactor `setting` package so that create a unit test will be easier
than before.

- All `LoadFromXXX` files has been splited as two functions, one is
`InitProviderFromXXX` and `LoadCommonSettings`. The first functions will
only include the code to create or new a ini file. The second function
will load common settings.
- It also renames all functions in setting from `newXXXService` to
`loadXXXSetting` or `loadXXXFrom` to make the function name less
confusing.
- Move `XORMLog` to `SQLLog` because it's a better name for that.

Maybe we should finally move these `loadXXXSetting` into the `XXXInit`
function? Any idea?

---------

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
2023-02-20 00:12:01 +08:00
zeripath
2b02343e21
Migration v244.go should be v243.go (#22988) 2023-02-19 09:24:23 -05:00
zeripath
54d7435d28
Adjust manifest to prevent tagging latest on rcs (#22811) 2023-02-19 09:24:08 -05:00
wxiaoguang
6cb76bf1df
Add some guidelines for refactoring (#22880)
Just some brief ideas.

Feel free to complete these guidelines, feel free to edit on this PR
directly.
2023-02-19 21:25:23 +08:00
yp05327
7eaf192967
Rename GetUnits to LoadUnits (#22970)
Same as https://github.com/go-gitea/gitea/pull/22967

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-19 16:31:39 +08:00
zeripath
61b89747ed
Provide the ability to set password hash algorithm parameters (#22942)
This PR refactors and improves the password hashing code within gitea
and makes it possible for server administrators to set the password
hashing parameters

In addition it takes the opportunity to adjust the settings for `pbkdf2`
in order to make the hashing a little stronger.

The majority of this work was inspired by PR #14751 and I would like to
thank @boppy for their work on this.

Thanks to @gusted for the suggestion to adjust the `pbkdf2` hashing
parameters.

Close #14751

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-19 15:35:20 +08:00
yp05327
d5e417a33d
Fix no user listed in org teams page (#22979)
https://github.com/go-gitea/gitea/pull/22294 introduced this bug.
Before:

![picture](https://user-images.githubusercontent.com/18380374/219916000-5b28db1a-22b5-481a-807b-49c14ac1cd35.png)
After:

![picture](https://user-images.githubusercontent.com/18380374/219916260-6b94efbb-836a-4551-b6a8-3f9cb37d822a.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-19 12:57:49 +08:00
wxiaoguang
d32af84a10
Refactor hiding-methods, remove jQuery show/hide, remove .hide class, remove inline style=display:none (#22950)
Close #22847

This PR:

* introduce Gitea's own `showElem` and related functions
* remove jQuery show/hide
* remove .hide class
* remove inline style=display:none 

From now on:

do not use:
* "[hidden]" attribute: it's too weak, can not be applied to an element
with "display: flex"
* ".hidden" class: it has been polluted by Fomantic UI in many cases
* inline style="display: none": it's difficult to tweak
* jQuery's show/hide/toggle: it can not show/hide elements with
"display: xxx !important"

only use:
* this ".gt-hidden" class
* showElem/hideElem/toggleElem functions in "utils/dom.js"

cc: @silverwind , this is the all-in-one PR
2023-02-19 12:06:14 +08:00
Brecht Van Lommel
6221a6fd54
Scoped labels (#22585)
Add a new "exclusive" option per label. This makes it so that when the
label is named `scope/name`, no other label with the same `scope/`
prefix can be set on an issue.

The scope is determined by the last occurence of `/`, so for example
`scope/alpha/name` and `scope/beta/name` are considered to be in
different scopes and can coexist.

Exclusive scopes are not enforced by any database rules, however they
are enforced when editing labels at the models level, automatically
removing any existing labels in the same scope when either attaching a
new label or replacing all labels.

In menus use a circle instead of checkbox to indicate they function as
radio buttons per scope. Issue filtering by label ensures that only a
single scoped label is selected at a time. Clicking with alt key can be
used to remove a scoped label, both when editing individual issues and
batch editing.

Label rendering refactor for consistency and code simplification:

* Labels now consistently have the same shape, emojis and tooltips
everywhere. This includes the label list and label assignment menus.
* In label list, show description below label same as label menus.
* Don't use exactly black/white text colors to look a bit nicer.
* Simplify text color computation. There is no point computing luminance
in linear color space, as this is a perceptual problem and sRGB is
closer to perceptually linear.
* Increase height of label assignment menus to show more labels. Showing
only 3-4 labels at a time leads to a lot of scrolling.
* Render all labels with a new RenderLabel template helper function.

Label creation and editing in multiline modal menu:

* Change label creation to open a modal menu like label editing.
* Change menu layout to place name, description and colors on separate
lines.
* Don't color cancel button red in label editing modal menu.
* Align text to the left in model menu for better readability and
consistent with settings layout elsewhere.

Custom exclusive scoped label rendering:

* Display scoped label prefix and suffix with slightly darker and
lighter background color respectively, and a slanted edge between them
similar to the `/` symbol.
* In menus exclusive labels are grouped with a divider line.

---------

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-18 21:17:39 +02:00
07df0a6b1c
Switch back to mainline go-ap
Marius merged my last go-ap patch (https://lists.sr.ht/~mariusor/activitypub-go/%3Cf23190d1-1376-6ad1-63ee-9c0d291d1eb5%40exozy.me%3E#%3C20230218114214.b5hecpabruk66g7r@slate%3E) so we no longer have to use my custom fork
2023-02-18 17:15:14 +00:00
Yarden Shoham
feed1ff38f
Rename "People" to "Members" in organization page and use a better icon (#22960)
`member` is how it's named in the code

Closes #22931 

Before | After
--- | ---

![image](https://user-images.githubusercontent.com/20454870/219781155-69a8476e-0f04-4b70-bda5-ea6fa8ce676c.png)
|
![image](https://user-images.githubusercontent.com/20454870/219780887-61644c27-36a2-4e1f-8f98-be3911883b49.png)

---------

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: delvh <leon@kske.dev>
2023-02-18 21:41:31 +08:00
yp05327
bd66fa586a
Rename repo.GetOwner to repo.LoadOwner (#22967)
Fixes https://github.com/go-gitea/gitea/issues/22963

---------

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
2023-02-18 20:11:03 +08:00
KN4CK3R
007d181bb5
Notify on container image create (#22806)
Fixes #22791

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-18 13:36:38 +08:00
Ferdinand Thiessen
8bba7e30b2
webview: Fix overflowing diff body (#22959)
If the content is quite large the diff body overflows the container and
can not be read.
This is fixed by setting the diff body maximum width to 100% and enable
overflow scrollbars:

before | after
---|---

![Screenshot_20230217_184716](https://user-images.githubusercontent.com/1855448/219733934-75bec38c-7cfe-47bb-b001-b090c02b769e.png)
|
![Screenshot_20230217_184655](https://user-images.githubusercontent.com/1855448/219733971-4db092d1-ffcb-4298-a640-f740a3ac430b.png)

Signed-off-by: Ferdinand Thiessen <rpm@fthiessen.de>
2023-02-18 09:47:06 +08:00
wxiaoguang
e7ef94e00f
Introduce customized HTML elements, fix incorrect AppUrl usages in templates (#22861)
This PR follows:
* #21986
* #22831

This PR also introduce customized HTML elements, which would also help
problems like:
* #17760
* #21429
* #21440

With customized HTML elements, there won't be any load-search-replace
operations, and it can avoid page flicking (which @silverwind cares a
lot).

Browser support:
https://developer.mozilla.org/en-US/docs/Web/API/Window/customElements

# FAQ

## Why the component has the prefix?

As usual, I would strongly suggest to add prefixes for our own/private
names. The dedicated prefix will avoid conflicts in the future, and it
makes it easier to introduce various 3rd components, like GitHub's
`relative-time` component. If there is no prefix, it's impossible to
introduce another public component with the same name in the future.

## Why the `custcomp.js` is loaded before HTML body? The `index.js` is
after HTML body.

Customized components must be registered before the content loading.
Otherwise there would be still some flicking.

`custcomp.js` should have its own dependencies and should be very light,
so it won't affect the page loading time too much.

## Why use `data-url` attribute but not use the `textContent`?

According to the standard, the `connectedCallback` occurs on the
tag-opening moment. The element's children are not ready yet.

## Why not use `{{.GuessCurrentOrigin $.ctx ...}}` to let backend decide
the absolute URL?

It's difficult for backend to guess the correct protocol(scheme)
correctly with zero configuration. Generating the absolute URL from
frontend can guarantee that the URL is 100% correct -- since the user is
visiting it.

# Screenshot

<details>

![image](https://user-images.githubusercontent.com/2114189/218256757-a267c8ba-3108-4755-9ae5-329f1b08f615.png)

</details>
2023-02-17 22:02:20 +08:00
Brecht Van Lommel
ca445cf566
Sort issues and pulls by recently updated in user and organization home (#22925)
The main purpose of these home pages should be getting an overview of
what's going on or needs attention. Recently updated is a better default
than newest for that purpose, to avoid missing active issues and pulls
that were not created recently.

The default sorting order in repository issues and pulls remains newest.
Repositories in an organization are already sorted by recently updated.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-17 15:13:35 +08:00
Zettat123
5a12e95d2a
Fix 404 error viewing the LFS file (#22945)
Fix #22734.

According to
[`view_file.tmpl`](https://github.com/go-gitea/gitea/blob/main/templates/repo/view_file.tmpl#L82),
`lfs_file.tmpl` should use `AssetUrlPrefix` instead of `AppSubUrl`.

Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-17 11:55:33 +08:00
gempir
d9c6cb71e1
Always go full width in PR view (#22844)
This is an alternative solution to #22824 
and would also close #22781

This makes the PR diff view always full width.
It makes sense to make use of that screen real estate. If you want a
more narrow view you can always resize your browser.
It also avoids cluttering the UI with another button + the database with
another column for the setting.

This is also how github and gitlab do it.
2023-02-16 13:25:00 -06:00
zeripath
52dd383b6d
Increase Content field size of gpg_key_import to MEDIUMTEXT (#22897)
Unfortunately #20896 does not completely prevent Data too long issues
and GPGKeyImport needs to be increased too.

Fix #22896

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-02-16 12:08:40 -06:00
Lunny Xiao
f196da12db
Fix context bug (#22940)
Fix https://try.gitea.io/wxiaoguang/test/issues/19
2023-02-16 11:20:53 -06:00
Sybren
aa45777c92
Allow custom "created" timestamps in user creation API (#22549)
Allow back-dating user creation via the `adminCreateUser` API operation.
`CreateUserOption` now has an optional field `created_at`, which can
contain a datetime-formatted string. If this field is present, the
user's `created_unix` database field will be updated to its value.

This is important for Blender's migration of users from Phabricator to
Gitea. There are many users, and the creation timestamp of their account
can give us some indication as to how long someone's been part of the
community.

The back-dating is done in a separate query that just updates the user's
`created_unix` field. This was the easiest and cleanest way I could
find, as in the initial `INSERT` query the field always is set to "now".
2023-02-16 10:32:01 -06:00
Dalai Felinto
a0b9767df8
Use "Title Case" for text "Reference in new issue" (#22936)
The "Reference in new issue" option shows up in a menu when looking at
pull requests. All the other options there follow the "Title case":

* Copy Link
* Quote Reply
* Edit

This patch makes sure this option also follow the Title case.

Screenshot of how it looks without this patch:

![image](https://user-images.githubusercontent.com/843498/219346003-728d07c1-d150-41a5-b084-faef118228b1.png)

Co-authored-by: Dalai Felinto <dalai@blender.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-16 23:06:07 +08:00
wxiaoguang
2e97a77e12
First step to refactor the .hide to .gt-hidden (#22916)
A separate PR from #22884 (without touching the jQuery methods)
2023-02-16 20:07:21 +08:00
zeripath
6c90f5e4c0
Add continue option to backport.go (#22930)
Sometimes it can be helpful to continue from a broken cherry-pick. This
PR adds another option which can be used to determine the version and pr
number from the current branch name instead of reading the config.yaml
file.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-02-16 10:48:08 +01:00
delvh
3361bbf058
Add title to PR file tree items (#22918)
Previously, a file/directory name was simply cut when it was too long.
Now, we display the browser-native tooltip (`title`) instead, so you can
still see it when hovering over it.
In this case, we don't use the normal `tippy` tooltips for three
reasons:
1. Vue components are not included in the global tooltip initialization
2. Vue components would need to initialize their tooltips themselves
whenever their content is changed
3. The tooltips are shown too long under the default configuration (the
tooltip one element above is still shown when hovering on the element
below)

Fixes #22915

## Appearance


![image](https://user-images.githubusercontent.com/51889757/219049642-43668a38-0e86-42bf-a1d0-3742c4dc7fd9.png)

## Room for future improvement

We could think about displaying the whole file path in the title, not
just its name.
This is not done at the moment:

![image](https://user-images.githubusercontent.com/51889757/219050689-1e6e3d57-f2bf-48be-8553-415e744a6e10.png)

---------

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-16 00:57:25 -05:00
3f318a4bad
Fix shabox regression (#22924)
- Regression from https://github.com/go-gitea/gitea/pull/22294

Error:

![image](https://user-images.githubusercontent.com/25481501/219115669-52b98fdb-bcbb-430d-a205-beb305c37e85.png)
2023-02-16 09:37:11 +08:00
Zettat123
0ab22a1a02
fix incorrect role labels for migrated issues and comments (#22914)
Fix #22797.

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

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-15 12:29:13 -05:00
wxiaoguang
2c04595762
Always show the command line instructions button even if there are conflicts (#22909)
Always show the `command line instructions` button even if there are
conflicts.
2023-02-15 09:31:35 -06:00
Morgan
4d306325c1
Remove thehowl from maintainers (#22917) 2023-02-15 08:35:46 -06:00
Lunny Xiao
bd820aa9c5
Add context cache as a request level cache (#22294)
To avoid duplicated load of the same data in an HTTP request, we can set
a context cache to do that. i.e. Some pages may load a user from a
database with the same id in different areas on the same page. But the
code is hidden in two different deep logic. How should we share the
user? As a result of this PR, now if both entry functions accept
`context.Context` as the first parameter and we just need to refactor
`GetUserByID` to reuse the user from the context cache. Then it will not
be loaded twice on an HTTP request.

But of course, sometimes we would like to reload an object from the
database, that's why `RemoveContextData` is also exposed.

The core context cache is here. It defines a new context
```go
type cacheContext struct {
	ctx  context.Context
	data map[any]map[any]any
        lock sync.RWMutex
}

var cacheContextKey = struct{}{}

func WithCacheContext(ctx context.Context) context.Context {
	return context.WithValue(ctx, cacheContextKey, &cacheContext{
		ctx:  ctx,
		data: make(map[any]map[any]any),
	})
}
```

Then you can use the below 4 methods to read/write/del the data within
the same context.

```go
func GetContextData(ctx context.Context, tp, key any) any
func SetContextData(ctx context.Context, tp, key, value any)
func RemoveContextData(ctx context.Context, tp, key any)
func GetWithContextCache[T any](ctx context.Context, cacheGroupKey string, cacheTargetID any, f func() (T, error)) (T, error)
```

Then let's take a look at how `system.GetString` implement it.

```go
func GetSetting(ctx context.Context, key string) (string, error) {
	return cache.GetWithContextCache(ctx, contextCacheKey, key, func() (string, error) {
		return cache.GetString(genSettingCacheKey(key), func() (string, error) {
			res, err := GetSettingNoCache(ctx, key)
			if err != nil {
				return "", err
			}
			return res.SettingValue, nil
		})
	})
}
```

First, it will check if context data include the setting object with the
key. If not, it will query from the global cache which may be memory or
a Redis cache. If not, it will get the object from the database. In the
end, if the object gets from the global cache or database, it will be
set into the context cache.

An object stored in the context cache will only be destroyed after the
context disappeared.
2023-02-15 21:37:34 +08:00
delvh
03638f9725
Add tooltip to issue reference (#22913)
Previously, you had no idea what you are copying with the issue
reference button for either long repo names, user names, or issue
indexes.
Now, it is simply a bit redundant for short references but a lot easier
for long references.

## Before

![image](https://user-images.githubusercontent.com/51889757/218995943-3b609ee9-4138-49ce-99b1-73fb1ea80280.png)

## After

![image](https://user-images.githubusercontent.com/51889757/218996119-4b6bf6c1-abfa-4618-81ca-a72914e73eb8.png)
2023-02-15 19:34:10 +08:00
zeripath
aa1d95300a
Add command to bulk set must-change-password (#22823)
As part of administration sometimes it is appropriate to forcibly tell
users to update their passwords.

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-02-14 16:12:19 -06:00
Nick
618c9118c1
Remember to attach the parent tree when converting TreeEntry() -> Tree() (#22902)
!fixup https://github.com/go-gitea/gitea/pull/22177

The only place this function is used so far is in
findReadmeFileInEntries(), so the only visible effect of this oversight
was in an obscure README-related corner: if the README was in a
subfolder and was a symlink that pointed up, as in .github/README.md ->
../docs/old/setup.md, the README would fail to render when FollowLinks()
hit the nil ptree. This makes the ptree non-nil and thus repairs it.
2023-02-14 21:23:04 +00:00
Zettat123
71ee488098
Fix dark-colored description text in arc-green theme (#22908)
Fix #22873.
2023-02-14 13:05:19 -06:00
wxiaoguang
e314c9e866
Fix the full-height problem for all pages (#22905)
Really fix #22883, close #22901

I made a mistake that the global styles in RepoActionView.vue could
still pollute global styles (I forgot that the code of this component is
still loaded on every page, instead of loaded on demand)

This PR makes a complete fix: only change the page's full-height
behavior if the component is used.

Screenshot after the fix:

<details>

![image](https://user-images.githubusercontent.com/2114189/218664776-0dbcd469-2c36-4e17-972f-e44fa3b81ba6.png)

</details>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-14 21:04:22 +08:00
wxiaoguang
d306ab2b8f
Remove Fomantic-UI's .hidden CSS class for menu elements (#22895)
* Like #22851
* All other dropdown menu elements do not have such `hidden` class.
* Actually the dropdown menu elements do not need it in HTML, so this PR
removes it.
* There is already `.ui.dropdown .menu { display: none; }`, so when
loading the page, the menu is correctly hidden initially, no need to add
any more CSS classes.
* The Fomantic UI's `.hidden` class should still exist until there is no
its checkbox/dropdown module anymore. The Fomantic UI JS code still
addes `hidden` for `ui checkbox` and addes `transition hidden` for `ui
menu` at the moment.
* This PR also cleans the legacy inline `style`, which is quite hacky
and no need anymore.

All these dropdown menus work well.

I have tested these 5 places:

* The code search from User Profile
* The issue sidebar to lock issue
* The repo search form
* The repo setting page: branch list
* The repo setting page: merge option list

Screenshot:

![image](https://user-images.githubusercontent.com/2114189/218534515-e7dfe291-6765-4e0b-833c-b74f17e30117.png)
2023-02-14 19:53:54 +08:00
Nick
7b5b739a2f
Move IsReadmeFile* from modules/markup/ to modules/util (#22877)
These functions don't examine contents, just filenames, so they don't
fit in well in a markup module.

This was originally part of
https://github.com/go-gitea/gitea/pull/22177.

Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
2023-02-13 15:01:09 -05:00
zeripath
51383ec084
Move helpers to be prefixed with gt- (#22879)
As discussed in #22847 the helpers in helpers.less need to have a
separate prefix as they are causing conflicts with fomantic styles

This will allow us to have the `.gt-hidden { display:none !important; }`
style that is needed to for the reverted PR.

Of note in doing this I have noticed that there was already a conflict
with at least one chroma style which this PR now avoids.

I've also added in the `gt-hidden` style that matches the tailwind one
and switched the code that needed it to use that.

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

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-02-13 17:59:59 +00:00
Jason Song
00b18ab42f
Remove _actions.less (#22885)
Fix #22883.

Revert commit 59beb2dba6b35b88dae5ac5c3d094bc6c1bba19c.
2023-02-13 08:33:33 -06:00
delvh
ffa89945d1
Highlight focused diff file (#22870)
When a diff file has been focused through the URL ID fragment, it will
be highlighted.

![light
theme](https://user-images.githubusercontent.com/51889757/218283880-ce551cb3-0c21-4044-adb0-d9ceb8a15ec5.png)
![dark
theme](https://user-images.githubusercontent.com/51889757/218283885-e96e989a-4670-49b6-9733-fbd6fffabf20.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-13 18:46:47 +08:00
Brecht Van Lommel
49919c636e
Pull Requests: setting to allow edits by maintainers by default, tweak UI (#22862)
Add setting to allow edits by maintainers by default, to avoid having to
often ask contributors to enable this.

This also reorganizes the pull request settings UI to improve clarity.
It was unclear which checkbox options were there to control available
merge styles and which merge styles they correspond to.

Now there is a "Merge Styles" label followed by the merge style options
with the same name as in other menus. The remaining checkboxes were
moved to the bottom, ordered rougly by typical order of operations.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-13 14:09:52 +08:00
Xinyu Zhou
b6d77229cf
docs: Update translation from-binary.zh-cn.md (#22820)
Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-13 13:14:51 +08:00
Lunny Xiao
f2772b5920
Move delete user to service (#22478)
Move delete user to service

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-13 13:11:41 +08:00
wxiaoguang
eb5e1bcd21
Remove Fomantic-UI's .hidden CSS class for checkbox elements (#22851)
Fomantic-UI's `.hidden` CSS class is badly designed.

* Checkbox elements do not need it in HTML, so this PR removes it (JS
adds the `.hidden` class back by `$('.ui.checkbox').checkbox()`)
* `menu transaction hidden` is still needed, and it should be the only
usage for the `.hidden` from now on (until they get refactored properly)

Co-authored-by: zeripath <art27@cantab.net>
2023-02-13 11:16:59 +08:00
Felipe Leopoldo Sologuren Gutiérrez
c8093a13ff
Add some headings to repo views (#22869)
* Add role heading level 1 to username/repo title.
* Copy behaviour of Releases to some other views.

Contributed by @Forgejo.

![Screenshot with
h2](https://user-images.githubusercontent.com/5055343/218287363-dfae9ab2-7297-4367-ab64-ab141506e131.png)
![Screenshot with former
div](https://user-images.githubusercontent.com/5055343/218287419-77d0ed56-935d-492f-b3ed-71051d169ba8.png)

Co-authored-by: delvh <leon@kske.dev>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-12 20:20:12 +08:00
Jason Song
a354636966
Fix style of actions rerun button (#22835)
Authored by @a1012112796 at
https://github.com/go-gitea/gitea/pull/22798#issuecomment-1421820001

Avoid putting `button` in `a`.

A patch for #22798 .

Now it looks like:

<img width="393" alt="image"
src="https://user-images.githubusercontent.com/9418365/217791913-b491fc86-ee9b-4672-80ea-7286eef2d11f.png">
<img width="389" alt="image"
src="https://user-images.githubusercontent.com/9418365/217791967-d8c09c8b-4cea-4011-b01e-db0d1333e7f6.png">

---------

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-12 19:19:50 +08:00
sillyguodong
34399cfd7a
Make issue and code search support camel case (#22829)
Fixes #22714 
### Changes:
1. Add a token filter which named "camelCase" between custom unicode
token filter and "to_lower" token filter when add custom analyzer.

### Notice:
If users want this feature to work, they should delete folder under
{giteaPath}/data/indexers and restart application. Then application will
create a new IndexMapping.

### Screenshots:

![image](https://user-images.githubusercontent.com/33891828/217715692-c18c41f2-57a1-4727-861c-470935c8e0c8.png)

### Others:
I originally attempted to give users the ability to configure the
"token_filters" in the "app.ini" file. But I found that if users does
not strictly follow a right order to register "token_filters", they
won't get the expected results. I think it is difficult to ask users to
do this. So I finally give up this idea.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-12 18:09:03 +08:00
Lunny Xiao
00f695da48
Revert "Fix notification and stopwatch empty states" (#22876)
Per https://github.com/go-gitea/gitea/pull/22845#issuecomment-1426950234

Reverts go-gitea/gitea#22845

Let's have a better PR.

@silverwind @zeripath

Co-authored-by: zeripath <art27@cantab.net>
2023-02-12 08:18:07 +00:00
Nick
e1aca7cbdd
Deduplicate findReadmeFile() (#22177)
This code was copy-pasted at some point. Revisit it to reunify it.

~~Doing that then encouraged simplifying the types of a couple of
related functions.~~

~~As a follow-up, move two helper functions, `isReadmeFile()` and
`isReadmeFileExtension()`, intimately tied to `findReadmeFile()`, in as
package-private.~~

Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
2023-02-12 15:08:10 +08:00
wxiaoguang
b0f18726a3
Fix milestone title font problem (#22863)
Replace #22853 since it's closed, and actually there are 2 places need
to be fixed.

~~Follow @fsologureng 's suggestion to keep the `<hX>` tags.~~ 

Update: from fsologureng: this doesn't change anything from a11y's point
of view. So I think this PR could be fine to fix the UI looking problems
as a quick patch, then defer the a11y problems to new PRs together.

Before: the font-size is too large.

After: it seems better.

![image](https://user-images.githubusercontent.com/2114189/218266257-fc2d5872-9e96-4c6a-87ea-f27531ac15c0.png)

![image](https://user-images.githubusercontent.com/2114189/218266247-efc09d83-405f-4495-967a-30d9744134ce.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-12 11:19:09 +08:00
gempir
e460b6ef4d
Fix PR file tree folders no longer collapsing (#22864)
Collapsing folders currently just throws a console error

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

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

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

Screenshots:

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

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

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-12 10:34:46 +08:00
sillyguodong
51ab495198
escape filename when assemble URL (#22850)
Fixes: #22843 

### Cause:

affdd40296/services/repository/files/content.go (L161)

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


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

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

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

### Screenshot:

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

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2023-02-12 09:31:14 +08:00
e61e9fba59
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-02-11 23:52:36 +00:00
silverwind
8fa54d0fda
Fix notification and stopwatch empty states (#22845)
Previous solution was relying on fomantic selector `.ui.label.hidden` to
hide the elements in their empty state, but this doesn't work any more
with the removal of the `label` class. Instead, introduce a standalone
CSS rule for the `hidden` class, which is universally usable as a single
class.

We can unfortunately not use the existing `hide` class because without
the `!important`, it does not have enough specificity to win against
fomantic's `.ui.menu:not(.vertical) .item {display: flex}` rule.

Followup and fixes regression from
https://github.com/go-gitea/gitea/pull/22169.

Before:

<img width="98" alt="image"
src="https://user-images.githubusercontent.com/115237/217959380-d3279ff3-526a-4ac4-9a18-3ab7c9ae91dd.png">

After:

<img width="77" alt="image"
src="https://user-images.githubusercontent.com/115237/217959463-44852716-cb25-4110-8481-668842ad4454.png">
2023-02-11 21:45:58 +00:00
zeripath
2152c4e98f
Fix .golangci.yml (#22868)
When we updated the .golangci.yml for 1.20 we should have used a string
as 1.20 is not a valid number.

In doing so we need to restore the nolint markings within the pq driver.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-02-11 21:44:53 +00:00
Nathaniel Sabanski
d4a9b35c4b
Fix migration issue. (#22867)
See:
https://github.com/go-gitea/gitea/pull/22112#issuecomment-1426872992
2023-02-11 21:28:41 +00:00
KN4CK3R
9057a008a1
Add /$count endpoints for NuGet v2 (#22855)
Fixes #22838

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-11 19:30:44 +08:00
Nathaniel Sabanski
fb1a2a13f0
Preview images for Issue cards in Project Board view (#22112)
Original Issue: https://github.com/go-gitea/gitea/issues/22102

This addition would be a big benefit for design and art teams using the
issue tracking.

The preview will be the latest "image type" attachments on an issue-
simple, and allows for automatic updates of the cover image as issue
progress is made!

This would make Gitea competitive with Trello... wouldn't it be amazing
to say goodbye to Atlassian products? Ha.

First image is the most recent, the SQL will fetch up to 5 latest images
(URL string).

All images supported by browsers plus upcoming formats: *.avif *.bmp
*.gif *.jpg *.jpeg *.jxl *.png *.svg *.webp

The CSS will try to center-align images until it cannot, then it will
left align with overflow hidden. Single images get to be slightly
larger!

Tested so far on: Chrome, Firefox, Android Chrome, Android Firefox.

Current revision with light and dark themes:

![image](https://user-images.githubusercontent.com/24665/207066878-58e6bf73-0c93-4caa-8d40-38f4432b3578.png)


![image](https://user-images.githubusercontent.com/24665/207066555-293f65c3-e706-4888-8516-de8ec632d638.png)

---------

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2023-02-11 16:12:41 +08:00
wxiaoguang
e9288c2477
Fix improper HTMLURL usages in Go code (#22839)
In Go code, HTMLURL should be only used for external systems, like
API/webhook/mail/notification, etc.

If a URL is used by `Redirect` or rendered in a template, it should be a
relative URL (aka `Link()` in Gitea)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-11 14:34:11 +08:00
1cb8d14bf7
Use proxy for pull mirror (#22771)
- Use the proxy (if one is specified) for pull mirrors syncs.
- Pulled the code from
c2774d9e80/modules/git/repo.go (L164-L170)

Downstream issue: https://codeberg.org/forgejo/forgejo/issues/302

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-11 08:39:50 +08:00
1a54d5e897
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-02-10 00:24:43 +00:00
wxiaoguang
affdd40296
Make issue title edit buttons focusable and fix incorrect ajax requests (#22807)
Replace #19922 , which is stale since my last review:
https://github.com/go-gitea/gitea/pull/19922#pullrequestreview-1003546506
and https://github.com/go-gitea/gitea/pull/19922#issuecomment-1153181546

Close #19769

Changes:
1. Use `<button>` instead of `<div>` for buttons
2. Prevent default event handler in `initGlobalButtonClickOnEnter`
3. Fix the incorrect call to `pullrequest_targetbranch_change`
4. Add a slight margin-left to the input element to make UI look better

The logic in repo-issue.js is not ideal, but this PR isn't going to
touch the logic.

This is also an example for future developers to understand how to make
buttons work properly.

### Before


![image](https://user-images.githubusercontent.com/2114189/217262515-ec0462f7-7051-46a5-bfa2-2f6c6a807b7d.png)

### After

* Add a slight margin-left.
* The `Cancel` button is focused.


![image](https://user-images.githubusercontent.com/2114189/217264891-934c9c8d-d190-4866-98b5-666cea57e28d.png)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-09 12:11:16 -05:00
Brecht Van Lommel
bdd2c9d2ef
Fix update by rebase being wrongly disabled by protected base branch (#22825)
The branch this is force pushing to is the head branch in the head repo,
so it should be checking if that is protected, not the base.
2023-02-09 12:08:42 -05:00
Brecht Van Lommel
137fcc989b
Fix inconsistent Filter Project name in issue list (#22827)
Use Project instead of Filter Project like the other filter menus.
2023-02-09 11:39:31 -05:00
wxiaoguang
24a9caa2f3
Fix more HTMLURL in templates (#22831)
I haven't tested `runs_list.tmpl` but I think it could be right.

After this PR, besides the `<meta .. HTMLURL>` in html head, the only
explicit HTMLURL usage is in `pull_merge_instruction.tmpl`, which
doesn't affect users too much and it's difficult to fix at the moment.

There are still many usages of `AppUrl` in the templates (eg: the
package help manual), they are similar problems as the HTMLURL in
pull_merge_instruction, and they might be fixed together in the future.

Diff without space:
https://github.com/go-gitea/gitea/pull/22831/files?diff=unified&w=1
2023-02-09 11:31:30 -05:00
John Olheiser
0c190e396d
Fix unmatched div in project filter (#22832)
(Note that the below screenshots aren't the same repo, the former is try
and the latter is local)

Before

![div-before](https://user-images.githubusercontent.com/42128690/217723899-a15da77f-a196-4b23-a157-e7f1e1979610.png)

After

![div-after](https://user-images.githubusercontent.com/42128690/217723878-e54235bc-a7d7-425e-bd0d-47d1814f18ba.png)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-09 11:15:07 -05:00
wxiaoguang
cef8f50286
Improve AppUrl/ROOT_URL checking (#22836)
After some PRs:
* #21986
* #22795
* #22808
* #22831
* #22839

Users won't be affected by the ROOT_URL problem in most cases. Close
#19345

This PR improves AppUrl/ROOT_URL checking, only check it on the admin
page, and the message is also updated.

Feel free to suggest about more English-native messages.



![image](https://user-images.githubusercontent.com/2114189/217811809-7d44ddb7-2c4a-46d0-a5db-8ae6ee65f8c3.png)
2023-02-09 11:14:45 -05:00
Jason Song
e253888a0e
Fix isAllowed of escapeStreamer (#22814)
The use of `sort.Search` is wrong: The slice should be sorted, and
`return >= 0` doen't mean it exists, see the
[manual](https://pkg.go.dev/sort#Search).

Could be fixed like this if we really need it:

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

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

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

But I don't think so, a map is better to do it.
2023-02-09 20:51:36 +08:00
wxiaoguang
29aea3642f
Make clone URL use current page's host (#22808)
Follow #21986

Even if the ROOT_URL is incorrect, the clone URL on the UI should be
correct.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-09 17:29:13 +08:00
yp05327
7ae10cb7f1
change org_type.go to visible_type.go and fix the notes (#22752)
It seems `VisibleType` is only designed for org at first. But it is also
used by user's visibility now.
So I think `org_type.go` can be changed to `visible_type.go`.
2023-02-09 06:40:34 +00:00
silverwind
90cf07a2c8
Improve notification and stopwatch styles (#22169)
- Add dot-style indicators to notification and time tracker
- Slightly reduce whitespace between right-aligned icons
- Move notification icon to right on mobile
- Switch menu icon to SVG

<img width="270" alt="Screenshot 2022-12-19 at 19 40 32"
src="https://user-images.githubusercontent.com/115237/208496795-ce8734a0-f109-47b7-8eb8-96931e867b23.png">
<img width="607" alt="Screenshot 2022-12-19 at 19 41 04"
src="https://user-images.githubusercontent.com/115237/208496797-2ff68197-f520-4174-927e-ead15addd63e.png">

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-09 13:42:18 +08:00
Brecht Van Lommel
87261f3fb9
Fix blame view missing lines (#22826)
Creating a new buffered reader for every part of the blame can miss
lines, as it will read and buffer bytes that the next buffered reader
will not get.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-09 11:51:02 +08:00
John Olheiser
4dd7d61ac8
Load issue before accessing index in merge message (#22822)
Fixes #22821

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-02-09 10:47:52 +08:00
Michal
5ae07d4c2f
include build info in Prometheus metrics (#22819)
Related to: https://github.com/go-gitea/gitea/issues/18061

This PR adds build info to the Prometheus metrics. This includes:
- goarch: https://pkg.go.dev/runtime#GOARCH
- goos: https://pkg.go.dev/runtime#pkg-constants
- goversion: https://pkg.go.dev/runtime#Version
- gitea version: just exposes the existing
code.gitea.io/gitea/modules/setting.AppVer

It's a similar approach to what some other Golang projects are doing,
e.g. Prometheus:
https://github.com/prometheus/common/blob/main/version/info.go

example /metrics response from Prometheus:
```
# HELP prometheus_build_info A metric with a constant '1' value labeled by version, revision, branch, goversion from which prometheus was built, and the goos and goarch for the build.
# TYPE prometheus_build_info gauge
prometheus_build_info{branch="HEAD",goarch="amd64",goos="linux",goversion="go1.19.4",revision="c0d8a56c69014279464c0e15d8bfb0e153af0dab",version="2.41.0"} 1
```

/metrics response from gitea with this PR:
```
# HELP gitea_build_info Build information
# TYPE gitea_build_info gauge
gitea_build_info{goarch="amd64",goos="linux",goversion="go1.20",version="2c6cc0b8c"} 1
```

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>

<!--

Please check the following:

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

-->

Signed-off-by: Michal Wasilewski <mwasilewski@gmx.com>
2023-02-08 19:54:01 +02:00
Jason Song
7d3c4c3e8a
Fix rerun button of Actions (#22798)
When clicking the return button, the page should be refreshed. However,
the browser may cancel the previous fetch request, and it fails to rerun
the job. It's easier to reproduce the bug in Safari or Firefox than
Chrome for some reason.

<img width="384" alt="image"
src="https://user-images.githubusercontent.com/9418365/217142792-a783f9a1-7089-44db-b7d8-46c46c72d284.png">


<img width="752" alt="image"
src="https://user-images.githubusercontent.com/9418365/217132406-b8381b63-b323-474e-935b-2596b1b5c046.png">
2023-02-08 15:55:57 +08:00
KN4CK3R
e8186f1c0f
Map OIDC groups to Orgs/Teams (#21441)
Fixes #19555

Test-Instructions:
https://github.com/go-gitea/gitea/pull/21441#issuecomment-1419438000

This PR implements the mapping of user groups provided by OIDC providers
to orgs teams in Gitea. The main part is a refactoring of the existing
LDAP code to make it usable from different providers.

Refactorings:
- Moved the router auth code from module to service because of import
cycles
- Changed some model methods to take a `Context` parameter
- Moved the mapping code from LDAP to a common location

I've tested it with Keycloak but other providers should work too. The
JSON mapping format is the same as for LDAP.


![grafik](https://user-images.githubusercontent.com/1666336/195634392-3fc540fc-b229-4649-99ac-91ae8e19df2d.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-08 14:44:42 +08:00
wxiaoguang
2c6cc0b8c9
Fix links for the menus in the view file page (#22795) 2023-02-08 00:08:44 +08:00
wxiaoguang
d5fa2e7510
Fix restore repo bug, clarify the problem of ForeignIndex (#22776)
Fix #22581

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

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


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

Co-authored-by: zeripath <art27@cantab.net>
2023-02-07 09:18:52 +08:00
Peyton Duncan
3ae78bc0a9
Grammar fix (#22790)
Noticed a minor grammatical error.
2023-02-06 16:05:59 -06:00
Lunny Xiao
769be877f2
Use link in UI which returned a relative url but not html_url which contains an absolute url (#21986)
partially fix #19345

This PR add some `Link` methods for different objects. The `Link`
methods are not different from `HTMLURL`, they are lack of the absolute
URL. And most of UI `HTMLURL` have been replaced to `Link` so that users
can visit them from a different domain or IP.

This PR also introduces a new javascript configuration
`window.config.reqAppUrl` which is different from `appUrl` which is
still an absolute url but the domain has been replaced to the current
requested domain.
2023-02-06 12:09:18 -06:00
John Olheiser
189d5b7045
Add repo adoption to FAQ (#22778)
This should be a simple set of steps to achieve
repo adoption.
2023-02-06 10:20:20 -06:00
KN4CK3R
f8c1e14a13
Use import of OCI structs (#22765)
Fixes #22758

Otherwise we would need to rewrite the structs in `oci.go`.
2023-02-06 10:07:09 +00:00
John Olheiser
361d807274
Update gogs upgrade information (#22777)
It seems that migrating from Gogs `0.12.x` and above may require more
work as time goes on and the projects continue to diverge.

This PR updates the docs to make it more clear.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-02-06 14:37:18 +08:00
Adi
c13eb8e6b3
Add CLI option tenant ID for oauth2 source (#22769)
Fixes #22713
2023-02-05 22:12:13 -06:00
wxiaoguang
50111c71c3
Refactor legacy strange git operations (#22756)
During the refactoring of the git module, I found there were some
strange operations. This PR tries to fix 2 of them

1. The empty argument `--` in repo_attribute.go, which was introduced by
#16773. It seems unnecessary because nothing else would be added later.
2. The complex git service logic in repo/http.go. 
* Before: the `hasAccess` only allow `service == "upload-pack" ||
service == "receive-pack"`
* After: unrelated code is removed. No need to call ToTrustedCmdArgs
anymore.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-06 10:23:17 +08:00
KN4CK3R
d987ac6bf1
Add Chef package registry (#22554)
This PR implements a [Chef registry](https://chef.io/) to manage
cookbooks. This package type was a bit complicated because Chef uses RSA
signed requests as authentication with the registry.


![grafik](https://user-images.githubusercontent.com/1666336/213747995-46819fd8-c3d6-45a2-afd4-a4c3c8505a4a.png)


![grafik](https://user-images.githubusercontent.com/1666336/213748145-d01c9e81-d4dd-41e3-a3cc-8241862c3166.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-06 09:49:21 +08:00
techknowlogick
ff18d17442
use drone secrets for s3 config (#22770) 2023-02-05 16:42:48 -05:00
yp05327
c07199f9ab
remove update language in ProfilePost (#22748)
Fixes https://github.com/go-gitea/gitea/issues/22703

Change language has been moved to `UpdateUserLang`

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-06 00:06:26 +08:00
Jason Song
d74d16a4b1
Set PR for issue when load attributes for PRs (#22766)
A missing patch for #22650.
2023-02-05 08:24:43 -06:00
Jason Song
c18a62279a
Fix time to NotifyPullRequestSynchronized (#22650)
Should call `PushToBaseRepo` before
`notification.NotifyPullRequestSynchronized`.

Or the notifier will get an old commit when reading branch
`pull/xxx/head`.

Found by ~#21937~ #22679.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-05 19:57:38 +08:00
KN4CK3R
df789d962b
Add Cargo package registry (#21888)
This PR implements a [Cargo registry](https://doc.rust-lang.org/cargo/)
to manage Rust packages. This package type was a little bit more
complicated because Cargo needs an additional Git repository to store
its package index.

Screenshots:

![grafik](https://user-images.githubusercontent.com/1666336/203102004-08d812ac-c066-4969-9bda-2fed818554eb.png)

![grafik](https://user-images.githubusercontent.com/1666336/203102141-d9970f14-dca6-4174-b17a-50ba1bd79087.png)

![grafik](https://user-images.githubusercontent.com/1666336/203102244-dc05743b-78b6-4d97-998e-ef76341a978f.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-05 18:12:31 +08:00
ByLCY
7baeb9c52a
Add new captcha: cloudflare turnstile (#22369)
Added a new captcha(cloudflare turnstile) and its corresponding
document. Cloudflare turnstile official instructions are here:
https://developers.cloudflare.com/turnstile

Signed-off-by: ByLCY <bylcy@bylcy.dev>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-05 15:29:03 +08:00
yp05327
e35f8e15a6
add default user visibility to cli command "admin user create" (#22750)
Fixes https://github.com/go-gitea/gitea/issues/22523
2023-02-04 17:35:04 +00:00
Lunny Xiao
8574a6433f
Show all projects, not just repo projects and open/closed projects (#22640)
This PR fixes two problems. One is when filter repository issues, only
repository level projects are listed. Another is if you list open
issues, only open projects will be displayed in filter options and if
you list closed issues, only closed projects will be displayed in filter
options.

In this PR, both repository level and org/user level projects will be
displayed in filter, and both open and closed projects will be listed as
filter items.

---------

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2023-02-04 22:35:08 +08:00
delvh
4d20a4a1ba
Remove ONLY_SHOW_RELEVANT_REPOS setting (#21962)
Every user can already disable the filter manually, so the explicit
setting is absolutely useless and only complicates the logic.

Previously, there was also unexpected behavior when multiple query
parameters were present.

---------

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-04 21:26:38 +08:00
wxiaoguang
ea13b23349
Escape path for the file list (#22741)
Fix #22740
2023-02-04 10:30:55 +00:00
techknowlogick
2741546bed
Repositories: by default disable all units except code and pulls on forks (#22541)
Most of the time forks are used for contributing code only, so not
having
issues, projects, release and packages is a better default for such
cases.
They can still be enabled in the settings.

A new option `DEFAULT_FORK_REPO_UNITS` is added to configure the default
units on forks.

Also add missing `repo.packages` unit to documentation.

code by: @brechtvl

## ⚠️ BREAKING ⚠️ 

When forking a repository, the fork will now have issues, projects,
releases, packages and wiki disabled. These can be enabled in the
repository settings afterwards. To change back to the previous default
behavior, configure `DEFAULT_FORK_REPO_UNITS` to be the same value as
`DEFAULT_REPO_UNITS`.

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-02-04 14:48:38 +08:00
silverwind
c2774d9e80
Fix color of tertiary button on dark theme (#22739)
Before:
<img width="266" alt="Screenshot 2023-02-03 at 14 07 34"
src="https://user-images.githubusercontent.com/115237/216611151-92e98305-c4b5-42f3-b2e2-8b1b805fa644.png">

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

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

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-04 11:17:43 +08:00
wxiaoguang
6bc3079c00
Refactor git command package to improve security and maintainability (#22678)
This PR follows #21535 (and replace #22592)

## Review without space diff

https://github.com/go-gitea/gitea/pull/22678/files?diff=split&w=1

## Purpose of this PR

1. Make git module command completely safe (risky user inputs won't be
passed as argument option anymore)
2. Avoid low-level mistakes like
https://github.com/go-gitea/gitea/pull/22098#discussion_r1045234918
3. Remove deprecated and dirty `CmdArgCheck` function, hide the `CmdArg`
type
4. Simplify code when using git command

## The main idea of this PR

* Move the `git.CmdArg` to the `internal` package, then no other package
except `git` could use it. Then developers could never do
`AddArguments(git.CmdArg(userInput))` any more.
* Introduce `git.ToTrustedCmdArgs`, it's for user-provided and already
trusted arguments. It's only used in a few cases, for example: use git
arguments from config file, help unit test with some arguments.
* Introduce `AddOptionValues` and `AddOptionFormat`, they make code more
clear and simple:
    * Before: `AddArguments("-m").AddDynamicArguments(message)`
    * After: `AddOptionValues("-m", message)`
    * -
* Before: `AddArguments(git.CmdArg(fmt.Sprintf("--author='%s <%s>'",
sig.Name, sig.Email)))`
* After: `AddOptionFormat("--author='%s <%s>'", sig.Name, sig.Email)`

## FAQ

### Why these changes were not done in #21535 ?

#21535 is mainly a search&replace, it did its best to not change too
much logic.

Making the framework better needs a lot of changes, so this separate PR
is needed as the second step.


### The naming of `AddOptionXxx`

According to git's manual, the `--xxx` part is called `option`.

### How can it guarantee that `internal.CmdArg` won't be not misused?

Go's specification guarantees that. Trying to access other package's
internal package causes compilation error.

And, `golangci-lint` also denies the git/internal package. Only the
`git/command.go` can use it carefully.

### There is still a `ToTrustedCmdArgs`, will it still allow developers
to make mistakes and pass untrusted arguments?

Generally speaking, no. Because 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.

### Why there was a `CmdArgCheck` and why it's removed?

At the moment of #21535, to reduce unnecessary changes, `CmdArgCheck`
was introduced as a hacky patch. Now, almost all code could be written
as `cmd := NewCommand(); cmd.AddXxx(...)`, then there is no need for
`CmdArgCheck` anymore.


### Why many codes for `signArg == ""` is deleted?

Because in the old code, `signArg` could never be empty string, it's
either `-S[key-id]` or `--no-gpg-sign`. So the `signArg == ""` is just
dead code.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-04 10:30:43 +08:00
zeripath
3c5655ce18
Improve trace logging for pulls and processes (#22633)
Our trace logging is far from perfect and is difficult to follow.

This PR:

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

Ref #22578

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-02-03 18:11:48 -05:00
Francesco Siddi
01f082287d
Remove 'primary' class from tab counter labels (#22687)
Using the primary color for each label counter makes the use of color
redundant, as well as suggesting this is a call to action. Use the base
grey color instead.



![grey_lables](https://user-images.githubusercontent.com/451841/215778889-0d5dddad-353f-4703-a48f-1540080dee26.jpg)
2023-02-03 17:25:55 -05:00
Yarden Shoham
ce4fd95233
Use native error checking with exec.ErrDot (#22735)
This was meant to land in #22073 but was blocked until #22732 was merged

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-02-03 17:22:11 +00:00
techknowlogick
cfb1cb1168
update to build with go1.20 (#22732)
as title

---------

Co-authored-by: Lauris BH <lauris@nix.lv>
2023-02-03 11:23:52 -05:00
Lunny Xiao
1410e13dc5
Add missed reverse proxy authentication documentation (#22250)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-03 18:37:25 +08:00
jladbrook
891391689a
Update button is shown when a Pull Request is marked WIP - Issue #21740 (#22683)
Fix #21740.

Updated the Pull Request template so that the 'Update branch by merge'
button is visible for WIP PR's. Making the behaviour match a non WIP-PR.

Previous WIP page with changes pending on the branch:


![image](https://user-images.githubusercontent.com/1656302/215738307-e68a2f92-5ff8-4f48-a541-35ca81d1f1a4.png)

Updated UI adding the update button:


![image](https://user-images.githubusercontent.com/1656302/215737872-e0e9d712-b7aa-4b90-b7ed-6a92a14fc182.png)

## Notes

* have not removed the **$canAutoMerge** variable from the pull.tmpl on
this
[line](36dc11869d/templates/repo/issue/view_content/pull.tmpl (L131))
- doesn't appear to be used elsewhere but wasn't sure
* In order to avoid duplicating code corresponding UI code was added to
a new tmpl file, ```update_branch_by_merge.tmpl``` and is called in two
places from ```pull.tmpl```.

---------

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-03 14:24:45 +08:00
Jason Song
82728a7cec
Do not overwrite empty DefaultBranch (#22708)
Fix #21994. 
And fix #19470.

While generating new repo from a template, it does something like
"commit to git repo, re-fetch repo model from DB, and update default
branch if it's empty".


19d5b2f922/modules/repository/generate.go (L241-L253)

Unfortunately, when load repo from DB, the default branch will be set to
`setting.Repository.DefaultBranch` if it's empty:


19d5b2f922/models/repo/repo.go (L228-L233)

I believe it's a very old temporary patch but has been kept for many
years, see:
[2d2d85bb](https://github.com/go-gitea/gitea/commit/2d2d85bb#diff-1851799b06733db4df3ec74385c1e8850ee5aedee70b8b55366910d22725eea8)

I know it's a risk to delete it, may lead to potential behavioral
changes, but we cannot keep the outdated `FIXME` forever. On the other
hand, an empty `DefaultBranch` does make sense: an empty repo doesn't
have one conceptually (actually, Gitea will still set it to
`setting.Repository.DefaultBranch` to make it safer).
2023-02-02 14:48:48 -06:00
zeripath
2914c5299b
Improve error report when user passes a private key (#22726)
The error reported when a user passes a private ssh key as their ssh
public key is not very nice.

This PR improves this slightly.

Ref #22693

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2023-02-02 18:25:54 +00:00
wxiaoguang
ccb3851281
Add some comments for recent code (#22725)
When using the main branch, I found that some changed code didn't have
comments.

This PR adds some comments.
2023-02-02 11:39:38 -06:00
Lunny Xiao
368d43643f
Fix actions workflow branches match bug (#22724)
caused by #22680 

`pushPayload.Ref` and `prPayload.PullRequest.Base.Ref` have the format
like `refs/heads/<branch_name>`, so we need to trim the prefix before
comparing.
2023-02-02 20:40:08 +08:00
Pavel Ezhov
98770d3db8
Fix group filter for ldap source sync (#22506)
There are 2 separate flows of creating a user: authentication and source
sync.
When a group filter is defined, source sync ignores group filter, while
authentication respects it.
With this PR I've fixed this behavior, so both flows now apply this
filter when searching users in LDAP in a unified way.

- Unified LDAP group membership lookup for authentication and source
sync flows
- Replaced custom group membership lookup (used for authentication flow)
with an existing listLdapGroupMemberships method (used for source sync
flow)
- Modified listLdapGroupMemberships and getUserAttributeListedInGroup in
a way group lookup could be called separately
- Added user filtering based on a group membership for a source sync
- Added tests to cover this logic

Co-authored-by: Pavel Ezhov <paejov@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-02 15:45:00 +08:00
yp05327
9ef8bfb69b
set user dashboard org visibility to basic (#22706)
Same to https://github.com/go-gitea/gitea/pull/22674 and
https://github.com/go-gitea/gitea/pull/22605

Sorry to create 3 PR to fix this.
I checked all span with class `org-visibility`, i think this is the last
one :)

And I found that private/limited user has no private/limited tag in
dashboard. but org does.
If it is ok i will add this feature in another pr.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-02 14:53:14 +08:00
wxiaoguang
c46f53a627
Fix diff UI for unexpandable items (#22700)
Follows #21094

Before:

There are 2 problems:

1. Sometimes, the header starts with a number, sometimes, it starts with
an icon button. It makes the UI look like misaligned.
2. The second item's bottom border is too thick (actually, that's an
empty element with border, which should be hidden as well)
3. (An old problem) the number is not mono-font


![image](https://user-images.githubusercontent.com/2114189/215935944-003fe2d3-69bf-413c-bbae-0a4668a508c3.png)


After:

Fix above problems.


![image](https://user-images.githubusercontent.com/2114189/215944811-b867a20c-110c-47a2-aa52-572a8162a44d.png)

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-02 13:39:55 +08:00
crystal
5d9c64b3fe
Fix line spacing for plaintext previews (#22699)
Adding `<br>` between each line is not necessary since the entire file
is rendered inside a `<pre>`

fixes https://codeberg.org/Codeberg/Community/issues/915
2023-02-01 22:51:02 -06:00
Lunny Xiao
4e946e5a7d
Small refactor for loading PRs (#22652) 2023-02-01 21:49:28 -06:00
Lukas
3f2e721372
Allow setting access token scope by CLI (#22648)
Followup for #20908 to allow setting the scopes when creating new access
token via CLI.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-02-02 11:10:37 +08:00
e44c986b86
Use ctx instead of db.DefaultContext 2023-02-02 02:09:31 +00:00
Felipe Leopoldo Sologuren Gutiérrez
15c035775a
Add main landmark to templates and adjust titles (#22670)
* Add main aria landmark to templates
 * Adjust some titles to improve understanding of location in navigation

Contributed by @Forgejo
2023-02-01 22:56:10 +00:00
Brecht Van Lommel
1e0e79dcbf
Fix cache-control header clearing comment text when editing issue (#22604)
The `no-store` cache control added in #20432 is causing form input to be
cleared unnecessarily on page reload. Instead use
`max-age=0,private,must-revalidate` which avoids this.

This was particularly a problem when typing a long comment for an issue
and then for example changing the label. The page would be reloaded and
lose the unsubmitted comment.

Fixes #22603
2023-02-01 15:28:06 -06:00
de771dcd76
make fmt 2023-02-01 21:25:12 +00:00
8f42f98d9f
Implement paging for person collections 2023-02-01 21:24:46 +00:00
delvh
b6b8feb3de
Enable @<user>- completion popup on the release description textarea (#22359)
For some unknown reason, this was previously disabled.
Additionally removed an unused return value.
2023-02-01 13:14:40 -06:00
KN4CK3R
6ba9ff7b48
Add Conda package registry (#22262)
This PR adds a [Conda](https://conda.io/) package registry.
2023-02-01 12:30:39 -06:00
KN4CK3R
5882e179a9
Add user secrets (#22191)
Fixes #22183
Replaces #22187

This PR adds secrets for users. I refactored the files for organizations
and repos to use the same logic and templates. I splitted the secrets
from deploy keys again and reverted the fix from #22187.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-02-01 20:53:04 +08:00
zeripath
9f9a1ce922
Add missing close bracket in imagediff (#22710)
There was a missing `]` in imagediff.js:

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

This PR simply adds this.

Fix #22702
2023-02-01 19:48:35 +08:00
yp05327
72a83dcc82
Explain that the no-access team unit does not affect public repositories (#22661)
Fixes https://github.com/go-gitea/gitea/issues/22600

Add explanations to team unit access control.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-01 16:14:40 +08:00
zeripath
19d5b2f922
Fix bugs with WebAuthn preventing sign in and registration. (#22651)
This PR fixes two bugs with Webauthn support:

* There was a longstanding bug within webauthn due to the backend using
URLEncodedBase64 but the javascript using decoding using plain base64.
This causes intermittent issues with users reporting decoding errors.
* Following the recent upgrade to webauthn there was a change in the way
the library expects RPOrigins to be configured. This leads to the
Relying Party Origin not being configured and prevents registration.

Fix #22507

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-02-01 07:24:10 +00:00
Lunny Xiao
2871ea0809
Add more events details supports for actions (#22680)
#21937 implemented only basic events based on name because of `act`'s
limitation. So I sent a PR to parse all possible events details in
https://gitea.com/gitea/act/pulls/11 and it merged. The ref
documentation is
https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows

This PR depends on that and make more detail responses for `push` events
and `pull_request` events. And it lefts more events there for future
PRs.

---------

Co-authored-by: Jason Song <i@wolfogre.com>
2023-02-01 13:32:46 +08:00
Felipe Leopoldo Sologuren Gutiérrez
7fd5d38860
Improve checkbox accessibility a bit by adding the title attribute (#22593)
EDIT: The main change of this PR was resolved by #22599. This
complements that PR for some cases without label and complicated layout
to be added.

NOTE: Contributed by @Forgejo.
2023-02-01 01:43:06 +00:00
Brecht Van Lommel
faa96553d1
Add repository setting to enable/disable releases unit (#22671)
To go along with similar settings for issues, pulls, projects, packages.
2023-02-01 01:31:19 +00:00
Jason Song
b6145bfaa3
Use relative url in actions view (#22675)
Use relative url in actions view.
2023-01-31 22:46:10 +00:00
Jason Song
707ecec715
Fix ref to trigger Actions (#22679)
If triggered by PR, the ref should be `pull/<index>/head` instead of
`repo.DefaultBranch`.

And improve UI:

<img width="493" alt="image"
src="https://user-images.githubusercontent.com/9418365/215731280-312564f2-2450-45d0-b986-1accb0670976.png">


Related to #21937.
2023-01-31 22:45:25 +00:00
Melroy van den Berg
fd29071e57
Rootless Docker - Mistake with the repo-avatars parent folder name (#22637)
There was a mistake when choosing the structure for the repo avatars parent folder and it added a spurious /gitea.

The `data` directory should contain folders like:

  - `attachments/`
  - `avatars/`
  - `log/`
  - `repo-avatars/`
2023-01-31 22:42:48 +00:00
Brecht Van Lommel
1947409ef0
Fix missing title and filter in issue sidebar project menu (#22557)
These exist in the new issue form but were seemingly forgotten here.
2023-01-31 22:40:38 +00:00
Lunny Xiao
cc910014ab
Fix wrong hint when deleting a branch successfully from pull request UI (#22673)
Fix #18785
2023-01-31 22:11:48 +00:00
zeripath
f1f0430f9f
Add Contributed backport command (#22643)
This PR provides a contributed backport command to help create backports
for Gitea.

It represents a significant improvement on my previously described
shell-script.

It can be installed using `go install contrib/backport/backport.go`.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-31 22:10:54 +00:00
Ivan Maximov
519939fa8c
Fix typo in command-line.en-us.md (#22681)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-31 21:43:39 +00:00
Ivan Maximov
f518b42d4c
Fix typo in linked-references.en-us.md (#22682) 2023-01-31 21:43:27 +00:00
Ivan Maximov
66877aed54
Fix typo in guidelines-backend.en-us.md (#22690) 2023-01-31 21:43:12 +00:00
Ivan Maximov
706f4686b8
Fix typo in storage.en-us.md (#22694) 2023-01-31 22:42:41 +01:00
JakobDev
be93e48ccb
Hide collapse icon in diff with no lines (#21094)
Sometimes (e.g. renaming a file) nothing of the content is changed. In
this case, it makes no sense to show the collapse icon in a diff.
2023-01-31 11:40:22 -06:00
Felipe Leopoldo Sologuren Gutiérrez
85016af1fe
Fixes accessibility behavior of Watching, Staring and Fork buttons (#22634)
Add tabindex to buttons of repository views.
2023-01-31 16:28:43 +01:00
KN4CK3R
b80538f37d
Disable test for incoming email (#22686)
Disable this test for the moment because the used imap container image
seems unstable which results in many failed CI builds.

Co-authored-by: Jason Song <i@wolfogre.com>
2023-01-31 14:56:22 +01:00
Francesco Siddi
c14d3e80e8
Remove label color from global issue filters (#22660)
The use of ui colors (red, green, etc) should be limited to actionable
or dismissable entries. Before this commit, a green/red label was used
to display issues count on each repository. This did not add any
meaningful information to the list.

Removing the label reduces ambiguity and makes the list easier to scan
visually.


![label_compare](https://user-images.githubusercontent.com/451841/215360696-a881b765-207d-4ffa-8bec-398f8e5dab1e.jpg)

---------

Co-authored-by: delvh <dev.lh@web.de>
2023-01-31 20:58:34 +08:00
wxiaoguang
36dc11869d
Use correct captured group range when parsing cross-reference (#22672)
Fixes #22666 (Replace #22668)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: zeripath <art27@cantab.net>
2023-01-31 10:08:05 +01:00
yp05327
f47ea60c07
set user visibility class to basic (#22674)
Same to https://github.com/go-gitea/gitea/pull/22605

![user
package](https://user-images.githubusercontent.com/18380374/215669905-71fe01c3-c011-4867-97a6-3df5f940a6bf.PNG)
![user
projects](https://user-images.githubusercontent.com/18380374/215669909-1a4f74f1-bbde-4913-9ba5-51c44cc63862.PNG)

These two page are both used at user and org, so if i fixed the org
page, the user page will be also be fixed.
2023-01-31 07:05:25 +00:00
crystal
03f37d82fe
Fix README TOC links (#22577)
Fixes anchored markup links by adding `user-content-` (which is
prepended to IDs)

Closes https://codeberg.org/Codeberg/Community/issues/894
2023-01-31 13:21:29 +08:00
Jason Song
4011821c94
Implement actions (#21937)
Close #13539.

Co-authored by: @lunny @appleboy @fuxiaohei and others.

Related projects:
- https://gitea.com/gitea/actions-proto-def
- https://gitea.com/gitea/actions-proto-go
- https://gitea.com/gitea/act
- https://gitea.com/gitea/act_runner

### Summary

The target of this PR is to bring a basic implementation of "Actions",
an internal CI/CD system of Gitea. That means even though it has been
merged, the state of the feature is **EXPERIMENTAL**, and please note
that:

- It is disabled by default;
- It shouldn't be used in a production environment currently;
- It shouldn't be used in a public Gitea instance currently;
- Breaking changes may be made before it's stable.

**Please comment on #13539 if you have any different product design
ideas**, all decisions reached there will be adopted here. But in this
PR, we don't talk about **naming, feature-creep or alternatives**.

### ⚠️ Breaking

`gitea-actions` will become a reserved user name. If a user with the
name already exists in the database, it is recommended to rename it.

### Some important reviews

- What is `DEFAULT_ACTIONS_URL` in `app.ini` for?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1055954954
- Why the api for runners is not under the normal `/api/v1` prefix?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1061173592
- Why DBFS?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1061301178
- Why ignore events triggered by `gitea-actions` bot?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1063254103
- Why there's no permission control for actions?
  - https://github.com/go-gitea/gitea/pull/21937#discussion_r1090229868

### What it looks like

<details>

#### Manage runners

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205870657-c72f590e-2e08-4cd4-be7f-2e0abb299bbf.png">

#### List runs

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872794-50fde990-2b45-48c1-a178-908e4ec5b627.png">


#### View logs

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205872501-9b7b9000-9542-4991-8f55-18ccdada77c3.png">



</details>

### How to try it

<details>

#### 1. Start Gitea

Clone this branch and [install from
source](https://docs.gitea.io/en-us/install-from-source).

Add additional configurations in `app.ini` to enable Actions:

```ini
[actions]
ENABLED = true
```

Start it.

If all is well, you'll see the management page of runners:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205877365-8e30a780-9b10-4154-b3e8-ee6c3cb35a59.png">


#### 2. Start runner

Clone the [act_runner](https://gitea.com/gitea/act_runner), and follow
the
[README](https://gitea.com/gitea/act_runner/src/branch/main/README.md)
to start it.

If all is well, you'll see a new runner has been added:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205878000-216f5937-e696-470d-b66c-8473987d91c3.png">

#### 3. Enable actions for a repo

Create a new repo or open an existing one, check the `Actions` checkbox
in settings and submit.

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879705-53e09208-73c0-4b3e-a123-2dcf9aba4b9c.png">
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205879383-23f3d08f-1a85-41dd-a8b3-54e2ee6453e8.png">

If all is well, you'll see a new tab "Actions":

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205881648-a8072d8c-5803-4d76-b8a8-9b2fb49516c1.png">

#### 4. Upload workflow files

Upload some workflow files to `.gitea/workflows/xxx.yaml`, you can
follow the [quickstart](https://docs.github.com/en/actions/quickstart)
of GitHub Actions. Yes, Gitea Actions is compatible with GitHub Actions
in most cases, you can use the same demo:

```yaml
name: GitHub Actions Demo
run-name: ${{ github.actor }} is testing out GitHub Actions 🚀
on: [push]
jobs:
  Explore-GitHub-Actions:
    runs-on: ubuntu-latest
    steps:
      - run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
      - run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
      - run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
      - name: Check out repository code
        uses: actions/checkout@v3
      - run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
      - run: echo "🖥️ The workflow is now ready to test your code on the runner."
      - name: List files in the repository
        run: |
          ls ${{ github.workspace }}
      - run: echo "🍏 This job's status is ${{ job.status }}."
```

If all is well, you'll see a new run in `Actions` tab:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884473-79a874bc-171b-4aaf-acd5-0241a45c3b53.png">

#### 5. Check the logs of jobs

Click a run and you'll see the logs:

<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/205884800-994b0374-67f7-48ff-be9a-4c53f3141547.png">

#### 6. Go on

You can try more examples in [the
documents](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions)
of GitHub Actions, then you might find a lot of bugs.

Come on, PRs are welcome.

</details>

See also: [Feature Preview: Gitea
Actions](https://blog.gitea.io/2022/12/feature-preview-gitea-actions/)

---------

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: ChristopherHX <christopher.homberger@web.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-31 09:45:19 +08:00
Brecht Van Lommel
b5b3e0714e
Pull request yaml template support for including commit body in a field (#22629)
When using a markdown template the commit body is prepended to text in
the description. This adds the same functionality for yaml templates,
adding the commit message in a field with id "body".

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 22:39:07 +08:00
1b53a9e914
Don't return duplicated users who can create org repo (#22560)
- Currently the function `GetUsersWhoCanCreateOrgRepo` uses a query that
is able to have duplicated users in the result, this is can happen under
the condition that a user is in team that either is the owner team or
has permission to create organization repositories.
- Add test code to simulate the above condition for user 3,
[`TestGetUsersWhoCanCreateOrgRepo`](a1fcb1cfb8/models/organization/org_test.go (L435))
is the test function that tests for this.
- The fix is quite trivial use a map keyed by user id in order to drop
duplicates.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 18:12:45 +08:00
Brecht Van Lommel
be315c76fb
Fix poor alignment of organization description on organization home page (#22656)
Don't generate nested `<p>`, use `<div>` like description on the user
profile page.

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 16:16:12 +08:00
techknowlogick
203681d084
Issues: support setting issue template field values with query (#22545) 2023-01-30 12:36:04 +08:00
d8c1f87b32
Start working on pagination for collections 2023-01-30 03:48:46 +00:00
2a296a9082
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-01-30 03:46:00 +00:00
KN4CK3R
d0d257b243
Add support for commit cross references (#22645)
Fixes #22628

This PR adds cross references for commits by using the format
`owner/repo@commit` . References are rendered like
[go-gitea/lgtm@6fe88302](#dummy).

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-30 09:50:01 +08:00
Brecht Van Lommel
3ff5a6a365
Fix missing message in git hook when pull requests disabled on fork (#22625)
And also the other way around, it would show an non-working URL in the
message when pull requests are disabled on the base repository but
enabled on the fork.
2023-01-29 15:00:10 -06:00
KN4CK3R
d283a31f03
Check quota limits for container uploads (#22450)
The test coverage has revealed that container packages were not checked
against the quota limits.
2023-01-29 11:34:29 -06:00
John Olheiser
2052a9e2b4
Consume hcaptcha and pwn deps (#22610)
This PR just consumes the
[hcaptcha](https://gitea.com/jolheiser/hcaptcha) and
[haveibeenpwned](https://gitea.com/jolheiser/pwn) modules directly into
Gitea.

Also let this serve as a notice that I'm fine with transferring my
license (which was already MIT) from my own name to "The Gitea Authors".

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-29 09:49:51 -06:00
techknowlogick
e88b529b31
Issues: add Project filter to issues list and search (#22544)
Currently only a single project like milestone, not multiple like
labels.

Implements #14298

Code by @brechtvl

---------

Co-authored-by: Brecht Van Lommel <brecht@blender.org>
2023-01-29 11:45:29 +08:00
Felipe Leopoldo Sologuren Gutiérrez
2b1e47e2a2
Improve accessibility of navigation bar and footer (#22635)
Added ARIA navigation landmark to navigation bar and aria label for both
nav bar and footer.

Contributed by @forgejo.

---------

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-29 09:29:10 +08:00
Lunny Xiao
c0015979a6
Support system hook API (#14537)
This add system hook API
2023-01-28 19:12:10 +01:00
zeripath
78e6b21c1a
Improve checkIfPRContentChanged (#22611)
The code for checking if a commit has caused a change in a PR is
extremely inefficient and affects the head repository instead of using a
temporary repository.

This PR therefore makes several significant improvements:

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

Ref #22578

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-28 15:54:40 +00:00
Felipe Leopoldo Sologuren Gutiérrez
e9cd18b557
Link issue and pull requests status change in UI notifications directly to their event in the timelined view. (#22627)
Adding the related comment to the issue and pull request status change
in the UI notifications allows to navigate directly to the specific
event in its dedicated view, easing the reading of last comments and to
the editor for additional comments if desired.
2023-01-28 11:16:46 +00:00
a1012112796
48f5d51908
fix permission check for creating comment while mail (#22524)
only creating comment on locked issue request write permission,
for others, read permission is enough.

related to https://github.com/go-gitea/gitea/pull/22056

/cc @KN4CK3R

---------

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-28 17:28:55 +08:00
Otto Richter (fnetX)
95d9fbdcf3
Fix error on account activation with wrong passwd (#22609)
On activating local accounts, the error message didn't differentiate
between using a wrong or expired token, or a wrong password. The result
could already be obtained from the behaviour (different screens were
presented), but the error message was misleading and lead to confusion
for new users on Codeberg with Forgejo.

Now, entering a wrong password for a valid token prints a different
error message.

The problem was introduced in 0f14f69e60.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-28 15:59:46 +08:00
Felipe Leopoldo Sologuren Gutiérrez
74466eb133
Fixes accessibility of empty repository commit status (#22632)
Avoid empty labelled anchor in repo without commits.

Contributed by @forgejo.

<!--

Please check the following:

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

-->
2023-01-28 00:40:17 +02:00
KN4CK3R
51a92cb821
Use --index-url in PyPi description (#22620)
Fixes #22616

Co-authored-by: zeripath <art27@cantab.net>
2023-01-27 15:12:18 +01:00
KN4CK3R
5ff037ef51
Show migration validation error (#22619)
Discord request:
https://discord.com/channels/322538954119184384/322910365237248000/1067083214096703488

If there is a json schema validation error the full file content gets
dumped into the log. That does not help and may be a lot of data. This
PR prints the schema validation error message instead.
2023-01-27 20:56:00 +08:00
techknowlogick
2903afb78f
Allow issue templates to not render title (#22589)
This adds a yaml attribute that will allow the option for when markdown
is rendered that the title will be not included in the output

Based on work from @brechtvl
2023-01-26 22:45:49 -06:00
John Olheiser
642db3c8f7
Fix delete_repo in template (#22606)
Currently the value doesn't match the model, so selecting it results in
a 500.

e8ac6a9aea/models/auth/token_scope.go (L42)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-26 14:36:15 -06:00
yp05327
4f8c0eba9a
set org visibility class to basic in header (#22605)
Fixes https://github.com/go-gitea/gitea/issues/22601

At people and team page, we have red private tag or orange limited tag,
but at repo page, it is gray (basic).
I think it is better to set them into same color (basic).
2023-01-26 12:44:34 -06:00
JakobDev
4d072a4c4e
Add API endpoint to get latest release (#21267)
This PR adds a new API endpoint to get the latest stable release of a
repo, similar to [GitHub
API](https://docs.github.com/en/rest/releases/releases#get-the-latest-release).
2023-01-26 10:33:47 -06:00
wxiaoguang
e8ac6a9aea
Add ARIA support for Fomantic UI checkboxes (#22599)
Replace #22593

This is a general approach to add ARIA support for all Fomantic UI
checkboxes (including radioboxes)

* Pros:
* General approach, it works for all Fomantic UI checkboxes / radioboxes
    * No need to write IDs manually everywhere
    * No need to tell new contributors to write IDs again and again

* Cons:
* Slightly affects performance, but it's really trivial, because there
was already a heavy `$('.ui.checkbox').checkbox()` for Fomantic UI
before. So everything is still fine.


Screenshot (from the repo setting page, which has various checkboxes):

<details>


![image](https://user-images.githubusercontent.com/2114189/214480937-3a54d36f-55c3-49de-9c45-c4bb21f1f4c6.png)

</details>
2023-01-25 17:52:10 +02:00
Brecht Van Lommel
c8139c0f64
Webhooks: for issue close/reopen action, add commit ID that caused it (#22583)
The `commit_id` property name is the same as equivalent functionality in
GitHub. If the action was not caused by a commit, an empty string is
used.

This can for example be used to automatically add a Resolved label to an
issue fixed by a commit, or clear it when the issue is reopened.
2023-01-24 23:47:53 -05:00
Brecht Van Lommel
a31fedd2c2 Add templates to customize text when creating and migrating repositories
These can be used to explain which types of repositories a Gitea instance is
willing to host, or other rules for creating repositories.
2023-01-24 22:36:48 -05:00
Sybren
25f4b7d7cd
Prevent duplicate labels when importing more than 99 (#22591)
Importing labels (via `gitea restore-repo`) did not split them up into
batches properly. The first "batch" would create all labels, the second
"batch" would create all labels except those in the first "batch", etc.
This meant that when importing more than 99 labels (the batch size)
there would always be duplicate ones.

This is solved by actually passing `labels[:lbBatchSize]` to the
`CreateLabels()` function, instead of the entire list `labels`.
2023-01-24 19:44:55 +00:00
Yarden Shoham
b91bc68092
Remove address from DCO (#22595)
I copy-pasted from https://developercertificate.org/
2023-01-24 18:52:38 +00:00
Sybren
95e8ea9440
Allow setting redirect_to cookie on OAuth login (#22594)
The regular login flow can use a `redirect_to` cookie to ensure the user
ends their authentication flow on the same page as where they started
it.

This commit adds the same functionality to the OAuth login URLs, so that
you can use URLs like these to directly use a specific OAuth provider:

`/user/oauth2/{provider}?redirect_to={post-login path}`

Only the `auth.SignInOAuth()` function needed a change for this, as the
rest of the login flow is aware of this cookie and uses it properly
already.
2023-01-24 11:41:38 -05:00
250aad9533
make generate-swagger 2023-01-23 23:54:24 +00:00
John Olheiser
9cc15d18df
Project links should use parent link methods (#22587)
Instead of re-creating, these should use the available `Link` methods
from the "parent" of the project, which also take sub-urls into account.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-23 15:51:18 -06:00
rekayno
519b91ad2d
link update in README files (#22582)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-01-23 15:57:57 -05:00
90afd4f329
Delete buggy and unneeded GET outbox 2023-01-23 20:47:31 +00:00
John Olheiser
649f89efdc
Frontport 1.18.2 and 1.18.3 Changelogs (#22580)
Frontport #22530 #22575

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-23 09:36:00 -06:00
tiny6996
29b78bce33
Fix incorrect Redis URL snippets in the example app.ini (#22573)
Fixes #22571

Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
2023-01-23 02:17:15 +00:00
5a9fe9adc4
Properly address outgoing activities 2023-01-22 19:49:28 +00:00
KN4CK3R
21dd4a252a
Prevent multiple To recipients (#22566)
Change the mailer interface to prevent leaking of possible hidden email
addresses when sending to multiple recipients.

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2023-01-22 08:23:52 -06:00
techknowlogick
6737e1c5d5
gitlab supports ssh key signing (#22564) 2023-01-22 18:17:49 +08:00
Francesco Siddi
920ae2367f
Address feedback from #22517 (#22563)
- use octicons for icon
- use fomantic for centering the link
2023-01-21 22:14:43 -06:00
Lunny Xiao
eb793c3361
Fix bug on user setting (#22539)
Fix #22537

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-01-21 15:31:11 +01:00
silverwind
a1fcb1cfb8
Update JS dependencies (#22538)
- Update all JS dependencies
- Add new eslint rules
- Rebuild SVGs
- Tested citation and build

SVG changes are because of https://github.com/primer/octicons/pull/883.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-01-21 10:42:13 +08:00
Yarden Shoham
f417157bdd
Split default gitpod view to include all tasks (#22555)
It was showing only the `docs` process

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-01-20 13:46:33 -06:00
John Olheiser
46d024428f
fix: read:org scope (#22556)
Hard to see in the diff, but this was duplicated in the wrong section.


![read-org](https://user-images.githubusercontent.com/42128690/213774506-9b47ce23-d2e5-4dfd-af49-6ae4947ac724.png)
2023-01-20 13:42:54 -05:00
a86a11f874
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-01-20 18:14:48 +00:00
Brecht Van Lommel
86c6b0de06 Pull Requests: add color to approved/reject icon in pull requests list
Makes it easier to scan the list of pull requests and see the status.
2023-01-20 12:50:13 -05:00
508a848616
Check if Create object is Note to prevent panic 2023-01-20 17:25:19 +00:00
zeripath
b8eb282327
Truncate commit summary on repo files table. (#22551)
There was an unintended regression in #21124 which assumed that
`.commits-list .message-wrapper` would only match the commit summaries
on `/{owner}/{name}/commits/*`. This assumption is incorrect as the
directory/file view also uses a `.commits-list` wrapper.

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

Fix #22360

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-20 23:23:03 +08:00
Lunny Xiao
6fe3c8b398
Support org/user level projects (#22235)
Fix #13405

<img width="1151" alt="image"
src="https://user-images.githubusercontent.com/81045/209442911-7baa3924-c389-47b6-b63b-a740803e640e.png">

Co-authored-by: 6543 <6543@obermui.de>
2023-01-20 19:42:33 +08:00
Lunny Xiao
0c048e554b
Fix template bug of access scope (#22540)
Fix https://github.com/go-gitea/gitea/pull/20908#discussion_r1082075526

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-01-20 15:43:43 +08:00
silverwind
b833ce4964
Mute all links in issue timeline (#22533)
https://github.com/go-gitea/gitea/pull/21799 introduced a regression
where some links in the issue timeline were not muted any more. Fix it
by replacing all `class="text grey"` with `class="text grey
muted-links"` in the file.

Before:
<img width="384" alt="Screenshot 2023-01-19 at 22 23 05"
src="https://user-images.githubusercontent.com/115237/213565351-1bb82f4e-fa72-4cd7-8e36-e527bbfe5c5f.png">

After:
<img width="377" alt="Screenshot 2023-01-19 at 22 23 11"
src="https://user-images.githubusercontent.com/115237/213565359-87e14855-6599-472a-be0b-61297b168f9a.png">

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-01-20 12:00:32 +08:00
zeripath
4199d28053
When updating by rebase we need to set the environment for head repo (#22535)
The update by rebase code reuses the merge code but shortcircuits and
pushes back up to the head. However, it doesn't set the correct pushing
environment - and just uses the same environment as the base repo. This
leads to the push update failing and thence the PR becomes out-of-sync
with the head.

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

Fix #18802

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-19 17:31:44 -05:00
Sybren
b383652e02
Fix assignment to cm.AssigneeID when importing comments (#22528)
This is a fix for https://github.com/go-gitea/gitea/pull/22510

The code assumed that the `AssigneeID` from the comment YAML was an
`int64`, but it is actually an `int`, causing a panic. It also had no
check on whether the type cast was actually valid, so badly formatted
YAML could also cause a panic.

Both these issues have been fixed.
2023-01-19 13:24:40 -05:00
Francesco Siddi
9f919cf083
Dropzone: Add "Copy link" button for new uploads (#22517)
Once an attachment is successfully uploaded via Dropzone, display a
"Copy link" under the "Remove file" button.
Once the button is clicked, depending if the attachment is an image or a
file, the appropriate markup is written to the clipboard, so it can be
conveniently pasted in the description.
2023-01-19 13:33:40 +08:00
359be39430
Send out notes to followers when starring repos 2023-01-19 02:38:02 +00:00
Sybren
151b1a9508
Support importing comment types (#22510)
This commit adds support for specifying comment types when importing
with `gitea restore-repo`. It makes it possible to import issue changes,
such as "title changed" or "assigned user changed".

An earlier version of this pull request was made by Matti Ranta, in
https://future.projects.blender.org/blender-migration/gitea-bf/pulls/3

There are two changes with regard to Matti's original code:

1. The comment type was an `int64` in Matti's code, and is now using a
string. This makes it possible to use `comment_type: title`, which is
more reliable and future-proof than an index into an internal list in
the Gitea Go code.

2. Matti's code also had support for including labels, but in a way that
would require knowing the database ID of the labels before the import
even starts, which is impossible. This can be solved by using label
names instead of IDs; for simplicity I I left that out of this PR.
2023-01-18 21:14:56 -05:00
Brecht Van Lommel
cdf53fa4a7
Fix issue not auto-closing when it includes a reference to a branch (#22514)
Ensure branch prefix is stripped away for both when comparing the branch
name.
2023-01-18 19:24:38 -05:00
Brecht Van Lommel
e0a8965208
Fix invalid issue branch reference if not specified in template (#22513)
When an issue template does not contain a ref, it would end up with an
invalid `ref/heads/` value instead of having no branch referenced .
2023-01-18 16:50:22 -05:00
Brecht Van Lommel
aa87b36900
Fix 500 error viewing pull request when fork has pull requests disabled (#22512)
Swallow error just like in #20839, for the case where there is no
protected branch.

Fixes #20826 for me, though I can't tell if this now covers all cases.
2023-01-18 13:54:57 -06:00
Jason Song
4804900ac9
Load asciicast css async (#22502)
Load asciicast css asynchronously.

Related to #22448.
2023-01-18 12:19:38 -06:00
Sybren
326d29dce0
Reliable selection of admin user (#22509)
When importing a repository via `gitea restore-repo`, external users
will get remapped to an admin user. This admin user is obtained via
`users.GetAdminUser()`, which unfortunately picks a more-or-less random
admin to return.

This makes it hard to predict which admin user will get assigned. This
patch orders the admin by ascending ID before choosing the first one,
i.e. it picks the admin with the lowest ID.

Even though it would be nicer to have full control over which user is
chosen, this at least gives us a predictable result.
2023-01-18 10:57:16 -06:00
Lunny Xiao
f59ce77772
Display unreferenced packages total size in package admin panel (#22498) 2023-01-18 09:52:04 -06:00
wxiaoguang
7ddc11def7
Simplify the error message when index.js couldn't be loaded (#22354)
In some cases, the loading failure of `index.js` is not related to the
ROOT_URL directly, ex: https://gitea.com/gitea/helm-chart/issues/392

If the user's reversed proxy is mis-configured:
`http://public-domain/gitea/xxx` -> `http://gitea:3000/gitea/xxx`, it
also causes the loading failure.

So this PR removes the ROOT_URL related tip from the error message.
2023-01-17 19:36:40 -06:00
Jason Song
d9f748a700
Support asciicast files as new markup (#22448)
Support [asciicast
files](https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v2.md)
as a new markup via
[asciinema-player](https://github.com/asciinema/asciinema-player). For
more on asciinema, see the [introduction](https://asciinema.org/).

So users can use asciinema recorder to generate an asciicast file (or
you can download a sample file from
https://asciinema.org/a/335480.cast?dl=1), then upload it to Gitea and
play it on Gitea.

Snapshots:
<details>

## Upload asciicast files

<img width="1134" alt="image"
src="https://user-images.githubusercontent.com/9418365/212461061-cc2c7181-0e14-4534-af55-1ec60a639fd1.png">

## Open an asciicast file

<img width="1137" alt="image"
src="https://user-images.githubusercontent.com/9418365/212461090-a3b5141f-4894-430d-a2b4-ea257801a0ed.png">

## Play it

<img width="1144" alt="image"
src="https://user-images.githubusercontent.com/9418365/212461157-4e82db69-0e41-471d-928f-ac1fe0737105.png">

## Copy contents from the "video"

<img width="1145" alt="image"
src="https://user-images.githubusercontent.com/9418365/212461286-211612bc-15d6-427a-89a9-6abff5c6a0a5.png">


## View the source

<img width="1140" alt="image"
src="https://user-images.githubusercontent.com/9418365/212461187-05473b2d-ba3d-4072-84a6-4aa1e7d82182.png">


</details>

Known issue:

Don't support the [v1 version asciicast
files](https://github.com/asciinema/asciinema/blob/develop/doc/asciicast-v1.md),
it's a poorly designed version, it does not specify the file extension
and uses `*.json` usually, so it's impossible to recognize the files.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-18 08:46:58 +08:00
Chongyi Zheng
de484e86bc
Support scoped access tokens (#20908)
This PR adds the support for scopes of access tokens, mimicking the
design of GitHub OAuth scopes.

The changes of the core logic are in `models/auth` that `AccessToken`
struct will have a `Scope` field. The normalized (no duplication of
scope), comma-separated scope string will be stored in `access_token`
table in the database.
In `services/auth`, the scope will be stored in context, which will be
used by `reqToken` middleware in API calls. Only OAuth2 tokens will have
granular token scopes, while others like BasicAuth will default to scope
`all`.
A large amount of work happens in `routers/api/v1/api.go` and the
corresponding `tests/integration` tests, that is adding necessary scopes
to each of the API calls as they fit.


- [x] Add `Scope` field to `AccessToken`
- [x] Add access control to all API endpoints
- [x] Update frontend & backend for when creating tokens
- [x] Add a database migration for `scope` column (enable 'all' access
to past tokens)

I'm aiming to complete it before Gitea 1.19 release.

Fixes #4300
2023-01-17 15:46:03 -06:00
Lunny Xiao
db2286bbb6
some refactor about code comments (#20821) 2023-01-17 15:03:44 -06:00
John Olheiser
60c4725cc2
docs: add swagger.json file location to FAQ (#22489)
This just adds a mention on how to get the `swagger.json` for an
instance.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-17 14:18:42 -06:00
John Olheiser
0a6b57bcaf
docs: bump Gitea version (#22490)
Forgot to do this with the frontport

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-17 18:42:12 +00:00
John Olheiser
51951d4503
chore: changelog 1.18.1 (#22471) (#22487)
Frontport #22471

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-17 12:18:22 -06:00
Emily
7a0f2fb1dc
Fixed lint warnings in Grafana raised by Mixtool (#22486)
This PR introduces a few minor changes to the gitea-monitoring-mixin,
specifically linting issues raised by
[Mixtool](https://github.com/monitoring-mixins/mixtool):
- Query selectors using `job` and `instance` have been update to allow
multi-select
- Added missing attributes to `job` and `instance` template

As this change is very minor I haven't created an issue, but please let
me know if you'd like me to do so. According to the guidelines, it
seemed to only be for larger designs :)
2023-01-17 10:23:25 -06:00
Jason Song
21c91b7dff
Set disable_gravatar/enable_federated_avatar when offline mode is true (#22479)
When offline mode is true, we should set `disable_gravatar` to `true`
and `enable_federated_avatar` to `false` in system settings.
2023-01-17 17:00:19 +02:00
Yarden Shoham
e763fab685
Fix pull request API field closed_at always being null (#22482)
Fix #22480
2023-01-17 11:42:32 +00:00
Haruo Kinoshita
9edf80f472
Fix migration from gitbucket (repost) (#22477)
Reposting pull request for #22465 

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

Co-authored-by: zeripath <art27@cantab.net>
2023-01-17 15:22:00 +08:00
KN4CK3R
3510d7e33a
Fix container blob mount (#22226) 2023-01-16 17:35:48 -05:00
Bradley D. Thornton
1aba53db62
Update overview.en-us.md (#22463)
Fix grammar
2023-01-16 16:24:24 -06:00
9fc10ce83c
Refactor activitypub.RepositoryIRIToRepository to repo_model.GetRepositoryByIRI 2023-01-16 21:20:50 +00:00
KN4CK3R
8117e41dfa
Add reply hint to mail text (#22459)
Addition to #22056

This PR adds a hint to mail text if replies are supported.
I can't tell if the text structure is supported in every language. Maybe
we need to put the whole line in the translation file and use
parameters.
2023-01-16 14:58:01 -06:00
zeripath
2cc3a6381c
Add cron method to gc LFS MetaObjects (#22385)
This PR adds a task to the cron service to allow garbage collection of
LFS meta objects. As repositories may have a large number of
LFSMetaObjects, an updated column is added to this table and it is used
to perform a generational GC to attempt to reduce the amount of work.
(There may need to be a bit more work here but this is probably enough
for the moment.)

Fix #7045

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-16 13:50:53 -06:00
Felipe Leopoldo Sologuren Gutiérrez
04c97aa364
Change use of Walk to WalkDir to improve disk performance (#22462)
As suggest by Go developers, use `filepath.WalkDir` instead of
`filepath.Walk` because [*Walk is less efficient than WalkDir,
introduced in Go 1.16, which avoids calling `os.Lstat` on every file or
directory visited](https://pkg.go.dev/path/filepath#Walk).

This proposition address that, in a similar way as
https://github.com/go-gitea/gitea/pull/22392 did.


Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-16 16:21:44 +00:00
wxiaoguang
da274380a7
Remove the netgo tag for Windows build (#22467)
Fix #22370 and more.

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

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

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

This PR just removes the `netgo` tag for Windows build, then the Gitea
for Windows can have the old DNS behavior.
2023-01-16 13:29:10 +00:00
zeripath
16e9dec827
Fix Operator does not exist bug on explore page with ONLY_SHOW_RELEVANT_REPOS (#22454)
There is a mistake in the code for SearchRepositoryCondition where it
tests topics as a string. This is incorrect for postgres where topics is
cast and stored as json. topics needs to be cast to text for this to
work. (For some reason JSON_ARRAY_LENGTH does not work, so I have taken
the simplest solution of casting to text and doing a string comparison.)

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2023-01-16 11:25:22 +00:00
zeripath
1e7f3c16a4
Fix environments for KaTeX and error reporting (#22453)
In #22447 it was noticed that display environments were not working
correctly. This was due to the setting displayMode not being set.

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

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

Fix #22447

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-16 18:25:46 +08:00
Lunny Xiao
2782c14396
Supports wildcard protected branch (#20825)
This PR introduce glob match for protected branch name. The separator is
`/` and you can use `*` matching non-separator chars and use `**` across
separator.

It also supports input an exist or non-exist branch name as matching
condition and branch name condition has high priority than glob rule.

Should fix #2529 and #15705

screenshots

<img width="1160" alt="image"
src="https://user-images.githubusercontent.com/81045/205651179-ebb5492a-4ade-4bb4-a13c-965e8c927063.png">

Co-authored-by: zeripath <art27@cantab.net>
2023-01-16 16:00:22 +08:00
zeripath
cc1f8cbe96
Prevent panic on looking at api "git" endpoints for empty repos (#22457)
The API endpoints for "git" can panic if they are called on an empty
repo. We can simply allow empty repos for these endpoints without worry
as they should just work.

Fix #22452

Signed-off-by: Andrew Thornton <art27@cantab.net>
2023-01-15 08:33:25 -06:00
Jimmy Praet
fe519d8633
Restore previous official review when an official review is deleted (#22449)
Fix #22406

Co-authored-by: Lauris BH <lauris@nix.lv>
2023-01-15 07:00:09 +02:00
KN4CK3R
fc037b4b82
Add support for incoming emails (#22056)
closes #13585
fixes #9067
fixes #2386
ref #6226
ref #6219
fixes #745

This PR adds support to process incoming emails to perform actions.
Currently I added handling of replies and unsubscribing from
issues/pulls. In contrast to #13585 the IMAP IDLE command is used
instead of polling which results (in my opinion 😉) in cleaner code.

Procedure:
- When sending an issue/pull reply email, a token is generated which is
present in the Reply-To and References header.
- IMAP IDLE waits until a new email arrives
- The token tells which action should be performed

A possible signature and/or reply gets stripped from the content.

I added a new service to the drone pipeline to test the receiving of
incoming mails. If we keep this in, we may test our outgoing emails too
in future.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-14 23:57:10 +08:00
Sascha Bannier
20e3ffd208
Fix stylesheet HTML snippet for external renderers documentation (#22435)
The documentation is missing the rel attribute. Neither Firefox nor
Chrome did use the linked file as CSS if rel="stylesheet" is not set.

The problem is described in issue #22434.

Co-authored-by: silverwind <me@silverwind.io>
2023-01-13 23:25:15 +00:00
Jonathan Tran
02ae63297b
Log STDERR of external renderer when it fails (#22442)
When using an external renderer, STDOUT is expected to be HTML. But
anything written to STDERR is currently ignored. In cases where the
renderer fails, I would like to log any error messages that the external
program outputs to STDERR.
2023-01-13 20:41:23 +00:00
Lunny Xiao
a3ab82e592
Fix error when calculate the repository size (#22392)
Fix #22386 

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

Co-authored-by: Jason Song <i@wolfogre.com>
2023-01-13 18:54:02 +00:00
b89242ee66
Refactoring
- Add extra code paths where `ctx` can be passed and used.
- Remove useless `id` path to get comment note.
- Add extra checks in note API.
- Use `ctx.ParamsInt64` to get the ID from the request.
- Handle `GetXXX` more gracefully by returning 404 when appropiate.
2023-01-13 15:53:46 +01:00
crystal
4fc1517da0
clarify "open issues" text for labels (#22431)
see also https://codeberg.org/Codeberg/Community/issues/877
2023-01-13 12:40:39 +01:00
zeripath
c0da3638e7
Restore function to "Show more" buttons (#22399)
There was a serious regression in #21012 which broke the Show More
button on the diff page, and the show more button was also broken on the
file tree too.

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

Fix #22380

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-13 13:50:32 +08:00
zeripath
99cf0d394e
Continue GCing other repos on error in one repo (#22422)
The current code propagates all errors up to the iteration step meaning
that a single malformed repo will prevent GC of other repos.

This PR simply stops that propagation.

Fix #21605

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-13 09:48:48 +08:00
crystal
f1c13b4ace
improve explore relevancy note (#22421)
makes the explore relevancy note much prettier on most themes
2023-01-12 19:10:12 -06:00
f8a1dba197
Add missing newline, fix wrong copyright comment on a few files 2023-01-12 22:00:32 +00:00
d03f5bde7e
Remove some files that were accidentally committed 2023-01-12 21:55:17 +00:00
72247b8d49
Fix lint errors 2023-01-12 21:48:05 +00:00
7853231ea1
Set user.FullName before creating user 2023-01-12 21:38:45 +00:00
a5daa36573
Return if user does exist, not if does not exist 2023-01-12 21:35:11 +00:00
bb38b9737f
Replace personIRIToUser with GetUserByIRI, do a WebFinger request to get correct username 2023-01-12 21:28:35 +00:00
John Olheiser
1ee1147baa
fix: don't replace err variable in nested check (#22416)
We can use `:=` to make `err` local to the if-scope instead of
overwriting the `err` in outer scope.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-12 14:57:12 -06:00
Jason Song
c86be819bb
Add more packages to denylist (#22412)
After this, we can remove
[`denylist_imports`](https://gitea.com/gitea/gitea-vet/src/branch/master/checks/denylisted-imports.go#L13)
in gitea-vet
([gitea-vet/pulls/23](https://gitea.com/gitea/gitea-vet/pulls/23)).

```go
deniedImports   = []string{"io/ioutil", "encoding/json", "gitea.com/gitea/go-crypto"}
```

However, we needn't keep `gitea.com/gitea/go-crypto` any longer, it's
gone and can't be imported again.

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-12 23:35:53 +08:00
crystal
9ffaf19d89
fix wrong theme class when logged out if default theme is changed (#22408)
If you don't use the `auto` theme as the default, the `<html>` tag has
`theme-auto` as it's class when users are logged out. This PR changes it
to use the correct theme class for the default theme when logged out.
2023-01-12 08:52:05 -06:00
techknowlogick
b36854df37
Update golang deps (#22410)
Note, hashicorp's LRU has been updated to v2 which supports generics but
this was left out as it is a more involved upgrade.
2023-01-12 09:21:16 +01:00
techknowlogick
6f231a7980
Replace deprecated Webauthn library (#22400)
Fix #22052

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-11 21:51:00 -05:00
Lunny Xiao
2220e5d245
Allow HOST has no port (#22280)
Fix #22274

This PR will allow `HOST` without port. Then a default port will be
given in future steps.
2023-01-11 20:09:24 +00:00
3aba06d429
Implement Delete activity for deleting users 2023-01-11 20:07:47 +00:00
Jason Song
477a1cc40e
Improve utils of slices (#22379)
- Move the file `compare.go` and `slice.go` to `slice.go`.
- Fix `ExistsInSlice`, it's buggy
  - It uses `sort.Search`, so it assumes that the input slice is sorted.
- It passes `func(i int) bool { return slice[i] == target })` to
`sort.Search`, that's incorrect, check the doc of `sort.Search`.
- Conbine `IsInt64InSlice(int64, []int64)` and `ExistsInSlice(string,
[]string)` to `SliceContains[T]([]T, T)`.
- Conbine `IsSliceInt64Eq([]int64, []int64)` and `IsEqualSlice([]string,
[]string)` to `SliceSortedEqual[T]([]T, T)`.
- Add `SliceEqual[T]([]T, T)` as a distinction from
`SliceSortedEqual[T]([]T, T)`.
- Redesign `RemoveIDFromList([]int64, int64) ([]int64, bool)` to
`SliceRemoveAll[T]([]T, T) []T`.
- Add `SliceContainsFunc[T]([]T, func(T) bool)` and
`SliceRemoveAllFunc[T]([]T, func(T) bool)` for general use.
- Add comments to explain why not `golang.org/x/exp/slices`.
- Add unit tests.
2023-01-11 13:31:16 +08:00
techknowlogick
dc5f2cf590
cgo cross-compile for freebsd (#22397)
Provide pre-compiled cgo binaries for freebsd

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2023-01-10 17:21:24 -05:00
delvh
70043da3dd
Fix typo (#22396)
DEFAUlT -> DEFAULT
2023-01-10 22:00:42 +01:00
John Olheiser
e7f1d45eb5
fix: omit avatar_url in discord payload when empty (#22393)
Fixes #22391

This field is optional for Discord, however when it exists in the
payload it is now validated.
Omitting it entirely just makes Discord use the default for that
webhook, which is set on the Discord side.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-10 14:01:52 -05:00
c40dd620a3
Merge remote-tracking branch 'origin/main' into forgejo-federation 2023-01-10 18:27:20 +00:00
Yarden Shoham
3b804ff76c
Fix "remember this device" case (#22388)
In the title case, it should be "Remember This Device"

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-01-10 17:43:54 +08:00
Lunny Xiao
50f67d7e38
Don't display stop watch top bar icon when disabled and hidden when click other place (#22374)
Fix #22286 

When timetracking is disabled, the stop watch top bar icon should be
hidden.
When the stop watch recording popup, it should be allowed to hide with
some operation. Now click any place on this page will hide the popup
window.
2023-01-09 21:53:11 -05:00
Jason Song
a35714372d
Fix halfCommitter and WithTx (#22366)
Related to #22362.

I overlooked that there's always `committer.Close()`, like:

```go
		ctx, committer, err := db.TxContext(db.DefaultContext)
		if err != nil {
			return nil
		}
		defer committer.Close()

		// ...

		if err != nil {
			return nil
		}

		// ...

		return committer.Commit()
```

So the `Close` of `halfCommitter` should ignore `commit and close`, it's
not a rollback.

See: [Why `halfCommitter` and `WithTx` should rollback IMMEDIATELY or
commit
LATER](https://github.com/go-gitea/gitea/pull/22366#issuecomment-1374778612).

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-01-09 12:19:19 -05:00
Lunny Xiao
99a675f4a1
Don't lookup mail server when using sendmail (#22300)
Fix #22287
2023-01-09 11:09:46 -05:00
ahab
82235fb681
Update index.de-de.md (#22363)
Some minor changes related to the language.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-09 19:25:13 +08:00
Khaled Yakdan
dbfc5aa016
Move fuzz tests into tests/fuzz (#22376)
This puts the fuzz tests in the same directory as other tests and eases
the integration in OSS-Fuzz

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2023-01-09 15:30:14 +08:00
Jason Song
9e94346529
Remove satori/go.uuid (#22375)
`github.com/satori/go.uuid` is no longer used, so the `replace` is not
needed now
2023-01-09 01:00:10 -05:00
Jason Song
7adc2de464
Use context parameter in models/git (#22367)
After #22362, we can feel free to use transactions without
`db.DefaultContext`.

And there are still lots of models using `db.DefaultContext`, I think we
should refactor them carefully and one by one.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-09 11:50:54 +08:00
delvh
b878155b87
Replace can not with cannot (#22372)
Fixes #22371.
2023-01-08 18:25:28 +00:00
Lunny Xiao
dfd2db5695
Fix set system setting failure once it cached (#22333)
Unfortunately, #22295 introduced a bug that when set a cached system
setting, it will not affect.
This PR make sure to remove the cache key when updating a system
setting.

Fix #22332
2023-01-08 21:22:41 +08:00
dependabot[bot]
bdf8c80f41
Bump json5 from 1.0.1 to 1.0.2 (#22365)
Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/json5/json5/releases">json5's
releases</a>.</em></p>
<blockquote>
<h2>v1.0.2</h2>
<ul>
<li>Fix: Properties with the name <code>__proto__</code> are added to
objects and arrays. (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/199">#199</a>)
This also fixes a prototype pollution vulnerability reported by Jonathan
Gregson! (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/295">#295</a>).
This has been backported to v1. (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/298">#298</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/json5/json5/blob/main/CHANGELOG.md">json5's
changelog</a>.</em></p>
<blockquote>
<h3>Unreleased [<a
href="https://github.com/json5/json5/tree/main">code</a>, <a
href="https://github.com/json5/json5/compare/v2.2.3...HEAD">diff</a>]</h3>
<h3>v2.2.3 [<a
href="https://github.com/json5/json5/tree/v2.2.3">code</a>, <a
href="https://github.com/json5/json5/compare/v2.2.2...v2.2.3">diff</a>]</h3>
<ul>
<li>Fix: json5@2.2.3 is now the 'latest' release according to npm
instead of
v1.0.2. (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/299">#299</a>)</li>
</ul>
<h3>v2.2.2 [<a
href="https://github.com/json5/json5/tree/v2.2.2">code</a>, <a
href="https://github.com/json5/json5/compare/v2.2.1...v2.2.2">diff</a>]</h3>
<ul>
<li>Fix: Properties with the name <code>__proto__</code> are added to
objects and arrays.
(<a
href="https://github-redirect.dependabot.com/json5/json5/issues/199">#199</a>)
This also fixes a prototype pollution vulnerability reported by
Jonathan Gregson! (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/295">#295</a>).</li>
</ul>
<h3>v2.2.1 [<a
href="https://github.com/json5/json5/tree/v2.2.1">code</a>, <a
href="https://github.com/json5/json5/compare/v2.2.0...v2.2.1">diff</a>]</h3>
<ul>
<li>Fix: Removed dependence on minimist to patch CVE-2021-44906. (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/266">#266</a>)</li>
</ul>
<h3>v2.2.0 [<a
href="https://github.com/json5/json5/tree/v2.2.0">code</a>, <a
href="https://github.com/json5/json5/compare/v2.1.3...v2.2.0">diff</a>]</h3>
<ul>
<li>New: Accurate and documented TypeScript declarations are now
included. There
is no need to install <code>@types/json5</code>. (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/236">#236</a>,
<a
href="https://github-redirect.dependabot.com/json5/json5/issues/244">#244</a>)</li>
</ul>
<h3>v2.1.3 [<a
href="https://github.com/json5/json5/tree/v2.1.3">code</a>, <a
href="https://github.com/json5/json5/compare/v2.1.2...v2.1.3">diff</a>]</h3>
<ul>
<li>Fix: An out of memory bug when parsing numbers has been fixed. (<a
href="https://github-redirect.dependabot.com/json5/json5/issues/228">#228</a>,
<a
href="https://github-redirect.dependabot.com/json5/json5/issues/229">#229</a>)</li>
</ul>
<h3>v2.1.2 [<a
href="https://github.com/json5/json5/tree/v2.1.2">code</a>, <a
href="https://github.com/json5/json5/compare/v2.1.1...v2.1.2">diff</a>]</h3>
<!-- raw HTML omitted -->
</blockquote>
<p>... (truncated)</p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="a62db1e51e"><code>a62db1e</code></a>
1.0.2</li>
<li><a
href="e0c23fe458"><code>e0c23fe</code></a>
docs: update CHANGELOG for v1.0.2</li>
<li><a
href="62a6540840"><code>62a6540</code></a>
fix: add <strong>proto</strong> to objects and arrays</li>
<li>See full diff in <a
href="https://github.com/json5/json5/compare/v1.0.1...v1.0.2">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=json5&package-manager=npm_and_yarn&previous-version=1.0.1&new-version=1.0.2)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the
default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as
the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as
the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the
default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/go-gitea/gitea/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-01-08 19:48:00 +08:00
Jason Song
6135359a04
Always reuse transaction (#22362) 2023-01-08 09:34:58 +08:00
crystal
d42b52fcfa
make /{username}.png redirect to user/org avatar (#22356)
fix #22355

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-06 13:44:02 +01:00
Jason Song
3dbd2d942b
Remove old HookEventType (#22358)
Supplement to #22256.
2023-01-06 19:49:14 +08:00
KN4CK3R
f74293f9c2
Fix unstable emoji sort (#22346)
Without the second sort every generate run produces a different result.
2023-01-05 13:58:51 +02:00
AdamKorcz
906d8cc5dc
Rewrite fuzzers to native Go harnesses (#22313) 2023-01-05 10:33:00 +08:00
isla w
f41ad344cb
Update Emoji dataset to Unicode 14 (#22342)
Gitea emoji dataset was out of date because it gets manually built and
hasn't been rebuilt since it was added. This means Gitea doesn't
recognize some newer emoji or changes to existing ones.

After changing the max unicode version to 14 I just ran: `go run
build/generate-emoji.go`

This should address the initial issue seen in #22153 where Gitea doesn't
recognize a standard alias used elsewhere when importing content.

14 is the latest supported version from the upstream source as 15 is not
widely supported (in their opinion) yet
2023-01-04 11:52:48 -06:00
Lunny Xiao
fdbb0b4762
fix gravatar disable bug (#22336) 2023-01-04 16:19:56 +08:00
John Olheiser
32e863439c
fix: update settings table on install (#22326)
Related to #22325 

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2023-01-03 14:33:41 -06:00
Lunny Xiao
efa708501b
Use git command instead of exec.Cmd in blame (#22098)
extract from #18147

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2023-01-03 16:17:13 +08:00
Lunny Xiao
c59e1537a8
Display error log when a modified template has an error so that it could recovery when the error fixed (#22261)
A drawback is the previous generated template has been cached, so you
cannot get error in the UI but only from log

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: delvh <dev.lh@web.de>
2023-01-03 15:17:36 +08:00
Kyle D
f0159c3e8a
Add deprecated warning for DISABLE_GRAVATAR and ENABLE_FEDERATED_AVATAR (#22318) 2023-01-03 07:54:27 +08:00
96797fed31
Unify hashing for avatar (#22289)
- Unify the hashing code for repository and user avatars into a
function.
- Use a sane hash function instead of MD5.
- Only require hashing once instead of twice(w.r.t. hashing for user
avatar).
- Improve the comment for the hashing code of why it works.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Yarden Shoham <hrsi88@gmail.com>
2023-01-02 22:46:39 +01:00
John Olheiser
fcd6ceef2b
fix: code search title translation (#22285)
`code.title` isn't an existing translation.

`explore.code` is the translation used for the tab, which I think
matches closely enough for this instead of a brand new translation.

Open to feedback on whether a new translation would be preferred
instead.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2023-01-02 17:18:08 +08:00
James Liu
e61ce934bc
Update Gmail mailer configuration (#22291)
This PR updates the `[mailer]` configuration snippet for Gmail:

- The `HELO_HOSTNAME` isn't required.
- The `USER` must not include the @gmail domain.
- `HOST` needs to be supplied, and the SMTP port number needs to be
appended to the URL.

I also added a note about the requirement to use App passwords instead
of your Google account password directly.

Co-authored-by: delvh <dev.lh@web.de>
2023-01-02 10:52:36 +08:00
Yarden Shoham
b994b2ea9c
Fix due date rendering the wrong date in issue (#22302)
Previously, the last minute of the chosen date caused bad timezone
rendering.

For example, I chose January 4th, 2023.

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

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

---

Closes #21999

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2023-01-02 10:49:05 +08:00
eabba0cf19
Add TODO not about fixing issue creation index 2023-01-01 18:46:42 +00:00
58d937eb29
Fix swagger note endpoint typo 2023-01-01 18:44:44 +00:00
05d9a6dc1d
Remove unneeded ap.Item() 2023-01-01 18:09:58 +00:00
Lunny Xiao
a1c30740bb
Fix get system setting bug when enabled redis cache (#22295)
Fix #22281

In #21621 , `Get[V]` and `Set[V]` has been introduced, so that cache
value will be `*Setting`. For memory cache it's OK. But for redis cache,
it can only store `string` for the current implementation. This PR
revert some of changes of that and just store or return a `string` for
system setting.
2023-01-02 00:06:52 +08:00
delvh
0f4e1b9ac6
Restructure webhook module (#22256)
Previously, there was an `import services/webhooks` inside
`modules/notification/webhook`.
This import was removed (after fighting against many import cycles).
Additionally, `modules/notification/webhook` was moved to
`modules/webhook`,
and a few structs/constants were extracted from `models/webhooks` to
`modules/webhook`.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2023-01-01 23:23:15 +08:00
Jason Song
f8e93ce423
Reminder for no more logs to console (#22282)
Even if the log mode is `file`, there are still few logs printed to the
console at the very beginning.

That's fine but confusing. Someone will think the console is the only
place to find logs, and get nothing helpful. See
https://github.com/go-gitea/gitea/issues/22274#issuecomment-1367917717.

There should be a reminder that there are no more logs to the console.

And to avoid log loss, we should add configured loggers first, then
remove console logger if there's no `console` in the mode.

Tests with `MODE = file`:

Before:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/210079862-d591677f-347e-46ed-a548-bb2ddbb0885c.png">

After:
<img width="1792" alt="image"
src="https://user-images.githubusercontent.com/9418365/210080002-d66cc418-6888-4909-b370-d03f5986ef41.png">

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2023-01-01 22:00:33 +08:00
Lunny Xiao
9c8fc7f677
Fix bug of DisableGravatar default value (#22296)
#18058 made a mistake. The disableGravatar's default value depends on
`OfflineMode`. If it's `true`, then `disableGravatar` is true, otherwise
it's `false`. But not opposite.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2023-01-01 20:19:23 +08:00
Lunny Xiao
2bbf9e7302
Upgrade go-chi to v5.0.8 (#22304) 2023-01-01 11:23:26 +01:00
KN4CK3R
b1a4eb40a1 [skip ci] Updated licenses and gitignores 2023-01-01 00:19:35 +00:00
a238112529
Use GetIRI() instead of OriginalURL for fetching repo IRI 2022-12-31 18:32:22 +00:00
d475724cc5
Use GetIRI() instead of LoginName to fetch user IRI 2022-12-31 18:29:53 +00:00
46e35c61ec
Make Create Actor a Person 2022-12-31 18:28:33 +00:00
13b09cef50
Move Create() to activities.go 2022-12-31 18:27:38 +00:00
be2a3375f3
Set Actor on Create activities 2022-12-31 18:26:46 +00:00
adb161c6ee
Refactor activities.go 2022-12-31 18:22:11 +00:00
b4cb2356d8
Clean up IRI processing code 2022-12-31 18:01:12 +00:00
258fd151da
Fix lint errors 2022-12-31 17:58:01 +00:00
KN4CK3R
3fef47b41c
Use ErrInvalidArgument in packages (#22268)
Related to
https://github.com/go-gitea/gitea/pull/22262#discussion_r1059010774

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-31 12:49:37 +01:00
6543
dce8887494
Changelog v1.18.0 (#22215) (#22269)
frontport #22215

& bump numbers in docs
2022-12-31 03:17:54 +01:00
Jason Song
e5deeda0aa
Support estimated count with multiple schemas (#22276)
The `EstimateCount` could be incorrect when the table lives in multiple
schemas. Related to #19775.
2022-12-30 12:25:58 -06:00
JonRB
cf07f247b7
Add Gentoo to the from package providers (#22284)
Signed-off-by: Jonathan Roadley-Battin <jon.roadleybattin@gmail.com>
2022-12-30 11:14:51 -06:00
Jason Song
d34f3a2213
Fix sitemap (#22272)
Fix #22270.

Related to #18407.

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

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

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

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

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: delvh <dev.lh@web.de>
2022-12-30 23:31:00 +08:00
Chongyi Zheng
9dcaf14a14
Add sync_on_commit option for push mirrors api (#22271)
Push mirrors `sync_on_commit` option was added to the web interface in
v1.18.0. However, it's not added to the API. This PR updates the API
endpoint.

Fixes #22267

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

Before:

![image](https://user-images.githubusercontent.com/25481501/209404800-0e7c39ce-861a-455b-b234-62498d750aa8.png)

After:

![image](https://user-images.githubusercontent.com/25481501/209404821-c70f81c6-fd10-4197-ab58-61cb9fc873d8.png)

Co-authored-by: zeripath <art27@cantab.net>
2022-12-30 12:53:05 +08:00
2d7e644b3a
make fmt 2022-12-30 00:20:38 +00:00
121be02f37
Merge remote-tracking branch 'origin/main' into forgejo-federation 2022-12-30 00:20:02 +00:00
be381fe16b
Implement unstarring 2022-12-30 00:07:00 +00:00
zeripath
a609cae9fb
Correctly handle select on multiple channels in Queues (#22146)
There are a few places in FlushQueueWithContext which make an incorrect
assumption about how `select` on multiple channels works.

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

```go
package main

import "fmt"

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

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

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

Fix #22145

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-30 02:06:47 +02:00
cc4901ccec
Federated starring and code cleanup 2022-12-29 23:13:48 +00:00
Jason Song
47efba78ec
Support template for merge message description (#22248)
Fix #21435.

Use the first line of the template as the git commit message title, and
the rest as the description.

## Snapshots

<img width="806" alt="image"
src="https://user-images.githubusercontent.com/9418365/209644083-5d85179c-cf58-404f-bc98-c662398a2411.png">
<img width="860" alt="image"
src="https://user-images.githubusercontent.com/9418365/209644392-22573090-e2c1-458b-ba44-855b79735632.png">
<img width="1154" alt="image"
src="https://user-images.githubusercontent.com/9418365/209644457-a1b2711a-6787-45b4-b52c-a88d7fc132d7.png">

Co-authored-by: delvh <dev.lh@web.de>
2022-12-29 14:40:20 +02:00
KN4CK3R
a35749893b
Move convert package to services (#22264)
Addition to #22256

The `convert` package relies heavily on different models which is
[disallowed by our definition of
modules](https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md#design-guideline).
This helps to prevent possible import cycles.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-29 10:57:15 +08:00
KN4CK3R
309e86a9bf
Use dynamic package type list (#22263)
Replace the hardcoded list with the dynamic list.
2022-12-29 00:31:54 +01:00
Lunny Xiao
ca67c5a8a7
refactor auth interface to return error when verify failure (#22119)
This PR changed the Auth interface signature from 
`Verify(http *http.Request, w http.ResponseWriter, store DataStore, sess
SessionStore) *user_model.User`
to 
`Verify(http *http.Request, w http.ResponseWriter, store DataStore, sess
SessionStore) (*user_model.User, error)`.

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

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

This will fix #20563

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Jason Song <i@wolfogre.com>
2022-12-28 13:53:28 +08:00
Xinyu Zhou
7cc7db73b9
Add option to prohibit fork if user reached maximum limit of repositories (#21848)
If user has reached the maximum limit of repositories:

- Before
  - disallow create
  - allow fork without limit
- This patch:
  - disallow create
  - disallow fork
- Add option `ALLOW_FORK_WITHOUT_MAXIMUM_LIMIT` (Default **true**) :
enable this allow user fork repositories without maximum number limit

fixed https://github.com/go-gitea/gitea/issues/21847

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
2022-12-27 15:21:14 -06:00
Yarden Shoham
22a6e97597
Update standard copyright header to use a placeholder year (#22254) 2022-12-27 11:51:23 -06:00
Christian Ullrich
d0c3d0ba26
Add the 'ui.user' section to the cheat sheet (#22249)
The `ui.user` ini section with its single setting is not yet mentioned
in the config cheat sheet.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-27 09:38:15 -06:00
Jason Song
6cf09ccab4
Use complete SHA to create and query commit status (#22244)
Fix #13485.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-27 21:12:49 +08:00
Lunny Xiao
90237d8abd
Add more test directory to exclude dir of air, remove watching templates from air include dir because gitea has internal mechanism (#22246)
Since #20218 introduced internal watching template, template watching
should be removed from `air`. This will prevent restart the whole server
once the template files changed to speed up developing when using `make
watch`.

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

This PR also added more exclude testdata directories.
2022-12-27 14:00:34 +08:00
b48cf03717
Remove deadcode (#22245)
- Remove code that isn't being used.

Found this is my stash from a few weeks ago, not sure how I found this
in the first place.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-27 09:15:35 +08:00
zeripath
83640c449e
Remove ReverseProxy authentication from the API (#22219)
Since we changed the /api/v1/ routes to disallow session authentication
we also removed their reliance on CSRF. However, we left the
ReverseProxy authentication here - but this means that POSTs to the API
are no longer protected by CSRF.

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

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

Replace #22077
Close #22221 
Close #22077 

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-27 08:34:05 +08:00
af572f7b2b
Fix typo in activities.go comments 2022-12-26 17:43:31 +00:00
Jason Song
814b44aeaf
Fix typo of Asia/Shanghai (#22242)
As the title.
2022-12-26 16:50:58 +08:00
silverwind
f5cd0d9319
Add Mermaid copy button, avoid unnecessary tooltip hide (#22225)
- Add Copy button to mermaid diagrams which copies their source.
- Set tippy to not hide on click and avoid tooltip re-creation for
temporary tooltips. This avoids hide and show when copying repo url.
Popovers still hide the tooltip as usual.


<img width="815" alt="Screenshot 2022-12-23 at 14 02 32"
src="https://user-images.githubusercontent.com/115237/209341696-98e30953-f246-46d9-9157-2ececfd791c9.png">

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-12-25 18:17:48 +01:00
Lunny Xiao
3bd49f7801 [skip ci] Updated licenses and gitignores 2022-12-25 00:19:36 +00:00
Lunny Xiao
2b0b56319e
Improve testing for pgsql empty repository (#22223) 2022-12-23 12:34:51 -06:00
silverwind
2cf0cf0de1
JS refactors (#22227)
- Replace all default exports with named exports, except for Vue SFCs
- Remove names from Vue SFCs, they are automatically inferred from the
filename
- Misc whitespace-related tweaks
2022-12-24 00:03:11 +08:00
Jason Song
71ca3067bc
Check primary keys for all tables and drop ForeignReference (#21721)
Some dbs require that all tables have primary keys, see
- #16802
- #21086

We can add a test to keep it from being broken again.

Edit:

~Added missing primary key for `ForeignReference`~ Dropped the
`ForeignReference` table to satisfy the check, so it closes #21086.

More context can be found in comments.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
2022-12-23 19:35:43 +08:00
silverwind
41f0668da8
Hide file borders on sticky diff box (#22217)
Before: (1px border left and right when scrolled to a file)
<img width="1143" alt="Screenshot 2022-12-22 at 15 37 54"
src="https://user-images.githubusercontent.com/115237/209158082-c1a413b1-45b7-46b7-a71c-8e5a06324f43.png">

After: (no border)
<img width="1149" alt="Screenshot 2022-12-22 at 15 39 01"
src="https://user-images.githubusercontent.com/115237/209158086-9b00641f-2f41-4de1-9c08-22230c8a966a.png">

Layout in the box does not shift with the changes.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-23 11:58:30 +08:00
Nick
a2779def36 Test views of LFS files (#22196) 2022-12-23 07:41:56 +08:00
e8c3886995
Merge remote-tracking branch 'origin/main' into forgejo-federation 2022-12-22 21:12:50 +00:00
techknowlogick
ea5a752ee6
update docs latest to 1.17.4 2022-12-22 10:47:57 -05:00
Lunny Xiao
7bf7c13b64
Frontport 1.17.4 changelog (#22216) 2022-12-22 09:36:01 -06:00
Lunny Xiao
8c1bb77437
Remove test session cache to reduce possible concurrent problem (#22199) 2022-12-22 21:09:35 +08:00
silverwind
ac5b44b2f4
Upgrade hugo to 0.82 (#22209)
See
https://github.com/go-gitea/gitea/pull/22206#issuecomment-1362523796.
Apparently hugo 0.81.0 is a broken release in regards to checksums.

https://github.com/gohugoio/hugo/releases/tag/v0.82.0

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-22 19:29:33 +08:00
Lauris BH
6037043adf
Fix container layer display overflow (#22208)
Before:

![attels](https://user-images.githubusercontent.com/165205/209109653-6c690569-ddbe-4d8b-ab42-66b9a9c6a556.png)


After:

![attels](https://user-images.githubusercontent.com/165205/209110521-8aa8fc1c-21c8-4280-9b39-ab560b6d95f4.png)
2022-12-22 12:33:17 +02:00
silverwind
3affb02df5
Run hugo via go run and lock its version (#22206)
- Don't rely on obscure docker images like `plugins/hugo`
- Lock down `hugo` to same version the image had used
- Remove unnecessary verbosity in `trans-copy`
- Rename `trans-copy` to `trans-copy.sh`

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john+github@jolheiser.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-21 21:09:53 -05:00
zeripath
8e17fb5c06
Update bleve and zapx to fix unaligned atomic (#22031)
There is an unaligned atomic field in zapx 15.3.5 which should have been
fixed in a subsequent patch

This bug causes issues on 32bit builds.

Update bleve and zapx to account for this.

Fix #21957

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-21 19:08:26 -06:00
KN4CK3R
b76718249a
Allow empty assignees on pull request edit (#22150)
Fixes #22140
2022-12-21 16:45:44 -06:00
Reo
48d71b7d6b
Add Feed for Releases and Tags (#21696)
Fixes #19091

Add Feed for Releases and Tags, can be accessed through
`reponame/releases.rss`, `reponame/releases.atom`, `reponame/tags.rss`,
and `reponame/tags.atom`

Signed-off-by: Reo <reo_999@proton.me>
2022-12-21 15:06:26 -06:00
John Olheiser
9914b21493
fix: update libcurl in docs pipeline (#22203)
updating libcurl fixes the mismatch between curl and libcurl

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2022-12-21 13:45:32 -06:00
MisterCavespider
c403e2f1cf
Fixed colour transparency regex matching in project board sorting (#22091) (#22092)
As described in the linked issue (#22091), semi-transparent UI elements
would result in JS errors due to the fact that the CSS `backgroundColor`
element was being matched by the pattern
`^rgb\((\d+),\s*(\d+),\s*(\d+)\)$`, which does not take the alpha
channel into account.

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

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-21 20:19:04 +08:00
Nathaniel Sabanski
8e267afd35
Mobile fix for Project view: Add delay to Sortable.js on mobile, to ensure scrolling is possible. (#22152)
Mobile / touch devices currently get "hung up" on the sortable action,
preventing any ability to visually scroll through the Project board to
see issues.

Solution: Sortable.js has a built-in fix using `delayOnTouchOnly`

BEFORE

https://user-images.githubusercontent.com/24665/208266817-6f2968b7-4788-4656-a941-f85b25fc59d5.mp4

AFTER

https://user-images.githubusercontent.com/24665/208266822-3d327002-7a9d-41cf-9890-6d6b8dcb17be.mp4

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-20 23:56:58 -05:00
KN4CK3R
86ace4b5c2
Normalize NuGet package version on upload (#22186)
Fixes #22178

After this change upload versions with different semver metadata are
treated as the same version and trigger a duplicated version error.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-20 22:20:23 -05:00
zeripath
fe6608f72b
Attempt to fix TestExportUserGPGKeys (#22159)
There are repeated failures with this test which appear related to
failures in getTokenForLoggedInUser. It is difficult to further evaluate
the cause of these failures as we do not get given further information.

This PR will attempt to fix this.

First it adds some extra logging and it uses the csrf cookie primarily
for the csrf value.

If the problem does not occur again with those changes we could merge,
assume that it is fixed and hope that if it occurs in future the
additional logging will be helpful.

If not I will add more changes in attempt to fix.

Fix #22105

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: delvh <dev.lh@web.de>
2022-12-21 09:46:16 +08:00
90572c5a22
Specify ID in TestAPITeam (#22192)
- There have been [CI
failures](https://codeberg.org/forgejo/forgejo/issues/111) in this
specific test function. The code on itself looks good, the CI failures
are likely caused by not specifying any field in `TeamUser`, which might
have caused to unittest to return another `TeamUser` than the code
expects.

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-12-21 09:22:23 +08:00
Nick
c4df10d219
Repair LFS web rendering. (#22195)
There was just a missing check.

Fixes #22193.

Signed-off-by: Nick Guenther <nick.guenther@polymtl.ca>
2022-12-21 09:21:26 +08:00
Dan Church
70d15e7785
Fix misc whitespace issues in install docs (#22189)
I ran into issues when copy-pasting the docker-compose.yml contents from
https://docs.gitea.io/en-us/install-with-docker/ - specifically the part
about adding PostgreSQL to the YAML file; I tried manually adding the
diffs by removing the `+` at the beginning of lines, and the resulting
YAML was unparsable.

This forces the indentation to be consistent across all places where
YAML is used.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-20 17:26:03 -05:00
silverwind
e767b3372a
Update JS dependencies and eslint (#22190)
- Update all JS dependencies to latest version
- Enable unicorn/prefer-node-protocol and autofix issues
- Regenerate SVGs
- Add some comments to eslint rules
- Tested build, Mermaid and Katex rendering
2022-12-20 17:15:47 -05:00
Lunny Xiao
495b8b3635
Fix delete secret modal (#22187)
Fix #22181
2022-12-20 12:18:15 -06:00
Jason Song
659055138b
Secrets storage with SecretKey encrypted (#22142)
Fork of #14483, but [gave up
MasterKey](https://github.com/go-gitea/gitea/pull/14483#issuecomment-1350728557),
and fixed some problems.

Close #12065.
Needed by #13539.

Featrues:
- Secrets for repo and org, not user yet.
- Use SecretKey to encrypte/encrypt secrets.
- Trim spaces of secret value.
- Add a new locale ini block, to make it easy to support secrets for
user.

Snapshots:

Repo level secrets:

![image](https://user-images.githubusercontent.com/9418365/207823319-b8a4903f-38ca-4af7-9d05-336a5af906f3.png)

Rrg level secrets

![image](https://user-images.githubusercontent.com/9418365/207823371-8bd02e93-1928-40d1-8c76-f48b255ace36.png)

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-12-20 17:07:13 +08:00
40ba750c4b
Check for zero time instant in TimeStamp.IsZero() (#22171)
- Currently, the 'IsZero' function for 'TimeStamp' just checks if the
unix time is zero, which is not the behavior of 'Time.IsZero()', but
Gitea is using this method in accordance with the behavior of
'Time.IsZero()'.
- Adds a new condition to check for the zero time instant.
- Fixes a bug where non-expiring GPG keys where shown as they expired on
Jan 01, 0001.
- Related https://codeberg.org/Codeberg/Community/issues/791

Before:

![image](https://user-images.githubusercontent.com/25481501/208509035-ecc5fa4a-3bd1-4fa3-beba-90875719163c.png)

After:

![image](https://user-images.githubusercontent.com/25481501/208508950-3e7f6eeb-be83-432a-89a6-d738553dafe4.png)
2022-12-20 10:04:55 +08:00
silverwind
2774671584
Fix heatmap first color being unused (#22157)
vue3-calendar-heatmap has the behaviour that the first and second colors
are mapped to values null and 0, meaning the second color was not used
as intended for values > 0. I think this is a behaviour change from
previous vue2 version that was missed during the upgrade.

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

Before:
<img width="710" alt="Screenshot 2022-12-18 at 09 17 58"
src="https://user-images.githubusercontent.com/115237/208288347-df4973af-8ebd-4582-b828-bec948ffdf60.png">

After:
<img width="709" alt="Screenshot 2022-12-18 at 09 18 15"
src="https://user-images.githubusercontent.com/115237/208288350-e0b85aa2-6925-4a37-83d2-89e2518c91ce.png">

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-19 16:14:49 -05:00
zeripath
d6b96627c1
Add setting to disable the git apply step in test patch (#22130)
For a long time Gitea has tested PR patches using a git apply --check
method, and in fact prior to the introduction of a read-tree assisted
three-way merge in #18004, this was the only way of checking patches.

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

Given the uncertainty here and the now relative stability of the
read-tree method - this PR makes using this fallback optional and
disables it by default. The hope is that users will not notice any
significant difference in conflict detection and we will be able to
remove the git apply fallback in future, and/or improve the read-tree
three-way merge method to catch any conflicts that git apply method
might have been able to fix.

An additional benefit is that patch checking should be significantly
less resource intensive and much quicker.

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

Ref #22083

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-12-19 19:37:15 +08:00
zeripath
a89b399faa
Local storage should not store files as executable (#22162)
The PR #21198 introduced a probable security vulnerability which
resulted in making all storage files be marked as executable.

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

Fix #22161

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-19 08:50:36 +08:00
zeripath
998fe26051 [skip ci] Updated licenses and gitignores 2022-12-18 00:19:33 +00:00
zeripath
6e22605793
Ensure that plain files are rendered correctly even when containing ambiguous characters (#22017)
As recognised in #21841 the rendering of plain text files is somewhat
incorrect when there are ambiguous characters as the html code is double
escaped. In fact there are several more problems here.

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

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

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

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

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

Replace #21841

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-17 22:22:25 +02:00
Meisam
f3370eeaee
verify nodeinfo response by schema (#22137)
... using
[github.com/xeipuuv/gojsonschema](https://github.com/xeipuuv/gojsonschema)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-17 01:22:34 -05:00
silverwind
c4c4151f7d
Fix margin and alignment in dashboard repolist (#22120)
Seems this has recently regressed, previously, there was a significant
whitespace between icon and text, but it seems to be gone, so I added
the margin and also vertically aligned the icon because it was slightly
misaligned.

Before:
<img width="419" alt="Screenshot 2022-12-13 at 20 03 51"
src="https://user-images.githubusercontent.com/115237/207422938-7c45110c-f73e-4344-afc8-c072266d1f95.png">

After:
<img width="419" alt="image"
src="https://user-images.githubusercontent.com/115237/207447579-95525405-574d-4ca8-84ba-d8a9af50015a.png">

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-12-17 09:58:57 +08:00
Xinyu Zhou
84001467bd
Update username (#22147)
update my email & username
2022-12-16 15:11:03 +02:00
Christian Ullrich
84285a1169
Do not list active repositories as unadopted (#22034)
This fixes a bug where, when searching unadopted repositories, active
repositories will be listed as well. This is because the size of the
array of repository names to check is larger by one than the
`IterateBufferSize`.

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

Bug found in 1.17.3.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-16 16:58:56 +08:00
zeripath
651fe4bb7d
Add doctor command for full GC of LFS (#21978)
The recent PR adding orphaned checks to the LFS storage is not
sufficient to completely GC LFS, as it is possible for LFSMetaObjects to
remain associated with repos but still need to be garbage collected.

Imagine a situation where a branch is uploaded containing LFS files but
that branch is later completely deleted. The LFSMetaObjects will remain
associated with the Repository but the Repository will no longer contain
any pointers to the object.

This PR adds a second doctor command to perform a full GC.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-15 20:44:16 +00:00
silentcodeg
3243dbe1a9
remove silentcode from MAINTAINERS (#22143)
Signed-off-by: silentcode <silentcode@senga.org>
2022-12-15 09:41:38 -06:00
Nathaniel Sabanski
ae97197404
Fixed Project view .board-column height for tall screens. (#22108)
This bug occurs because we are calculating `.board-column` height
strictly off of `vh`, when the layout header is of static height.

BEFORE


https://user-images.githubusercontent.com/24665/206991060-372c24e3-986e-4fc6-9fc8-aab8b4ef09bb.mp4


AFTER


https://user-images.githubusercontent.com/24665/206991070-91b7cbab-d807-4016-8696-e43bdaf8a7ff.mp4
2022-12-14 21:14:50 +00:00
zeripath
cdc43454a4
Correctly handle moved files in apply patch (#22118)
Moved files in a patch will result in git apply returning:

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

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

Fix #22083

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-14 21:45:33 +08:00
Lunny Xiao
1b32ed014a
remove duplicated read file code (#22042)
Merge the duplicated read file code as one function in reading text file
and readme file.
2022-12-14 18:11:11 +08:00
KN4CK3R
07461e18d3
Fix condition for is_internal (#22095)
depends on #22094

Fixes https://codeberg.org/forgejo/forgejo/issues/77

The old logic did not consider `is_internal`.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-14 17:16:01 +08:00
zeripath
4fb2006ca1
Make gitea work using cmd.exe again (#22073)
Gitea will attempt to lookup its location using LookPath however, this
fails on cmd.exe if gitea is in the current working directory.

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

Fix #22063

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-14 01:15:11 -05:00
Yakov5776
5aa854693f
Fix markdown typo of an extra backtick in docs (#22123)
Fixes a visual bug in docs which is caused by a typo of an extra backtick.
2022-12-13 18:20:36 -06:00
Chongyi Zheng
a95247b7df
Fix autofilled text visibility in dark mode (#22088)
Fixes #22087
2022-12-13 19:06:23 +08:00
Lunny Xiao
87c64f655a
Fix permission check on issue/pull lock (#22110)
Fix #21826
2022-12-12 23:02:51 +08:00
Lunny Xiao
36a2d2f919
Add a simple test for external renderer (#20033)
Fix #16402
2022-12-12 20:45:21 +08:00
Lunny Xiao
6398ca745a
refactor bind functions based on generics (#22055) 2022-12-12 16:09:26 +08:00
Lunny Xiao
003b4e209c
Allow disable code tab (#20805)
I know some users created a repository in an organization but just use
issues and projects to handle the whole organizations issues. So that
`Code` could be disabled per repository.

<img width="1148" alt="image"
src="https://user-images.githubusercontent.com/81045/184792075-346cb508-b620-4adb-bc9a-cba76fdcb294.png">

It could also become a wiki repository.

<img width="1173" alt="image"
src="https://user-images.githubusercontent.com/81045/184792324-e15c6f68-35c0-4105-ab77-83585ce53672.png">

Co-authored-by: delvh <dev.lh@web.de>
2022-12-12 13:29:27 +08:00
Lunny Xiao
3e8285b824
Use multi reader instead to concat strings (#22099)
extract from #20326
2022-12-12 11:03:54 +08:00
aceArt-GmbH
352a50d65f
Fix sorting admin user list by last login (#22081)
Admin User Account list sort

`updated_unix` is not the same as "Last Sign-In"
2022-12-11 18:00:17 -06:00
Lunny Xiao
c9ef03af65
Fix wrong default value for update checker on app.example.ini (#22084) 2022-12-11 16:08:01 -06:00
Restray
112e425f90
fix(config): remove context on config template (#22096)
👋 Hey
I'm new around here, so I may have done some mistakes, sorry! 

---

## Context
On a fresh Gitea install, when I go to the [config admin
page](http://localhost:3000/admin/config) I had a 500 error page.
The logs:
```
2022/12/10 20:08:47 ...s/context/context.go:232:HTML() [E] [6394d93f] Render failed: template: admin/config:180:22: executing "admin/config" at <.Service.DefaultAllowOnlyContributorsToTrackTime>: DefaultAllowOnlyContributorsToTrackTime has arguments but cannot be invoked as function
2022/12/10 20:08:47 [6394d93f] router: completed GET /admin/config for [::1]:43800, 500 Internal Server Error in 5.1ms @ admin/config.go:99(admin.Config)
```

## The fix

I removed the `$.Context` on the
`.Service.DefaultAllowOnlyContributorsToTrackTime` to fix the 500 error
page happening. It could be a mistake, and I don't fully understand what
I've done!

Signed-off-by: Restray <contact@restray.org>
2022-12-11 12:06:12 +08:00
KN4CK3R
601d126627 [skip ci] Updated licenses and gitignores 2022-12-11 00:19:34 +00:00
KN4CK3R
0e2d04601a
Update xorm (#22094) 2022-12-10 18:53:32 -05:00
Yarden Shoham
9745c33e9e
Remove unnecessary whitespace in snapcraft.yaml (#22090)
Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-12-10 08:31:16 -06:00
Lunny Xiao
68704532c2
Rename almost all Ctx functions (#22071) 2022-12-10 10:46:31 +08:00
Felipe Leopoldo Sologuren Gutiérrez
097d4e30b1
Change ID pattern of raw content container for issue (#21966)
Implement differentiation to html id for issue raw content container.

Fixes #21965
2022-12-10 00:25:32 +08:00
Jason Song
2779d47ad3
Optimize html templates (#22080)
Replace `active{{end}} item` with `active{{end}} item`.
2022-12-09 21:34:51 +08:00
KN4CK3R
3c59d31bc6
Add API management for issue/pull and comment attachments (#21783)
Close #14601
Fix #3690

Revive of #14601.
Updated to current code, cleanup and added more read/write checks.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Signed-off-by: Andre Bruch <ab@andrebruch.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-09 14:35:56 +08:00
Jason Song
8fb1e53ca2
Rename actions to operations on UI (#22067)
Use "operations" to indicate "some something can be done", to prevent
users from confusing it with CICD.

Releated to: #13539.

Snapshots:

<img width="389" alt="image"
src="https://user-images.githubusercontent.com/9418365/206409797-a99bac25-2d38-4066-b9ab-27a4f6fe67e7.png">
<img width="398" alt="image"
src="https://user-images.githubusercontent.com/9418365/206410099-bbd258a9-54d9-4664-8d95-31d29cb35209.png">
<img width="442" alt="image"
src="https://user-images.githubusercontent.com/9418365/206410218-009a3103-a9b9-4d0c-86b6-540dda5bce89.png">

I'm not a native English speaker, but I think "operations" may be good
enough, and Gitea already uses this word:

<img width="1440" alt="image"
src="https://user-images.githubusercontent.com/9418365/206410671-4a718b14-0603-40cb-bdcb-f6f84d1f5e24.png">
2022-12-08 21:14:09 +08:00
silverwind
0585ac3ac6
Update go dev dependencies (#22064)
`golangci-lint`
[deprecated](https://github.com/golangci/golangci-lint/issues/1841) a
bunch of linters, removed them.
2022-12-08 16:21:37 +08:00
hr-98
cf27403e18
Round language stats percentage using largest remainder (#22026)
Fix #22023 

I've changed how the percentages for the language statistics are rounded
because they did not always add up to 100%
Now it's done with the largest remainder method, which makes sure that
total is 100%

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-08 10:47:47 +08:00
Jason Song
0a85537c79
Support disabling database auto migration (#22053)
Gitea will migrate the database model version automatically, but it
should be able to be disabled and keep Gitea shutdown if the version is
not matched.
2022-12-07 09:58:31 -06:00
silverwind
e2fa84fddc
Release and Tag List tweaks (#21712)
- Reduce font size on tag list and add muted links
- Move Release tag to right side on release list
- Move Release edit button to far-right and make it icon-only
- Add styles for error dropdowns, seen on release edit page
- Make the release page slightly more mobile-friendly

<img width="468" alt="Screen Shot 2022-11-07 at 22 10 44"
src="https://user-images.githubusercontent.com/115237/200417500-149f40f5-2376-42b4-92a7-d7eba3ac359d.png">

<img width="1015" alt="Screen Shot 2022-11-07 at 22 27 14"
src="https://user-images.githubusercontent.com/115237/200419201-b28f39d6-fe9e-4049-8023-b301c9bae528.png">
<img width="1019" alt="Screen Shot 2022-11-07 at 22 27 27"
src="https://user-images.githubusercontent.com/115237/200419206-3f07d988-42f6-421d-8ba9-303a0d59e711.png">

<img width="709" alt="Screen Shot 2022-11-07 at 22 42 10"
src="https://user-images.githubusercontent.com/115237/200421671-f0393cde-2d8f-4e1f-a788-f1f51fc4807c.png">
<img width="713" alt="Screen Shot 2022-11-07 at 22 42 27"
src="https://user-images.githubusercontent.com/115237/200421676-5797f8cf-dfe8-4dd6-85d4-dc69e31a9912.png">


<img width="406" alt="image"
src="https://user-images.githubusercontent.com/115237/200418220-8c3f7549-61b4-4661-935e-39e1352f7851.png">
<img width="416" alt="Screen Shot 2022-11-07 at 22 21 36"
src="https://user-images.githubusercontent.com/115237/200418107-cdb0eb6f-1292-469c-b89a-2cb13f24173c.png">

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-06 21:15:46 +08:00
Jason Song
74874d065f
Fix issue/PR numbers (#22037)
When deleting a closed issue, we should update both `NumIssues`and
`NumClosedIssues`, or `NumOpenIssues`(`= NumIssues -NumClosedIssues`)
will be wrong. It's the same for pull requests.

Releated to #21557.

Alse fixed two harmless problems:

- The SQL to check issue/PR total numbers is wrong, that means it will
update the numbers even if they are correct.
- Replace legacy `num_issues = num_issues + 1` operations with
`UpdateRepoIssueNumbers`.
2022-12-06 15:53:09 +08:00
Yarden Shoham
77f50356f4
Remove useless "Cancel" buttons (#21872)
* Continues #21381

These buttons have no real use. To cancel, one would simply navigate
away.

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-12-05 20:38:34 +08:00
zeripath
a08584ee36
Ensure that Chinese punctuation is not ambiguous when locale is Chinese (#22019)
Although there are per-locale fallbacks for ambiguity the locale names
for Chinese do not quite match our locales. This PR simply maps zh-CN on
to zh-hans and other zh variants on to zh-hant.

Ref #20999

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-04 17:57:30 +00:00
zeripath
ea86c2b56a
Use GhostUser if needed for TrackedTimes (#22021)
When getting tracked times out of the db and loading their attributes
handle not exist errors in a nicer way. (Also prevent an NPE.)

Fix #22006

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-04 17:48:18 +00:00
Michael Kriese
84d2a820e5
Add dumb-init to rootless docker (#21775)
Add dumb-init as process reaper to the rootless image to reap defunct git processes.
2022-12-04 11:12:06 +00:00
6543
46485848fa
On tag/branch-exist check, dont panic if repo is nil (#21787)
fix a panic found in gitea logs
2022-12-04 10:28:57 +00:00
Lunny Xiao
36cbaec54c
Fix ListBranches to handle empty case (#21921)
Fix #21910

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-12-04 08:57:17 +00:00
Percy Ma
9eb9cf5153
fix(web): reduce page jitter on browsers that support overlay scrollbar (#21850)
Reduce jitter caused by the presence or absence of scrollbars in page
switching

---

Ref [scrollbar-gutter |
MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/scrollbar-gutter)


https://user-images.githubusercontent.com/45708948/165972251-7d5a5017-f76d-4ba2-9106-a224b3ee521f.mp4
2022-12-04 08:56:10 +00:00
zeripath
d084ce306a [skip ci] Updated licenses and gitignores 2022-12-04 00:19:34 +00:00
zeripath
0e46499258
Do not emit ambiguous character warning on rendered pages (#22016)
The real sensitivity of ambiguous characters is in source code -
therefore warning about them in rendered pages causes too many warnings.
Therefore simply remove the warning on rendered pages.

The escape button will remain available and it is present on the view
source page.

Fix #20999

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-12-03 23:47:00 +08:00
Xinyu Zhou
181f4bfdb1
docs: add Edit this page (#21981)
Update theme to support `Edit this page`:
https://gitea.com/gitea/theme/pulls/116

Screenshot:
![Edit this
page](https://user-images.githubusercontent.com/76462613/205257167-d6039d0c-c913-4ebc-98c1-834aece4b5e9.png)

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-03 19:51:53 +08:00
Lunny Xiao
0a7d3ff786
refactor some functions to support ctx as first parameter (#21878)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-03 10:48:26 +08:00
Chongyi Zheng
8698458f48
Remove deprecated packages & staticcheck fixes (#22012)
`ioutil` is deprecated and should use `io` instead
2022-12-02 17:06:23 -05:00
21bcb92926
Add pnpm to packages/overview (#22008)
[`pnpm`](https://pnpm.io/) is a "fast, disk space efficient" node
package manager.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-02 11:23:47 -05:00
flynnnnnnnnnn
350bc83d00
Update to Alpine 3.17 (#21904)
This pull request is for updating the base docker images to build with
the latest version of Alpine.
2022-12-02 11:23:26 -05:00
Jason Song
f59a74852b
Update gitea-vet to check FSFE REUSE (#22004)
Related to:
- #21840
- https://gitea.com/gitea/gitea-vet/pulls/21

What it looks like when it's working:
https://drone.gitea.io/go-gitea/gitea/64040/1/5

All available SPDX license identifiers: [SPDX License
List](https://spdx.org/licenses/).

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-02 22:14:57 +08:00
silverwind
d64063277d
Multiple improvements for comment edit diff (#21990)
- Use explicit avatar size so when JS copies the HTML, the size gets
copied with it
- Replace icon font use with SVG
- Improve styling and diff rendering
- Sort lists in `svg.js`

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

<img width="933" alt="Screenshot 2022-11-30 at 17 52 17"
src="https://user-images.githubusercontent.com/115237/204859608-f322a8f8-7b91-45e4-87c0-82694e574115.png">

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-12-02 11:42:34 +02:00
Lunny Xiao
df676a47d0
Remove session in api tests (#21984)
It's no meaning to request an API route with session.
2022-12-01 22:39:42 -05:00
Mark Ormesher
665d02efaf
Remove duplicate "Actions" label in mobile view (#21974)
Closes #21973.

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

Before:


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

After:


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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-01 22:39:19 -05:00
Lunny Xiao
f7ade6de7c
Fix generate index failure possibility on postgres (#21998)
@wxiaoguang Please review

Co-authored-by: silverwind <me@silverwind.io>
2022-12-02 11:15:36 +08:00
zeripath
64973cf18f
Use path not filepath in template filenames (#21993)
Paths in git are always separated by `/` not `\` - therefore we should
`path` and not `filepath`

Fix #21987

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-02 07:56:51 +08:00
silverwind
f0bd219a5e
Update chroma to v2.4.0 (#22000)
Did a few cursory tests, seems to work well.
2022-12-01 16:44:38 -05:00
Jason Song
f9cbf5a1bc
Util type to parse ref name (#21969)
Provide a new type to make it easier to parse a ref name.

Actually, it's picked up from #21937, to make the origin PR lighter.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-12-01 19:56:04 +08:00
Jason Song
4e5d4d0073
Skip initing LFS storage if disabled (#21996)
A complement to #21985.

I overlooked it because the name of the switch is `StartServer`, not
`Enabled`. I believe the weird name is a legacy, but renaming is out of
scope.
2022-12-01 11:02:04 +02:00
Lunny Xiao
b2c4870481
Fix parallel creating commit status bug with tests (#21911)
This PR is a follow up of #21469

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-12-01 00:41:49 +08:00
Jason Song
67881ae99a
Skip initing disabled storages (#21985)
If `Attachment` or `Packages` are disabled, we don't have to init the
storages for them.
2022-11-30 21:39:02 +08:00
花墨
7020c4afb7
Fix leaving organization bug on user settings -> orgs (#21983)
Fix #21772

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-11-30 17:00:00 +08:00
luzpaz
fdfd77f478
Fix typos (#21979)
Found via codespell
2022-11-29 18:41:29 -06:00
Saswat Padhi
715cf46dc4
Normalize AppURL according to RFC 3986 (#21950)
Fixes #21865.

Scheme-based normalization ([RFC 3986, section
6.2.3](https://www.rfc-editor.org/rfc/rfc3986#section-6.2.3)) was
already implemented, but only for `defaultAppURL`.
This PR implements the same for `AppURL`.

Signed-off-by: Saswat Padhi <saswatpadhi@protonmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-29 15:30:47 +08:00
a8be3ece4b
Use GetIRI() function instead of manually constructing IRI 2022-11-28 19:22:23 +00:00
Jason Song
f047ee0a40
Use random bytes to generate access token (#21959) 2022-11-28 23:37:42 +08:00
Jason Song
9607750b5e
Replace fmt.Sprintf with hex.EncodeToString (#21960)
`hex.EncodeToString` has better performance than `fmt.Sprintf("%x",
[]byte)`, we should use it as much as possible.

I'm not an extreme fan of performance, so I think there are some
exceptions:

- `fmt.Sprintf("%x", func(...)[N]byte())`
- We can't slice the function return value directly, and it's not worth
adding lines.
    ```diff
    func A()[20]byte { ... }
    - a := fmt.Sprintf("%x", A())
    - a := hex.EncodeToString(A()[:]) // invalid
    + tmp := A()
    + a := hex.EncodeToString(tmp[:])
    ```
- `fmt.Sprintf("%X", []byte)`
- `strings.ToUpper(hex.EncodeToString(bytes))` has even worse
performance.
2022-11-28 11:19:18 +00:00
439f6754ac
Don't send emails to federated users 2022-11-27 22:37:28 +00:00
c64d3fa195
Implement commenting on issues from Mastodon 2022-11-27 22:30:00 +00:00
f5a50ce457
Add Note object endpoint 2022-11-27 19:29:03 +00:00
3e690fbae2
Federated issue creation 2022-11-27 19:09:10 +00:00
77896f1a50
Save issue IRIs when creating them from AS objects 2022-11-27 18:38:20 +00:00
flynnnnnnnnnn
e81ccc406b
Implement FSFE REUSE for golang files (#21840)
Change all license headers to comply with REUSE specification.

Fix #16132

Co-authored-by: flynnnnnnnnnn <flynnnnnnnnnn@github>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-27 18:20:29 +00:00
zeripath
f6fd501841
Correct the fallbacks for mailer configuration (#21945)
Unfortunately the fallback configuration code for [mailer] that were
added in #18982 are incorrect. When you read a value from an ini section
that key is added. This leads to a failure of the fallback mechanism.
Further there is also a spelling mistake in the startTLS configuration.

This PR restructures the mailer code to first map the deprecated
settings on to the new ones - and then use ini.MapTo to map those on to
the struct with additional validation as necessary.

Ref #21744

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-11-27 10:08:40 +00:00
1066cfe785
Implement commenting and fix lint errors 2022-11-27 04:18:39 +00:00
3f5f626264
Fix AppSubURL -> AppURL typo 2022-11-27 03:51:09 +00:00
a666eefe8f
Rewrite createPullRequest and add createPersonFromIRI 2022-11-27 02:05:36 +00:00
c982b67626
Set issue Index, not ID, when creating issues from an AS object 2022-11-27 01:44:02 +00:00
2d74e4f555
Delete fork code and move createPullRequest to create.go 2022-11-27 01:40:15 +00:00
fd4d0e730e
Move AS object processing to routers/api/v1/activitypub, move AP transport and IRI code to services/activitypub
This is to follow https://docs.gitea.io/en-us/guidelines-backend/ and avoid import cycles.
2022-11-27 00:34:24 +00:00
KN4CK3R
32590db4ca [skip ci] Updated licenses and gitignores 2022-11-27 00:19:33 +00:00
41e9a10763
make fmt 2022-11-26 18:30:01 +00:00
447650f21c
Remove @ from regex because idk what it was doing there in the first place 2022-11-26 17:36:59 +00:00
d22dab748f
Add custom NotEmpty function to handle ForgeFed types 2022-11-26 17:34:43 +00:00
KN4CK3R
4b5a6e5ef0
Fix typos (#21947)
Two typos

The `recieve` typo is also present in a translation.

5f38acd9a0/options/locale/locale_sv-SE.ini (L1760)
Someone with a Crowdin account should fix that.

... and in a license file but I don't think we can change that because
that's the official text.

5f38acd9a0/options/license/xinetd (L21)
2022-11-27 00:21:54 +08:00
silverwind
5f38acd9a0
Fix markdown anchor re-clicking (#21931)
The hashchange event did not fire on re-click of a active anchor.
Instead, use the click event which always fires.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-11-26 19:15:44 +08:00
zeripath
d7f12af805
Prevent NPE if trying to restore an already restored deleted branch (#21940)
If a deleted-branch has already been restored, a request to restore it
again will cause a NPE. This PR adds detection for this case, but also
disables buttons when they're clicked in order to help prevent
accidental repeat requests.

Fix #21930

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-11-25 20:58:20 +00:00
19af0c9267
Implement loading remote tickets 2022-11-25 18:45:06 +00:00
Meisam
abecf632d2
add rel="me" to org.website link (#21941)
This lets organizations verify their link on 3rd party websites.
2022-11-25 09:33:37 -06:00
KN4CK3R
7a4f7b35e3
Fix typo in sidebar (#21934)
Same as #21922 
I used the npm file as template which was a bad idea to spot these
casing errors...
2022-11-25 17:52:23 +08:00
Percy Ma
b91167b772
fix(web): keep the pages of the navigation in the center (#21867)
Keep the pages of the navigation in the center

<table>
  <tr>
    <th>Before</th>
    <th>After</th>
  </tr>

  <tr>
    <td>
<img width="200" alt="image"
src="https://user-images.githubusercontent.com/45708948/202838756-d6d57b3f-8144-4a43-a33b-ea7c8ab3a495.png">
</td>
    <td>
<img width="192" alt="image"
src="https://user-images.githubusercontent.com/45708948/202838740-bbae1e86-b14c-421d-92d4-d0e53d5952a2.png">
</td>
  </tr>
</table>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-25 14:37:02 +08:00
KN4CK3R
a1ae83f36e
Workaround for container registry push/pull errors (#21862)
This PR addresses #19586

I added a mutex to the upload version creation which will prevent the
push errors when two requests try to create these database entries. I'm
not sure if this should be the final solution for this problem.

I added a workaround to allow a reupload of missing blobs. Normally a
reupload is skipped because the database knows the blob is already
present. The workaround checks if the blob exists on the file system.
This should not be needed anymore with the above fix so I marked this
code to be removed with Gitea v1.20.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-25 13:47:46 +08:00
silverwind
9ce5e092f3
Fix scroll over mermaid frame (#21925)
When starting a scroll while the mouse is over a mermaid diagram, the
scroll sometimes propagates to the iframe, preventing the parent page
from scrolling. Fix this by disabling scroll inside the iframe. This is
not a problem because those frames are never meant to scroll. Bug seems
to affect Firefox only.


![scroll](https://user-images.githubusercontent.com/115237/203847578-6831e3c8-9df4-4577-8501-822fb9ea1278.gif)
2022-11-24 20:56:57 +00:00
KN4CK3R
fc7a2d5a95
Add support for HEAD requests in Maven registry (#21834)
Related #18543

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-24 16:25:13 +02:00
Xinyu Zhou
26f941fbda
Fix button in branch list, avoid unexpected page jump before restore branch actually done (#21562)
This patch:
- Use `<button>` replace anchor link `<a>` in **_Delete/Restore
Branch_** button to avoid unexpected page jump before restore branch
actually done.
- Also replace right side buttons with `<button>` in branch list, let
some screen readers know they are buttons.


## Before
click restore branch -> restore triggered -> page refreshed, but branch
status not update -> manually refresh page

<details>


https://user-images.githubusercontent.com/76462613/197389108-5a0bd259-0455-40b2-92ac-4326900276f8.mp4

</details>

## After
waiting restore done -> page refresh -> branch status update

<details>


https://user-images.githubusercontent.com/76462613/197428683-616fcbd2-70f9-4572-bf76-e0b7f77b6dd7.mp4

</details>

Signed-off-by: baronbunny <its@baronbunny.cn>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-11-24 20:29:43 +08:00
KN4CK3R
b2269dedf2
Fix typo in sidebar (#21922) 2022-11-24 18:31:32 +08:00
silverwind
b97548a2ee
Fix table misalignments and tweak webhook and githook lists (#21917)
- Fix regression from #21893 which had misaligned a few tables like repo
lists and e-mails
- Bring githooks list in line with webhooks list for styling
- Change webhook list icons to just colored dots, like githook list
- Increase size of dot in webhook and githook list from 16 to 22px
2022-11-24 00:43:07 -06:00
Xinyu Zhou
09b7d8198c
Fix flex layout for repo list icons (#21896)
#20241 Added a tooltip, which does not satisfy the flex layout, and the
icons are not aligned

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
2022-11-23 22:01:30 -06:00
Jason Song
702f4b521e
Add index for access_token (#21908)
The `token_last_eight` field has been used in `GetAccessTokenBySHA `:
2022-11-23 20:49:41 -06:00
Xinyu Zhou
e483ec3a00
Fix vertical align of committer avatar rendered by email address (#21884)
Committer avatar rendered by `func AvatarByEmail` are not vertical align
as `func Avatar` does.

- Replace literals `ui avatar` and `ui avatar vm` with the constant
`DefaultAvatarClass`
2022-11-23 15:57:37 -06:00
Xinyu Zhou
a3c09fb36d
Improve docker rootless documentation (#21913)
Emphasize folder creation/permission granting

Signed-off-by: Xinyu Zhou <i@sourcehut.net>

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-11-23 13:01:38 -05:00
zeripath
787f6c3227
Ensure that Webhook tasks are not double delivered (#21558)
When re-retrieving hook tasks from the DB double check if they have not
been delivered in the meantime. Further ensure that tasks are marked as
delivered when they are being delivered.

In addition:
* Improve the error reporting and make sure that the webhook task
population script runs in a separate goroutine.
* Only get hook task IDs out of the DB instead of the whole task when
repopulating the queue
* When repopulating the queue make the DB request paged

Ref #17940 

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-23 22:10:04 +08:00
zeripath
4c00d8f916
Move migration test fixtures to the correct directories (#21901)
Unfortunately #21549 changed the name of Testcases without changing
their associated fixture directories.

Fix #21854

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-23 18:24:55 +08:00
kolaente
13746f070d
feat: add button to quickly clear merge message (#21548)
This PR adds a button to allow quickly clearing the merge message of a
PR. The button will remove everything but the git trailers.

I found myself often pruning the commit message before merging,
especially for PRs generated by renovate - renovate puts a very long and
detailed comment with the full changelog in each PR it opens. This
clutters the commit message. However, I want to explicitly preserve the
git commit trailers. Doing this manually works, but having a button is a
lot easier.

Screenshot:

![image](https://user-images.githubusercontent.com/13721712/197337525-d456d0f8-1f7c-43a9-815d-ca93b1e7a90a.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2022-11-23 18:24:03 +08:00
zeripath
4d42cbbcc2
Handle empty author names (#21902)
Although git does expect that author names should be of the form: `NAME
<EMAIL>` some users have been able to create commits with: `<EMAIL>`

Fix #21900

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-23 08:52:57 +08:00
silverwind
ee21d5453f
Move all remaining colors into CSS variables (#21903)
This should eliminate all non-variable color usage in the styles, making
gitea fully themeable via CSS variables. Also, it adds a linter to
enforce variables for colors.
2022-11-23 08:22:27 +08:00
Xinyu Zhou
68e934ab5d
Add option to enable CAPTCHA validation for login (#21638)
Enable this to require captcha validation for user login. You also must
enable `ENABLE_CAPTCHA`.

Summary:
- Consolidate CAPTCHA template
- add CAPTCHA handle and context
- add `REQUIRE_CAPTCHA_FOR_LOGIN` config and docs
- Consolidate CAPTCHA set-up and verification code 

Partially resolved #6049 

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-11-22 21:13:18 +00:00
zeripath
e77b76425e
Prepend refs/heads/ to issue template refs (#20461)
Fix #20456

At some point during the 1.17 cycle abbreviated refishs to issue
branches started breaking. This is likely due serious inconsistencies in
our management of refs throughout Gitea - which is a bug needing to be
addressed in a different PR. (Likely more than one)

We should try to use non-abbreviated `fullref`s as much as possible.
That is where a user has inputted a abbreviated `refish` we should add
`refs/heads/` if it is `branch` etc. I know people keep writing and
merging PRs that remove prefixes from stored content but it is just
wrong and it keeps causing problems like this. We should only remove the
prefix at the time of
presentation as the prefix is the only way of knowing umambiguously and
permanently if the `ref` is referring to a `branch`, `tag` or `commit` /
`SHA`. We need to make it so that every ref has the appropriate prefix,
and probably also need to come up with some definitely unambiguous way
of storing `SHA`s if they're used in a `ref` or `refish` field. We must
not store a potentially
ambiguous `refish` as a `ref`. (Especially when referring a `tag` -
there is no reason why users cannot create a `branch` with the same
short name as a `tag` and vice versa and any attempt to prevent this
will fail. You can even create a `branch` and a
`tag` that matches the `SHA` pattern.)

To that end in order to fix this bug, when parsing issue templates check
the provided `Ref` (here a `refish` because almost all users do not know
or understand the subtly), if it does not start with `refs/` add the
`BranchPrefix` to it. This allows people to make their templates refer
to a `tag` but not to a `SHA` directly. (I don't think that is
particularly unreasonable but if people disagree I can make the `refish`
be checked to see if it matches the `SHA` pattern.)

Next we need to handle the issue links that are already written. The
links here are created with `git.RefURL`

Here we see there is a bug introduced in #17551 whereby the provided
`ref` argument can be double-escaped so we remove the incorrect external
escape. (The escape added in #17551 is in the right place -
unfortunately I missed that the calling function was doing the wrong
thing.)

Then within `RefURL()` we check if an unprefixed `ref` (therefore
potentially a `refish`) matches the `SHA` pattern before assuming that
is actually a `commit` - otherwise is assumed to be a `branch`. This
will handle most of the problem cases excepting the very unusual cases
where someone has deliberately written a `branch` to look like a `SHA1`.

But please if something is called a `ref` or interpreted as a `ref` make
it a full-ref before storing or using it. By all means if something is a
`branch` assume the prefix is removed but always add it back in if you
are using it as a `ref`. Stop storing abbreviated `branch` names and
`tag` names - which are `refish` as a `ref`. It will keep on causing
problems like this.

Fix #20456

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-22 20:58:49 +08:00
Felipe Leopoldo Sologuren Gutiérrez
1d52228ee7
Fixes #21895: standardize UTC tz for util tests (#21897)
Standardize UTC timezone for `translateMonth` and `translateDay` tests.
2022-11-22 16:46:29 +08:00
mpeter50
371dd96e3e
Clarify logging documentation (#21665)
My pull request changes the logging documentation that is visible here:
https://docs.gitea.io/en-us/logging-configuration/
The reason behind the changes is that for some time I've found the
logging documentation confusing, and wanted to give a try at making it
more clear.

---

If you find the existing changes to be ok, please don't merge yet, as I
have further ideas which I want to discuss with you before making the
changes.

### Swap the "Log Groups" and "Log outputs" sections.
I want to move the "Log outputs" section before the "Log Groups"
section. The reason is that the "Log Groups" section refers to ini
sections that are only later explained, and to concepts that are general
and should be documented in "Log outputs" or a different section.

This change is essentially a swap of the "Log Groups" and "Log outputs"
sections. That way the doumentation would follow the structure in which
the ini file is built: first explaining the outer sections, and then the
inner ones ([log], [log.name], [log.name.default], ...)

### Explain the workings of ambigous settings below the settings listing
Right now the basics of a setting is shown later than the explanation of
its special workings, for example with `FILE_NAME` at [the file output
mode](https://docs.gitea.io/en-us/logging-configuration/#file-mode)
(well, if the first changes are taken into account).

Currently I have `TODO` witten at 2 settings, which I have to figure out
how do they exactly work before I can document them.

### New section about [log]
New section after "Collecting Logs for Help" about how the top level
[log] itself works and what can go there.
Currently, variables that directly go into [log] are noted throughout
the whole document.

---

Please let me know what you think about the changes.

A counterargument that I myself see is that some of this is already
present in the cheatsheet, but I think it would be better to have [this
document](https://docs.gitea.io/en-us/logging-configuration/) as a
throrough explanation of how logging is configured, and the cheatsheet
would only have a short outline of the possible sections and variables.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-22 09:04:29 +08:00
silverwind
c8b217110b
Update JS dependencies (#21881)
- Update all JS deps
- Regenerate SVGs
- Add new eslint rules, fix issues
- Tested Mermaid, Swagger, Vue, Webpack, Citation

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-22 08:58:55 +08:00
silverwind
1c7496c7a7
Webhook list enhancements (#21893) 2022-11-22 07:10:42 +08:00
silverwind
2e5ac53bdc
Embed Matrix icon as SVG (#21890)
Embed the SVG icon directly, making further invertion unnecessary
because the icon color can now follow text color.

<img width="240" alt="Screenshot 2022-11-21 at 20 16 32"
src="https://user-images.githubusercontent.com/115237/203142189-89f20de9-c0bd-4d05-92c0-44dadf20d78f.png">
<img width="245" alt="Screenshot 2022-11-21 at 20 16 46"
src="https://user-images.githubusercontent.com/115237/203142191-658239ba-1859-49c6-91ad-10ddf14780d0.png">
2022-11-21 20:25:26 +00:00
Percy Ma
2836382f34
fix(web): add alt for logo in home page (#21887)
add `alt` for logo in home page
2022-11-21 15:09:55 -05:00
silverwind
c2fb27beb4
Improvements for Content Copy (#21842)
It now supports copying Markdown, SVG and Images (not in Firefox
currently because of lacking
[`ClipboardItem`](https://developer.mozilla.org/en-US/docs/Web/API/ClipboardItem)
support, but can be enabled in `about:config` and works). It will fetch
the data if in a rendered view or when it's an image.

Followup to https://github.com/go-gitea/gitea/pull/21629.
2022-11-21 17:59:42 +08:00
Jason Song
e4eaa68a2b
Replace yaml.v2 with yaml.v3 (#21832)
I don't see why we have to use two versions of yaml. The difference
between the two versions has nothing to do with our usage.
2022-11-21 16:36:59 +08:00
Xinyu Zhou
b4802b9b2e
Allow disable RSS/Atom feed (#21622)
This patch provide a mechanism to disable RSS/Atom feed.

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-11-21 13:14:58 +08:00
silverwind
9380bb6d0c
Consolidate security-check into checks-backend (#21882)
Also, run it via exact version instead of relying on global binary.
2022-11-21 10:39:00 +08:00
Andrew Buettner
43aafc5ba1
Improve documentation for PAM and static deployment (#21866)
## Changes proposed in [referenced issue 21845][1]

- Expand PAM configuration description with working examples.
- Clarify `STATIC_URL_PREFIX` use (include "assets" and only works after
database has been initialized)
- Add note for HTTPS proxy support VIA Apache.

[1]: https://github.com/go-gitea/gitea/issues/21845
2022-11-20 20:14:03 +00:00
KN4CK3R
32db62515f
Add package registry cleanup rules (#21658)
Fixes #20514
Fixes #20766
Fixes #20631

This PR adds Cleanup Rules for the package registry. This allows to
delete unneeded packages automatically. Cleanup rules can be set up from
the user or org settings.
Please have a look at the documentation because I'm not a native english
speaker.

Rule Form

![grafik](https://user-images.githubusercontent.com/1666336/199330792-c13918a6-e196-4e71-9f53-18554515edca.png)

Rule List

![grafik](https://user-images.githubusercontent.com/1666336/199331261-5f6878e8-a80c-4985-800d-ebb3524b1a8d.png)

Rule Preview

![grafik](https://user-images.githubusercontent.com/1666336/199330917-c95e4017-cf64-4142-a3e4-af18c4f127c3.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-20 16:08:38 +02:00
Jason Song
d3f850cc0e
Support comma-delimited string as labels in issue template (#21831)
The [labels in issue YAML
templates](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms#top-level-syntax)
can be a string array or a comma-delimited string, so a single string
should be valid labels.

The old codes committed in #20987 ignore this, that's why the warning is
displayed:

<img width="618" alt="image"
src="https://user-images.githubusercontent.com/9418365/202112642-93dc72d0-71c3-40a2-9720-30fc2d48c97c.png">

Fixes #17877.
2022-11-19 15:22:15 +00:00
Jim Kirisame
c8f3eb6acb
Fix wechatwork webhook sends empty content in PR review (#21762)
Wechatwork webhook is sending the following string for pull request reviews:

``` markdown
# 
>
```

This commit fixes this problem.
2022-11-19 15:19:14 +00:00
silverwind
eec1c71880
Show syntax lexer name in file view/blame (#21814)
Show which Chroma Lexer is used to highlight the file in the file
header. It's useful for development to see what was detected, and I
think it's not bad info to have for the user:

<img width="233" alt="Screenshot 2022-11-14 at 22 31 16"
src="https://user-images.githubusercontent.com/115237/201770854-44933dfc-70a4-487c-8457-1bb3cc43ea62.png">
<img width="226" alt="Screenshot 2022-11-14 at 22 36 06"
src="https://user-images.githubusercontent.com/115237/201770856-9260ce6f-6c0f-442c-92b5-201e5b113188.png">
<img width="194" alt="Screenshot 2022-11-14 at 22 36 26"
src="https://user-images.githubusercontent.com/115237/201770857-6f56591b-80ea-42cc-8ea5-21b9156c018b.png">

Also, I improved the way this header overflows on small screens:

<img width="354" alt="Screenshot 2022-11-14 at 22 44 36"
src="https://user-images.githubusercontent.com/115237/201774828-2ddbcde1-da15-403f-bf7a-6248449fa2c5.png">

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-19 13:08:06 +02:00
KN4CK3R
044c754ea5
Add context.Context to more methods (#21546)
This PR adds a context parameter to a bunch of methods. Some helper
`xxxCtx()` methods got replaced with the normal name now.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-19 16:12:33 +08:00
silverwind
fefdb7ffd1
Timeline and color tweaks (#21799)
Followup to https://github.com/go-gitea/gitea/pull/21784.

- Restore muted effect on timeline author and issuelist comment icon
- Remove whitespace inside shared user templates, fixing link hover
underline
- Use shared author link template more
- Use `bold` class instead of CSS
- Fix grey-light color being too dark on arc-green
- Add missing black-light color
- Fix issuelist progress bar color
- Fix various other cases of missing `.muted`

<img width="416" alt="Screenshot 2022-11-13 at 12 15 22"
src="https://user-images.githubusercontent.com/115237/201519497-1d4725c6-bc8b-47b5-9f68-1278ac9a8c92.png">
<img width="324" alt="Screenshot 2022-11-13 at 12 16 52"
src="https://user-images.githubusercontent.com/115237/201519501-c0d03700-f9af-4316-ab46-482f2c7c738b.png">
<img width="79" alt="Screenshot 2022-11-13 at 12 30 55"
src="https://user-images.githubusercontent.com/115237/201519502-46dc2d73-bbdf-4a2e-84d3-d2976f793163.png">
<img width="440" alt="Screenshot 2022-11-13 at 12 41 03"
src="https://user-images.githubusercontent.com/115237/201519876-ada33948-f84a-4aeb-a40d-5c873f9a49e9.png">
<img width="213" alt="Screenshot 2022-11-13 at 12 52 54"
src="https://user-images.githubusercontent.com/115237/201520291-a4d7238e-aeca-46c7-9008-8b644b1b676e.png">
<img width="208" alt="Screenshot 2022-11-13 at 12 56 16"
src="https://user-images.githubusercontent.com/115237/201520436-aa8ba109-b959-42fb-831a-021e806c7082.png">

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-11-19 12:02:30 +08:00
silverwind
595d940daa
Fix webpack license warning (#21815)
#19999 introduced a indirect dependency with a license that was not on
our allowlist yet which produced this warning during webpack:

````
WARNING in License: citeproc@2.4.62 has disallowed license CPAL-1.0 OR AGPL-1.0
````

I've added both licenses to the allowed list and made it so webpack will
now abort on such license errors so that we don't miss those next time.

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-18 11:54:32 -06:00
Percy Ma
6da8bc6be9
chore: add webpack export type check (#21857)
add webpack export type check

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-11-18 11:01:06 -06:00
Gusted
20385b52a3
Prevent dangling user redirects (#21856)
- It's possible that the `user_redirect` table contains a user id that
no longer exists.
- Delete a user redirect upon deleting the user.
- Add a check for these dangling user redirects to check-db-consistency.
2022-11-18 22:23:34 +08:00
wxiaoguang
0b993a0d04
Fix "build from source" document to clarify the bindata tag is required. (#21853) 2022-11-18 14:34:39 +08:00
dependabot[bot]
6dbcf724ac
Bump loader-utils from 2.0.3 to 2.0.4 (#21852)
Bumps [loader-utils](https://github.com/webpack/loader-utils) from 2.0.3
to 2.0.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a
href="https://github.com/webpack/loader-utils/releases">loader-utils's
releases</a>.</em></p>
<blockquote>
<h2>v2.0.4</h2>
<h3><a
href="https://github.com/webpack/loader-utils/compare/v2.0.3...v2.0.4">2.0.4</a>
(2022-11-11)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>ReDoS problem (<a
href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/225">#225</a>)
(<a
href="ac09944dfa">ac09944</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a
href="https://github.com/webpack/loader-utils/blob/v2.0.4/CHANGELOG.md">loader-utils's
changelog</a>.</em></p>
<blockquote>
<h3><a
href="https://github.com/webpack/loader-utils/compare/v2.0.3...v2.0.4">2.0.4</a>
(2022-11-11)</h3>
<h3>Bug Fixes</h3>
<ul>
<li>ReDoS problem (<a
href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/225">#225</a>)
(<a
href="ac09944dfa">ac09944</a>)</li>
</ul>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a
href="6688b50281"><code>6688b50</code></a>
chore(release): 2.0.4</li>
<li><a
href="ac09944dfa"><code>ac09944</code></a>
fix: ReDoS problem (<a
href="https://github-redirect.dependabot.com/webpack/loader-utils/issues/225">#225</a>)</li>
<li>See full diff in <a
href="https://github.com/webpack/loader-utils/compare/v2.0.3...v2.0.4">compare
view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility
score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=loader-utils&package-manager=npm_and_yarn&previous-version=2.0.3&new-version=2.0.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after
your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge
and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating
it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop
Dependabot creating any more for this major version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop
Dependabot creating any more for this minor version (unless you reopen
the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop
Dependabot creating any more for this dependency (unless you reopen the
PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the
default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as
the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as
the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the
default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the
[Security Alerts
page](https://github.com/go-gitea/gitea/network/alerts).

</details>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-11-17 21:32:59 -05:00
KN4CK3R
88d5275614
Do not allow Ghost access to limited visible user/org (#21849)
The Ghost user should not be allowed to have access to a limited visible
user/org.

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-11-17 14:29:33 -05:00
KN4CK3R
43ab9324c5
Fix setting HTTP headers after write (#21833)
The headers can't be modified after it was send to the client.
2022-11-18 01:55:15 +08:00
silverwind
c144942b23
Tweak katex options (#21828)
- Render directly into DOM, skipping string conversion
- Add limiting options to prevent excessive size/macros
- Remove invalid `display` option previously passed

Ref: https://katex.org/docs/options.html

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-11-17 09:04:09 +08:00
Jason Song
92dd24716d
Ignore issue template with a special name (#21830)
A file in `ISSUE_TEMPLATE` with the name `config.yml` shouldn't be
treated as a YAML template, it's for [configuring the template
chooser](https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser).

The old code tried to ignore the file, but it didn't work, caused by
#20987. That's why the warning is displayed:

<img width="415" alt="image"
src="https://user-images.githubusercontent.com/9418365/202094067-804c42fe-0e9e-4fc5-bf01-d95fa336f54f.png">

Note that this PR is not an implementation of `config.yml`, there will
be another one to do it.
2022-11-16 19:14:58 +08:00
May
f311d15a0b
Added space between avatar and username (#21825)
Added space between avatar and username which is missing on verified
commit message and avatar is too close to username which is don't look
nice.

Current state

![image](https://user-images.githubusercontent.com/3164256/202007728-d7d6ecac-f754-454c-a67f-e422f4aac5a5.png)


This is how it looks after change

![image](https://user-images.githubusercontent.com/3164256/202007984-d4a38a1c-7c24-4278-aa0f-9aa51c10f772.png)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-11-15 16:36:53 -05:00
Gary Moon
40229a7dd8
Skip GitHub migration tests if the API token is undefined (#21824)
GitHub migration tests will be skipped if the secret for the GitHub API
token hasn't been set.

This change should make all tests pass (or skip in the case of this one)
for anyone running the pipeline on their own infrastructure without
further action on their part.

Resolves https://github.com/go-gitea/gitea/issues/21739

Signed-off-by: Gary Moon <gary@garymoon.net>
2022-11-15 15:22:16 -05:00
Yarden Shoham
6c8ff32511
Add updated_at field to PullReview API object (#21812)
* Closes #19997

Adds an `updated_at` time field to the `PullReview` API object to
specify when the pull request review's state changed.

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-15 11:33:52 +02:00
zeripath
c772934ff6
Adjust gitea doctor --run storages to check all storage types (#21785)
The doctor check `storages` currently only checks the attachment
storage. This PR adds some basic garbage collection functionality for
the other types of storage.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-15 16:08:59 +08:00
Yarden Shoham
de6dfb7141
Remove href="javascript:;" in "save topics (Done)" button (#21813)
To use an anchor tag as a button and have it be accessible I added
`role="button" tabindex="0"`,
[reference](https://stackoverflow.com/a/10510353/7414734).

* Closes #19912
2022-11-15 10:10:50 +08:00
delvh
55115dbb73
Improve pull/ push mirror documentation (especially for GitHub) (#21801) 2022-11-14 21:17:39 +00:00
zeripath
d9ba7f7442
Prevent panic in doctor command when running default checks (#21791)
There was a bug introduced in #21352 due to a change of behaviour caused
by #19280. This causes a panic on running the default doctor checks
because the panic introduced by #19280 assumes that the only way
opts.StdOut and opts.Stderr can be set in RunOpts is deliberately.
Unfortunately, when running a git.Command the provided RunOpts can be
set, therefore if you share a common set of RunOpts these two values can
be set by the previous commands.

This PR stops using common RunOpts for the commands in that doctor check
but secondly stops RunCommand variants from changing the provided
RunOpts.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-11-13 20:45:20 +00:00
silverwind
3e3975e0fa
fix webpackChunkName for citation-js-csl (#21806) 2022-11-13 15:10:58 -05:00
delvh
8ce2dd588a
Add plural definitions for German translations (#21802)
Previously, there were discussions on how to write certain plurals.
So, we explicitly document the special plurals to end the discussion.
2022-11-13 11:58:21 -05:00
Jim Kirisame
0ace4cee33
Fix webhook attachment text is not set in review comment (#21763)
The `getPullRequestPayloadInfo` function is widely used in many webhook,
it works well when PR is open or edit. But when we comment in PR review
panel (not PR panel), the comment content is not set as
`attachmentText`.

This commit set comment content as `attachmentText` when PR review, so
webhook could obtain this information via this function.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-11-13 11:57:52 -05:00
Yarden Shoham
6f3efdfe11
Render number of commits in repo page in a user friendly way (#21786)
Use `JsPrettyNumber` to render the number of commits

* Closes #12637

### Before

![1094](https://user-images.githubusercontent.com/20454870/201484428-eaa80d27-eeed-444e-9dc5-ae046424de2f.png)

### After

![1,094](https://user-images.githubusercontent.com/20454870/201484385-b5bdc290-86fd-493b-a87c-c987012b18ad.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-11-13 00:55:19 -05:00
Gusted
bea25d77ce
Upgrade golang.org/x/crypto (#21792)
- Update the crypto dependency to include
6fad3dfc18
- Resolves #17798

Executed: `go get
golang.org/x/crypto@6fad3dfc18918c2ac9c112e46b32473bd2e5e2f9 && rm
go.sum && go mod tidy`
2022-11-12 22:14:35 -06:00
Lunny Xiao
34283a74e8
Allow detect whether it's in a database transaction for a context.Context (#21756)
Fix #19513

This PR introduce a new db method `InTransaction(context.Context)`,
and also builtin check on `db.TxContext` and `db.WithTx`.
There is also a new method `db.AutoTx` has been introduced but could be used by other PRs.

`WithTx` will always open a new transaction, if a transaction exist in context, return an error.
`AutoTx` will try to open a new transaction if no transaction exist in context.
That means it will always enter a transaction if there is no error.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
2022-11-12 21:18:50 +01:00
zeripath
a0a425a13b
Add some documentation to packages (#21648)
In #21637 it was mentioned that the purpose of the API routes for the
packages is unclear. This PR adds some documentation.

Fix #21637

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-11-12 18:59:15 +00:00
zeripath
158b088ec3
Adjust clone timeout error to suggest increasing timeout (#21769)
There are far too many error reports regarding timeouts from migrations.
We should adjust error report to suggest increasing this timeout.

Ref #20680

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-11-12 18:58:26 +00:00
silverwind
aed1622766
Simplify text color selectors and tweak arc-green colors (#21784)
Move the text color rules out of the unneeded `.ui` block, add missing
colors, tweak colors on arc-green to be more readable (red was
particulary bad to read).

Also, this removes the previous inheritance of link colors. I think
links should always be in primary color and if they are to be
discolored, the color should be set on them explicitely.

<img width="165" alt="Screenshot 2022-11-12 at 13 28 30"
src="https://user-images.githubusercontent.com/115237/201474098-700d9fed-3133-43c7-b57e-d4cc5c2795cb.png">

<img width="152" alt="Screenshot 2022-11-12 at 13 18 48"
src="https://user-images.githubusercontent.com/115237/201474156-b6de4cb5-bce8-4553-b3d4-8365aff9a3a7.png">

HTML to test with:

```html
<div class="text red">some text with <a href="#foo">a link</a>.</div>
<div class="text orange">some text with <a href="#foo">a link</a>.</div>
<div class="text yellow">some text with <a href="#foo">a link</a>.</div>
<div class="text olive">some text with <a href="#foo">a link</a>.</div>
<div class="text green">some text with <a href="#foo">a link</a>.</div>
<div class="text teal">some text with <a href="#foo">a link</a>.</div>
<div class="text blue">some text with <a href="#foo">a link</a>.</div>
<div class="text violet">some text with <a href="#foo">a link</a>.</div>
<div class="text purple">some text with <a href="#foo">a link</a>.</div>
<div class="text pink">some text with <a href="#foo">a link</a>.</div>
<div class="text brown">some text with <a href="#foo">a link</a>.</div>
<div class="text grey">some text with <a href="#foo">a link</a>.</div>
2022-11-12 16:30:52 +02:00
20e8c64317
Fix UnfollowUser addressing 2022-11-12 05:35:30 +00:00
ca502244a0
Send out undo follow activity in UnfollowUser 2022-11-12 05:13:07 +00:00
Jason Song
bf2078640f
Load GitRepo in API before deleting issue (#21720)
Fix #20921.

The `ctx.Repo.GitRepo` has been used in deleting issues when the issue
is a PR.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-11-12 08:32:04 +08:00
Nolann
9f8e778918
Copy citation file content, in APA and BibTex format, on repo home page (#19999)
Add feature to easily copy CITATION.cff content in APA and BibTex format.
2022-11-11 18:02:50 +01:00
silverwind
9db221780f
Ignore line anchor links with leading zeroes (#21728)
Fixes: https://github.com/go-gitea/gitea/issues/21722

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-11 18:22:36 +08:00
Jason Song
50dd32ede4
Update message of reach_limit_of_creation (#21757)
When I'm trying to use a user which has no repo numbers limit to create
a repo for a org which has reached the limit, it says "You have already
reached your limit of 5 repositories."

That's confusing. "I" haven't reached the limit, the owner has.

<img width="828" alt="xnip_2022-11-10_11-57-45"
src="https://user-images.githubusercontent.com/9418365/200997290-d0819e40-fb10-4c37-917c-167e2070b4f9.png">

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-11-11 17:19:12 +08:00
Drew Noel
2cbea23d70
Add configuration for CORS allowed headers (#21747)
This PR enhances the CORS middleware usage by allowing for the headers
to be configured in `app.ini`.

Fixes #21746

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-11 14:39:27 +08:00
f75ab80b5c
make fmt 2022-11-11 04:01:30 +00:00
0cacdc37fb
More Ticket IRI processing to iri.go 2022-11-11 03:58:09 +00:00
wxiaoguang
fb704f6c72
Revert unrelated changes for SMTP auth (#21767)
The purpose of #18982 is to improve the SMTP mailer, but there were some
unrelated changes made to the SMTP auth in
d60c438694

This PR reverts these unrelated changes, fix #21744
2022-11-10 16:12:23 -05:00
wxiaoguang
92525ddffd
Init git module before database migration (#21764)
Close #21761

Some database migrations depend on the git module.
2022-11-10 14:22:39 +00:00
Jason Song
1d22911cfe
Extract updateSession function to reduce repetition (#21735)
A simple refactor to reduce duplicate codes.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2022-11-10 19:43:06 +08:00
Lunny Xiao
385462d36c
Fix dashboard ignored system setting cache (#21621)
This is a performance regression from #18058

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-11-10 14:43:53 +08:00
Jason Song
ce5aafbc69
Add .dockerignore (#21753)
There's a lot of work that has been done on `.dockerignore`:

- #329
- #2927
- #8338

And finally, it has been deleted by #2927.

This is a copy of the `.gitignore`.
Creating a soft link is more elegant, but it may cause trouble to the Windows users.
2022-11-10 04:04:09 +01:00
zeripath
99688ef994
Attempt clarify AppWorkPath etc. (#21656)
Attempt clarify the AppWorkPath in the documentation by using different
notation and adding a section to the start of the cheat sheet.

Fix #21523

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-11-09 20:22:31 -05:00
Jason Song
5a6cba4cf4
Set last login when activating account (#21731)
Fix #21698.

Set the last login time to the current time when activating the user
successfully.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-09 11:42:06 -05:00
Xinyu Zhou
dd7f1c0334
Quick fixes monaco-editor error: "vs.editor.nullLanguage" (#21734)
fixes: https://github.com/go-gitea/gitea/issues/21733

Uncaught Error: Language id "vs.editor.nullLanguage" is not configured
nor known

Note that this monaco-editor worked fine on 0.33.0 and broke on 0.34.0.
If upstream fixed, remove this code.

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-09 18:02:19 +08:00
wxiaoguang
7e40ceee9e
Fix UI language switching bug (#21597)
Related:
* https://github.com/go-gitea/gitea/pull/21596#issuecomment-1291450224


There was a bug when switching language by AJAX: the irrelevant POST
requests were processed by the target page's handler.

Now, use GET instead of POST. The GET requests should be harmless.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-09 15:40:26 +08:00
KN4CK3R
20674dd05d
Add package registry quota limits (#21584)
Related #20471

This PR adds global quota limits for the package registry. Settings for
individual users/orgs can be added in a seperate PR using the settings
table.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-09 14:34:27 +08:00
Yarden Shoham
cb83288530
Add attention blocks within quote blocks for Note and Warning (#21711)
For each quote block, the first `**Note**` or `**Warning**` gets an icon
prepended to it and its text is colored accordingly. GitHub does this
(community/community#16925). [Initially requested on
Discord.](https://discord.com/channels/322538954119184384/322538954119184384/1038816475638661181)

### Before

![image](https://user-images.githubusercontent.com/20454870/200408558-bd318302-6ff9-4d56-996f-9190e89013ec.png)

### After

![image](https://user-images.githubusercontent.com/20454870/200658863-1bac6461-dae7-4bf2-abd2-672d209574e4.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
2022-11-09 02:11:26 +02:00
Lunny Xiao
2ebab42934
Move svg html render to modules/svg (#21716)
Also added more checks for the render function.

Co-authored-by: silverwind <me@silverwind.io>
2022-11-08 23:13:58 +08:00
Lunny Xiao
91c7a3e66f
Fix tests on migrations (#21705) 2022-11-08 12:07:46 +08:00
Wayne Starr
8c1d9885e5
Remove semver compatible flag and change pypi to an array of test cases (#21708)
This addresses #21707 and adds a second package test case for a
non-semver compatible version (this might be overkill though since you
could also edit the old package version to have an epoch in front and
see the error, this just seemed more flexible for the future).

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-11-08 09:41:39 +08:00
69c1bdddc7
Merge remote-tracking branch 'upstream/main' 2022-11-08 00:22:55 +00:00
KN4CK3R
fd89c062bd
Allow local package identifiers for PyPI packages (#21690)
Fixes #21683

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-07 21:35:04 +02:00
Xinyu Zhou
a0367c2bf0
Fix typo (#21695)
Duplicate parentheses written in link.

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-11-07 09:48:46 +08:00
Gusted
7b45092d66
Remove template previewer (#21701)
- Remove "unused" code, I don't think anyone ever used this or was aware
of this feature. It doesn't even work properly as most fields/data are
empty.
2022-11-06 20:13:54 +00:00
Lunny Xiao
57df0f116a
Revert "[skip ci] Updated translations via Crowdin" (#21689)
This reverts commit cb4473692f.
2022-11-06 11:29:52 +08:00
Xinyu Zhou
cb4473692f [skip ci] Updated translations via Crowdin 2022-11-05 00:19:43 +00:00
Xinyu Zhou
20da666d6d
Fix docs relref (#21685)
reslove
https://github.com/go-gitea/gitea/issues/21627#issuecomment-1303678781
2022-11-04 17:55:25 -04:00
Yarden Shoham
e3a7f15791
Add "Copy" button to file view of raw text (#21629)
If a raw text file is displayed, a copy button of the text is enabled.

* Closes #12866

### Before

![image](https://user-images.githubusercontent.com/20454870/198898628-df1bcb0c-79d7-4ffb-95e4-441d77430827.png)

### After

![image](https://user-images.githubusercontent.com/20454870/199988152-ea1099ad-29e1-4765-a9ca-4c03c1737453.png)

#### Rendered files and binaries have their button disabled

![image](https://user-images.githubusercontent.com/20454870/199988408-73de6327-5e9e-462b-b2b6-8c3f5b878386.png)

![image](https://user-images.githubusercontent.com/20454870/199988563-844f8656-f48d-4929-880e-b6558c1c054a.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-11-04 15:33:50 -04:00
wxiaoguang
2900dc90a7
Improve valid user name check (#20136)
Close https://github.com/go-gitea/gitea/issues/21640

Before: Gitea can create users like ".xxx" or "x..y", which is not
ideal, it's already a consensus that dot filenames have special
meanings, and `a..b` is a confusing name when doing cross repo compare.

After: stricter

Co-authored-by: Jason Song <i@wolfogre.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2022-11-04 17:04:08 +08:00
Gusted
4c6b4a67d9
Remove Gusted as Gitea maintainer (#21676) 2022-11-03 19:34:24 -05:00
wxiaoguang
4d1e2b8334
Fix token generation when using INTERNAL_TOKEN_URI (#21669)
Fix https://github.com/go-gitea/gitea/issues/21666
Caused by https://github.com/go-gitea/gitea/pull/19663

Before: when install, the INTERNAL_TOKEN was always generated and saved.
But the internal token may be already there by INTERNAL_TOKEN_URI

After: INTERNAL_TOKEN_URI file must be non-empty. When install, skip
internal token generation if the token exists.
2022-11-03 20:55:09 +00:00
zeripath
3e8618949e
Clean up formatting on install page (#21668)
The install page has been somewhat inconsistently styled for a while.
This PR simplifies and standardises the styling of these fields makes
things line up better across widths.

Replace #21660

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

Old:
![Screenshot from 2022-11-02
23-07-05](https://user-images.githubusercontent.com/1824502/199619007-4a6b66c5-e19c-4d29-b71b-9aa73f2789ca.png)


New:
![Screenshot from 2022-11-02
23-04-28](https://user-images.githubusercontent.com/1824502/199618779-370f88e7-b590-4abd-afb9-b66cc3194a5d.png)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-11-03 20:41:01 +00:00
oliverpool
b6e81357bd
Add Webhook authorization header (#20926)
_This is a different approach to #20267, I took the liberty of adapting
some parts, see below_

## Context

In some cases, a weebhook endpoint requires some kind of authentication.
The usual way is by sending a static `Authorization` header, with a
given token. For instance:

- Matrix expects a `Bearer <token>` (already implemented, by storing the
header cleartext in the metadata - which is buggy on retry #19872)
- TeamCity #18667
- Gitea instances #20267
- SourceHut https://man.sr.ht/graphql.md#authentication-strategies (this
is my actual personal need :)

## Proposed solution

Add a dedicated encrypt column to the webhook table (instead of storing
it as meta as proposed in #20267), so that it gets available for all
present and future hook types (especially the custom ones #19307).

This would also solve the buggy matrix retry #19872.

As a first step, I would recommend focusing on the backend logic and
improve the frontend at a later stage. For now the UI is a simple
`Authorization` field (which could be later customized with `Bearer` and
`Basic` switches):


![2022-08-23-142911](https://user-images.githubusercontent.com/3864879/186162483-5b721504-eef5-4932-812e-eb96a68494cc.png)

The header name is hard-coded, since I couldn't fine any usecase
justifying otherwise.

## Questions

- What do you think of this approach? @justusbunsi @Gusted @silverwind 
- ~~How are the migrations generated? Do I have to manually create a new
file, or is there a command for that?~~
- ~~I started adding it to the API: should I complete it or should I
drop it? (I don't know how much the API is actually used)~~

## Done as well:

- add a migration for the existing matrix webhooks and remove the
`Authorization` logic there


_Closes #19872_

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2022-11-03 20:23:20 +02:00
kolaente
085f717529
feat: notify doers of a merge when automerging (#21553)
I found myself wondering whether a PR I scheduled for automerge was
actually merged. It was, but I didn't receive a mail notification for it
- that makes sense considering I am the doer and usually don't want to
receive such notifications. But ideally I want to receive a notification
when a PR was merged because I scheduled it for automerge.

This PR implements exactly that.

The implementation works, but I wonder if there's a way to avoid passing
the "This PR was automerged" state down so much. I tried solving this
via the database (checking if there's an automerge scheduled for this PR
when sending the notification) but that did not work reliably, probably
because sending the notification happens async and the entry might have
already been deleted. My implementation might be the most
straightforward but maybe not the most elegant.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-11-03 23:49:00 +08:00
Xinyu Zhou
f17edfaf5a
Remove deprecated DSA host key from Docker Container (#21522)
Since OpenSSH 7.0 and greater similarly disable the ssh-dss (DSA) public
key algorithm, and recommend against its use.
http://www.openssh.com/legacy.html

## ⚠️ BREAKING ⚠️

This patch will remove DSA host key form OpenSSH daemon configuration
file.

Signed-off-by: baronbunny <its@baronbunny.cn>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-11-03 19:49:12 +08:00
KN4CK3R
f8f859b8fa
Alter package_version.metadata_json to LONGTEXT (#21667) 2022-11-03 15:28:46 +08:00
Chongyi Zheng
81ea4f95a0
Handle branch name with prefix in GitHub migration (#20357)
GitHub allows releases with target commitish `refs/heads/BRANCH`, which
then causes issues in Gitea after migration. This fix handles cases that
a branch already has a prefix.

Fixes #20317

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-11-03 10:32:52 +08:00
Lunny Xiao
44cc684a50 [skip ci] Updated translations via Crowdin 2022-11-03 00:19:50 +00:00
Lunny Xiao
e72acd5e5b
Split migrations folder (#21549)
There are too many files in `models/migrations` folder so that I split
them into sub folders.
2022-11-02 16:54:36 +08:00
Gusted
4827f42f56 [skip ci] Updated translations via Crowdin 2022-11-02 00:19:48 +00:00
Gusted
c2d2323fc8
Configure update checker on installation page (#21655)
- I recently became aware that this was enabled by-default, I don't
necessary agree with that and this should rather be configured by the
user(this patch does that on the installation page) as it connects to a
homeserver, which I'd prefer to avoid on my instance.


![image](https://user-images.githubusercontent.com/25481501/199260613-a77a1b10-347a-4542-8982-9b9b24dad28c.png)
2022-11-01 19:23:56 +00:00
zeripath
f211d235c7
Fix repository adoption on Windows (#21646)
A bug was introduced in #17865 where filepath.Join is used to join
putative unadopted repository owner and names together. This is
incorrect as these names are then used as repository names - which shoud
have the '/' separator. This means that adoption will not work on
Windows servers.

Fix #21632

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-10-31 23:16:48 +00:00
Xinyu Zhou
563945c50c
Refactor docs (#21627)
This patch:
- Rename some files( `.md` to `.en-us.md`), fix missed translation copy
- Update link which shoud be refer to `../hacking-on-gitea/` instead of
`../make/` (outdated)
- Update `_redirects`:
  -  redirect `/{zh-cn|fr-fr}/make/` to `../hacking-on-gitea/`
  - redirect `/zh-cn/third-party-tools/` to `/zh-cn/integrations/`
- Delete duplicated/outdated files.
- Update menu `weight` of developers.zh-cn.md

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
2022-10-31 23:16:19 +00:00
melkor0
8f85a49947
Update "email usage" page to current ver. (1.18) (#21649)
In version 1.18 the naming scheme for smtp has been changed, HOST has
been split in SMTP_ADDR and SMTP_PORT
(https://docs.gitea.io/en-us/config-cheat-sheet/#mailer-mailer).
2022-10-31 22:02:37 +00:00
silverwind
57a0a7ef64
Fix opaque background on mermaid diagrams (#21642)
Browsers introduce a opaque background on iframes if the iframe
element's color-scheme does not match the document's color scheme which
in case of a dark theme results in a mismatch and the browser adds a
white background. Avoid this by specifying the same color scheme outside
and inside the iframe.

See https://fvsch.com/transparent-iframes for more info.

My initial attempt was to make the iframe document the same color-scheme
as the parent page (light or dark) but with that, there was a ugly
background flash on load in Chrome because Chrome apparently always
loads iframe in light scheme initially. Firefox still shows a background
flash on load but this is not possible to get rid of and it's certainly
a browser bug.

Before:
<img width="1147" alt="Screen Shot 2022-10-31 at 13 30 55"
src="https://user-images.githubusercontent.com/115237/199017132-9828aace-bdd0-4ede-8118-359e72bcf2fe.png">

After:
<img width="1152" alt="Screen Shot 2022-10-31 at 13 30 36"
src="https://user-images.githubusercontent.com/115237/199017137-989a9e67-3fe0-445f-a191-df5bf290dabf.png">
2022-10-31 20:57:31 +00:00
Lunny Xiao
9a70a12a34
Merge db.Iterate and IterateObjects (#21641)
These two functions are similiar, merge them.
2022-10-31 23:51:14 +08:00
Jason Song
4ae3f76217
Deal with markdown template without metadata (#21639)
Fixed #21636.

Related to #20987.

A markdown template without metadata should not be treated as an invalid
template.

And this PR fixed another bug that non-template files(neither .md nor
.yaml) are treated as yaml files.

<img width="504" alt="image"
src="https://user-images.githubusercontent.com/9418365/198968668-40082fa1-4f25-4d3e-9b73-1dbf6d1a7521.png">
2022-10-31 17:10:33 +02:00
KN4CK3R
9b3e2c5450 [skip ci] Updated translations via Crowdin 2022-10-31 00:19:34 +00:00
KN4CK3R
d33b2d473c [skip ci] Updated licenses and gitignores 2022-10-30 00:19:37 +00:00
KN4CK3R
49436c2c62
Keep languages defined in .gitattributes (#21403)
Fixes #21377

This marks all "defined" languages in the `.gitattributes` file so they
are not removed if they are not of type `programming` or `markup`.


![grafik](https://user-images.githubusercontent.com/1666336/194942021-1e641b60-bb8a-49c6-9a1c-413e7c4ba17d.png)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-29 15:04:21 +08:00
Jason Song
434622ab6f [skip ci] Updated translations via Crowdin 2022-10-29 00:19:53 +00:00
Jason Song
60dc48dc00
Sync git hooks when config file path changed (#21619)
A patch to #17335.

Just like AppPath, Gitea writes its own CustomConf into git hook scripts
too. If Gitea's CustomConf changes, then the git push may fail.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-28 19:53:08 +03:00
Xinyu Zhou
100448a007
Allow disable sitemap (#21617)
This patch provide a mechanism to disable
[sitemap](https://github.com/go-gitea/gitea/pull/18407).

Signed-off-by: Xinyu Zhou <i@sourcehut.net>
Co-authored-by: 6543 <6543@obermui.de>
2022-10-28 11:17:38 -04:00
kolaente
cd5c067abe
fix: PR status layout on mobile (#21547)
This PR fixes the layout of PR status layouts on mobile. For longer
status context names or on very small screens the text would overflow
and push the "Details" and "Required" badges out of the container.

Before:

![Screen Shot 2022-10-22 at 12 27
46](https://user-images.githubusercontent.com/13721712/197335454-e4decf09-4778-43e8-be88-9188fabbec23.png)

After:

![Screen Shot 2022-10-22 at 12 53
24](https://user-images.githubusercontent.com/13721712/197335449-2c731a6c-7fd6-4b97-be0e-704a99fd3d32.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-28 09:49:42 -04:00
Yarden Shoham
5f0cbb3e80
Make rss/atom identifier globally unique (#21550)
This field should be globally unique.

[RSS
reference](https://www.rssboard.org/rss-specification#ltguidgtSubelementOfLtitemgt).

### Before
```xml
    <item>
      <title>abc opened issue &lt;a href=&#34;https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg/issues/1&#34;&gt;abc/defg#1&lt;/a&gt;</title>
      <link>https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg/issues/1</link>
      <description>1#Colors</description>
      <content:encoded><![CDATA[<p><code>#FF0000<span class="color-preview" style="background-color: #FF0000"></span></code></p>
]]></content:encoded>
      <author>abc</author>
      <guid>2</guid>
      <pubDate>Mon, 17 Oct 2022 16:06:08 +0000</pubDate>
    </item>
    <item>
      <title>abc created repository &lt;a href=&#34;https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg&#34;&gt;abc/defg&lt;/a&gt;</title>
      <link>https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg</link>
      <description></description>
      <author>abc</author>
      <guid>1</guid>
      <pubDate>Mon, 17 Oct 2022 16:05:43 +0000</pubDate>
    </item>
```
### After
```xml
    <item>
      <title>abc opened issue &lt;a href=&#34;https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg/issues/1&#34;&gt;abc/defg#1&lt;/a&gt;</title>
      <link>https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg/issues/1</link>
      <description>1#Colors</description>
      <content:encoded><![CDATA[<p><code>#FF0000<span class="color-preview" style="background-color: #FF0000"></span></code></p>
]]></content:encoded>
      <author>abc</author>
      <guid>2: https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg/issues/1</guid>
      <pubDate>Mon, 17 Oct 2022 16:06:08 +0000</pubDate>
    </item>
    <item>
      <title>abc created repository &lt;a href=&#34;https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg&#34;&gt;abc/defg&lt;/a&gt;</title>
      <link>https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg</link>
      <description></description>
      <author>abc</author>
      <guid>1: https://3000-yardenshoham-gitea-3pzuhkduf6t.ws-eu72.gitpod.io/abc/defg</guid>
      <pubDate>Mon, 17 Oct 2022 16:05:43 +0000</pubDate>
    </item>
```

* Fixes #21542

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-28 09:49:04 -04:00
Xinyu Zhou
830f5c3736
Fix UI column width, button overflow Fomantic's grid (#21559)
resolved #21310 

Before:

![](https://user-images.githubusercontent.com/76462613/197395358-78698f7f-776a-4ed1-954e-e6c09a648f2b.png)


After:

![](https://user-images.githubusercontent.com/76462613/197395356-63289761-a0d4-47a7-a103-a6e6f4ad2eed.png)

Signed-off-by: baronbunny <its@baronbunny.cn>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-28 09:48:48 -04:00
Yarden Shoham
125e3e3d66
Localize time units on activity heatmap (#21570)
Previously, the months and days were hardcoded into English

* Closes #15541

## Screenshots
### English

![image](https://user-images.githubusercontent.com/20454870/197410352-1b28a637-ce19-41ae-b4e5-27955555b082.png)

### German

![image](https://user-images.githubusercontent.com/20454870/197410455-f243ca84-807f-476e-b8ed-c24e827bfc2d.png)

### Spanish

![image](https://user-images.githubusercontent.com/20454870/197410366-55202ca5-08f9-4152-8f9d-d5eeebd532ef.png)

### Italian

![image](https://user-images.githubusercontent.com/20454870/197410385-75f754dd-e845-4444-8a04-472a8f45b617.png)

### Portuguese
This one has a bit of overflow

![image](https://user-images.githubusercontent.com/20454870/197410414-b91f962e-77e9-4cc7-990b-01c0fc0cbd0b.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-28 09:48:24 -04:00
Clar Fon
76e9a4f701
Use right syntax for symbolic-ref command (#21577)
Follow-up to #21352: when testing this out, I found out that the syntax
for the `symbolic-ref` command was different than originally assumed in
that PR. Never got around to submitting a PR until now.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-28 09:41:09 -04:00
silverwind
b1dd1ba48f
Update JS dependencies and misc tweaks (#21583)
- Update all JS dependencies to latest version
- Disable two redundant eslint rules
- Adapt stylelint config to codebase
- Regenerate SVGs
- Make file editor spinner "reserve" height so page does not shift
- Tested katex, swagger, monaco

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-10-28 09:40:50 -04:00
Lunny Xiao
f337c32e86
Add index for hook_task table (#21545)
Since `hook_id` and `uuid` will become a search condition column. It's
better to add some index for them.
2022-10-28 13:05:39 +02:00
wxiaoguang
e09025fdce
Revert: auto generate INTERNAL_TOKEN (#21608)
Follow #19663

Some users do cluster deployment, they still depend on this
auto-generating behavior.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-28 17:58:32 +08:00
silverwind
07178f4d0c
Use CSS color-scheme instead of invert (#21616)
The
[`color-scheme`](https://developer.mozilla.org/en-US/docs/Web/CSS/color-scheme)
property changes the base color of certain form elements like the
datepicker icon in Chrome. Set it and remove the previous invert hack.

Before with invert removed:
<img width="840" alt="Screen Shot 2022-10-27 at 11 42 54"
src="https://user-images.githubusercontent.com/115237/198251927-b742e14e-0c62-492c-b667-ee6c69de4ad8.png">
<img width="238" alt="Screen Shot 2022-10-27 at 12 23 28"
src="https://user-images.githubusercontent.com/115237/198260413-37c1ca85-c2de-4c09-8b37-6aa8a23ab575.png">

After:
<img width="841" alt="Screen Shot 2022-10-27 at 11 43 05"
src="https://user-images.githubusercontent.com/115237/198251934-568fa291-0d18-4cd4-adec-58ae1ad90ab2.png">
<img width="839" alt="Screen Shot 2022-10-27 at 11 44 36"
src="https://user-images.githubusercontent.com/115237/198251936-a435105e-572b-41f6-8262-a53820f1d364.png">
<img width="243" alt="Screen Shot 2022-10-27 at 12 23 42"
src="https://user-images.githubusercontent.com/115237/198260432-5eaffc82-ffb8-4559-b1c2-08a39e8f4427.png">

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-28 13:45:08 +08:00
mpeter50
2cc7408b98 [skip ci] Updated translations via Crowdin 2022-10-28 00:19:53 +00:00
mpeter50
10b8506023
Improve documentation (#21612)
Fix file reference at the FLAGS line at the Log subsections heading,
improve COLORIZE line wording.

The FLAGS line referenced a file that doesn't exist in the repository as
of now. The COLORIZE line's wording implied that it would
unconditionally colorize the log by default.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-27 16:47:19 +08:00
5612130bcf
Merge remote-tracking branch 'upstream/main' 2022-10-27 00:28:53 +00:00
qwerty287
096aed5c1d [skip ci] Updated translations via Crowdin 2022-10-27 00:21:00 +00:00
qwerty287
8430f738e2
Fix 500 on PR files API (#21602)
Fixes an 500 error/panic if using the changed PR files API with pages
that should return empty lists because there are no items anymore.
`start-end` is then < 0 which ends in panic.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
2022-10-26 23:46:11 +08:00
KN4CK3R
ed47d0062e
Fix Timestamp.IsZero (#21593)
Our implementation of `IsZero` can't work. An "empty" timestamp (= 0)
calls `time.Unix(int64(ts), 0).IsZero()` which is always `false`. Only
`time.Time{}.IsZero()` is `true`.
We call this method ~~only at one place~~ and there the value
(`UpdatedUnix`) should be always != 0 so this PR may not have
consequences.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-26 21:34:44 +08:00
techknowlogick
49a4e4555a [skip ci] Updated translations via Crowdin 2022-10-26 00:20:58 +00:00
techknowlogick
3f7cab42dc
Revert "Do not send notifications for draft releases (#21451)" (#21594)
This reverts commit a37e8b275d / #21451

Temporarily revert this PR to be able to continue discussion, and
potentially get it into 1.19.0
2022-10-26 00:00:00 +02:00
KN4CK3R
5c2089a01d
Change commits-table column width (#21564)
Fixes #21561

Before

![image](https://user-images.githubusercontent.com/20903656/197388658-0ea1d941-8bc7-4f10-b5db-4ece8602b13a.png)

After

![image](https://user-images.githubusercontent.com/20903656/197388665-78fb8421-105d-408d-84cf-a86b1cc61e2e.png)
2022-10-25 18:00:37 +01:00
Lunny Xiao
5e8e3ecbeb
Fix issues count bug (#21557)
fix #19349 , #19505

Co-authored-by: delvh <dev.lh@web.de>
2022-10-25 14:47:46 +02:00
Gusted
29c00eb1ed
Improve code comment review on mobile (#21461)
- Fix placement of avatar image, this was not placed in the
`comment-header-left` and add CSS to cover the limiting of width+height
of avatar for code-review comment on "Files changed" page. This fixes
the big noticeable avatar issue.
- Apply `margin-bottom` to the "next" button, so it's consistent with
the "previous" button.
- Make sure the "next"/"previous" start at `flex-start` on mobile and
not off-screen at `flex-end`. As well force them to have `flex: 1` so
they won't overflow on x-asis. This also requires the `width: 100%` for
the `.ui.buttons` div.
- Resolves #20074


### Before
<details><img width="512"
src="https://user-images.githubusercontent.com/25481501/195952930-09560cad-419f-43a3-a8a4-a4166c117994.jpg"></details>

### After
<details><img width="512"
src="https://user-images.githubusercontent.com/25481501/197340081-0365dfa8-4344-46b4-8702-a40c778c073f.jpg"></details>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2022-10-25 19:11:49 +08:00
silverwind
06a7ed4e04
Consolidate remaining colors into variables (#21582)
Remove remaining non-color variables in arc-green, so the theme is now
100% defined from variables (excluding inverts). Adjusted red/green to
match previous overwritten colors.

`--color-gold-light` is removed, it was unused and is not part of
fomantic colors.

<img width="772" alt="Screen Shot 2022-10-24 at 20 22 25"
src="https://user-images.githubusercontent.com/115237/197599339-1d1bf6e3-aa90-4f38-9753-24effd4b178d.png">
<img width="275" alt="Screen Shot 2022-10-24 at 20 25 52"
src="https://user-images.githubusercontent.com/115237/197599344-79c1d3ac-c709-4e30-a60b-4738af672c12.png">
<img width="446" alt="Screen Shot 2022-10-24 at 20 26 46"
src="https://user-images.githubusercontent.com/115237/197599346-f2ef6449-7efd-4f81-bbb6-e7bee4528f50.png">

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-25 07:08:54 +03:00
Yarden Shoham
3bd05172d5 [skip ci] Updated translations via Crowdin 2022-10-25 00:20:58 +00:00
Yarden Shoham
fc1048a411
Add sqlite vscode extension to Gitpod configuration (#21552)
It allows for quick database inspections in the IDE.


![image](https://user-images.githubusercontent.com/20454870/197355299-222f5027-aba8-4fe2-b1d4-fff93d5ccb3c.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-24 16:55:59 -04:00
delvh
0ebb45cfe7
Replace all instances of fmt.Errorf(%v) with fmt.Errorf(%w) (#21551)
Found using
`find . -type f -name '*.go' -print -exec vim {} -c
':%s/fmt\.Errorf(\(.*\)%v\(.*\)err/fmt.Errorf(\1%w\2err/g' -c ':wq' \;`

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-24 20:29:17 +01:00
KN4CK3R
7c11a73833
Fix package access for admins and inactive users (#21580)
I noticed an admin is not allowed to upload packages for other users
because `ctx.IsSigned` was not set.
I added a check for `user.IsActive` and `user.ProhibitLogin` too because
both was not checked. Tests enforce this now.

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-24 22:23:25 +03:00
Wayne Starr
49a4464160
Allow for resolution of NPM registry paths that match upstream (#21568)
This PR fixes issue #21567 allowing for package tarball URLs to match
the upstream registry (and GitLab/JFrog Artifactory URLs). It uses a
regex to parse the filename (which contains the NPM version) and does a
fuzzy search to pull it out. The regex was built/expanded from
http://json.schemastore.org/package,
https://github.com/Masterminds/semver, and
https://docs.npmjs.com/cli/v6/using-npm/semver and is testable here:
https://regex101.com/r/OydBJq/5

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-24 21:50:22 +08:00
Vladimir Yakovlev
0218fa7cf1
Added missing headers on user packages page (#21172)
User packages page had missing tabs.


![packages-2](https://user-images.githubusercontent.com/183965/190411160-c8138a8c-dbc4-4cf1-af2c-52497a10cee8.png)

![packages-1](https://user-images.githubusercontent.com/183965/190411155-af2cb398-c9a0-4fcc-adcd-1711aaa28345.png)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-24 20:01:05 +08:00
M Hickford
191a74d622
Record OAuth client type at registration (#21316)
The OAuth spec [defines two types of
client](https://datatracker.ietf.org/doc/html/rfc6749#section-2.1),
confidential and public. Previously Gitea assumed all clients to be
confidential.

> OAuth defines two client types, based on their ability to authenticate
securely with the authorization server (i.e., ability to
>   maintain the confidentiality of their client credentials):
>
>   confidential
> Clients capable of maintaining the confidentiality of their
credentials (e.g., client implemented on a secure server with
> restricted access to the client credentials), or capable of secure
client authentication using other means.
>
>   **public
> Clients incapable of maintaining the confidentiality of their
credentials (e.g., clients executing on the device used by the resource
owner, such as an installed native application or a web browser-based
application), and incapable of secure client authentication via any
other means.**
>
> The client type designation is based on the authorization server's
definition of secure authentication and its acceptable exposure levels
of client credentials. The authorization server SHOULD NOT make
assumptions about the client type.

 https://datatracker.ietf.org/doc/html/rfc8252#section-8.4

> Authorization servers MUST record the client type in the client
registration details in order to identify and process requests
accordingly.

Require PKCE for public clients:
https://datatracker.ietf.org/doc/html/rfc8252#section-8.1

> Authorization servers SHOULD reject authorization requests from native
apps that don't use PKCE by returning an error message

Fixes #21299

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-24 15:59:24 +08:00
a1012112796
e1ce45eabf
adapt README_{Country}.md stype name in localizedExtensions (#21486)
This stype name is also used in many repos, example:
[``README_ZH.md``](https://github.com/go-gitea/gitea/blob/main/README_ZH.md)

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-10-24 14:12:15 +08:00
Johan Van de Wauw
49874b7aad
dump: Add option to skip index dirs (#21501)
closes #20683

Add an option to gitea dump to skip the bleve indexes, which can become
quite large (in my case the same size as the repo's) and can be
regenerated after restore.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-10-24 11:19:21 +08:00
Yarden Shoham
c04ad7632f
Use recommended vscode configuration in gitpod environments (#21537)
To make go tests run in gitpod, the vscode settings.json must be in the
correct place in the filesystem

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-24 02:24:33 +01:00
silverwind
bf2a72d126
Expand "Go to File" button again, fix 'Add File' margin (#21543)
With https://github.com/go-gitea/gitea/pull/21428 we gained some space
so we are again able to show the "Go to File" button as text instead of
icon-only (the old icon was not particularily fitting anyways).

Before:
<img width="328" alt="image"
src="https://user-images.githubusercontent.com/115237/197334423-07731d9d-bf26-4aeb-95fa-490d9d0bf2a2.png">

After:
<img width="339" alt="Screen Shot 2022-10-22 at 12 28 01"
src="https://user-images.githubusercontent.com/115237/197334383-467c4107-09c9-4881-b75f-7f403eab7f3a.png">
<img width="413" alt="Screen Shot 2022-10-22 at 12 28 16"
src="https://user-images.githubusercontent.com/115237/197334384-f7d1fdda-a011-4138-ad1e-b52fc987501f.png">
2022-10-24 02:23:04 +01:00
Yarden Shoham
578b43ddb5
Add yardenshoham to maintainers (#21566)
[List of merged
PRs](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3Ayardenshoham+is%3Amerged)
(with many more on the way!)

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-23 12:09:21 -04:00
wxiaoguang
dcd9fc7ee8
Refactor git command arguments and make all arguments to be safe to be used (#21535)
Follow #21464

Make all git command arguments strictly safe. Most changes are one-to-one replacing, keep all existing logic.
2022-10-23 22:44:45 +08:00
Lunny Xiao
4eeea7b30e
Update binding to fix bugs (#21556)
Fix #19698
2022-10-23 13:50:48 +03:00
Yarden Shoham
88a03a6133
Link mentioned user in markdown only if they are visible to viewer (#21554)
We need to make sure a user can't confirm the existence of a user with
private visibility

* Follow up on #21533 

### Before
#### User

![image](https://user-images.githubusercontent.com/20454870/197357580-340911d7-1659-4fc9-a9f6-7ed6bc3476b4.png)

#### Admin

![image](https://user-images.githubusercontent.com/20454870/197357676-a8f0ae63-8f80-4221-a9b5-b6311552910a.png)

### After
#### User

![image](https://user-images.githubusercontent.com/20454870/197357536-05616edb-7821-469d-8e51-6f8cb84c1362.png)

#### Admin

![image](https://user-images.githubusercontent.com/20454870/197357703-071fe984-de79-43aa-a77c-a85b046292a4.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-23 17:13:52 +08:00
M Hickford
afebbf29a9
Require authentication for OAuth token refresh (#21421)
According to the OAuth spec
https://datatracker.ietf.org/doc/html/rfc6749#section-6 when "Refreshing
an Access Token"

> The authorization server MUST ... require client authentication for
confidential clients


Fixes #21418

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-23 13:28:46 +08:00
silverwind
f982a71997
CSS color enhancements (#21534)
- Add
[`accent-color`](https://developer.mozilla.org/en-US/docs/Web/CSS/accent-color)
which will change the color of various native HTML elements from
OS-color to specified one. Affects unstyled checkbox, radio, range and
progress
- Change `--color-accent` to `--color-primary-light-1`
- Change progress bar color to `--color-accent`
- Add new `--color-primary-contrast` meant to contrast over primary
- Avoid layout shift on clicking `.viewed-file-form`
- Add styles for `input[type=file]` upload button

<img width="301" alt="Screen Shot 2022-10-21 at 18 05 35"
src="https://user-images.githubusercontent.com/115237/197246896-7b3b5591-2934-4436-bf37-6aebcdfecb13.png">
<img width="98" alt="Screen Shot 2022-10-21 at 19 41 27"
src="https://user-images.githubusercontent.com/115237/197256892-c8fc6a0a-5d2f-4757-a98b-a79f9b7fcbc5.png">
<img width="93" alt="image"
src="https://user-images.githubusercontent.com/115237/197257029-293c02e9-ebf9-448a-a58f-ca418cf36953.png">
<img width="204" alt="Screen Shot 2022-10-21 at 18 21 24"
src="https://user-images.githubusercontent.com/115237/197246957-a99f5178-bbd5-4204-bd32-7a6977026f76.png">
<img width="449" alt="Screen Shot 2022-10-21 at 18 56 59"
src="https://user-images.githubusercontent.com/115237/197249305-d481abb7-9f16-4b48-936a-c75ed29f5b04.png">
<img width="449" alt="Screen Shot 2022-10-21 at 18 57 09"
src="https://user-images.githubusercontent.com/115237/197249309-7ab70c3b-325e-41bc-a4ba-07402c6826b6.png">

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-23 12:05:20 +08:00
KN4CK3R
876ee8c3cd
Allow package version sorting (#21453) 2022-10-23 09:18:15 +08:00
Yarden Shoham
63ebb53fd5
Add link to user profile in markdown mention only if user exists (#21533)
Previously mentioning a user would link to its profile, regardless of
whether the user existed. This change tests if the user exists and only
if it does - a link to its profile is added.

* Fixes #3444

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-23 01:15:52 +08:00
Ashley Nelson
82ecd3b19e
Update milestone counters when issue is deleted (#21459)
When actions besides "delete" are performed on issues, the milestone
counter is updated. However, since deleting issues goes through a
different code path, the associated milestone's count wasn't being
updated, resulting in inaccurate counts until another issue in the same
milestone had a non-delete action performed on it.

I verified this change fixes the inaccurate counts using a local docker
build.

Fixes #21254

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-22 23:08:10 +08:00
KN4CK3R
154efa59a5
Prevent Authorization header for presigned LFS urls (#21531)
Fixes #21525

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-22 21:36:44 +08:00
Raymond
69fcca2d45
Remove deleted repos from searchresult (#21512)
This prevents a 500 response, because null pointer exceptions in
rendering the template.
This happends bc the repoId is not in the repoMap because it is delete

fix #19076

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-22 17:23:20 +08:00
Yarden Shoham
2c77d4b195
Remove unnecessary debug log (#21536)
It distractingly shows up on unit tests

* Looks like a leftover from #20571

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-22 15:25:34 +08:00
rock2dust
cd33979f5a
Added check for disabled Packages (#21540)
At the moment, If admin disable Packages, still show the Packages on the
admin dashboard

This patch added a check to hide the Packages entry

Signed-off-by: baronbunny <its@baronbunny.cn>

Signed-off-by: baronbunny <its@baronbunny.cn>
2022-10-22 11:24:09 +08:00
f133e9ca11
Implement sending follow activities
I moved around a lot of files to fix import cycles
2022-10-21 21:06:59 +00:00
KN4CK3R
1887c95254
Decouple HookTask from Repository (#17940)
At the moment a repository reference is needed for webhooks. With the
upcoming package PR we need to send webhooks without a repository
reference. For example a package is uploaded to an organization. In
theory this enables the usage of webhooks for future user actions.

This PR removes the repository id from `HookTask` and changes how the
hooks are processed (see `services/webhook/deliver.go`). In a follow up
PR I want to remove the usage of the `UniqueQueue´ and replace it with a
normal queue because there is no reason to be unique.

Co-authored-by: 6543 <6543@obermui.de>
2022-10-21 18:21:56 +02:00
Yarden Shoham
e828564445
Add color previews in markdown (#21474)
* Resolves #3047

Every time a color code will be in \`backticks`, a cute little color
preview will pop up


[Inspiration](https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#supported-color-models)

#### Before

![image](https://user-images.githubusercontent.com/20454870/196631524-298afbbf-d2c8-4018-92a5-0393a693d850.png)

#### After

![image](https://user-images.githubusercontent.com/20454870/196631397-36c561e4-08f5-465a-a36e-76084e30b08a.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-21 20:00:53 +08:00
Lunny Xiao
16cbd5b59c
Fix generating compare link (#21519)
Fix #6318

Co-authored-by: zeripath <art27@cantab.net>
2022-10-21 16:39:26 +08:00
Vladimir Yakovlev
da3b657c45 [skip ci] Updated translations via Crowdin 2022-10-21 00:21:01 +00:00
Vladimir Yakovlev
ffa4f4b570
Check for valid user token in integration tests (#21520)
Added checks for logged user token.

Some builds fail at unrelated tests, due to missing token.

Example:
https://drone.gitea.io/go-gitea/gitea/62011/2/14

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-20 19:20:01 +01:00
delvh
6a0330979f
Ignore error when retrieving changed PR review files (#21487)
When a PR reviewer reviewed a file on a commit that was later gc'ed,
they would always get a `500` response from then on when loading the PR.
This PR simply ignores that error and instead marks all files as
unchanged.
This approach was chosen as the only feasible option without diving into
**a lot** of error handling.

Fixes #21392

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-20 16:29:40 +08:00
6543
bd272e416a
move invite by mail to services package (#21513)
followup  #20307
close #21511

-> make it easy to also add API equivalent later ...
2022-10-20 11:23:31 +08:00
silverwind
fe442dba4b
Enable Monaco automaticLayout (#21515)
Enable
[`automaticLayout`](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IDiffEditorOptions.html#automaticLayout)
for monaco so it can reflow itself.

Fixes: https://github.com/go-gitea/gitea/issues/21508
2022-10-20 02:54:18 +01:00
RainboWu
fbcf1ab477
Update macOS install command (#21507)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-19 21:30:21 -04:00
KN4CK3R
99597dd76a [skip ci] Updated translations via Crowdin 2022-10-20 00:20:58 +00:00
KN4CK3R
1713beb73b
Suppress ExternalLoginUserNotExist error (#21504)
Fixes #21202
Closes #21276

An `ExternalLoginUser` is not mandatory if the current user account was
created with/by the external login source.
2022-10-19 20:07:21 +01:00
Gusted
6b712465a8
Revert increased width on pull pages (#21470)
- Revert a behavior from #21012, which liberally added `fluid padded` to
non-split style pull pages, this caused it to take up the whole
screen(such in split-style pull pages) on pull pages where the diff was
shown.
- Resolves #21460


### Before

![image](https://user-images.githubusercontent.com/25481501/196005545-bb8370c1-330d-4d47-be52-6d0c93e61583.png)

![image](https://user-images.githubusercontent.com/25481501/196005546-0022198e-6ef7-45d1-958c-77a042e5f80b.png)

### After

![image](https://user-images.githubusercontent.com/25481501/196005572-76a38309-9a41-412a-854f-24eae2b9ae4f.png)

![image](https://user-images.githubusercontent.com/25481501/196005551-2495b93d-ad08-4f59-abba-c327dadcc915.png)
2022-10-19 15:48:29 +01:00
KN4CK3R
c3b2e44392
Add team member invite by email (#20307)
Allows to add (not registered) team members by email.

related #5353

Invite by mail:

![grafik](https://user-images.githubusercontent.com/1666336/178154779-adcc547f-c0b7-4a2a-a131-4e41a3d9d3ad.png)

Pending invitations:

![grafik](https://user-images.githubusercontent.com/1666336/178154882-9d739bb8-2b04-46c1-a025-c1f4be26af98.png)

Email:

![grafik](https://user-images.githubusercontent.com/1666336/178164716-f2f90893-7ba6-4a5e-a3db-42538a660258.png)

Join form:

![grafik](https://user-images.githubusercontent.com/1666336/178154840-aaab983a-d922-4414-b01a-9b1a19c5cef7.png)

Co-authored-by: Jack Hay <jjphay@gmail.com>
2022-10-19 14:40:28 +02:00
silverwind
7d1aed83f4
Disable the 'Add File' button when not able to edit repo (#21503)
Previously, the button would render a dropdown with zero items when
`.CanEnableEditor` was false (for example on a mirror repo). Now it
disables the button instead which is better UX.

<img width="310" alt="image"
src="https://user-images.githubusercontent.com/115237/196546655-7262070d-dd8f-4fbe-ad5c-ecb443a9caef.png">
<img width="292" alt="image"
src="https://user-images.githubusercontent.com/115237/196546694-51ef5792-16d4-463d-aae8-7ef22dba6bb4.png">

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-19 16:08:33 +08:00
silverwind
37ca4cb7d6
Remove vitest globals (#21505)
Explicitly import them instead which is cleaner and enables better
editor integration.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-19 14:50:19 +08:00
silverwind
e27d52b276
Fix branch dropdown shifting on page load (#21428)
Removed the "tag/branch" prefix and did some misc tweaks like changing to `<button>` for a11y and adding a bit of margin besides repo path.
2022-10-19 13:39:55 +08:00
wxiaoguang
522dfd5425 [skip ci] Updated translations via Crowdin 2022-10-19 00:21:12 +00:00
e78dd699de
Merge remote-tracking branch 'upstream/main' 2022-10-18 18:25:01 +00:00
wxiaoguang
0614ae1c44
Remove unnecessary misspell ignore pattern (#21475)
It doesn't make sense to ignore the pattern again and again.
2022-10-18 12:52:25 -04:00
Lunny Xiao
f0182d8840
Fix read system configuration bug when installing (#21489)
Fix https://github.com/go-gitea/gitea/pull/18058#issuecomment-1280944311

Co-authored-by: 6543 <6543@obermui.de>
2022-10-18 23:16:58 +08:00
zenofile
20a5452ea6
Fix viewing user subscriptions (#21482)
Fix enumeration of user subscriptions. `watch.mode` is not a boolean but
a smallint.

Fixes #21447
Regression of #17156
2022-10-18 10:01:02 +02:00
zeripath
716fcfcf72
Make every not exist error unwrappable to a fs.ErrNotExist (#20891)
A lot of our code is repeatedly testing if individual errors are
specific types of Not Exist errors. This is repetitative and unnecesary.
`Unwrap() error` provides a common way of labelling an error as a
NotExist error and we can/should use this.

This PR has chosen to use the common `io/fs` errors e.g.
`fs.ErrNotExist` for our errors. This is in some ways not completely
correct as these are not filesystem errors but it seems like a
reasonable thing to do and would allow us to simplify a lot of our code
to `errors.Is(err, fs.ErrNotExist)` instead of
`package.IsErr...NotExist(err)`

I am open to suggestions to use a different base error - perhaps
`models/db.ErrNotExist` if that would be felt to be better.


Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2022-10-18 07:50:37 +02:00
techknowlogick
6af1a0c8c0
inline gitpod image (#21494)
fix #21492

Co-authored-by: 6543 <6543@obermui.de>
2022-10-18 09:55:57 +08:00
KN4CK3R
ea08559045 [skip ci] Updated translations via Crowdin 2022-10-18 00:21:08 +00:00
KN4CK3R
a37e8b275d
Do not send notifications for draft releases (#21451)
Fixes #21448

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-10-17 17:33:27 -04:00
rock2dust
c0888def50
Update reverse-proxies.zh-cn.md (#21484)
add proxy header to nginx config example
```
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
```
Signed-off-by: rock2dust <its@baronbunny.cn>

Signed-off-by: rock2dust <its@baronbunny.cn>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-17 17:30:30 -04:00
delvh
6771b1005a
Docs: Update the feature comparison to other Git Hosting Services (#20933)
This was drastically outdated recently.
2022-10-17 17:29:57 -04:00
KN4CK3R
a577214760
Add some api integration tests (#18872)
depends on #18871

Added some api integration tests to help testing of #18798.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-18 00:23:27 +08:00
6543
18622a0705
probe if sha before exec git (#21467) 2022-10-17 16:40:37 +02:00
wxiaoguang
11ac14cfe1
Fix incorrect notification commit url (#21479)
For normal commits the notification url was wrong because oldCommitID is received from the shrinked commits list.

This PR moves the commits list shrinking after the oldCommitID assignment.
2022-10-17 12:58:20 +08:00
Yarden Shoham
acdb92ad42
Localize all timestamps (#21440)
Following
* #21410 

We are now able to localize all timestamps. Some examples:

`short-date` format, French, user profile page:

![image](https://user-images.githubusercontent.com/20454870/195622461-aa0d5b93-f8df-42ad-881c-9c16606bf387.png)

`date-time` format, Portuguese, mirror repository settings page:

![image](https://user-images.githubusercontent.com/20454870/195623191-7a37d77c-4a02-4140-846d-f290a65ea21d.png)

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

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-17 12:08:21 +08:00
Lunny Xiao
683c9af89f [skip ci] Updated translations via Crowdin 2022-10-17 00:20:53 +00:00
Lunny Xiao
f860a6d2e4
Add system setting table with cache and also add cache supports for user setting (#18058) 2022-10-17 07:29:26 +08:00
Gusted
5d3dbffa15
Return 404 when user is not found on avatar (#21476)
- Instead of returning a 500 Internal Server when the user wasn't found,
return 404 Not found
2022-10-16 19:48:17 +01:00
KN4CK3R
11d3677818
Enforce grouped NuGet search results (#21442)
Fixes #21434

Added tests to enforce this behaviour.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-17 01:18:09 +08:00
KN4CK3R
cad9adeff4
Display total commit count in hook message (#21400)
Fixes #21379

The commits are capped by `setting.UI.FeedMaxCommitNum` so
`len(commits)` is not the correct number. So this PR adds a new
`TotalCommits` field.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-17 00:22:34 +08:00
wxiaoguang
6f48a36227
Refactor GetNextResourceIndex to make it work properly with transaction (#21469)
Related:
* #21362

This PR uses a general and stable method to generate resource index (eg:
Issue Index, PR Index)

If the code looks good, I can add more tests

ps: please skip the diff, only have a look at the new code. It's
entirely re-written.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-10-16 18:44:16 +08:00
silverwind
0647df3e83
Simplify fmt-check (#21458)
`fmt-check` now simply does `fmt` before and relies on `git diff` like
other checks like 'tidy-check' already do, so we can remove the argument
in the tool that handles printing changed files.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-16 16:11:17 +08:00
techknowlogick
9fb251fb6f
update current stable version 2022-10-15 22:04:25 -04:00
techknowlogick
288adbdea6
1.17.3 changelog 2022-10-15 22:03:59 -04:00
silverwind
e2727b73a3 [skip ci] Updated translations via Crowdin 2022-10-16 00:20:58 +00:00
silverwind
32159cc4a3
Fix mermaid-related bugs (#21431) 2022-10-15 18:04:00 -04:00
Lauris BH
8e8b536c29
Update OpenRC startup script (#21436) 2022-10-15 17:59:52 -04:00
Yarden Shoham
bc53256316
Use own Go version instead of hardcoded 1.17 for make fmt (#21457)
We should make sure we're using the same version across the codebase.
* We upgraded in #19918 but forgot about the following line
6bb6a108e0/build/code-batch-process.go (L273)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-10-15 21:10:25 +01:00
Yarden Shoham
b9cd6fb703
Add code highlighting in issue titles (#21432)
This changes the rendering logic of issue titles. If a substring in an
issue title is enclosed with a pair of backticks, it'll be rendered with
a monospace font (HTML `code` tag).

* Closes #20887

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-10-16 02:24:41 +08:00
Yarden Shoham
671c609c46
Add wording about keeping PRs up-to-date in CONTRIBUTING.md (#21468)
Following a discord discussion from today I've written the policy
explained to me about keeping PRs up-to-date.

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-15 12:41:24 -04:00
6543
a33ff822ff
[refactor] Use const for wiki DefaultBranch (#21466)
just a nit, that will make it easier to change things and we now have a
single source of truth
2022-10-15 16:40:32 +02:00
wxiaoguang
677af6ac57
Follow improve code quality (#21465)
After some discussion, introduce a new slice `brokenArgs` to make
`gitCmd.Run()` return errors if any dynamic argument is invalid.

Co-authored-by: delvh <dev.lh@web.de>
2022-10-15 14:18:31 +02:00
wxiaoguang
d98c5db58f
alternative to PR "improve code quality" (#21464)
This PR doesn't require new git version, and can be backported easily.

Co-authored-by: 6543 <6543@obermui.de>
2022-10-15 12:49:26 +02:00
Yarden Shoham
7917123209 [skip ci] Updated translations via Crowdin 2022-10-15 00:21:30 +00:00
Yarden Shoham
94d6d93cc2
Fix Drone pushing commits with wrong author info (#21450)
I don't know how to test this so I'll explain my thought process:

After a discussion with @techknowlogick in
cda2c38f4a
I saw the CI config has this block:

cda2c38f4a/.drone.yml (L618-L630)

I don't know much about Drone but after looking at
[appleboy/drone-git-push](https://github.com/appleboy/drone-git-push)'s
source code, I think each setting becomes an environment variable (e.g.
`remote` to `PLUGIN_REMOTE`, `commit_message` to `PLUGIN_COMMIT_MESSAGE`
etc...). Take a look at the code block loading the author info:

a69878c006/main.go (L32-L42)

Two environment variables are listed for each setting. This PR forces
both to have the same value.

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-14 15:09:04 -04:00
Yarden Shoham
6bb6a108e0
Add vitest tests to Gitpod (#21449)
The vitest PR is merged, we can now add vitest to Gitpod's testing pane
* #21444

We couldn't use jest in the same manner because we had to customize
`NODE_OPTIONS`.

Screenshot (look at all the cool stuff circled in red):

![image](https://user-images.githubusercontent.com/20454870/195728971-9a2eaa80-8d91-4e4f-899b-a068edb9ff30.png)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-14 11:22:57 -04:00
silverwind
c3098076b5
Switch from jest to vitest (#21444)
Even if we are not bundling with `vite` yet, we can use `vitest` in
place of Jest which brings a few benefits like not requiring to use
`NODE_OPTIONS` to run and having sane module resolution.

It's possible to also use `jest-extended` with vitest, but I opted to
not do so for now because it brings heavyweight dependencies and it was
trivial to just rewrite the affected matchers to be compatible.

This PR also removes 153 JS dependencies, which is certainly nice.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-14 21:36:16 +08:00
silverwind
9dc264a2ee
Diff file tree tweaks (#21446)
- Left-align the diff stat line again like previously.
- Default the file tree to collapsed view, which means the tree will
rendered initially collapsed and it may "pop in" via JS if enabled. I
think this is more desirable than having the empty space for the tree
"pop out" like it currently does.
- Mute the icon, removing color unless hovered.
- Increase icon size and vertically center it.

Before:
<img width="1271" alt="image"
src="https://user-images.githubusercontent.com/115237/195666451-55771595-0525-42b8-be1b-d03cc1cb2961.png">


After:
<img width="1280" alt="image"
src="https://user-images.githubusercontent.com/115237/195666385-c91fd0de-6dcc-4d9c-89ff-7581828fcf14.png">

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-14 17:43:25 +08:00
Patrick Schratz
4de48d5252
Add cynkra bronze sponsor (#21325)
@techknowlogick 

Only added a placeholder, the index is possibly wrong. But I think you
need to do/finalize that as the opencollective holder :)

You can take the logo of the opencollective account. LMK if I can help
more!

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <matti@mdranta.net>
2022-10-13 21:44:04 -04:00
Yarden Shoham
c4f7c96903
Run make fmt (#21437)
The only change is what `make fmt` did, I am merely a vessel for its
glorious function

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-13 21:33:54 -04:00
wxiaoguang
f40833d1f0
Remove useless appVer from JS window.config (#21445)
The only usage of `appVer` was in serviceworker.js, while indeed it
needs the asset version.
2022-10-14 01:16:27 +08:00
KN4CK3R
0e58201d1a
Add support for Chocolatey/NuGet v2 API (#21393)
Fixes #21294

This PR adds support for NuGet v2 API.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-13 18:19:39 +08:00
Neel
c35531dd11
Fix #21406: Hide repo information from file view/blame mode (#21420)
# Summary

The repo information such as description, stats and topics are getting
displayed in the top-bar when viewing a file. This has been fixed to
display the repo information only while navigating the repo and not
while viewing or blaming a file from the repo

## Before fix

Screenshot from the issue


![image](https://user-images.githubusercontent.com/47709856/195278543-9afbb735-7bd3-4f42-b3ba-da514c6989d2.png)

## After the fix

- **Repo homepage**

The repo description, topics and summary will be displayed


![image](https://user-images.githubusercontent.com/47709856/195443913-2ca967cd-6694-4a97-98d0-4d0750692b5d.png)

- **When opening a file**

The repo description, topic and summary has been conditionally hidden
from the view

<img width="1311" alt="image"
src="https://user-images.githubusercontent.com/47709856/195278964-9479231c-62ad-4c0e-b438-2018f22289db.png">

- **When running blame on a file**

> This was originally not part of the issue #21406. However the fix
seems relevant for the blame view as well.

<img width="1312" alt="image"
src="https://user-images.githubusercontent.com/47709856/195279619-02010775-aec3-4c8d-a184-d2d838c797e8.png">

- **From within a directory**

The repo description, topics and summary will not be displayed


![image](https://user-images.githubusercontent.com/47709856/195444080-ff5b2def-7e0f-47d7-b54a-7e9df5f9edd8.png)


Supporting integration tests have also been added.
2022-10-13 11:31:10 +03:00
Yarden Shoham
cda2c38f4a [skip ci] Updated translations via Crowdin 2022-10-13 00:21:26 +00:00
Yarden Shoham
6a6dc97b0f
Respect user's locale when rendering the date range in the repo activity page (#21410)
# Description
Previously, to make the date range understood by all, we used the format
"2006-01-02" for the dates as it's locale-generic.

This commit changes the rendering logic. Instead of rendering the date
on the server, we send a formatted computer-readable timestamp. The
client's javascript then renders it according to the user's locale.

This approach is reusable across the codebase, any `<time></time>` tag
with the data-format="date" attribute would get rendered according to
the user's chosen locale.

## Previous View

![image](https://user-images.githubusercontent.com/20454870/195099143-e1c5df86-282a-42f1-898f-a36bb5fe7c2f.png)

## New View

### English

![image](https://user-images.githubusercontent.com/20454870/195099301-5cda4eab-4012-49d5-97e5-b1f9cada9c06.png)

### French

![image](https://user-images.githubusercontent.com/20454870/195099434-ce23e394-8d65-4c4c-8ac8-8b96bc9044f3.png)

### Portuguese

![image](https://user-images.githubusercontent.com/20454870/195099559-9a7aed28-944a-45ec-bedb-64403e3faede.png)

### Italian

![image](https://user-images.githubusercontent.com/20454870/195099661-17758d55-3fe0-4797-879b-d45de0ee8ba3.png)

# References
* #21380 
* #21387
* #21396

Inspiration:

I think either differentiating by class, or probably better by a custom
attribute such as `data-format` or similar, is the best course of
action.

_Originally posted by @delvh in
https://github.com/go-gitea/gitea/issues/21396#issuecomment-1274424788_
      


Resolves #21380

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2022-10-13 00:14:14 +03:00
silverwind
ac3a61ea17
Consolidate more CSS colors into variables (#21402)
Move more colors into variables. The only real notable change is the dot
in the release timeline. Also, made the variable comments a bit more
clear.

<img width="279" alt="Screen Shot 2022-10-10 at 21 10 23"
src="https://user-images.githubusercontent.com/115237/194938496-e5a21056-67c4-4219-9c68-134b0edf0e61.png">

<img width="88" alt="Screen Shot 2022-10-10 at 21 31 53"
src="https://user-images.githubusercontent.com/115237/194939712-f666c43e-fb1a-4045-be52-1176391bd8ea.png">

<img width="90" alt="Screen Shot 2022-10-10 at 21 31 44"
src="https://user-images.githubusercontent.com/115237/194939710-2e620c06-75a9-41b7-a3e1-18eab7a57614.png">

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-12 12:26:27 -04:00
Clar Fon
42b803554c
Add HEAD fix to gitea doctor (#21352)
Due to a bug in presumably an older version of Gitea, multiple of my
repositories still have their HEADs pointing to a `master` branch while
the default branch on the UI is listed as `main`. This adds a `gitea
doctor` command that will fix all of the HEAD references for repos when
they're not synchronized with the default branch in the DB.

This will help with cloning to ensure that git automatically checks out
the right branch, instead of a nonexistent one.

Note: I'm not sure if I actually need to do more other than add a file
here. Will try testing this out on my server soon.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-12 12:17:55 -04:00
KN4CK3R
444e9df465
Contribution guidelines (#21425)
Some changes to the contribution guidelines.

- I removed the `Large Character Comments` part because I think they are
bad design. They are used in big files to group sections of code. This
code should be organized into individual files.
- Updated some paths.
- Added `Documentation` because our documentation is not good at the
moment. We should enforce documentation of newly added features to help
our users.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-12 12:17:28 -04:00
Yarden Shoham
b474730cf6
Refactor Gitpod configuration to improve quick spin up of automated dev environments (#21411)
This commit instructs Gitpod to run `docs` in watch mode in fresh
development environments so any dev could start hacking in seconds.

Also included some vscode extensions for Vue, Go, and Docker.


Try it here:

[![Open in
Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/yardenshoham/gitea/tree/gitpod)

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-10-12 12:17:04 -04:00
qwerty287
a902af75f4
Support instance-wide OAuth2 applications (#21335)
Support OAuth2 applications created by admins on the admin panel, they
aren't owned by anybody.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-12 22:08:29 +08:00
Hubert Wawrzyńczyk
c41b30760b
Case-insensitive NuGet symbol file GUID (#21409)
NuGet symbol file lookup returned 404 on Visual Studio 2019 due to
case-sensitive api router. The api router should accept case-insensitive GUID.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-12 14:53:56 +08:00
KN4CK3R
0e57ff7eee
Add generic set type (#21408)
This PR adds a generic set type to get rid of maps used as sets.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-12 13:18:26 +08:00
M Hickford
e84558b093
Improve OAuth integration tests (#21390)
In particular, test explicit error responses.

No change to behaviour.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-12 12:22:43 +08:00
Andreas Fischer
9862936ed3
Make e-mail sanity check more precise (#20991)
For security reasons, all e-mail addresses starting with
non-alphanumeric characters were rejected. This is too broad and rejects
perfectly valid e-mail addresses. Only leading hyphens should be
rejected -- in all other cases e-mail address specification should
follow RFC 5322.

Co-authored-by: Andreas Fischer <_@ndreas.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-11 22:44:09 -04:00
Yarden Shoham
b5a54f03a2
Fix broken link to frontend guidelines in hacking guidelines (#21382) 2022-10-11 21:23:21 -04:00
KN4CK3R
4dc3b2ec57
Use Name instead of DisplayName in LFS Lock (#21415)
Fixes #21268

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-11 21:03:15 -04:00
kolaente
e026459a2d [skip ci] Updated translations via Crowdin 2022-10-12 00:21:02 +00:00
kolaente
d8a80b0ed7
feat(pr review): add more space on mobile (#21326)
This PR adds more space to the review screen on mobile so that comments
are more readable and less "squashed" an smaller screens.

Before:

![Screen Shot 2022-10-03 at 17 12
26](https://user-images.githubusercontent.com/13721712/193612834-6add9e25-f635-4a5b-84f6-b8e2b320ec29.png)

After:

![Screen Shot 2022-10-03 at 17 10
15](https://user-images.githubusercontent.com/13721712/193612671-ab4ef640-0360-44ef-9184-b366b7abeb37.png)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-10-11 16:42:31 -04:00
Gusted
5ba23066ff
Bump golang.org/x/text (#21412)
- Update the `golang.org/x/text` dependency, this fixes [a security
issue](https://groups.google.com/g/golang-announce/c/-hjNw559_tE/m/KlGTfid5CAAJ).
2022-10-11 20:01:07 +01:00
plsnp
a99074b267
Update gitea.service (#21399)
`LimitMEMLOCK=infinity` is already the default, so removed that

Default soft limit for LimitNOFILE is 1024
Default hard limit for LimitNOFILE is 524288

`LimitNOFILE=65535` increases the soft limit, but decreases the hard
limit

References:
* https://www.freedesktop.org/software/systemd/man/systemd.exec.html
*
https://blog.skbali.com/2019/09/set-ulimits-for-a-script-started-using-systemd/

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-11 12:26:32 -04:00
zeripath
4a23212102
Do DB update after merge in hammer context (#21401)
When merge was changed to run in the background context, the db updates
were still running in request context. This means that the merge could
be successful but the db not be updated.

This PR changes both these to run in the hammer context, this is not
complete rollback protection but it's much better.

Fix #21332

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-11 12:26:22 -04:00
Anbraten
5aceedc7fd
add gitpod config (#20995)
Add a config for <https://www.gitpod.io/>. This allows users to easily
run an online IDE pre-configured to develop and test Gitea by opening
<https://gitpod.io/#https://github.com/go-gitea/gitea>.

[![Open in
Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/go-gitea/gitea)

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-10-11 12:15:14 -04:00
Yarden Shoham
9b7675d0cf
Remove cancel button in repo creation page (#21381) 2022-10-11 22:47:35 +08:00
Bill Wenrich
ea3c6c6d7b
Improve clarity for camo proxy parameters (#21386)
Updates the Config Cheat Sheet for the `ALLWAYS` option in Camo proxy.

- Clarifies the behavior for true (both HTTP and HTTPS is proxied) vs
false (only HTTP is proxied)
- Minor grammar and typo improvements

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-11 21:12:44 +08:00
KN4CK3R
8752d89be7
Redirect to new repository owner (#21398)
Fixes #17655

If you rename `user1` to `user2` and visit `/user1` you get redirected
to `/user2`. But if you visit `/user1/repo` you just get a 404 error.
With this PR the user is redirected to `/user2/repo`.
2022-10-11 19:54:44 +08:00
Yarden Shoham
2d4c6321c3
Use ISO date format instead of hard-coded English date format for date range in repo activity page (#21396)
January 2, 2006 -> 2006-01-02

Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-11 18:48:17 +08:00
Lunny Xiao
1428877c37
log real ip of requests from ssh (#21216)
Partially fix #21213.

This PR will get client IP address from SSH_CONNECTION env which should
be the first field of that. And deliver it to the internal API so Gitea
routers could record the real IP from SSH requests.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2022-10-11 16:57:37 +08:00
Gusted
c540ee08d3
Add Num{Issues,Pulls} stats checks (#21404)
- Currently `repository.Num{Issues,Pulls}` weren't checked and could
become out-of-consistency. Adds these two checks to `CheckRepoStats`.
- Fix incorrect SQL query for `repository.NumClosedPulls`, the check
should be for `repo_num_pulls`.
- Reference: https://codeberg.org/Codeberg/Community/issues/696
2022-10-11 07:41:39 +01:00
Lauris BH
b59b0cad0a
Add user/organization code search (#19977)
Fixes #19925 

Screenshots:

![attels](https://user-images.githubusercontent.com/165205/173864718-fe789429-55bc-4cad-808c-9f02f335cddf.png)
2022-10-11 00:12:03 +01:00
zeripath
3ccebf7f40
Stop logging CheckPath returns error: context canceled (#21064)
We should only log CheckPath errors if they are not simply due to
context cancellation - and we should add a little more context to the
error message.

Fix #20709

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-10-10 21:54:30 +01:00
silverwind
94037ada24
Hook go-licenses into tidy again (#21353)
Running it as part of the build is really unnecessary because we have a
valid output file in the repo and assuming go dependencies do not change
unless go.mod also changes, tidy really is the best target to run the
license generation after.

Also, regenerate the file as I missed to do so during the chroma update,
and mark all json files in assets as generated.
2022-10-10 20:45:02 +02:00
Yarden Shoham
083ac164dc
Fix missing left and right carets in TRANSLATORS (#21397) 2022-10-10 10:36:37 -04:00
wxiaoguang
23b6827151
Fix calls to i18n in templates (#21394)
Although the `.i18n` has been refactored to `.locale`, some PRs using
`.i18n` were still merged.

* #20219
* #21246

This PR fixes the calls to `.i18n`.

At the moment, `{{.nosuch.nosuch "..."}}` won't cause template error so
these mistakes don't cause 500 and haven't been found.
2022-10-10 15:05:32 +01:00
silverwind
7044d34ae5
Update JS dependencies and eslint config (#21388)
- Update all JS dependencies and playwright image
- Add new eslint rules, enable a few more, fix issues
- Regenerate SVGs
- Tested Vue and Swagger

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-10 20:02:20 +08:00
qwerty287
a813c9d8f3
Allow creation of OAuth2 applications for orgs (#18084)
Adds the settings pages to create OAuth2 apps also to the org settings
and allows to create apps for orgs.

Refactoring: the oauth2 related templates are shared for
instance-wide/org/user, and the backend code uses `OAuth2CommonHandlers`
to share code for instance-wide/org/user.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-09 20:07:41 +08:00
Yarden Shoham
97f3f1988b
Fix typos in PullRequestMergeForm.vue header comment (#21378)
Signed-off-by: Yarden Shoham <hrsi88@gmail.com>
2022-10-09 15:17:01 +08:00
wxiaoguang
768e16dad1
Use weighted algorithm for string matching when finding files in repo (#21370)
This PR is for:
* https://github.com/go-gitea/gitea/issues/20231

Now, when a user searches `word`, they always see `/{word}.txt` before
`/{w}e-g{o}t-{r}esult.{d}at`

Demo:

When searching "a", "a.ext" comes first. 

Then when searching "at", the longer matched "template" comes first.

<details>


![image](https://user-images.githubusercontent.com/2114189/194588738-3644d891-956f-40e4-b79b-b97d34265456.png)


![image](https://user-images.githubusercontent.com/2114189/194588797-9b124670-4e1e-4510-a170-780295ed89b8.png)

</details>

This PR also makes the frontend tests could import feature JS files by
introducing `jestSetup.js`

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: silverwind <me@silverwind.io>
2022-10-08 12:22:44 +01:00
Kyle D
7bb12d7efa
Bump playwright to 1.26.1 (#21357) 2022-10-08 16:54:34 +08:00
eleith
bbbf9a4b93
npm package registry support for bin (#21372)
Fix #21303

npm package.json supports binary packaging:
https://docs.npmjs.com/cli/v8/configuring-npm/package-json#bin

the npm registry documents that the binary references will be attached
to the abbreviated version object:

https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-object

unfortunately their api documentation leaves this out:
https://github.com/npm/registry/blob/master/docs/responses/package-metadata.md#abbreviated-version-objectdoc

which is likely to be the reason this was left out in gitea's initial
implementation

this response is critical for npm to install the binary in the `.bin`
folder so as to be included on the users default bin path, resulting in
immediate access to any binaries provided by the package
2022-10-08 13:24:44 +08:00
Michael Horstmann
6c53cf852f
Removed one extra whitespace in footer after "Template" (#21364) 2022-10-08 11:53:42 +08:00
Akshay Mankar
f0aed8205b
Fix formatted link for PR review notifications to matrix (#21319)
The PR review notifications HTML was written as markdown due to not
using `MatrixLinkFormatter`.
2022-10-07 22:06:34 +01:00
KN4CK3R
223556073c
Show private data in feeds (#21369)
Show private data in feeds for admins and matching users.
2022-10-07 22:06:04 +01:00
zeripath
7d2545d183
Add nicer error handling on template compile errors (#21350)
There are repeated issues reported whereby users are unable to interpret
the template errors. This PR adds some (somewhat complex) error handling
to the panic recovery for template renderering but hopefully makes the
interpretation of the error easier.

Reference #21344

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-10-07 22:02:24 +01:00
rj1
56aabf3e8d
Fix some typos and update db transaction demo in backend guideline (#21322)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-08 02:12:19 +08:00
wxiaoguang
c08e42c47e
Refactor parseTreeEntries, speed up tree list (#21368)
Close #20315 (fix the panic when parsing invalid input), Speed up #20231 (use ls-tree without size field)

Introduce ListEntriesRecursiveFast (ls-tree without size) and ListEntriesRecursiveWithSize (ls-tree with size)
2022-10-08 01:20:53 +08:00
KN4CK3R
69fc510d6d
Add GET and DELETE endpoints for Docker blob uploads (#21367)
This PR adds support for
https://docs.docker.com/registry/spec/api/#get-blob-upload
https://docs.docker.com/registry/spec/api/#delete-blob-upload

Both are not required by the OCI spec but some clients call these
endpoints.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-07 23:30:59 +08:00
Andrew Imeson
d94f15c2fd
Make external issue tracker regexp configurable via API (#21338)
Fixes #21336 

Signed-off-by: Andrew Imeson <andrew@andrewimeson.com>
2022-10-07 20:49:30 +08:00
delvh
81d7270cde
Add new CSS variables --color-accent and --color-small-accent (#21305)
At the moment, this is only used to replace the color of the `viewed`
checkbox and of the `has changed` label.
Previously, the used variable accentuated always either darker or
lighter, which meant that one theme looked good while the other didn't.

Co-authored-by: silverwind <me@silverwind.io>
2022-10-07 17:48:03 +08:00
KN4CK3R
30ca91666e
Set SemverCompatible to false for Conan packages (#21275)
Fixes #21250
Related #20414

Conan packages don't have to follow SemVer.
The migration fixes the setting for all existing Conan and Generic
(#20414) packages.
2022-10-07 12:22:05 +08:00
M Hickford
34f509eb7a
Parse OAuth Authorization header when request omits client secret (#21351)
This fixes error "unauthorized_client: invalid client secret" when
client includes secret in Authorization header rather than request body.
OAuth spec permits both.

Sanity validation that client id and client secret in request are
consistent with Authorization header.

Improve error descriptions. Error codes remain the same.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-10-07 10:53:49 +08:00
silverwind
f09f73d784
Disable Firefox E2E tests (#21363)
Make CI green again, until we figure out
https://github.com/go-gitea/gitea/issues/21355.
2022-10-06 21:55:26 +01:00
Joe Constant
d7f0d8d8ea
Add redirect of /upgrade/ to /upgrade-from-gitea/ on docs site (#21330)
Since adding an aliases block doesn't seem to work locally for me (I
suspect because a page actually exists and Hugo is granting preference
to existing pages over aliases), I also added entries to
static/_redirects file so Netlify will handle the redirects

Fixes #7208
2022-10-06 21:53:02 +01:00
Clark Boylan
f1f911df41
Update to go-enry v2.8.3 (#21360)
This fixes an issue with enry's isVendor() method being too greedy. This
lead to gitea classifying unvendored code as vendored. The impact of
this is fairly minimal, but our Gitea users did notice which led me to
fixing this in go-enry. Some files will be tagged with a vendored flag
in the UI. I think it also impacts the calculation of language
statistics in the repo as vendored files are not incorporated into the
stats.

For more information on the issue see the go-enry bug:
  https://github.com/go-enry/go-enry/issues/135
2022-10-06 21:51:38 +01:00
zeripath
64073276c4
Update go to 1.19 (#21361)
It appears that updating go to 1.19 for playwright was missed when we
updated to go 1.19 elsewhere.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-10-06 21:51:18 +01:00
Paweł Bogusławski
2d3b52c244
SessionUser protection against nil pointer dereference (#21358)
`SessionUser` should be protected against passing `sess` = `nil` to
avoid

```
PANIC: runtime error: invalid memory address or nil pointer dereference
```

in


https://github.com/go-gitea/gitea/pull/18452/files#diff-a215b82aadeb8b4c4632fcf31215dd421f804eb1c0137ec6721b980136e4442aR69

after upgrade from gitea v1.16 to v1.17.

Related: https://github.com/go-gitea/gitea/pull/18452
Author-Change-Id: IB#1126459
2022-10-06 21:50:38 +01:00
delvh
b001812df4
Fix and improve incorrect error messages (#21342)
L
2022-10-06 07:00:54 +01:00
rock2dust
1294f6c511
Fix default theme-auto selector when nologin (#21346)
the bug is theme selector is `theme-` when not login to Gitea

![theme-auto](https://user-images.githubusercontent.com/76462613/194099390-0ff6854a-1eb9-4dba-bb28-fd238f2225f8.png)

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-06 11:52:43 +08:00
Gennady Kovshenin
fd2d5f06b0
Add stat to ToCommit function for speed (#21337)
Calls to ToCommit are very slow due to fetching diffs, analyzing files.
This patch lets us supply `stat` as false to speed fetching a commit
when we don't need the diff.

/v1/repo/commits has a default `stat` set as true now. Set to false to
experience fetching thousands of commits per second instead of 2-5 per
second.
2022-10-06 11:21:04 +08:00
wxiaoguang
8765f139c7
Fix typo in API comment document (#21347)
Close #21307

After the fix:

![image](https://user-images.githubusercontent.com/2114189/194120843-52566b84-6e29-4f91-859a-eb5839c68c54.png)
2022-10-05 21:26:34 +01:00
rock2dust
abd59cd5cd
Update comment about repository.DISABLED_REPO_UNITS in app.example.ini (#21343)
Add allowed values: `repo.projects`
2022-10-05 20:38:30 +01:00
rock2dust
f693863a4f
Remove extra space from title element (#21345)
Removes a spurious additional space in the head template. 

![](https://user-images.githubusercontent.com/76462613/194077336-1e757242-6f92-4238-8856-746b2e9a1a2c.png)
2022-10-05 20:24:21 +01:00
zeripath
93df41f506
Fix slight bug in katex (#21171)
There is a small bug in #20571 whereby `$a a$b b$` will not be correctly
detected as a math inline block of `a a$b b`. This PR fixes this.

Also reenable test cases as per #21340 

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-05 19:55:36 +01:00
John Olheiser
2d2cf589f7
Fix linked account translation (#21331)
fix key used for translation
2022-10-04 07:51:07 -05:00
Jason Song
274523baf4 [skip ci] Updated translations via Crowdin 2022-10-04 00:20:52 +00:00
Jason Song
a08b484549
Tag list should include draft releases with existing tags (#21263)
Before, a tag for a draft release disappeared in the tag list, fix #21262.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-03 20:05:53 +08:00
techknowlogick
af849ac009 [skip ci] Updated translations via Crowdin 2022-10-03 00:20:54 +00:00
techknowlogick
9e2f37404c
Foreign ID conflicts if ID is 0 for each item (#21271)
The default is 0 if not defined, and that causes dupe index errors

Co-authored-by: 6543 <6543@obermui.de>
2022-10-02 17:43:16 -04:00
John Olheiser
f82f1d05b1
Make app.ini read-only message more prominent (#21315) 2022-10-02 04:12:59 -04:00
wxiaoguang
eaa67671cc
Fix doc and heatmap for the Vue3 refactoring (#21312) 2022-10-02 10:13:44 +08:00
Clar Fon
3d10193be2
Allow specifying SECRET_KEY_URI, similar to INTERNAL_TOKEN_URI (#19663)
Only load SECRET_KEY and INTERNAL_TOKEN if they exist.
Never write the config file if the keys do not exist, which was only a fallback for Gitea upgraded from < 1.5

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-10-02 01:26:33 +08:00
André Jaenisch
04e97b8311
Refactor from Vue2 to Vue3 (#20044)
Close #19902
2022-10-01 22:26:38 +08:00
techknowlogick
726afe8a9e
Update Golang deps (#21304) 2022-10-01 08:49:30 -05:00
Chongyi Zheng
c333b4d499
Fix issue that sync_on_commit is not set (#21309)
<!--

Please check the following:

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

-->  
Fixes #21308.

With the original frontend template
`templates/repo/settings/options.tmpl`, the field
`push_mirror_sync_on_commit` is always empty even when checkbox is
checked. Removing `value` from the input tag seems to solve the issue,
and will set `push_mirror_sync_on_commit: on` when the checkbox is
checked.

(I'm not familiar with the frontend logics Gitea is using, so I don't
really understand the cause of it)
2022-10-01 16:07:05 +03:00
qwerty287
edfba99f11 [skip ci] Updated translations via Crowdin 2022-10-01 00:20:52 +00:00
qwerty287
08609d439d
Add pages to view watched repos and subscribed issues/PRs (#17156)
Adds GitHub-like pages to view watched repos and subscribed issues/PRs
This is my second try to fix this, but it is better than the first since
it doesn't uses a filter option which could be slow when accessing
`/issues` or `/pulls` and it shows both pulls and issues (the first try
is #17053).

Closes #16111 
Replaces and closes #17053


![Screenshot](https://user-images.githubusercontent.com/80460567/134782937-3112f7da-425a-45b6-9511-5c9695aee896.png)

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-29 22:09:14 +03:00
wxiaoguang
3b6a7e5c8a
Fix the hook related FAQ contents (#21297)
Follows
https://github.com/go-gitea/gitea/issues/21129#issuecomment-1260802986
* https://github.com/go-gitea/gitea/issues/21129#issuecomment-1260802986

A lot of users are asking similar questions.

The old content in FAQ doesn't seem to be related to the problem.
2022-09-29 19:20:22 +02:00
Alexander Shimchik
1d3095b718
Check if email is used when updating user (#21289)
Fix #21075 
When updating user data should check if email is used by other users
2022-09-29 14:36:29 +02:00
KN4CK3R
b7309b8ccb
Add name field for org api (#21270)
related #21205

The field `UserName` is not really usefull for an organization.
This adds a second `Name` field.

The [GitHub API](https://docs.github.com/en/rest/orgs/orgs#get-an-organization) uses `name` too. `UserName` should be deprecated then.
2022-09-29 05:27:33 +02:00
qwerty287
1dfa28ffa5
Add API endpoint to get changed files of a PR (#21177)
This adds an api endpoint `/files` to PRs that allows to get a list of changed files.

built upon #18228, reviews there are included
closes https://github.com/go-gitea/gitea/issues/654

Co-authored-by: Anton Bracke <anton@ju60.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-29 04:27:20 +02:00
cbc2a970be
Set isResolved to true for closed issues 2022-09-29 01:59:55 +00:00
M Hickford
78c15dabf3 [skip ci] Updated translations via Crowdin 2022-09-29 00:20:54 +00:00
M Hickford
6a45a691c1
Ignore port for loopback redirect URIs (#21293)
Following https://datatracker.ietf.org/doc/html/rfc8252#section-7.3

Fixes #21285
2022-09-29 00:19:55 +02:00
M Hickford
0e83ab8df7
Improve error descriptions for unauthorized_client (#21292)
Fixes #21282


As suggested by the [OAuth RFC](https://www.rfc-editor.org/rfc/rfc6749)
(quoted below), it's helpful to give more detail in the description

> error_description
OPTIONAL. Human-readable ASCII
[[USASCII](https://www.rfc-editor.org/rfc/rfc6749#ref-USASCII)] text
providing **additional information, used to assist the client developer
in understanding the error that occurred.**
Values for the "error_description" parameter MUST NOT include characters
outside the set %x20-21 / %x23-5B / %x5D-7E.
2022-09-28 15:10:27 -04:00
silverwind
677a09eb74
Consolidate more CSS rules, fix inline code on arc-green (#21260)
- Consolidate various CSS rules into base rules
- Fix inline code in Markdown not having enough contrast on arc-green

Adds one new color variable, `--color-label-active-bg` for the
background of active labels.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-28 21:19:22 +08:00
6543
5a3b9ac875
Update bluemonday (#21281)
https://github.com/microcosm-cc/bluemonday/releases/tag/v1.0.20

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-09-27 22:02:41 -04:00
Hasnain Lakhani
64c3d55de7
Add support for authentication based on reverse proxy email (#19949)
This is useful in scenarios where the reverse proxy may have knowledge
of user emails, but does not know about usernames set on gitea,
as in the feature request in #19948.

I tested this by setting up a fresh gitea install with one user `mhl`
and email `m.hasnain.lakhani@gmail.com`. I then created a private repo,
and configured gitea to allow reverse proxy authentication.

Via curl I confirmed that these two requests now work and return 200s:

curl http://localhost:3000/mhl/private -I --header "X-Webauth-User: mhl"
curl http://localhost:3000/mhl/private -I --header "X-Webauth-Email: m.hasnain.lakhani@gmail.com"

Before this commit, the second request did not work.

I also verified that if I provide an invalid email or user,
a 404 is correctly returned as before

Closes #19948

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-09-28 02:00:15 +02:00
Wim
889a41c6a8
Do not allow organisation owners add themselves as collaborator (#20043)
We're already checking for repo owners, but we also need to check for
organisation owners that try to add themselves as collaborator

Closes #17966
2022-09-28 01:25:40 +02:00
HeySora
dabc06d13b
Feature: Case-insensitive "find files in repo" (#21269)
This (short) PR builds upon #15028 and makes the file search
case-insensitive.

Previously, having a file named `TestFile.cs` would not be shown if
`test` was typed in the search box.
This now changes the matching function to be case-insensitive (without
affecting the UI).

The matching function, `strSubMatch`, is only used for this feature (it
has been introduced by #15028), meaning that this PR does not affect the
behaviour of any unrelated functionality of Gitea.
2022-09-28 00:55:15 +02:00
John Olheiser
8cd3237a9e
Better repo API unit checks (#21130)
This PR would presumably
Fix #20522
Fix #18773
Fix #19069
Fix #21077

Fix #13622

-----

1. Check whether unit type is currently enabled
2. Check if it _will_ be enabled via opt
3. Allow modification as necessary


Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-09-28 00:23:58 +02:00
KN4CK3R
904b324716
Fix empty container layer history and UI (#21251)
Fixes #21248
2022-09-27 15:03:24 +02:00
sebastian-sauer
31f934c1d8
Add filetree on left of diff view (#21012)
This PR adds a filetree to the left side of the files/diff view.

Initially the filetree will not be shown and may be shown via a new
"Show file tree" button.

Showing and hiding is using the same icon as github. Folders are
collapsible. On small devices (max-width 991 PX) the file tree will be
hidden.

Close #18192

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-27 13:22:19 +08:00
Tyrone Yeh
525751243e [skip ci] Updated translations via Crowdin 2022-09-27 00:21:05 +00:00
Tyrone Yeh
2d94774c34
Add author search input (#21246)
New author filter in #20578 missing author search input
#20623 lost author, so add this

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-09-26 18:15:12 +08:00
silverwind
ec0a06e52c
Upgrade chroma to v2.3.0 (#21259)
The behaviour of `PreventSurroundingPre` has changed in
https://github.com/alecthomas/chroma/pull/618 so that apparently it now
causes line wrapper tags to be no longer emitted, but we need some form
of indication to split the HTML into lines, so I did what
https://github.com/yuin/goldmark-highlighting/pull/33 did and added the
`nopWrapper`.

Maybe there are more elegant solutions but for some reason, just
splitting the HTML string on `\n` did not work.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-26 13:50:03 +08:00
Julien Palard
2649e7ffbd [skip ci] Updated translations via Crowdin 2022-09-26 00:20:43 +00:00
Julien Palard
ed255fd8a1
Typo in config-cheat-sheet (#21261) 2022-09-25 18:16:46 -04:00
silverwind
3d92ad8eb9
Use native inputs in whitespace dropdown (#20980)
Use native `<input type="radio">` instead of fake icon font. The
`pointer-events: none` is necessary so the link click always takes
effect. Tested in Firefox, Safari and Chrome.

Before:
<img width="305" alt="Screen Shot 2022-08-27 at 20 42 11"
src="https://user-images.githubusercontent.com/115237/187044786-6655c766-c3fb-4672-9e3e-219b3ec4896c.png">

After:
<img width="298" alt="Screen Shot 2022-08-27 at 21 10 05"
src="https://user-images.githubusercontent.com/115237/187044790-33f87741-062e-4744-80b1-d3bd3fd725e3.png">
<img width="302" alt="image"
src="https://user-images.githubusercontent.com/115237/187044872-6c133cea-65ee-4ebd-b18a-a8b38c791565.png">
2022-09-25 22:01:05 +08:00
wxiaoguang
c4742fbea3 [skip ci] Updated licenses and gitignores 2022-09-25 00:20:43 +00:00
wxiaoguang
bb1e0d0aa5
Use en-US as fallback when using other default language (#21200)
Only en-US has complete translations. When use other language as
default, the en-US should still be used as fallback.

Close #21199

### Screenshot


![image](https://user-images.githubusercontent.com/2114189/190882906-b7a83958-0ea2-46c4-9084-42c4f9a239aa.png)

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-09-25 02:00:16 +03:00
KN4CK3R
0c8ce71188
Make NuGet service index publicly accessible (#21242)
Addition to #20734, Fixes #20717

The `/index.json` endpoint needs to be accessible even if the registry
is private. The NuGet client uses this endpoint without
authentification.

The old fix only works if the NuGet cli is used with `--source <name>`
but not with `--source <url>/index.json`.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-24 23:17:08 +08:00
Nulo (he/him)
cca189ef97
Save files in local storage as umask (#21198)
Go creates temporary files as 600, but sometimes we want the group to be able to read them (for example,
for another user to back up the storage)

This PR applies the umask to the renamed tmp files in local storage.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-24 21:04:14 +08:00
Jack Vine
83680c97a7
NPM Package Registry search API endpoint (#20280)
Close #20098, in the NPM registry API, implemented to match what's described by https://github.com/npm/registry/blob/master/docs/REGISTRY-API.md#get-v1search

Currently have only implemented the bare minimum to work with the [Unity Package Manager](https://docs.unity3d.com/Manual/upm-ui.html).

Co-authored-by: Jack Vine <jackv@jack-lemur-suse.cat-prometheus.ts.net>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-24 19:24:33 +08:00
Tyrone Yeh
da0a9ec811 [skip ci] Updated translations via Crowdin 2022-09-24 00:20:52 +00:00
f9d9019720
Fix Comment permission checking 2022-09-23 17:30:44 +00:00
379b9a7dce
Serve issues as ForgeFed tickets 2022-09-23 17:25:13 +00:00
Tyrone Yeh
10228387d2
Added search input field to issue filter (#20623)
Added search input field to issue filter for label and milestone and assignee

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-23 13:23:24 +08:00
silverwind
3f9e323ecd
Various CSS tweaks (#21244)
- Remove arc-green specific rules and instead fix the colors in the base
rules.
- Make file table row border visible on arc-green.
- Remove remnants of fomantic accordeon module that was removed.
2022-09-22 22:00:29 -05:00
KN4CK3R
301d84e83a [skip ci] Updated translations via Crowdin 2022-09-23 00:20:55 +00:00
26f57be49c
Merge remote-tracking branch 'upstream/main' 2022-09-22 23:57:01 +00:00
KN4CK3R
f52fe82add
Use absolute links in feeds (#21229)
fixes #20864

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-09-21 16:51:42 -04:00
delvh
acee32ca09
Prevent invalid behavior for file reviewing when loading more files (#21230)
The problem was that many PR review components loaded by `Show more`
received the same ID as previous batches, which confuses browsers (when
clicked). All such occurrences should now be fixed.

Additionally improved the background of the `viewed` checkbox.

Lastly, the `go-licenses.json` was automatically updated.

Fixes #21228.
Fixes #20681.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-22 01:02:56 +08:00
KN4CK3R
0a9a86b943
Respect REQUIRE_SIGNIN_VIEW for packages (#20873)
Fix #20863

When REQUIRE_SIGNIN_VIEW = true, even with public repositories, you can only see them after you login. The packages should not be accessed without login.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-21 21:01:18 +08:00
wxiaoguang
d9bc6881ef
Make Clone in VSCode link get updated correctly (#21225)
Follow #20557, fix #21224

The `clone_script` will update `.js-clone-url` and related elements,
so it should be put after these elements.
2022-09-21 19:51:10 +08:00
silverwind
399514453e
Configure golangci-lint to show all issues (#21106)
golangci by default [limits](https://golangci-lint.run/usage/configuration/#issues-configuration)
"same issues" to 3 which can be hindering when many issues are present.
Change it to always show all issues.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-20 17:39:00 +08:00
KN4CK3R
1b630ff7cd
Fix user visible check (#21210)
Fixes #21206

If user and viewer are equal the method should return true.
Also the common organization check was wrong as `count` can never be
less then 0.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-09-20 15:59:20 +08:00
Lunny Xiao
a196302472
Fix template bug of admin monitor (#21208)
Fix #21207

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-09-19 20:53:39 -04:00
delvh
0c51595eed
Clarify that ENABLE_SWAGGER only influences the API docs, not the routes (#21215)
Previously, the docs seemed to suggest that you can disable the API
completely by setting `ENABLE_SWAGGER=false`.
This is not the case.
2022-09-20 00:48:48 +02:00
silverwind
d0e3c53815
Enable fluid page layout on medium size viewports (#21178)
Fomantic has abrupt breakpoints at 991px and 768px which leads to
variable amounts of wasted screen space below those breakpoints.
Instead, enable fluid width for all viewport sizes below 1200px.
2022-09-19 14:50:15 +02:00
6543
c5e88fb03d
[API] teamSearch show teams with no members if user is admin (#21204)
close #21176
2022-09-19 20:02:29 +08:00
naoki kuroda
c87e6a89da
Fix typo (#21201)
<!--

Please check the following:

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

-->  
I fixed typo.
2022-09-18 16:13:34 +08:00
wxiaoguang
395f65c65a
Remove unnecessary length check for repo's Description & Website (#21194)
Follows #21119

The manual length check doesn't make sense nowadays:
1. The length check is already done by form's `binding:MaxSize` (then the manual check is unnecessary)
2. The CreateRepository doesn't have such check (then the manual check is inconsistent)

So this PR removes these manual length checks.
2022-09-18 10:35:24 +08:00
wxiaoguang
321964155a
Treat git object mode 40755 as directory (#21195)
Git uses 040000 for tree object, but some users may get 040755 for
unknown reasons

Try to fix #21190
* #21190
2022-09-18 09:31:20 +08:00
Jason Song
34f736ca04
Fix reaction of issues (#21185)
Fix #20860.

`CommentID` in `FindReactionsOptions` should be -1 to search reactions
with zero comment id.


8351172b6e/models/issues/reaction.go (L108-L121)

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-09-17 19:54:03 +08:00
KN4CK3R
43c10def68
Fix CSV diff for added/deleted files (#21189)
Fixes #21184
Regression of #19552

Instead of using `GetBlobByPath` I use the already existing instances.

We need more information from #19530 if that error is still present.
2022-09-17 10:45:32 +08:00
117463ba78
Change Ta180m/activitypub to xy/activitypub 2022-09-16 08:38:55 -05:00
JakobDev
548387b2be
Show label description in comments section (#21156)
The labels in the comment section are currently missing the description that all other labels have.
2022-09-16 20:44:00 +08:00
JakobDev
8351172b6e
Limit length of repo description and repo url input fields (#21119)
Both allow only limited characters. If you input more, you will get a error
message. So it make sense to limit the characters of the input fields.

Slightly relax the MaxSize of repo's Description and Website
2022-09-16 15:19:16 +08:00
silverwind
bdc4c4c379 [skip ci] Updated translations via Crowdin 2022-09-16 00:20:55 +00:00
silverwind
d3050e0d01
File header tweaks (#21175)
- Remove non-matching selector
- Set font-size on parent so `.mono` can correctly reduce it

Before (font subjectively too big):
<img width="1270" alt="Screenshot 2022-09-15 at 19 03 56"
src="https://user-images.githubusercontent.com/115237/190466867-283e9c23-cbfa-457e-8dbe-94902e886cc7.png">

After:
<img width="1266" alt="image"
src="https://user-images.githubusercontent.com/115237/190467290-eb392007-5db2-4ab0-a5be-e7cfe4618dcc.png">
2022-09-15 23:57:42 +03:00
f7dbbf73f6
Remove /integrations directory 2022-09-15 09:24:13 -05:00
47229ea208
Merge remote-tracking branch 'upstream/main' 2022-09-15 09:21:22 -05:00
JakobDev
bf325d4412
Keep path when creating a new branch (#21153)
If you are create a new new branch while viewing file or directory, you
get redirected to the root of the repo. With this PR, you keep your
current path instead of getting redirected to the repo root.
2022-09-15 21:25:16 +08:00
KN4CK3R
ef40324c43
Display image digest for container packages (#21170)
fixes #21160
2022-09-14 22:45:13 +02:00
JakobDev
cad8f1b1fe
Use correct branch for .editorconfig error (#21152)
In #21088 I accidentally forgot to support multiple branches. It always
checks the default branch, no matter on which branch you are working on.
With this fix, it always shows the error from the current branch. Sorry
for that.
2022-09-14 20:54:30 +02:00
wxiaoguang
0ba2f53ca1
Passing command line arguments correctly by string slice (#21168)
Using `append(args, strings.Fields(arg)...)` is dangerous, it may
generate incorrect results.

For example: `arg1 "the dangerous"` will be splitted to 3 arguments:
`arg1`, `"the`, `dangerous"`. In some cases the incorrect arguments may
lead to security problems.
2022-09-14 15:59:52 +02:00
sergemedvid
e07d089be0
Sort branches and tags by date descending (#21136)
This fixes #5709 and #17316 by changing the order of listed branches
and tags to show the ones with latest commits atop.
It's achieved with changing underlying "show-ref" git command with
"for-each-ref" as suggested in https://stackoverflow.com/a/5188364
Also, it's passing format string so the output matches "show-ref"
command output.

close #5709
close #17316
2022-09-14 14:11:24 +02:00
KN4CK3R
5933f04094
Skip dirty check for team forms (#21154)
The dirty check is not usefull for these forms.
2022-09-14 13:24:39 +02:00
zeripath
88c2e24360
Add KaTeX rendering to Markdown. (#20571)
This PR adds mathematical rendering with KaTeX.

The first step is to add a Goldmark extension that detects the latex
(and tex) mathematics delimiters.

The second step to make this extension only run if math support is
enabled.

The second step is to then add KaTeX CSS and JS to the head which will
load after the dom is rendered.

Fix #3445

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-09-14 00:33:37 +08:00
ya
eaa561145a
Update docs comparison.zh-cn.md (#21035)
- Update Chinese translation from comparison.en-us.md
<!--

Please check the following:

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

-->

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-09-13 00:16:32 -04:00
John Olheiser
2854031d87
Use form for admin purge user (#21070)
Fixes #20998

The basic modal actions were set up for basic confirmation-style modals,
however this modal also has a special form input, which instead requires
a form in the modal itself.
The basic modal actions are indirectly controlled by JS and are simple
`<div>` elements, whereas this requires a `<button>` to submit.

This appears to be similar to how we do it in (for example) the repo
deletion modal.

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-09-12 21:52:17 +01:00
42b1bac7a6
Merge remote-tracking branch 'upstream/main' 2022-09-12 15:19:35 -05:00
Blender Defender
defc401b27
Make labels clickable in the comments section. (#21137)
This commit adds the possibility to click the labels in the message
"User added/removed the X label", which will lead to the issues page,
filtered by the clicked label.

This pull requests aims to fix #19768

_I've tried to follow the contribution guidelines as carefully as
possible, but in case I made a mistake: Please correct me._

<!--

Please check the following:

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

-->

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-09-12 13:45:14 -04:00
silverwind
afdab9d8d4
Remove fomantic image module (#21145)
Remove this small, but unnecessary
[module](https://fomantic-ui.com/elements/image.html) and use `img`
selector over previous `.image`. Did a few tests, could not notice any
visual regression.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-09-12 17:08:46 +08:00
JakobDev
fe73246cf9 [skip ci] Updated translations via Crowdin 2022-09-12 00:20:40 +00:00
JakobDev
23fbf5e1ee
Show .editorconfig errors in frontend (#21088)
If the user views the .editorconfig of the Repo, an the the
.editorconfig contains error, those errors are now shown above the file.
2022-09-12 00:16:56 +02:00
silverwind
ec82a24547
Update JS dependencies and lint (#21144)
- Update all JS dependencies minus vue
- Enable one more eslint rule, no new issues with it
- Tested build
2022-09-11 17:34:38 +02:00
wxiaoguang
01eb465c92
Fix PlantUML example in document (#21142)
The document was written before Gitea 1.15. Now Gitea uses `/assets`
sub-directory (#15219).

Close #21023
* #21023
2022-09-11 22:14:46 +08:00
Bo-Yi Wu
24b5a384d2
chore(security): Support Go Vulnerability Management (#21139)
See https://go.dev/security/vuln/

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
2022-09-11 15:02:18 +08:00
silverwind
77c916f6d9 [skip ci] Updated licenses and gitignores 2022-09-11 00:20:43 +00:00
silverwind
754861a020 [skip ci] Updated translations via Crowdin 2022-09-10 00:20:50 +00:00
silverwind
52cbe2bdbc
Improve commit status icons (#21124)
- Show popover on hover/focus (tippy default) instead of click
- If there is only one status, add href to trigger element
- Increase tippy
[interactiveBorder](https://atomiks.github.io/tippyjs/v6/all-props/#interactiveborder),
making it easier to keep interactive tooltips open with sloppy mouse
movement
- Fix a overflow issue in the commit list

Commit list before:

<img width="459" alt="Screen Shot 2022-09-09 at 19 00 01"
src="https://user-images.githubusercontent.com/115237/189405517-68de5a69-e312-4ea2-ab81-87629db6064b.png">

Commit List after:
<img width="475" alt="Screen Shot 2022-09-09 at 19 01 43"
src="https://user-images.githubusercontent.com/115237/189405574-13e84885-9073-4f86-9eeb-d008c1639647.png">

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-09-09 17:03:18 -04:00
neon
0bd59381ad
Center-aligning content of WebAuthN page (#21127)
<!--

Please check the following:

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

-->

This attempts to correct #21126 , where the content of the page is not
center-aligned.

(Note: I think this contains the right commits - but, those other
commits seem superfluous. I'm not sure I've made the pull request
correctly. I don't often use the pull request pattern when working,
opting to use the merge-request pattern instead for my workplace. If
there are any issues, please let me know and I will try to correct
them.)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-09 16:18:54 -04:00
Jason Song
831e981357
Allow poster to choose reviewers (#21084)
Allow the poster of a PR to choose reviewers (add only). 

Solve #20746
2022-09-09 18:27:47 +01:00
silverwind
b5d21c0adf
Generate go-licenses during tidy again (#21108)
We can not have the `frontend` target depend on golang because of they
way drone is set up. Move the `go-licenses` generation back into `tidy`
where it will now also be checked for consistency during `tidy-check`.

(I assume all `main` branch builds should currently fail [like
this](https://drone.gitea.io/go-gitea/gitea/60244/1/11)).

The reasony why it shouldn't be treated the same as for example `go
generate` is because output files are checked in. tidy is imho the
optimal target to run this after.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-09-09 11:33:01 -04:00
Norwin
86ed47e622
Make the vscode clone link respect transport protocol (#20557) 2022-09-09 02:38:51 -04:00
Jason Song
5f127a729e
Fix typo of issue template name (#21117)
Should be

- .gitea/issue_template.md
- .gitea/issue_template.yaml
- .gitea/issue_template.~~md~~yml

Related to #20987, #21030.
2022-09-09 11:22:33 +08:00
Tyrone Yeh
619eed913c [skip ci] Updated translations via Crowdin 2022-09-09 00:20:54 +00:00
Tyrone Yeh
ebafb4b575
Fix pagination limit parameter problem (#21109)
In commits list can use limit parameter to change, but pagination number
is wrong
2022-09-08 11:56:14 -04:00
silverwind
52c2ef7902
Rewrite go license generator in go (#21078)
This removes the JS dependency in the checks pipeline. JSON output is
different because the previous JS did indent the license data
differently and a JSON key was changed, but the end result is the same
as it gets re-indented by wepack.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-09-07 17:35:54 -04:00
KN4CK3R
8b8bdb30fb
Allow uppercase ASCII alphabet in PyPI package names (#21095)
The PyPI name regexp is too restrictive and only permits lowercase characters. This PR adjusts the regexp to add in support for uppercase characters.

Fix #21014
2022-09-07 21:18:51 +01:00
luzpaz
cb3b3e519f
Fix various typos (#21103)
Found via `codespell -q 3 -S
./options/locale,./options/license,./public/vendor,./web_src/fomantic -L
actived,allways,attachements,ba,befores,commiter,pullrequest,pullrequests,readby,splitted,te,unknwon`

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-09-07 14:40:36 -04:00
ya
5c70e6aff0
Update docs issue-pull-request-templates.zh-cn.md (#21030)
Follow #20987, update docs issue-pull-request-templates.zh-cn.md

<!--

Please check the following:

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

-->

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-09-07 14:40:08 -04:00
wxiaoguang
aa5de4dcad
Upgrade the document about how to collect logs for systemd and docker (#21101)
Many users (#21099) do not know how to collect logs if they are using
systemd. This PR makes the document more clear.
2022-09-07 23:58:55 +08:00
Kyle D
7006d8297d [skip ci] Updated translations via Crowdin 2022-09-07 00:20:58 +00:00
Kyle D
6361b48b21
Bump playwright test image to match version in package.json (#21097)
Bump the playwright test image to match version in package.json (so it
doesn't re-download browsers setup)
2022-09-07 00:00:34 +01:00
Tyrone Yeh
f1ea6c92d1
Fix sub folder in repository missing add file dropdown (#21069)
In repository sub folder missing add file dropdown menu, Probably broken since #20602
2022-09-06 08:01:58 +01:00
silverwind
795bd946e2 [skip ci] Updated translations via Crowdin 2022-09-06 00:20:50 +00:00
f0269889c0
Fix build errors 2022-09-05 16:37:56 -05:00
silverwind
7f6306ccd1
Add missing volume to test-e2e (#21079)
Without it, the deps-backend step before is useless as `go test` will not see the files in GOPATH and re-download them.
2022-09-05 17:35:46 -04:00
ec1ffd66e3
Merge remote-tracking branch 'upstream/main' 2022-09-05 16:33:07 -05:00
Lunny Xiao
bc4cce138a
Fix delete user missed some comments (#21067)
There is a mistake in the batched delete comments part of DeleteUser which causes some comments to not be deleted

The code incorrectly updates the `start` of the limit clause resulting in most comments not being deleted.

```go
			if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, start).Find(&comments); err != nil {
```

should be:

```go
			if err = e.Where("type=? AND poster_id=?", issues_model.CommentTypeComment, u.ID).Limit(batchSize, 0).Find(&comments); err != nil {
```

Co-authored-by: zeripath <art27@cantab.net>
2022-09-05 19:41:16 +03:00
John Olheiser
b42aaf29ea
Remove insecure flag from curl (#21074)
Followup to #21071 
Thanks for the catch @wxiaoguang 

[WRT](https://github.com/go-gitea/gitea/pull/21071#discussion_r962706673)

Ref #21071
2022-09-05 14:22:44 +01:00
John Olheiser
0ad0190f69
Update curl usage in API docs (#21071) 2022-09-05 03:22:03 -04:00
zeripath
8080e23c9b
Move go-licenses to generate and separate generate into a frontend and backend component (#21061)
The `go-licenses` make task introduced in #21034 is being run on make vendor
and occasionally causes an empty go-licenses file if the vendors need to
change. This should be moved to the generate task as it is a generated file.

Now because of this change we also need to split generation into two separate 
steps:

1. `generate-backend`
2. `generate-frontend`

In the future it would probably be useful to make `generate-swagger` part of `generate-frontend` but it's not tolerated with our .drone.yml

Ref #21034

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2022-09-05 14:04:18 +08:00
Aaron F
0232601734 [skip ci] Updated translations via Crowdin 2022-09-05 00:20:46 +00:00
Aaron F
3963625b6e
Webhook for Wiki changes (#20219)
Add support for triggering webhook notifications on wiki changes.

This PR contains frontend and backend for webhook notifications on wiki actions (create a new page, rename a page, edit a page and delete a page). The frontend got a new checkbox under the Custom Event -> Repository Events section. There is only one checkbox for create/edit/rename/delete actions, because it makes no sense to separate it and others like releases or packages follow the same schema.

![image](https://user-images.githubusercontent.com/121972/177018803-26851196-831f-4fde-9a4c-9e639b0e0d6b.png)

The actions itself are separated, so that different notifications will be executed (with the "action" field). All the webhook receivers implement the new interface method (Wiki) and the corresponding tests.

When implementing this, I encounter a little bug on editing a wiki page. Creating and editing a wiki page is technically the same action and will be handled by the ```updateWikiPage``` function. But the function need to know if it is a new wiki page or just a change. This distinction is done by the ```action``` parameter, but this will not be sent by the frontend (on form submit). This PR will fix this by adding the ```action``` parameter with the values ```_new``` or ```_edit```, which will be used by the ```updateWikiPage``` function.

I've done integration tests with matrix and gitea (http).

![image](https://user-images.githubusercontent.com/121972/177018795-eb5cdc01-9ba3-483e-a6b7-ed0e313a71fb.png)

Fix #16457

Signed-off-by: Aaron Fischer <mail@aaron-fischer.net>
2022-09-04 20:54:23 +01:00
Eng Zer Jun
8b0aaa5f86
test: use T.TempDir to create temporary test directory (#21043)
A testing cleanup. 

This pull request replaces `os.MkdirTemp` with `t.TempDir`. We can use the `T.TempDir` function from the `testing` package to create temporary directory. The directory created by `T.TempDir` is automatically removed when the test and all its subtests complete. 

This saves us at least 2 lines (error check, and cleanup) on every instance, or in some cases adds cleanup that we forgot.

Reference: https://pkg.go.dev/testing#T.TempDir

```go
func TestFoo(t *testing.T) {
	// before
	tmpDir, err := os.MkdirTemp("", "")
	require.NoError(t, err)
	defer os.RemoveAll(tmpDir)

	// now
	tmpDir := t.TempDir()
}
```

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2022-09-04 16:14:53 +01:00
zeripath
c722a26e7e
Set uploadpack.allowFilter etc on gitea serv to enable partial clones with ssh (#20902)
When setting.Git.DisablePartialClone is set to false then the web server will add filter support to web http. It does this by using`-c` command arguments but this will not work on gitea serv as the upload-pack and receive-pack commands do not support this.
    
Instead we move these options into the .gitconfig instead.

Fix #20400

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-09-04 16:13:23 +01:00
qwerty287
be14e79e98
Fix 500 on time tracking in timeline API (#21052)
Fix #21041
2022-09-04 15:01:23 +01:00
zeripath
e6b3be4608
Add more checks in migration code (#21011)
When migrating add several more important sanity checks:

* SHAs must be SHAs
* Refs must be valid Refs
* URLs must be reasonable

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
2022-09-04 13:47:56 +03:00
Jason Song
93a610a819
Fill the specified ref in webhook test payload (#20961)
The webhook payload should use the right ref when it‘s specified in the testing request.

The compare URL should not be empty, a URL like `compare/A...A` seems useless in most cases but is helpful when testing.
2022-09-04 12:18:07 +03:00
silverwind
0887459ac6 [skip ci] Updated licenses and gitignores 2022-09-04 00:20:43 +00:00
silverwind
49efd1fb96
Add go licenses to licenses.txt (#21034)
`make go-licenses` will generate `assets/go-licenses.json` which is then included in the webpack build. 

This step depends on both go and node being present, so unfortunately, I could not automate the generation by hooking it up to `tidy` as that target is triggered on CI where we do not have a docker image with both go an node.

It should be ran from time to time, ideally after each go mod update.
2022-09-04 00:20:46 +02:00
Cypherpunk Samurai
82c6f7bf4a
Added docs for agit-setup (#21027)
This PR Adds Documentation for the new Agit feature. Agit allows creating PR directly while pushing code.

Close #21018

Co-authored-by: CypherpunkSamurai <CypherpunkSamurai@users.noreply.github.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: a1012112796 <1012112796@qq.com>
2022-09-03 19:52:19 +02:00
zeripath
58a80ba69c
Add another index for Action table on postgres (#21033)
In #21031 we have discovered that on very big tables postgres will use a
search involving the sort term in preference to the restrictive index.

Therefore we add another index for postgres and update the original migration.

Fix #21031

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-09-03 17:27:59 +01:00
KN4CK3R
5bc73ca666
Delete unreferenced packages when deleting a package version (#20977)
Delete a package if its last version got deleted. Otherwise removing the owner works only after the clean up job ran.

Fix #20969
2022-09-03 17:01:00 +01:00
silverwind
1670109b91
Improve arc-green code theme (#21039)
- Increase contrasts overall
- Add various missing theme classes
- Ensure strings and constants are colored the same across languages

Before:
<img width="575" alt="Screen Shot 2022-09-03 at 15 20 19" src="https://user-images.githubusercontent.com/115237/188272267-c3af3de0-a1d9-4a80-a3ab-278e9b04cb44.png">
<img width="705" alt="Screen Shot 2022-09-03 at 15 10 12" src="https://user-images.githubusercontent.com/115237/188272194-dc40ac7d-1629-44a0-a881-5f0922285195.png">

After:
<img width="579" alt="Screen Shot 2022-09-03 at 15 19 31" src="https://user-images.githubusercontent.com/115237/188272275-55b87bc7-1122-410f-9250-14cf9e973124.png">
<img width="703" alt="image" src="https://user-images.githubusercontent.com/115237/188272715-a5fcd180-c5dc-4303-8e77-de785d5e0937.png">
2022-09-03 23:24:18 +08:00
Tyrone Yeh
e7b5bf0d96
Add down key check has tribute container (#21016)
Fixes an issue where users would not be able to select by pressing the down arrow when using @TAG above a message

Bug videos:

https://user-images.githubusercontent.com/1255041/188095999-c4ccde18-e53b-4251-8a14-d90c4042d768.mp4
2022-09-03 10:43:27 +01:00
zeripath
de7b87fbc2
Do not add links to Posters or Assignees with ID < 0 (#20577)
There are several places in templates/repo/issue/view_content/comments.tmpl where links are made to Posters or Assignees who are Ghosts or have IDs <0.

Fix #20559

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-09-03 10:33:34 +01:00
JakobDev
18046eb91e [skip ci] Updated translations via Crowdin 2022-09-03 00:21:09 +00:00
JakobDev
96a9e15dff
Show language name on hover (#20923)
Each repo has a bar which shows the used programming languages. If you want to know, what language is behind a color, you need to click the bar. With this PR, you just need to hover over the color the view the name.
2022-09-02 23:06:54 +01:00
José Carlos
b8818a1c68
fix: PackageMetadataVersion deps (#21017)
Set DevDependencies, PeerDependencies & OptionalDependencies in npm package metadatas

Fix  #21013
2022-09-02 23:00:18 +01:00
wxiaoguang
2dbed4bd97
Fix the quick-submit for pending review comment (#20992)
If there is only one "Add comment" button (when there are pending review comments), the quick-submit should submit the form with is_review=true even if the "Add comment" button is not really clicked.

Close  #20990
2022-09-02 22:59:10 +01:00
Kyle D
c8ded77680
Kd/ci playwright go test (#20123)
* Add initial playwright config

* Simplify Makefile

* Simplify Makefile

* Use correct config files

* Update playwright settings

* Fix package-lock file

* Don't use test logger for e2e tests

* fix frontend lint

* Allow passing TEST_LOGGER variable

* Init postgres database

* use standard gitea env variables

* Update playwright

* update drone

* Move empty env var to commands

* Cleanup

* Move integrations to subfolder

* tests integrations to tests integraton

* Run e2e tests with go test

* Fix linting

* install CI deps

* Add files to ESlint

* Fix drone typo

* Don't log to console in CI

* Use go test http server

* Add build step before tests

* Move shared init function to common package

* fix drone

* Clean up tests

* Fix linting

* Better mocking for page + version string

* Cleanup test generation

* Remove dependency on gitea binary

* Fix linting

* add initial support for running specific tests

* Add ACCEPT_VISUAL variable

* don't require git-lfs

* Add initial documentation

* Review feedback

* Add logged in session test

* Attempt fixing drone race

* Cleanup and bump version

* Bump deps

* Review feedback

* simplify installation

* Fix ci

* Update install docs
2022-09-02 15:18:23 -04:00
Jason Song
5710ff343c
chore: add myself to maintainers (#21028) 2022-09-02 20:23:48 +08:00
Jason Song
84447df4d3
Support Issue forms and PR forms (#20987)
* feat: extend issue template for yaml

* feat: support yaml template

* feat: render form to markdown

* feat: support yaml template for pr

* chore: rename to Fields

* feat: template unmarshal

* feat: split template

* feat: render to markdown

* feat: use full name as template file name

* chore: remove useless file

* feat: use dropdown of fomantic ui

* feat: update input style

* docs: more comments

* fix: render text without render

* chore: fix lint error

* fix: support use description as about in markdown

* fix: add field class in form

* chore: generate swagger

* feat: validate template

* feat: support is_nummber and regex

* test: fix broken unit tests

* fix: ignore empty body of md template

* fix: make multiple easymde editors work in one page

* feat: better UI

* fix: js error in pr form

* chore: generate swagger

* feat: support regex validation

* chore: generate swagger

* fix: refresh each markdown editor

* chore: give up required validation

* fix: correct issue template candidates

* fix: correct checkboxes style

* chore: ignore .hugo_build.lock in docs

* docs: separate out a new doc for merge templates

* docs: introduce syntax of yaml template

* feat: show a alert for invalid templates

* test: add case for a valid template

* fix: correct attributes of required checkbox

* fix: add class not-under-easymde for dropzone

* fix: use more back-quotes

* chore: remove translation in zh-CN

* fix EasyMDE statusbar margin

* fix: remove repeated blocks

* fix: reuse regex for quotes

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-09-02 15:58:49 +08:00
silverwind
b7a4b45ff8
Include go.mod in gomod-check and rename to tidy-check (#21025)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-09-02 09:58:09 +08:00
zeripath
6b7bb419ed [skip ci] Updated translations via Crowdin 2022-09-02 00:20:55 +00:00
zeripath
38a4961f9e
Update a few go dependencies (#21022)
There are a lot of go dependencies that appear old and we should update them.

The following packages have been updated:

* codeberg.org/gusted/mcaptcha
* github.com/markbates/goth
* github.com/buildkite/terminal-to-html
* github.com/caddyserver/certmagic
* github.com/denisenkom/go-mssqldb
* github.com/duo-labs/webauthn
* github.com/editorconfig/editorconfig-core-go/v2
* github.com/felixge/fgprof
* github.com/gliderlabs/ssh
* github.com/go-ap/activitypub
* github.com/go-git/go-git/v5
* github.com/go-ldap/ldap/v3
* github.com/go-swagger/go-swagger
* github.com/go-testfixtures/testfixtures/v3
* github.com/golang-jwt/jwt/v4
* github.com/klauspost/compress
* github.com/lib/pq
* gitea.com/lunny/dingtalk_webhook - instead of github.com
* github.com/mattn/go-sqlite3
* github/matn/go-isatty
* github.com/minio/minio-go/v7
* github.com/niklasfasching/go-org
* github.com/prometheus/client_golang
* github.com/stretchr/testify
* github.com/unrolled/render
* github.com/xanzy/go-gitlab
* gopkg.in/ini.v1

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-09-01 23:13:17 +02:00
Lunny Xiao
d74390ee39 [skip ci] Updated translations via Crowdin 2022-09-01 00:20:54 +00:00
Lunny Xiao
de5b8cfad8
Fix missed sort bug (#20996)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-31 14:15:12 -04:00
ya
230176db5e
Fix typo (#21004)
Missing directory

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-31 12:47:34 -04:00
silverwind
647b2649b1
Make sure fmt catches all templates (#20979)
* Make sure fmt catches all templates

Make's `wildcard` is not recursive so it missed many template files, fix
that by using `find`.

* Update Makefile
2022-08-31 23:58:54 +08:00
silverwind
c80ca94ab1
Remove black labels and CSS cleanup (#21003)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-31 17:04:41 +08:00
John Olheiser
a48d6ba4b4
Go 1.19 format (#20758)
* 1.19 gofumpt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Change CSV test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Commit whitespace fixes from @zeripath

Co-authored-by: zeripath <art27@cantab.net>

* Update emoji

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* bump swagger & fix generate-swagger

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-08-30 21:15:45 -05:00
JonRB
3edc14b687 [skip ci] Updated translations via Crowdin 2022-08-31 00:21:00 +00:00
JonRB
e4addac26e
Fix typo (#20993) 2022-08-29 17:20:20 +02:00
Igor Rzegocki
354ebe4610
fix broken insecureskipverify handling in rediss connection uris (#20967)
fixes regression #19213
2022-08-29 16:38:49 +02:00
KN4CK3R
4bd3b05b62
Redirect if user does not exist (#20981) 2022-08-29 15:44:39 +02:00
Peter Gardfjäll
4562d40fce
fix hard-coded timeout and error panic in API archive download endpoint (#20925)
* fix hard-coded timeout and error panic in API archive download endpoint

This commit updates the `GET /api/v1/repos/{owner}/{repo}/archive/{archive}`
endpoint which prior to this PR had a couple of issues.

1. The endpoint had a hard-coded 20s timeout for the archiver to complete after
   which a 500 (Internal Server Error) was returned to client. For a scripted
   API client there was no clear way of telling that the operation timed out and
   that it should retry.

2. Whenever the timeout _did occur_, the code used to panic. This was caused by
   the API endpoint "delegating" to the same call path as the web, which uses a
   slightly different way of reporting errors (HTML rather than JSON for
   example).

   More specifically, `api/v1/repo/file.go#GetArchive` just called through to
   `web/repo/repo.go#Download`, which expects the `Context` to have a `Render`
   field set, but which is `nil` for API calls. Hence, a `nil` pointer error.

The code addresses (1) by dropping the hard-coded timeout. Instead, any
timeout/cancelation on the incoming `Context` is used.

The code addresses (2) by updating the API endpoint to use a separate call path
for the API-triggered archive download. This avoids producing HTML-errors on
errors (it now produces JSON errors).

Signed-off-by: Peter Gardfjäll <peter.gardfjall.work@gmail.com>
2022-08-29 11:45:20 +02:00
KN4CK3R
41c76ad714
Add support for Vagrant packages (#20930)
* Add support for Vagrant boxes.

* Add authentication.

* Add tests.

* Add integration tests.

* Add docs.

* Add icons.

* Update routers/api/packages/api.go

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2022-08-29 15:04:45 +08:00
JonRB
8a66b01e55 [skip ci] Updated translations via Crowdin 2022-08-29 00:20:41 +00:00
JonRB
8bbb622bb4
Add instructions how to add service dependencies (#20968) 2022-08-28 23:28:42 +08:00
zeripath
bb0ff77e46
Share HTML template renderers and create a watcher framework (#20218)
The recovery, API, Web and package frameworks all create their own HTML
Renderers. This increases the memory requirements of Gitea
unnecessarily with duplicate templates being kept in memory.

Further the reloading framework in dev mode for these involves locking
and recompiling all of the templates on each load. This will potentially
hide concurrency issues and it is inefficient.

This PR stores the templates renderer in the context and stores this
context in the NormalRoutes, it then creates a fsnotify.Watcher
framework to watch files.

The watching framework is then extended to the mailer templates which
were previously not being reloaded in dev.

Then the locales are simplified to a similar structure.

Fix #20210 
Fix #20211
Fix #20217

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-28 10:43:25 +01:00
silverwind
c21d6511a8 [skip ci] Updated licenses and gitignores 2022-08-28 00:20:43 +00:00
silverwind
532c223c45 [skip ci] Updated translations via Crowdin 2022-08-27 00:20:55 +00:00
silverwind
94549bcd11
Change review buttons to icons to make space for text (#20934)
The layout on the review code view was broken depending on length of the text. Change all three buttons to icons with tooltip to make more space for these long texts.

Fixes: #20922
2022-08-26 18:49:40 +02:00
Lunny Xiao
b0c62846f1
Fix download archiver of a commit (#20962) 2022-08-26 15:07:06 +02:00
silverwind
6c4688e1b1
Add whitespace removal inside template curly brackes (#20853) 2022-08-25 17:55:52 -04:00
Gusted
27ac65a124
Only show relevant repositories on explore page (#19361)
Adds a new option to only show relevant repo's on the explore page, for bigger Gitea instances like Codeberg this is a nice option to enable to make the explore page more populated with unique and "high" quality repo's. A note is shown that the results are filtered and have the possibility to see the unfiltered results.

Co-authored-by: vednoc <vednoc@protonmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
2022-08-25 20:38:41 +02:00
KN4CK3R
dc0253b063
Replace ServeStream with ServeContent (#20903)
* Replace ServeStream with ServeContent.

* Update modules/timeutil/timestamp.go

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-25 12:05:21 -04:00
silverwind
5e232e86de
Update JS dependencies (#20950)
- Update all JS dependencies minus vue
- Tested easymde, monaco, swagger
2022-08-25 16:11:12 +02:00
Jason Song
9e3aa4d16d
chore: remove broken gitea-format-imports (#20952) 2022-08-25 16:53:48 +08:00
soumyadey
a2db81063b
Fix input.value attr for RequiredClaimName/Value (#20946)
Values set for RequiredClaimName and RequiredClaimValue do not show up on UI.
Fix typo `values` to `value`.
2022-08-25 07:17:03 +01:00
Lunny Xiao
1d8543e7db
Move some files into models' sub packages (#20262)
* Move some files into models' sub packages

* Move functions

* merge main branch

* Fix check

* fix check

* Fix some tests

* Fix lint

* Fix lint

* Revert lint changes

* Fix error comments

* Fix lint

Co-authored-by: 6543 <6543@obermui.de>
2022-08-25 10:31:57 +08:00
xinyu
4a4bfafa23 [skip ci] Updated translations via Crowdin 2022-08-25 00:20:57 +00:00
xinyu
849b7c5558
docs[zh-cn]: Install on Kubernetes (#20874)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-24 21:26:41 +08:00
zeripath
a4a6a5987b
Return 404 NotFound if requested attachment does not exist (#20886)
Add code to test if GetAttachmentByID returns an ErrAttachmentNotExist error
and return NotFound instead of InternalServerError

Fix #20884

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-24 13:36:21 +01:00
Jason Song
15b189b570
Avoid frequent string2bytes conversions (#20940)
Fix #20939
2022-08-24 12:50:13 +01:00
KN4CK3R
9e0c43777e
Display total blob size of a package version. (#20927)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-24 13:48:33 +08:00
KN4CK3R
103b94f96e
Display all files. (#20917)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-23 21:39:25 -04:00
KN4CK3R
1939e87348
Enhance package date display (#20928)
* Use better date display.

* Update templates/package/view.tmpl
2022-08-23 21:39:00 -04:00
silverwind
7d1765e940 [skip ci] Updated translations via Crowdin 2022-08-24 00:20:55 +00:00
silverwind
2b0093cb9f
Forbid HTML string tooltips (#20935)
Tippy allows HTML strings to be passed as content but we do not use this
feature (we do pass HTML only as Element), so it's better to disable it
for increased security.

Ref: https://atomiks.github.io/tippyjs/v6/html-content/#string
2022-08-23 16:17:42 -04:00
zeripath
aa2e473991
Set no-tags in git fetch on compare (#20893)
* Set no-tags in git fetch on compare

In the compare endpoint the git fetch is restricted to a certain branch however,
this does not completely prevent tag acquisition/pollution as git fetch will collect
any tags on that branch.

This causes pollution of the tag namespace and could cause confusion by users.

This PR adds `--no-tags` to the `git fetch` call.

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

* Update modules/git/repo_compare.go

* Update modules/git/repo_compare.go

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-23 14:12:43 -04:00
Kiara Grouwstra
3d870f6dde
Update comparison.en-us.md: link subgroups issue (#20905)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-23 10:13:41 -04:00
silverwind
56220515fc
Enable contenthash in filename for dynamic assets (#20813)
This should solve the main problem of dynamic assets getting stale after
a version upgrade. Everything not affected will use query-string based
cache busting, which includes files loaded via HTML or worker scripts.
2022-08-23 20:58:04 +08:00
oliverpool
0a9ed54abb
refactor webhook *EditPost (#20780) 2022-08-23 02:52:35 -04:00
John Olheiser
fa8fc5d3a7
Changelog 1.17.1 (#20833) (#20919)
* Changelog 1.17.1 (#20833)

* Changelog 1.17.1

 ## [1.17.1](https://github.com/go-gitea/gitea/releases/tag/1.17.1) - 2022-08-17

* SECURITY
  * Correctly escape within tribute.js (#20831) (#20832)
* FEATURES
  * Add support for NuGet API keys (#20721) (#20734)
* ENHANCEMENTS
  * Display project in issue list (#20583)
  * Add disable download source configuration (#20548) (#20579)
* BUGFIXES
  * Use the total issue count for UI (#20785) (#20827)
  * Add proxy host into allow list (#20798) (#20819)
  * Add missing translation for queue flush workers (#20791) (#20792)
  * Improve comment header for mobile (#20781) (#20789)
  * Fix git.Init for doctor sub-command (#20782) (#20783)
  * Check webhooks slice length before calling xorm (#20642) (#20768)
  * Remove manual rollback for failed generated repositories (#20639) (#20762)
  * Use correct field name in npm template (#20675) (#20760)
  * Keep download count on Container tag overwrite (#20728) (#20735)
  * Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702) (#20707)
  * Use request timeout for git service rpc (#20689) (#20693)
  * Send correct NuGet status codes (#20647) (#20677)
  * Use correct context to get package content (#20673) (#20676)
  * Fix the JS error "EventSource is not defined" caused by some non-standard browsers (#20584) (#20663)
  * Add default commit messages to PR for squash merge (#20618) (#20645)
  * Fix package upload for files >32mb (#20622) (#20635)
  * Fix the new-line copy-paste for rendered code (#20612)
  * Clean up and fix clone button script (#20415 & #20600) (#20599)
  *  Fix default merge style (#20564) (#20565)
  * Add repository condition for issue count (#20454) (#20496)
* MISC
  * Make branch icon stand out more (#20726) (#20774)
  * Fix loading button with invalid form (#20754) (#20759)
  * Add username check to doctor (#20140) (#20671)
  * Enable Wire 2 for Internal SSH Server (#20616) (#20617)
  *  Fix SecToTime edge-cases (#20610) (#20611)

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

* Apply suggestions from code review

Co-authored-by: John Olheiser <john+github@jolheiser.com>

* Update CHANGELOG.md

Co-authored-by: delvh <dev.lh@web.de>

* Update CHANGELOG.md

* Update CHANGELOG.md

* update changelog

* Update CHANGELOG.md

Co-authored-by: John Olheiser <john+github@jolheiser.com>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: John Olheiser <john+github@jolheiser.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>

* update changelog

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-23 10:02:16 +08:00
Enrico
502f7526d0
Fix typo in backup documentation (pgdump->pg_dump) (#20913)
This PR fixes a small typo in the backup documentation: `pgdump` command is wrong, the correct name for the backup software in PostgreSQL is `pg_dump`
2022-08-22 19:39:59 +01:00
Gusted
2e957e7ebb
Fix repository tests 2022-08-22 19:56:41 +02:00
Gusted
45324e169f
Add todo 2022-08-22 19:50:47 +02:00
Gusted
2373b4177a
Add paginition to Person's outbox 2022-08-22 19:37:04 +02:00
Gusted
5ad0387fbd
Add copyright to test file 2022-08-22 19:37:04 +02:00
73284dbf0b
Add authorize_interaction case for Tickets 2022-08-22 12:29:16 -05:00
c0efdedaa9
Fix typo for JSONUnmarshalerFn description comment 2022-08-22 12:10:02 -05:00
ee85f7d957
Use the Repository AttributedTo to get owner IRI 2022-08-22 12:09:26 -05:00
Gusted
f1e61af242
Fix another linting error 2022-08-22 19:02:01 +02:00
Gusted
1bc8e67e9c
Fix linting errors (errcheck) 2022-08-22 18:59:45 +02:00
Gusted
819e495dc0
Make gofmt happy 2022-08-22 18:48:17 +02:00
Gusted
b9dd4a2f5f
Make revive linter happy 2022-08-22 18:31:39 +02:00
Gusted
18809f811d
Make the frontend linter happy 2022-08-22 18:29:08 +02:00
zeripath
9d6a2034bc
Increase Content field size of gpg_key and public_key to MEDIUMTEXT (#20896)
Unfortunately some keys are too big to fix within the 65535 limit of TEXT on MySQL
this causes issues with these large keys.

Therefore increase these fields to MEDIUMTEXT.

Fix #20894

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-22 14:32:28 +01:00
CodeDoctor
aedfc923ad
Improve single repo action for issue and pull requests (#20730)
Related to #20650.

This will fix the behavior of the single repo action for pull requests and disables the button for other screens that don't have a single repo action currently.
2022-08-22 13:51:48 +01:00
Gusted
353a5331d5
Remove deprecated licenses (#20222) 2022-08-22 00:33:01 -04:00
techknowlogick
7854c447d9
update current stable version 2022-08-21 22:14:13 -04:00
Gary Wang
585e80a7fa [skip ci] Updated translations via Crowdin 2022-08-22 00:20:55 +00:00
Gary Wang
36dfe544f4
Fix mirror address setting not working (#20850)
This patch fixes the issue that the mirror address field is ignored from the repo setting form.
2022-08-21 19:23:50 +01:00
zeripath
943753f560
Support Proxy protocol (#12527)
This PR adds functionality to allow Gitea to sit behind an
HAProxy and HAProxy protocolled connections directly.

Fix #7508

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-21 19:20:43 +01:00
Gusted
0b4c166e8a
Fix SQL Query for SearchTeam (#20844)
- Currently the function takes in the `UserID` option, but isn't being
used within the SQL query. This patch fixes that by checking that only
teams are being returned that the user belongs to.

Fix #20829

Co-authored-by: delvh <dev.lh@web.de>
2022-08-21 17:24:05 +01:00
b3c065ce80
Refactor RepoInbox to use On functions instead of type assertions 2022-08-21 10:22:42 -05:00
zeripath
6d3181406d
Double check CloneURL is acceptable (#20869)
Some Migration Downloaders provide re-writing of CloneURLs that may point to
unallowed urls. Recheck after the CloneURL is rewritten.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-21 14:28:15 +01:00
wxiaoguang
6784a707d1
Fix graceful doc (#20883) 2022-08-21 02:50:27 -04:00
zeripath
11bae50484
Pad GPG Key ID with preceding zeroes (#20878) 2022-08-21 02:50:15 -04:00
27cda2fcd4
Implement JSONLoad, To, and On functions for ForgeFed types 2022-08-20 23:07:11 -05:00
JonRB
0ee96da052 [skip ci] Updated translations via Crowdin 2022-08-21 00:20:58 +00:00
JonRB
cb37c6ba5c
call builtinUnused() if internal SSH is disabled (#20877)
The graceful manager waits for 4 listeners to be created or to be told that they are not needed. If it is not told about them it will indefinitely and timeout. 

This leads to SVC hosts not being told of being in the readyState but on Unix would lead to the termination of the process.

There was an unfortunate regression in #20299 which missed this subtly and in the case whereby SSH is disabled the `builtinUnused()` is not called.

This PR adds a call to `builtinUnused()` when not using the builtin ssh to allow `createServerWaitGroup.Done()` to be called. 

In addition it was noted that the if/else clauses for timeout informing of the SVC host were in the wrong order. These have been swapped.

Fix #20609
2022-08-20 22:09:41 +01:00
Gusted
3d52edc7a4
Don't open new page for ext wiki on same repository (#20725)
- When the external wiki has been set to a file on the repository, don't
open the page on a tab.
- Resolves #20657
2022-08-20 15:47:04 +01:00
wxiaoguang
8cceee4084 [skip ci] Updated translations via Crowdin 2022-08-20 00:20:56 +00:00
6a6c6b3481
Merge remote-tracking branch 'upstream/main' 2022-08-19 17:46:12 -05:00
wxiaoguang
7258a124af
Fix the mode of custom dir to 0700 in docker-rootless (#20861) 2022-08-19 11:05:07 -04:00
wxiaoguang
2dd0b88a93
Fix UI mis-align for PR commit history (#20845) 2022-08-19 15:01:06 +08:00
Gusted
fad0e7a497
Fix create repository page's help text (#20810) 2022-08-18 22:13:08 -04:00
zeripath
fc4680ea71
In PushMirrorsIterate and MirrorsIterate if limit is negative do not set it (#20837) 2022-08-18 22:12:00 -04:00
zeripath
3aa5749d53
Disable doctor logging on panic (#20847)
* Disable doctor logging on panic

If permissions are incorrect for writing to the doctor log simply disable the log file
instead of panicing.

Related #20570

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

* Update cmd/doctor.go

* Update cmd/doctor.go

Co-authored-by: delvh <dev.lh@web.de>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-18 21:27:27 -04:00
zeripath
68f3aaee80
Remove calls to load Mirrors in user.Dashboard (#20855)
Whilst looking at #20840 I noticed that the Mirrors data doesn't appear
to be being used therefore we can remove this and in fact none of the
related code is used elsewhere so it can also be removed.

Related #20840
Related #20804

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-18 20:53:31 -04:00
techknowlogick
3d12018a74
switch to node18 for snapcraft 2022-08-18 12:25:50 -04:00
zeripath
0724ca451e
Prevent 500 is head repo does not have PullRequest unit in IsUserAllowedToUpdate (#20839)
Some repositories do not have the PullRequest unit present in their configuration
and unfortunately the way that IsUserAllowedToUpdate currently works assumes
that this is an error instead of just returning false.

This PR simply swallows this error allowing the function to return false.

Fix #20621

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-08-18 13:31:15 +03:00
Lunny Xiao
999392f6a5
Fix owners cannot create organization repos bug (#20841)
* Fix owners cannot create organization repos bug

* Fix api

* Update routers/api/v1/org/team.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-08-18 11:58:21 +03:00
Lunny Xiao
5d0f643461
Fix migration file name (#20843) 2022-08-18 13:38:59 +08:00
zeripath
03df7d0452
Check Mirror exists before linking its Repo (#20840)
In MirrorRepositoryList.loadAttributes there is some code to load the Mirror entries
from the database. This assumes that every Repository which has IsMirror set has
a Mirror associated in the DB. This association is incorrect in the case of
Mirror repository under creation when there is no Mirror entry in the DB until
completion.

Unfortunately LoadAttributes makes this incorrect assumption and presumes that a
Mirror will always be loaded. This then causes a panic.

This PR simply double checks if there a Mirror before attempting to link back to
its Repo. Unfortunately it should be expected that there may be other cases where
this incorrect assumption causes further problems.

Fix #20804

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-18 10:22:56 +08:00
techknowlogick
4a797f8fab [skip ci] Updated translations via Crowdin 2022-08-18 00:21:28 +00:00
techknowlogick
d8e6c99125
Add badge capabilities to users (#20607)
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-08-18 02:25:25 +03:00
xinyu
208b4ee417
docs[zh-cn]: Managing Deployments With Environment Variables (#20817)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-17 15:44:07 -04:00
zeripath
87ca739a3f
Correctly escape within tribute.js (#20831)
When writing html in tribute.js ensure that strings are properly escaped.

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-17 15:43:53 -04:00
Balki
c138e76c1c
Fix panic when an invalid oauth2 name is passed (#20820) 2022-08-17 14:25:28 -04:00
parnic
7503cd35c2
Use the total issue count for UI (#20785)
* Use the total issue count for UI

This fixes a problem where the "All" line item on the Issues or Pull Requests page was only showing the count of the selected repos instead of the total of all issues/prs in all repos.

The "total number of shown issues" number is now stashed in a different context variable in case it wants to be used by the frontend later. It's currently not being used.

Fixes #20574

* Remove unused context variable

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-17 21:13:41 +08:00
Lunny Xiao
a4e91c4197
Add proxy host into allow list (#20798)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-16 20:15:54 -04:00
silverwind
1e0fcd1450
Fix tooltip init after review (#20814)
* Fix tooltip init after review

Previous code passed a jQuery collection which initTooltip couldn't
handle. Instead, iterate the individial matched elements and add a
dollar to the variable name to make it clear it's jQuery.

Fixes: https://github.com/go-gitea/gitea/issues/20809
2022-08-17 00:05:40 +03:00
Will Norris
82f89ff996
auth/reverseproxy: Add support for full name (#20776)
This adds support for getting the user's full name from the reverse
proxy in addition to username and email.

Tested locally with caddy serving as reverse proxy with Tailscale
authentication.

Signed-off-by: Will Norris <will@tailscale.com>

Signed-off-by: Will Norris <will@tailscale.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-16 14:30:27 +08:00
Lunny Xiao
1f146090ec
Add migrate repo archiver and packages storage support on command line (#20757)
* Add migrate repo archiver and packages storage support on command line

* Fix typo

* Use stdCtx

* Use packageblob and fix command description

* Add migrate packages unit tests

* Fix comment year

* Fix the migrate storage command line description

* Update cmd/migrate_storage.go

Co-authored-by: zeripath <art27@cantab.net>

* Update cmd/migrate_storage.go

Co-authored-by: zeripath <art27@cantab.net>

* Update cmd/migrate_storage.go

Co-authored-by: zeripath <art27@cantab.net>

* Fix test

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2022-08-16 12:05:15 +08:00
Lunny Xiao
86c85c19b6
Refactor AssertExistsAndLoadBean to use generics (#20797)
* Refactor AssertExistsAndLoadBean to use generics

* Fix tests

Co-authored-by: zeripath <art27@cantab.net>
2022-08-16 10:22:25 +08:00
MaeIsBad
e3308a092a [skip ci] Updated translations via Crowdin 2022-08-16 00:20:56 +00:00
6b73c097ed
Download avatar from URL and set it with user_service.UploadAvatar 2022-08-15 12:00:14 -05:00
d945e6ac72
Start working on Ticket object endpoint implementation 2022-08-15 11:15:21 -05:00
0b97c6aa69
Cache remote user public keys 2022-08-15 11:14:48 -05:00
MaeIsBad
f158840606
Fix the commit diff route (#20796)
Gitea used to return 500 on the /:user/:repo/:commit route due to locale
being undefined in the escape_title template.

Co-authored-by: bad <badatnames@tutanota.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2022-08-15 14:13:08 +08:00
xpy
efaa9958b5
Fix push mirror address backend get error Address cause setting page display error (#20593)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-14 23:12:01 -04:00
zeripath
58a4407acb
Remove follow from commits by file (#20765)
The use of `--follow` makes getting these commits very slow on large repositories
as it results in searching the whole commit tree for a blob.

Now as nice as the results of `--follow` are, I am uncertain whether it is really
of sufficient importance to keep around.

Fix #20764

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

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-14 21:22:13 -04:00
Gusted
7ae297800e [skip ci] Updated translations via Crowdin 2022-08-15 00:20:43 +00:00
Gusted
293544587c
Fix make watch for generated files (#20794)
- Don't rebuild the binary when generated files are updated, which is the
case by-default when running `make watch`.
2022-08-14 22:22:09 +01:00
Gusted
4f56ab3bf3
Add missing translation for queue flush workers (#20791)
- Add a missing translation key and value for the flush worker indication
- Resolves #20770
2022-08-14 20:28:19 +01:00
PEN²
cf0fef2c30
Update zh-cn translation for Installation from source (#20772)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-14 12:03:12 -04:00
Gusted
6a43d62e8b
Improve comment header for Mobile (#20781)
- Since
b9e8fa5beb
the avatar will be inlined into the comment header, so there's more room
for the actual comment container(thus more text per line in the comment
body). However this didn't take into consideration that the flex didn't
allow any wrapping and thus was shrinking the avatar. Well this isn't a
perfect solution, as you ideally all want these elements to be
individually wrapped(such that `comment-header-right` can be on the same
line as `comment-header-left`, which now causes a new line in certain
situations). It's a better solution than the current CSS and to not
mess with the desktop CSS/HTML.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2022-08-14 12:02:59 -04:00
PEN²
070e5d4a4a
Add myself to MAINTAINERS (#20786)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-14 13:08:53 +03:00
Frank
cc649f0cb3 [skip ci] Updated licenses and gitignores 2022-08-14 00:20:44 +00:00
Frank
1f0638747b
Preserve unix socket file (#20499)
By default Gitea will always unlink any sockets that are provided using the `LISTEN_FDS` environment variable. This is because it uses this variable to handle passing when it is doing a graceful restart. However, this same mechanism is used by systemd - which explicitly expects that passed in sockets should not be unlinked by the receiving process. 

This PR adjusts Gitea's graceful restart mechanism to use an additional environment variable which tracks if a listening socket was opened by Gitea - and therefore should be unlinked on shutdown by Gitea.

Fix #20490

Co-authored-by: zeripath <art27@cantab.net>
2022-08-13 22:31:33 +01:00
zeripath
99efa02edf
Switch Unicode Escaping to a VSCode-like system (#19990)
This PR rewrites the invisible unicode detection algorithm to more
closely match that of the Monaco editor on the system. It provides a
technique for detecting ambiguous characters and relaxes the detection
of combining marks.

Control characters are in addition detected as invisible in this
implementation whereas they are not on monaco but this is related to
font issues.

Close #19913

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-08-13 19:32:34 +01:00
wxiaoguang
11dc6df5be
Fix git.Init for doctor sub-command (#20782) 2022-08-14 00:33:18 +08:00
PEN²
3d7058adbe
Remove the translation key website by PR #20777 (#20779) 2022-08-13 02:24:21 -04:00
PEN²
bbce94ee91
Move the official website link at the footer of gitea (#20777) 2022-08-12 20:34:53 -05:00
silverwind
20b3a90450
Remove useless JS operation for relative time tooltips (#20756)
This operation that shifts the content from title to data-content is
useless when we can directly render the expected HTML instead.

This change does prevent these tooltips from working when the user has
JS disabled in their browser, but I think we made it clear by now that
JS is required for gitea to work properly.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-12 17:03:41 -04:00
silverwind
74515d3d17
Remove debug output when coverage fails (#20733)
* Remove debug output when coverage fails

When coverage fails, it logs megabytes of debug to stdout, which seems
to break the drone ui as well as the log output download in drone,
presumably because of the size. I think with removal of this print, we
should still see any errors created by gocovmerge.go, but a few CI runs
may be necessary to get it to fail again.

* Update Makefile

* restart ci

* restart ci

* restart ci

* restart ci

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-12 16:13:31 -04:00
silverwind
d30e02255f
Slightly reduce exclamation icon size (#20753)
It seemed a tad to big compared to other icons. Shrink it slightly.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-12 13:51:33 -04:00
Lunny Xiao
d26b652260
Fix disabled open in vscode menu when disabling download source from UI (#20713) 2022-08-12 13:16:05 +08:00
oliverpool
c81b26b0e5
refactor webhook *NewPost (#20729)
* refactor webhook *NewPost

* remove empty values

* always show errs.Message

* remove utils.IsValidSlackChannel

* move IsValidSlackChannel to services/webhook package

* binding: handle empty Message case

* make IsValidSlackChannel more strict
2022-08-11 17:48:23 +02:00
Kiel Hurley
2b4d43dd4d
Add SAML SP status to Feature Comparison docs (#20743)
* Add SAML SP integration

Add current SAML 2.0 Service Provider (SP) status. RhodeCode EE supports SAML, CE does not.

Included issue links for both Gitea and Gogs, as corporate users will likely be interested in the status of both.

* Add SAML SP status to comparison for other translations

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-11 07:04:09 +02:00
silverwind
57f1ea0366
Fix loading button with invalid form (#20754)
Previously, if a invalid form was submitted (for example issue with no
title), the form could not be re-submitted again because the button
would not stay stuck in loading state. Fix that by hooking the 'submit'
event instead which triggers only when the form is valid.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-11 11:54:34 +08:00
Gusted
54d9816502 [skip ci] Updated translations via Crowdin 2022-08-11 00:20:58 +00:00
ecefb6a2d0
Merge remote-tracking branch 'upstream/main' 2022-08-10 15:07:13 -05:00
Gusted
c315868b97
Make branch icon stand out more (#20726)
* Make branch icon stand out more

- Currently the branch icon is "squashed" between the two branch names
and feels a bit "amateur-ish" to my feeling(relative to other UI
elements).
- This patch tries to improve that by making the icon bigger
and by adding some margin to not have a "squashed" icon.
- This patch also includes a "fix", for some reason this symbol is not
centering correctly within the span(or without for that matter), so
simply manually patch this by adding `bottom: 1.px`.

* Use svg

* Apply suggestion

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-10 15:23:11 -04:00
wxiaoguang
3d76d6034e
Update docs for versions (#20750) 2022-08-10 13:37:15 -04:00
silverwind
802c5313e1
Replace some icons with SVG (#20741)
- Replace some icons with SVG
- Create teams help page
- Application and SSH keys icons
- Add new icon for app token
- Use fontawesom-send
2022-08-10 18:30:40 +02:00
silverwind
d751e35d81
Use separate class for tippy targets (#20742)
Previous solution that re-purposed the 'hide' class by making it
`!important` had various unintended side-effects where jQuery .show() was
not able to outweight it. Use a separate class to prevent these
interactions.
2022-08-10 22:47:28 +08:00
Gusted
58de07e5fd
Add support mCaptcha as captcha provider (#20458)
https://mcaptcha.org/

Co-authored-by: Felipe Leopoldo Sologuren Gutiérrez <fsologureng@users.noreply.github.com>
2022-08-10 15:20:10 +02:00
silverwind
452272c038
Fix CI status popup (#20737) 2022-08-10 12:08:06 +08:00
techknowlogick
1a538df5f4
Add documentation about pagination of the API (#20740)
* Add documentation about pagination of the API

* Update docs/content/doc/developers/api-usage.en-us.md

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-09 21:58:55 -04:00
silverwind
77d7b4c63d [skip ci] Updated translations via Crowdin 2022-08-10 00:20:57 +00:00
silverwind
89505ac650
Change commit status icons to SVG (#20736)
* Fix commit status popover and switch to svg icons

* margin tweak

* fix integration, use warning sign for error to match previous

* remove fix from here, will be a new pr

* use top/bottom positioning

* vertically center

* use no-entry over alert oction

* add exclamation icon

* fix test selector

* more test fixes
2022-08-09 23:55:29 +02:00
KN4CK3R
7009eb9a24
Add support for NuGet API keys (#20721)
* Add support for NuGet API key.

* lint

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-08-09 17:36:49 +03:00
KN4CK3R
920481340b
Keep download count on Container tag overwrite (#20728)
Co-authored-by: 6543 <6543@obermui.de>
2022-08-09 16:47:57 +03:00
silverwind
1b2cd4c4e1
Replace fomantic popup module with tippy.js (#20428)
- replace fomantic popup module with tippy.js
- fix chaining and add comment
- add 100ms delay to tooltips
- stopwatch improvments, raise default maxWidth
- update web_src/js/features/common-global.js
- use type=submit instead of js
2022-08-09 14:37:34 +02:00
CodeDoctor
36f9ee5813
Add an option to create new issues from "/issues" page (#20650) 2022-08-09 19:30:09 +08:00
silverwind
33b03e851f
Restore history button and hide add button when unable to add (#20718)
Fix two regressions from #20602:

- Restore the 'History' button that was previously unable to render
  because it's show condition was never hit
- Hide the 'Add File' button when there would be no items in the
  dropdown.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-09 18:32:41 +08:00
Gabriel Vasile
871082bc7b
Remove manual rollback for failed generated repositories (#20639)
Generating repositories from a template is done inside a transaction.
Manual rollback on error is not needed and it always results in error
"repository does not exist".

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-09 17:41:52 +08:00
KN4CK3R
fba20550f9
Add support for npm unpublish (#20688) 2022-08-09 15:23:43 +08:00
KN4CK3R
cc6927b2d8
Allow multiple files in generic packages (#20661)
* Allow multiple files in generic packages.
* Add deletion of a single file.
* Update docs.
* Change version check.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-09 12:39:24 +08:00
wxiaoguang
75d96f4a02
Refactor legacy git init (#20376)
* merge `CheckLFSVersion` into `InitFull` (renamed from `InitWithSyncOnce`)
* remove the `Once` during git init, no data-race now
* for doctor sub-commands, `InitFull` should only be called in initialization stage

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-09 11:22:24 +08:00
luzpaz
820031e556
Fix typo in source (#20723)
Algorightm -> Algorithm

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-09 09:53:40 +08:00
parnic
2660b0397a [skip ci] Updated translations via Crowdin 2022-08-09 00:21:27 +00:00
parnic
0066bc5113
Add issue filter for Author (#20578)
This adds a new filter option on the issues and pulls pages to filter by the author/poster/creator of the issue or PR
2022-08-08 22:03:58 +02:00
KN4CK3R
2b101994a6
Fix init mail render logic (#20704)
This bug affects tests which are sending emails (#20307). Some tests reinitialise the web routes (like `TestNodeinfo`) which messed up the mail templates. There is no reason why the templates should be loaded in the routes method.
2022-08-08 20:04:28 +02:00
6543
ccf03e19c2
Frontport changelog v1.17.0 (#20712)
* fix

* add
2022-08-08 23:21:57 +08:00
Lunny Xiao
98190d0024
Fix disable download button (#20701) 2022-08-08 15:42:36 +02:00
Norwin
68059ab697
docs: move search input to navbar (#20551)
* remove search item from sidebar
* fix search for some docs languages

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-08 15:27:04 +08:00
Gusted
498352c210
Fix SecToTime edge-cases (#20610) 2022-08-08 13:07:42 +08:00
Lunny Xiao
73e9854040 [skip ci] Updated translations via Crowdin 2022-08-08 00:21:03 +00:00
Lunny Xiao
5b4a84beb4
Fix v220 migration to be compatible for MSSQL 2008 r2 (#20702) 2022-08-08 02:16:22 +02:00
silverwind
abdebd2641
Rework repo buttons (#20602)
* Rework repo buttons

- Replace "New PR" and "Go to File" button with Icon Button
- Move all "Add File" actions into a dropdown button
- Remove most custom styling of clone buttons
- Margin and wiki tweaks

Buttons are now all equal height, mobile layout wraps gracefully.

Fixes: https://github.com/go-gitea/gitea/issues/13671
Replaces: https://github.com/go-gitea/gitea/pull/20375

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-08 02:15:11 +03:00
techknowlogick
be824890e4
Switch to building with go1.19 (#20695) 2022-08-07 12:25:03 -04:00
KN4CK3R
64c371a167
Update maven deploy docs (#20691)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-07 21:58:03 +08:00
KN4CK3R
f55af4675c
Add support for Pub packages (#20560)
* Added support for Pub packages.

* Update docs/content/doc/packages/overview.en-us.md

Co-authored-by: Gergely Nagy <algernon@users.noreply.github.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Gergely Nagy <algernon@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-08-07 18:09:54 +08:00
luzpaz
d4326afb25
Fix typo overrided -> overridden (#20687) 2022-08-06 20:54:26 -04:00
silverwind
cb97114e91 [skip ci] Updated licenses and gitignores 2022-08-07 00:20:52 +00:00
silverwind
dba14dc196
Update JS dependencies, adjust eslint (#20659)
* Update JS dependencies

- Update all JS dependencies minus vue-*
- Improve eslint restricted globals
- Tested build, lint and swagger

* few more lint improvements

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-06 18:30:13 +03:00
Luke Wyatt
fe78d35ef5
Background color of private list-items updated (#20630)
A minor color update on the dashboard. This PR simply changes the background from hard-coded light yellow to the theme colors (var).
2022-08-06 22:25:58 +08:00
parnic
27789908d8
Use request timeout for git service rpc (#20689)
This enables git.Command's Run to optionally use the given context directly so its deadline will be respected. Otherwise, it falls back to the previous behavior of using the supplied timeout or a default timeout value of 360 seconds.

repo's serviceRPC() calls now use the context's deadline (which is unset/unlimited) instead of the default 6-minute timeout. This means that large repo clones will no longer arbitrarily time out on the upload-pack step, and pushes can take longer than 6 minutes on the receive-pack step.

Fixes #20680

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-06 16:13:11 +03:00
Norwin
279e4e235c
Increase default item listing size ISSUE_PAGING_NUM to 20 (#20547)
* increase default page sizes to 20
* adjust docs to reflect that the setting is used all over the place
* fix tests

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-06 18:43:40 +08:00
KN4CK3R
61aafb9c7d [skip ci] Updated translations via Crowdin 2022-08-06 00:20:54 +00:00
KN4CK3R
baf374a3a4
Allow multiple metadata files for Maven packages (#20674)
* Allow file overwrite for meta files.

* Added tests.

* lint

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-05 15:00:47 -04:00
PEN²
d890f0d38c
docs: update comparison.zh-cn.md (#20656)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-05 14:56:09 -04:00
wxiaoguang
8a66967020
Add a notice for breaking check in upgrade document (#20682) 2022-08-05 10:20:13 -04:00
wxiaoguang
42d9a6a980
move handleGlobalEnterQuickSubmit into a separate file to avoid cycle-import (#20679) 2022-08-05 18:08:29 +08:00
KN4CK3R
ba0a0d31c9
Use correct field name. (#20675)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-05 14:49:03 +08:00
KN4CK3R
0f767e799c [skip ci] Updated translations via Crowdin 2022-08-05 00:20:59 +00:00
KN4CK3R
b678d1adae
Use correct context to get package content (#20673) 2022-08-04 16:14:47 -05:00
JonRB
7cc7c3e449
Executable check always returns true for windows (#20637)
* Executable check always returns true for windows 

Windows doesn't have the concept of "executable" POSIX bits so for now always return true to minimise doctor and logging noise. Addresses #20636

* gofmt tweak

* Update modules/repository/hooks.go

Co-authored-by: silverwind <me@silverwind.io>

* gofmt comment line

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-08-04 15:28:32 +08:00
Gabriel Vasile
cf06e20c0d
Check webhooks slice length before calling xorm (#20642)
xorm.db.Insert errors for empty slices. Fixes: #20641

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-04 00:22:50 -04:00
Gabriel Vasile
6c218f7a5c
Check issue labels slice length before calling xorm Insert; fixes #20654 (#20655)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-08-04 11:20:22 +08:00
fe8ef28bc2
Merge remote-tracking branch 'upstream/main' 2022-08-03 20:48:06 -05:00
wxiaoguang
b6bb3891fd [skip ci] Updated translations via Crowdin 2022-08-04 00:20:55 +00:00
wxiaoguang
96440e6ada
Fix the JS error "EventSource is not defined" caused by some non-standard browsers (#20584)
* fall back to periodic poller

Co-authored-by: silverwind <me@silverwind.io>
2022-08-03 22:58:27 +03:00
KN4CK3R
99fc419855
Send correct NuGet status codes (#20647)
* Fixed status codes.

* Fixed status codes.
2022-08-03 11:22:32 -04:00
Tyrone Yeh
7a31292c20
Add default commit messages to PR for squash merge (#20618)
Keep the same behavior as 1.16

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-08-03 12:56:59 +08:00
Gusted
7baa7cb98f [skip ci] Updated translations via Crowdin 2022-08-03 00:21:26 +00:00
Gusted
87a7c37ecb
Use strings.Cut for GIT_PROTOCOL value (#20638)
- As per https://github.com/go-gitea/gitea/pull/20616#discussion_r935612542
2022-08-03 01:34:50 +03:00
wxiaoguang
90b2657ae7
Fix the admin mailer config display (#20633) 2022-08-03 00:43:27 +08:00
Norwin
2754ecc293
Use correct page size for link header pagination (#20546)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-02 22:59:44 +08:00
KN4CK3R
631539c104
Fix package upload for files >32mb (#20622)
* Rewind file before first read.
* Added tests.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-02 21:35:48 +08:00
Gusted
e43bb2b0b5
Add info about Wire 2 when Git over SSH (#20619)
- Follow up of #20616. Add a note about this in the config cheat
sheet, given there's no dedicated page for this.
2022-08-02 18:25:26 +08:00
Gusted
8740631b79
Enable Wire 2 for Internal SSH Server (#20616)
- Git only decides to use the Wire 2 protocol when `git
{receive,upload}-pack` receive the `GIT_PROTOCOL` environment with as
value `version=2`. Currently the internal SSH Server wasn't passing this
environment through. The `gitea serv` code already passed all received
environments to the git command, so no code changes there.
2022-08-02 15:56:38 +08:00
Clar Fon
036dd8a788
Rework mailer settings (#18982)
* `PROTOCOL`: can be smtp, smtps, smtp+startls, smtp+unix, sendmail, dummy
* `SMTP_ADDR`: domain for SMTP, or path to unix socket
* `SMTP_PORT`: port for SMTP; defaults to 25 for `smtp`, 465 for `smtps`, and 587 for `smtp+startls`
* `ENABLE_HELO`, `HELO_HOSTNAME`: reverse `DISABLE_HELO` to `ENABLE_HELO`; default to false + system hostname
* `FORCE_TRUST_SERVER_CERT`: replace the unclear `SKIP_VERIFY`
* `CLIENT_CERT_FILE`, `CLIENT_KEY_FILE`, `USE_CLIENT_CERT`: clarify client certificates here

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-02 13:24:18 +08:00
silverwind
ae3b88bef3
Add default value for clone URLs (#20600)
Default clone URLs to HTTP(S) in DOM rendering. JS will immediately
replace this if the user preference is SSH.

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-02 10:52:05 +08:00
PEN²
cf40619215 [skip ci] Updated translations via Crowdin 2022-08-02 00:20:59 +00:00
PEN²
4f14c6de1e
docs: zh-cn translations for fail2ban setup (#20588)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-08-01 17:36:50 +02:00
Gary Wang
72b1fd7fdd
Should also support upper-case README files (#20581)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-08-01 20:15:40 +08:00
tryfail
e56005f901
Fix typos in backup documentation (#20567)
Fixed multiple typos "/user/local/bin" to the proper path "/usr/local/bin"
2022-08-01 13:16:38 +08:00
Gary Wang
1a8d7d03fd [skip ci] Updated translations via Crowdin 2022-08-01 00:20:39 +00:00
Gary Wang
c35535ce07
Support localized README (#20508)
* Support localized README

* Slightly simplify getting the readme file and add some tests. Ensure that i18n also
works for docs/ etc.

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

* Update modules/markup/renderer.go

* Update modules/markup/renderer.go

* Update modules/markup/renderer.go

Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-08-01 01:36:58 +03:00
silverwind
335e918b11
Clean up and fix clone button script (#20415)
The button 'primary' class needs to be set in a synchronous script to prevent flicker of the button which was regressed recently, fixed that.

Additionally, reduced the two script tags to just one, the previous scripts were actually initializing the buttons thrice on the empty repo page, now it only initializes once. Finally, removed duplicate code and re-used the inline function in the update code as well.

I had to split out the script into a separate template as on the empty repo page, the script needs access to the clone URL span in the example text, which is rendered below the clone buttons, so buttons and script could not be combined.
2022-07-31 20:29:55 +02:00
Lunny Xiao
589677fafb
Add disable download source configuration (#20548)
Add configuration to enable/disable download source from UI.

Co-authored-by: zeripath <art27@cantab.net>
2022-07-31 18:57:02 +02:00
wxiaoguang
2c2f75cb2c
Fix default merge style (#20564) 2022-07-31 17:13:31 +02:00
KN4CK3R
66b623c2aa
Update login methods in package docs (#20561) 2022-07-31 15:41:25 +02:00
6543
0b12abcfb5
Add missing Tabs on organisation/package view (Frontport #20539) (#20540)
hotfix #20106
2022-07-31 14:32:51 +02:00
Norwin
ff9b6fa663 [skip ci] Updated licenses and gitignores 2022-07-31 00:20:42 +00:00
Norwin
8a330b6b5b
Add setting SQLITE_JOURNAL_MODE to enable WAL (#20535)
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-07-30 21:57:41 +02:00
silverwind
ae3dde1c87
Rework file highlight rendering and fix yaml copy-paste (#19967)
* Rework file highlight rendering and fix yaml copy-paste

* use Split+Trim to replace tag parser

* remove unnecessary bytes.Count

* remove newLineInHTML = "&#10;"

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-30 21:17:43 +02:00
Mohamed Sekour
0e61a74e5a
Add new API endpoints for push mirrors management (#19841)
- Add a new push mirror to specific repository
- Sync now ( send all the changes to the configured push mirrors )
- Get list of all push mirrors of a repository
- Get a push mirror by ID
- Delete push mirror by ID

Signed-off-by: Mohamed Sekour <mohamed.sekour@exfo.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
2022-07-30 18:45:59 +02:00
zeripath
e819da0837
WebAuthn CredentialID field needs to be increased in size (#20530)
WebAuthn have updated their specification to set the maximum size of the
CredentialID to 1023 bytes. This is somewhat larger than our current
size and therefore we need to migrate.

The PR changes the struct to add CredentialIDBytes and migrates the CredentialID string 
to the bytes field before another migration drops the old CredentialID field. Another migration
renames this field back.

Fix #20457

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-30 15:25:26 +02:00
Gusted
692707f145
Add latest commit's SHA to content response (#20398)
* Add latest commit's SHA to content response

- When requesting the contents of a filepath, add the latest commit's
SHA to the requested file.
- Resolves #12840

* Add swagger

* Fix NPE

* Fix tests

* Hook into LastCommitCache

* Move AddLastCommitCache to a common nogogit and gogit file

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

* Prevent NPE

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-30 16:09:04 +08:00
Ben Yanke
2b94b02f33
Improve token and secret key generation docs (#20387)
This PR proposes a minor improvement to the docs which allows a user to paste a single command into their terminal and get the needed tokens and keys.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-30 13:28:50 +08:00
silverwind
33bb7c485d [skip ci] Updated translations via Crowdin 2022-07-30 00:21:27 +00:00
silverwind
eaf653f843
Rework raw file http header logic (#20484)
- Always respect the user's configured mime type map
- Allow more types like image/pdf/video/audio to serve with correct content-type
- Shorten cache duration of raw files to 5 minutes, matching GitHub
- Don't set `content-disposition: attachment`, let the browser decide whether it wants to download or display a file directly
- Implement rfc5987 for filenames, remove previous hack. Confirmed it working in Safari.
- Make PDF attachment work in Safari by removing `sandbox` attribute.

This change will make a lot more file types open directly in browser now. Logic should generally be more readable than before with less `if` nesting and such.

Replaces: https://github.com/go-gitea/gitea/pull/20460
Replaces: https://github.com/go-gitea/gitea/pull/20455
Fixes: https://github.com/go-gitea/gitea/issues/20404
2022-07-29 17:26:55 +02:00
zeripath
7fe77f0167
Update lunny/levelqueue to prevent NPE when reads are performed after close (#20534) 2022-07-29 13:41:13 +02:00
Alex Papadimoulis
c5bdea9bbc
Added guidance on file to choose to download (#20474)
* Added guidance on file to choose to download

* Update from-binary.en-us.md

* Update from-binary.en-us.md

* Update from-binary.en-us.md

* Update docs/content/doc/installation/from-binary.en-us.md

* Update docs/content/doc/installation/from-binary.en-us.md

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-07-29 14:07:52 +08:00
zeripath
98f6670cde [skip ci] Updated translations via Crowdin 2022-07-29 00:21:37 +00:00
zeripath
7a428fae4b
Ensure that all unmerged files are merged when conflict checking (#20528)
There is a subtle bug in the code relating to collating the results of
`git ls-files -u -z` in `unmergedFiles()`. The code here makes the
mistake of assuming that every unmerged file will always have a stage 1
conflict, and this results in conflicts that occur in stage 3 only being
dropped.

This PR simply adjusts this code to ensure that any empty unmergedFile
will always be passed down the channel.

The PR also adds a lot of Trace commands to attempt to help find future
bugs in this code.

Fix #19527

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-29 01:19:55 +02:00
Gergely Nagy
99f2f826ce
packages/generic: Do not restrict package versions to SemVer (#20414)
There are existing packages out there whose version do not conform to SemVer, yet, one would like to have them available in a generic package repository. To this end, remove the SemVer restriction on package versions when using the Generic package registry, and replace it with a check that simply makes sure the version isn't empty.

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
2022-07-29 00:09:54 +02:00
zeripath
c9c5bd88be
Stop logging EOFs and exit(1)s in ssh handler (#20476)
The code in modules/ssh/ssh.go:sessionHandler() currently cause an error to be
logged if `gitea serv` exits with a exit(1). This logging is useless because the
accompanying stderr is not provided and in any case the exit(1) is most likely due
to permissions errors.

Further it then causes the EOF to be logged - even though this is not helpful.

This PR simply checks the errors returned and stops logging them.

In the case of misconfigurations causing `gitea serv` to fail with exit(1)
the current logging is not helpful at determining this and users should simply
review the message passed over the ssh connection.

Fix #20473

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-28 20:56:55 +01:00
Gusted
9691d43101
Fix dashboard switching on Mobile (#20238)
- This is a regression of improving mobile experience on Gitea, currently organization dashboard aren't readable and the popup won't show up when you want to switch between users/organization(as we saw in #19978). 
- This patch fixes that, by allowing the popup to allocate the required pixels(for some absurd reason, z-index doesn't work on the popup, so it's not able to render over the existing elements, we can investigate later of why this is). And also remove the additional dropdown menu for the pages link, so it's one unified list which then can be displayed as rows.
2022-07-28 20:40:23 +02:00
Tyrone Yeh
8e3da0e27f
Modify milestone search keywords to be case insensitive again (#20513)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
2022-07-28 18:58:04 +02:00
wxiaoguang
2c108d20ba
Fix i18n for email notifications (#20518) 2022-07-28 17:28:46 +02:00
KN4CK3R
a846bfefd8
Extended permission checks. (#20517) 2022-07-28 21:04:03 +08:00
Tyrone Yeh
8b0e07e368
Add a checkbox to select all issues/PRs (#20177) 2022-07-28 18:25:18 +08:00
Tyrone Yeh
3bd8f50af8
Added email notification option to receive all own messages (#20179)
Sometimes users want to receive email notifications of messages they create or reply to,
Added an option to personal preferences to allow users to choose

Closes #20149
2022-07-28 16:30:12 +08:00
KN4CK3R
86e5268c39
Add Docker /v2/_catalog endpoint (#20469)
* Added properties for packages.
* Fixed authenticate header format.
* Added _catalog endpoint.
* Check owner visibility.
* Extracted condition.
* Added test for _catalog.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-28 11:59:39 +08:00
Philip Peterson
4604048010
Removed some vestigial code related to Range bounds checks (#20312) 2022-07-28 11:04:36 +08:00
silverwind
ae52df6a64
Add markdownlint (#20512)
Add `markdownlint` linter and fix issues. Config is based on the one
from electron's repo with a few rules relaxed.
2022-07-28 09:22:47 +08:00
71b2b4d815
Implement FederatedRepoNew 2022-07-27 14:43:01 -05:00
c94a891aad
Process Like activities for starring repos 2022-07-27 14:18:30 -05:00
Lunny Xiao
6554d5197f
Fix possible panic when repository is empty (#20509)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-28 00:46:34 +08:00
8e5621c9c3
Merge remote-tracking branch 'upstream/main' 2022-07-27 10:29:54 -05:00
d909c97da9
Move models/forgefed to modules/forgefed 2022-07-27 10:25:40 -05:00
f0cded88bf
Start cleaning up fork.go 2022-07-27 10:24:04 -05:00
Kevin Samuel
3f87525249
patch (doc): add heading to ssh flow explanation (#20506) 2022-07-27 10:06:02 -04:00
Norwin
2ae1675092
Show hint to link package to repo when viewing empty repo package list (#20504)
* show hint to link package to repo

on empty repo package listing

* reword
2022-07-27 19:58:21 +08:00
wxiaoguang
158f2746b8
Fix ROOT_URL detection for URLs without trailing slash (#20502) 2022-07-27 17:19:10 +08:00
Gusted
b899b2df5a
Add Tar ZSTD support (#20493)
- Add `.tar.zst` as supported output type.
- Resolves #14290
2022-07-27 07:16:28 +01:00
KN4CK3R
a3d55ac523
Hide internal package versions (#20492)
* Hide internal versions from most searches.

* Added test.
2022-07-27 09:59:10 +08:00
Vladimir Yakovlev
5ed082b624
Fix org members bug (#20489)
* Fix bug in public only org members list

bug was introduced in d6779c7ad3

* Expanded org unit test
2022-07-26 11:13:24 -05:00
techknowlogick
a701fd35cf
Add labels to two buttons that were missing them (#20419) 2022-07-26 17:43:13 +02:00
Norwin
305372efe3
fix enabling repo packages when projects are off (#20486) 2022-07-26 16:34:14 +02:00
aceArt-GmbH
ed6cd3cbb7
Display project in issue list (#20434)
Co-authored-by: lukas <lukas.walter@aceart.de>
2022-07-26 15:42:23 +02:00
Vladimir Yakovlev
4fc53a3f30
Make code review ceckboxes clickable (#20481) 2022-07-26 15:11:39 +02:00
38a687c60e
Replace GetID() with GetLink()
See https://lists.sr.ht/~mariusor/activitypub-go/%3CNXRUnlucUSX8FL9I57dimPx4dpMKz01JDjKXqeHC8V9Z7pSTnjoZyV8ukearYJOq4IDogmpDLoEK-ScPDKs_egPnFGcAAO4XqHbj2rTUm-E%3D%40proton.me%3E for more details
2022-07-25 15:45:15 -05:00
30b431da49
Set ap.ItemTyperFunc to correctly unmarshal JSON 2022-07-25 15:43:20 -05:00
zeripath
a2cfcdb91a
Slightly simplify LastCommitCache (#20444)
The LastCommitCache code is a little complex and there is unnecessary
duplication between the gogit and nogogit variants.

This PR adds the LastCommitCache as a field to the git.Repository and
pre-creates it in the ReferencesGit helpers etc. There has been some
simplification and unification of the variant code.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-25 16:39:42 +01:00
KN4CK3R
690272d2e2
Fix Ruby package parsing by removed unused email field (#20470) 2022-07-25 02:52:14 +02:00
Tyrone Yeh
7205f6b6a3 [skip ci] Updated translations via Crowdin 2022-07-25 00:21:14 +00:00
Tyrone Yeh
16edee85bd
Add repository condition for issue count (#20454)
* Add repository condition for issue count

* Update routers/web/user/home.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-07-24 19:53:40 +03:00
Gusted
9cf0352f14
Prepend commit message to template content (#20429)
- When a repository has a pull request template, it will always override
the current content. With this PR it will prepend content to the
template content when appropriate. This is similar how GitHub(and GitLab
I presume) does it and it saves developers time to not go open their
commit and copy paste their will written commit message.
2022-07-24 04:45:33 +01:00
bffb682117
Fix a bunch of lint errors (still 10 more to fix 🙁) 2022-07-23 22:12:09 -05:00
ab540d07be
Create new federated users in reqsignature.go 2022-07-23 21:27:20 -05:00
5da6b4fd84
Disable authorize_endpoint if federation is disabled 2022-07-23 20:52:12 -05:00
763f98b517
Create user at /authorize_interaction?uri= endpoint 2022-07-23 16:34:06 -05:00
wxiaoguang
91f1c285a1
Improve pprof doc (#20463) 2022-07-24 01:33:55 +08:00
wxiaoguang
3310dd1d19
Improve code diff highlight, fix incorrect rendered diff result (#19958)
Use Unicode placeholders to replace HTML tags and HTML entities first, then do diff, then recover the HTML tags and HTML entities. Now the code diff with highlight has stable behavior, and won't emit broken tags.
2022-07-23 19:28:02 +08:00
silverwind
14178c56bb
Add Cache-Control header to html and api responses, add no-transform (#20432)
`no-transform` allegedly disables CloudFlare auto-minify and we did not
set caching headers on html or api requests, which seems good to have
regardless.

Transformation is still allowed for asset requests.

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-07-23 14:38:03 +08:00
Gergely Nagy
d9608c4e76 [skip ci] Updated translations via Crowdin 2022-07-23 00:20:56 +00:00
Gergely Nagy
4d22bda4db
Allow non-semver packages in the Conan package registry (#20412)
A lot of existing packages do not conform to SemVer, yet, they should be allowed
in the Conan package registry as-is. To achieve this, remove the SemVer check
from `NewRecipeReference`, and replace it with a simple empty string check.

A unit test with a non-semver version is also included.

Fixes #20405.

Signed-off-by: Gergely Nagy <me@gergo.csillger.hu>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2022-07-22 22:54:02 +01:00
Lucas Azevedo
599ae09a94
Use body text color in repository files table links (#20386)
Use body text color in for links in the repository files table
Issue/PR links (`.ref-issue`) will not be affected, as seen in other git services.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-07-22 18:49:24 +08:00
Andrew Imeson
1a70fc9bc6
Correct code block in installation docs for Snap (#20440)
Without this, it was rendering on the site like: "sh snap install gitea", instead of: "snap install gitea"

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-22 18:12:27 +08:00
silverwind
339007bff0
Downgrade golangci-lint to 1.47.0 (#20445)
This should fix some recently seen linter performance issues. There is some log spam, but it's definitely faster.

Ref: https://github.com/golangci/golangci-lint/issues/2997

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-07-22 10:22:44 +08:00
silverwind
bc17cba835
Add eslint-plugin-sonarjs (#20431)
We had this plugin before but it was removed as it became outdated, now
it was updated again, so it's compatible again.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-07-22 09:10:22 +08:00
85abd9cfe0
Fix typo in follow.go 2022-07-21 20:07:17 -05:00
Dhruv Manilawala
3df33799c1
Fix: Actor is required to get user repositories (#20443)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-07-21 23:31:22 +02:00
6543
0a97480934
Add "X-Gitea-Object-Type" header for GET /raw/ & /media/ API (#20438) 2022-07-21 21:18:41 +02:00
KN4CK3R
7690de56f7
Simplify visibility checks (#20406)
Was looking into the visibility checks because I need them for something different and noticed the checks are more complicated than they have to be.

The rule is just: user/org is visible if
- The doer is a member of the org, regardless of the org visibility
- The doer is not restricted and the user/org is public or limited
2022-07-21 11:41:50 +01:00
John Olheiser
e5ef7c2a91
Add Cloudflare auto-minify to FAQ (#20430) 2022-07-21 12:54:42 +08:00
silverwind
755410162f [skip ci] Updated translations via Crowdin 2022-07-21 00:20:58 +00:00
5196dcd9a5
Check if httpsig keyID matches actor and attributedTo 2022-07-20 18:57:19 -05:00
c8a8e1ec91
Check err in Follow() to avoid crash and don't check FederatedUserNew error 2022-07-20 18:16:49 -05:00
6e100301cf
Merge remote-tracking branch 'upstream/main' 2022-07-20 14:45:19 -05:00
0925235a96
Fix federated following/unfollowing regression 2022-07-20 14:42:39 -05:00
silverwind
c7fa5cc017
Update JS dependencies (#20423)
- Update all JS dependencies minus vue ones
- Remove workaround for case-insensitive attribute selector
- Add new linter rules and fix issues
- Tested SVG display and swagger
2022-07-20 23:48:06 +08:00
silverwind
b8733e8f89
Update all tool dependencies to their latest versions (#20409) 2022-07-20 15:53:58 +08:00
6543
0d05bdbea8 [skip ci] Updated translations via Crowdin 2022-07-20 00:20:52 +00:00
6543
c0f5111fea
Dismiss prior pull reviews if done via web in review dismiss (#20197) 2022-07-19 15:20:28 +02:00
Lucas Azevedo
e519249266
Fix modified due date message (#20388) 2022-07-19 14:30:55 +02:00
Lunny Xiao
d6779c7ad3
Fix public org members displayed too many informations (#20403) 2022-07-19 12:22:38 +02:00
Tyrone Yeh
4c7e51ee3a
Add two factor status to admin cmd display (#20401) 2022-07-19 09:43:49 +01:00
silverwind
00d3876c85
Use tippy.js for context popup (#20393)
By appending the tooltips to `document.body`, we can avoid any stacking context issues caused by surrounding element's CSS.

This uses [tippy.js](https://github.com/atomiks/tippyjs) instead of Fomantic popups. We should aim to replace all Fomantic popups with this eventually and then get rid of the Fomantic `popup` module completely.
2022-07-19 00:33:34 +02:00
c100b8e1e0
Apply suggestions from code review 2022-07-17 11:19:48 -05:00
08cb2d6d34
Fix typos in FEDERATION.md 2022-07-17 11:09:10 -05:00
48deb8e1f5
Fix repo AP outbox path typo 2022-07-16 21:10:28 -05:00
f1577c2f62
Merge remote-tracking branch 'upstream/main' 2022-07-16 20:35:16 -05:00
705706bc00
Generate person outbox for only repo creates and stars 2022-07-16 20:33:28 -05:00
b491a2ec34
Update FEDERATION.md with a more accurate description of federated issues and PRs 2022-07-16 20:32:41 -05:00
CLanguagePurist
17ce5f8660 [skip ci] Updated licenses and gitignores 2022-07-17 00:20:41 +00:00
CLanguagePurist
6247a1dd5d
Comment on PrivateUsers option for gitea.service (#20383)
* Comment on PrivateUsers option for gitea.service

A user happens to encounter an issue where PrivateUsers sandboxed Gitea.service and it effectively stop systemd from applying capabilities for that gitea.service. I am opening this PR to provide comments on PrivateUsers, effectively a tiny FAQ information for end-user.
2022-07-16 14:58:56 +02:00
wxiaoguang
ce8e06f9f3 [skip ci] Updated translations via Crowdin 2022-07-16 00:20:56 +00:00
wxiaoguang
fee0e4dbea
Remove confusing TrimPrefix(... git.BranchPrefix) (#20369)
Make Repository.GetDefaultBranch return the real branch name, instead of the ref name. Then there is no need to do TrimPrefix for repo.DefaultBranch
2022-07-16 08:10:02 +08:00
Gusted
57e0bf43eb
Set target on create release with existing tag (#20381)
When you create a new release(e.g. via Tea) and specify a tag that already exists on
the repository, Gitea will instead use the `UpdateRelease`
functionality. However it currently doesn't set the Target field. This
PR fixes that.
2022-07-15 20:39:03 +02:00
zeripath
dbd3b7f9fd
Initialize cron last (#20373)
Cron will try to run certain things at startup but these depend on multiple things
being set-up. Therefore we should initialize cron last.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-15 16:20:05 +01:00
a1012112796
4f267ef643
Allow access to the Public Organization Member lists with minimal permissions (#20330)
Examining Organization membership should not necessarily require sign-in if the organization is public and the members are public. Therefore we should adjust `/org/{org}/members` to not require login.

Fix #7501

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-07-15 15:21:54 +01:00
silverwind
7d20c8323a
Fix commit status icon when in subdirectory (#20285)
When viewing a subdirectory and the latest commit to that directory in
the table, the commit status icon incorrectly showed the status of the
HEAD commit instead of the latest for that directory.
2022-07-15 14:01:32 +01:00
silverwind
4c0fce8f7b
Fix eslint parsing errors, remove eslint-plugin-html (#20323)
Introduce a separate .eslintrc in the Vue components folder to
selectively enable vue-eslint-parser there, so that the rest of the
files can use eslint's core parser which can deal with hashbangs.

The fact that the eslint-disable comments worked in HTML was a
unintended side-effect of the files being parsed via vue-eslint-parser,
so I had to disable the parsing of these files in .eslintrc.yaml to make
it work, and finally decided to remove eslint-plugin-html as it causes
more issues than it solves.
2022-07-15 17:38:18 +08:00
Baekjun Kim
e35a39e81d
Include login_name in adminCreateUser response (#20283)
`login_name` (Authentication Sign-in Name) is not included in the response of `adminUserCreate` API. 
This PR is to return user-specified `login_name` if there is one.
2022-07-15 16:52:11 +08:00
Bian Jiaping
e49ef56dde
Add allow_rebase_update, default_delete_branch_after_merge to repository api response (#20079)
`PATCH /repos/{owner}/{repo}` API allows users to update `allow_rebase_update`, `default_delete_branch_after_merge`, but `GET /repos/{owner}/{repo}` API does not return these two options, and API users has no other ways to find the state of these two options.

This PR add `allow_rebase_update`, `default_delete_branch_after_merge` to repository query api response.
2022-07-15 16:00:01 +08:00
Gusted
edd945bca3
Allow to specify colors for text in markup (#20363)
`<span style="color: red">Hello World!</span>` will now be accepted by
Bluemonday, other properties are still disallowed by Bluemonday.
2022-07-15 14:38:10 +08:00
6543
4ddae2c1b5 [skip ci] Updated translations via Crowdin 2022-07-15 00:20:57 +00:00
6543
1818149527
update xorm.io/xorm v1.3.2-0.20220714055524-c3bce556200f (#20371)
Xorm 1.3.2-0.20220714055524 contains a fix for interpreting db column sizes. Prior to this fix xorm would assume that the size of a column was within the range of an `int`. This is correct on 64bit machines where `int` is typical equivalent to `int64` however, on 32bit machines `int` tends to be `int32`. 

Unfortunately the size of a LONGTEXT field is actually `max_uint32`, thus using `strconv.Atoi` on these fields will fail and thus #20161 occurs on 32 bit arm. Xorm 1.3.2-0.20220714055524 changes this field to use int64 instead.

Fix  #20161
2022-07-14 19:40:30 +01:00
Tyrone Yeh
931c02d152
Add order by for assignee no sort issue (#20053)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-14 18:00:10 +02:00
a1012112796
f85bb6f70b
Make sure repo_dir is an empty directory or doesn't exist before 'dump-repo' (#20205) 2022-07-14 21:52:18 +08:00
Jeremy
725f9e40b3
Fix English mistakes in some Markdown documents (#20274) 2022-07-14 19:15:35 +08:00
silverwind
7740779b28
Fix versions check for busybox sh (#20358)
`printf` in busybox emits a ugly 'invalid number' error when formatting
string variables are present. Avoid that by reducing the go version
check to just two digits, which ought to be enough as patch-level go
versions are meant to be compatible. Avoid error on node-check as well.
2022-07-14 16:58:14 +08:00
silverwind
aec6b30e2a
Unbreak release pipeline (#20356)
Downgrade release pipeline to node 16 until xgo updates its base OS to a
version with a compatible glibc.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-14 16:09:26 +08:00
zeripath
bffa303020
Add option to purge users (#18064)
Add the ability to purge users when deleting them.

Close #15588

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-14 08:22:09 +01:00
1b4cd987b2
Merge remote-tracking branch 'upstream/main' 2022-07-13 22:36:00 -05:00
0609d7175c
Add more TODO notes 2022-07-13 22:11:24 -05:00
56717396fd
Big refactor: Improve inbox handling logic, move some IRI stuff to iri.go 2022-07-13 22:10:03 -05:00
Baoshuo Ren
175705356c
Fix icon margin in user/settings/repos (#20281) 2022-07-14 11:03:31 +08:00
Tyrone Yeh
715042c5bb
Fix org label open count, including close count issue (#20353)
Fixed using organization tags to see open issues in the tag list including closed issues count
2022-07-14 04:09:03 +02:00
zeripath
ed094dbab9 [skip ci] Updated translations via Crowdin 2022-07-14 00:21:35 +00:00
zeripath
fe09ee564d
Prevent context deadline error propagation in GetCommitsInfo (#20346)
* Prevent context deadline error propagation in GetCommitsInfo

Although `WalkGitLog` tries to test for `context.DeadlineExceededErr`
there is a small chance that the error will propagate to the reader
before it is recognised. This will cause the error to propagate up to
`renderDirectoryFiles` and cause a http status 500.

Here we check that the error passed is a `DeadlineExceededErr` via error.Is

Fix #20329

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-14 00:24:29 +02:00
Gusted
07ec8288bf
Add missing return for when topic isn't found (#20351)
Add missing return to DeleteTopic API when the topic is not found.
2022-07-13 18:39:19 +01:00
a63b2be21b
Merge remote-tracking branch 'upstream/main' 2022-07-13 12:14:35 -05:00
63aa270a2e
Initial implementation of federated pull requests 2022-07-13 12:14:14 -05:00
silverwind
9cd1f38f70
Upgrade to Node 18 on CI (#20340)
* Upgrade to Node 18 on CI

Should be pretty stable now.

* restart ci

Co-authored-by: 6543 <6543@obermui.de>
2022-07-13 11:45:08 -04:00
Ing. Jaroslav Šafka
8420c1bf4c
Fix checks in PR for empty commits #19603 (#20290)
* Fixes issue #19603 (Not able to merge commit in PR when branches content is same, but different commit id)
* fill HeadCommitID in PullRequest
* compare real commits ID as check for merging
* based on @zeripath patch in #19738
2022-07-13 16:22:51 +08:00
Gusted
b7c6ec91ba
Use default values when provided values are empty (#20318)
* Use default values when provided values are empty

- When provided values are empty like `:3000` would imply that host is
empty, use the default value.
- Resolves #20316

* Update database.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-07-13 13:33:31 +08:00
wxiaoguang
f67a1030b3
Add tests for the host checking logic, clarify the behaviors (#20328)
Before, the combination of AllowedDomains/BlockedDomains/AllowLocalNetworks is confusing.

This PR adds tests for the logic, clarify the behaviors.
2022-07-13 09:07:16 +08:00
6543
d94f517643
Changelog for 1.16.9 (update) (#20341) (#20343)
* Changelog for 1.16.9 (update)
2022-07-13 00:27:35 +02:00
luzpaz
d29d6d1991
Fix various typos (#20338)
* Fix various typos

Found via `codespell -q 3 -S ./options/locale,./options/license,./public/vendor -L actived,allways,attachements,ba,befores,commiter,pullrequest,pullrequests,readby,splitted,te,unknwon`

Co-authored-by: zeripath <art27@cantab.net>
2022-07-12 23:32:37 +02:00
Chongyi Zheng
966e7bdc9b
Correctly handle draft releases without a tag (#20314)
Fixes #20313.

`errors.Is(err, git.ErrNotExist{})` is not working
2022-07-12 13:57:38 +01:00
Gusted
3aec32ad16
Add write check for creating Commit status (#20332)
- Add write code checks for creating new commit status
- Regression #5314

Co-authored-by: zeripath <art27@cantab.net>
2022-07-12 14:51:06 +02:00
silverwind
e24c238ecc
Remove blue text on migrate page (#20273)
* Remove blue text on migrate page

* remove Safe

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-07-12 17:04:15 +08:00
BurritoVoid
4ce07a00e5
Updated dead link to Madeleine.js source (#20322) 2022-07-11 23:51:14 -04:00
silverwind
734e81d48c [skip ci] Updated translations via Crowdin 2022-07-12 00:10:13 +00:00
1b39e39fc1
Add basic implementation of federated commenting 2022-07-11 18:24:15 -05:00
silverwind
c8e0fd0bcc
Add spectral linter for Swagger (#20321)
[spectral](https://github.com/stoplightio/spectral) lints
openapi/swagger files for mistakes of which it has identified a few and
which I've fixed.

I had to put it into `lint-frontend` because it depends on node_modules
so can not run on Drone during the backend target. I plan to refactor
these targets later to `lint-js` and `lint-go` so that they are
categorized based on the tool dependencies.
2022-07-11 18:07:16 -05:00
79a59bd75b
Use a replace in go.mod to point to Ta180m/activitypub fork instead of modifying the include everywhere 2022-07-11 17:27:57 -05:00
d016dbbe70
Switch to using gitea.com/Ta180m/activitypub fork of the go-ap/activitypub module since we need more Write and Load functions exported 2022-07-11 12:45:00 -05:00
Gusted
8a7d1a3516
Store read access in access for team repo's (#20275)
- Currently when a Team has read access to a organization's non-private
repository, their access won't be stored in the database. This caused
issue for code that rely on read access being stored. So from now-on if
we see that the repository is owned by a organization don't increase the
minMode to write permission.
- Resolves #20083
2022-07-11 13:48:43 +02:00
Gusted
cb6c5f8193 [skip ci] Updated translations via Crowdin 2022-07-11 00:10:08 +00:00
Gusted
2399b5900a
Vertical align avatar at middle (#20302)
- Currently the avatar in the navbar is being vertically aligned to the
top, this caused that the icon besides it isn't being at the middle of
the avatar. Use the `vm` helper class to force the `vertical-align` to
be `middle`.
- Resolves #20292
2022-07-10 19:49:13 +01:00
8b354febf5
Merge remote-tracking branch 'upstream/main' 2022-07-10 11:49:22 -05:00
KN4CK3R
e24b0fc7b8
Changed scroll to auto for some UI elements. (#20294)
Addition to: Show scrollbar when necessary #20142
Fixes the "empty" scrollbars with Firefox.
2022-07-10 20:58:26 +08:00
Steven Kriegler
9f3906b2a3
Add hint to GNUPGHOME environment variable (#20134)
* Add hint for GNUPGHOME environment variable

With #19732, the default location for the `.gnupg` folder has changed. To mitigate this breaking change, users can specify the home directory for gnupg via `$GNUPGHOME` environment variable to keep using their current location.

* Update docs/content/doc/advanced/signing.en-us.md

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-07-10 17:04:46 +08:00
wxiaoguang
27e2def5f0
Refactor SSH init code, fix directory creation for TrustedUserCAKeys file (#20299)
* Refactor SSH init code, fix directory creation for TrustedUserCAKeys file

* Update modules/ssh/init.go

Co-authored-by: zeripath <art27@cantab.net>

* fix lint copyright

* Update modules/ssh/init.go

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-07-10 14:50:26 +08:00
Gusted
a9e66cfdad [skip ci] Updated translations via Crowdin 2022-07-10 00:10:33 +00:00
Gusted
87c563b706
Use dedicated draft PR icon when possible (#20303)
* Use dedicated draft PR icon when possible

- Currently the generic pull-request icon is used for draft PR's. This
patch changes that by using the dedicated icon for this.
- Resolves #20296

* Use draft title
2022-07-09 17:17:04 -05:00
Gusted
11c0748146
Update goldmark (#20300)
Update goldmark to v1.4.13 to fix a issue with quotes after a empty
list item(See https://github.com/yuin/goldmark/issues/313) and
downstream issue https://codeberg.org/Codeberg/Community/issues/645
2022-07-09 19:58:22 +01:00
wxiaoguang
36353e27e6
Do not create empty ".ssh" directory when loading config (#20289)
Creating the directory automatically is not correct.
In other places for ssh key writing (RewriteAllPrincipalKeys / appendAuthorizedKeysToFile, etc), the directory will still be created when updating the keys.
This PR will resolve the confusing and annoying problem: the dummy and empty ".ssh" directory in new git home.
2022-07-09 22:32:18 +08:00
Chongyi Zheng
49f9d43afe
Implement sync push mirror on commit (#19411)
Support synchronizing with the push mirrors whenever new commits are pushed or synced from pull mirror.

Related Issues: #18220

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-07-08 20:45:12 +01:00
wxiaoguang
496b8e3990
Use git.HOME_PATH for Git HOME directory (#20114)
* Add git.HOME_PATH

* add legacy file check

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* pass env GNUPGHOME to git command, move the existing .gitconfig to new home, make the fix for 1.17rc more clear.

* set git.HOME_PATH for docker images to default HOME

* Revert "set git.HOME_PATH for docker images to default HOME"

This reverts commit f120101ddc267cef74e4f4b92c783d5fc8e275a1.

* force Gitea to use a stable GNUPGHOME directory

* extra check to ensure only process dir or symlink for legacy files

* refactor variable name

* The legacy dir check (for 1.17-rc1) could be removed with 1.18 release, since users should have upgraded from 1.17-rc to 1.17-stable

* Update modules/git/git.go

Co-authored-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>

* remove initFixGitHome117rc

* Update git.go

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-07-08 16:09:07 +08:00
Baoshuo Ren
c273dea508
Add tooltip to repo icons in explore page (#20241)
* Add label to repo icons in explore page

Co-authored-by: silverwind <me@silverwind.io>
2022-07-07 22:17:41 +02:00
18b4cd32f3
Don't track go.work files 2022-07-07 13:14:01 -05:00
fa72294f64
Fix build errors and start working on constructing outbox activities for the various action types 2022-07-07 13:11:59 -05:00
721b734049
Merge remote-tracking branch 'upstream/main' 2022-07-07 12:58:51 -05:00
Gusted
3f513f9e54
Fix NPE when using non-numeric (#20277)
- This code is only valid when `refNumeric` exist(otherwise we didn't find
such numeric PR and can skip that check) and give a free-pas to the  "BEFORE" check when
`ref` is nil.
- Resolves #20109
2022-07-07 17:46:49 +02:00
Tyrone Yeh
970288f0b2
Modify milestone search keywords to be case insensitive (#20266)
Milestone search keywords are now sensitive, this modification is changed to insensitive
2022-07-06 22:05:12 +01:00
zeripath
a704e4b547
Fix toolip on mobile notification bell (#20270)
Unfortunately there is a bug in #20108 where the translation call was
not updated to use `.locale` from `.i18n`.

This PR updates the template to use `.locale`.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-06 22:03:52 +01:00
zeripath
354bfbe779
Allow RSA 2047 bit keys (#20272)
Unfortunately it appears that 2048 bit RSA keys can occasionally be created in such
a way that they appear to have 2047 bit length. This PR simply changes our defaults to
allow these.

Fix #20249

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-06 16:49:27 -04:00
zeripath
1e43a88578
Refix notification bell placement (#20251)
The use of `m-4 text black` for the notification bell results in this
icon being shifted upwards. Instead we should use the `item` class but
adjust `not-mobile` and `mobile-only` to make their `display: none`
settings `!important`.

(As an aside: This is probably one of the only times we should use
`!important` in our less files and the rest should be avoided or
removed.)

Ref #20069
Revert #20236

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-06 18:33:10 +01:00
dependabot[bot]
acbbbbfaf6
Bump mermaid from 9.1.1 to 9.1.2 (#20256)
Bumps [mermaid](https://github.com/knsv/mermaid) from 9.1.1 to 9.1.2.
- [Release notes](https://github.com/knsv/mermaid/releases)
- [Changelog](https://github.com/mermaid-js/mermaid/blob/develop/CHANGELOG.md)
- [Commits](https://github.com/knsv/mermaid/compare/9.1.1...9.1.2)

---
updated-dependencies:
- dependency-name: mermaid
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-07-06 09:41:54 +08:00
zeripath
6efbe49439
EscapeFilter the group dn membership (#20200)
The uid provided to the group filter must be properly escaped using the provided
ldap.EscapeFilter function.

Fix #20181

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-05 16:59:27 +01:00
zeripath
45f17528a8
Only show Followers that current user can access (#20220)
Users who are following or being followed by a user should only be
displayed if the viewing user can see them.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-05 16:47:45 +01:00
Gusted
ed13d7aadf
Init popup for new code comment (#20234)
- Initialize the popup for the tooltip inside the new code comment.
- This works and is good enough to have this issue fixed for 1.17


Fix #20068
2022-07-05 13:28:31 +01:00
wxiaoguang
f5c97172f0
Bypass Firefox (iOS) bug (#20244)
* https://github.com/go-gitea/gitea/issues/20240

At the moment, Firefox (iOS) (10x) has an engine bug. See https://github.com/go-gitea/gitea/issues/20240
If a script inserts a newly created (and content changed) element into DOM, there will be a nonsense error event reporting: Script error: line 0, col 0.

This PR ignores such nonsense error event.

Fix #20240
2022-07-05 13:27:13 +01:00
zeripath
8ee823037f
Adjust max-widths for the repository file table (#20243)
Adjust the max-widths for the repository file table to allow for nicer
resizing of the names and commit messages.

Fix #20040

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

## Screenshots

## MediaXL
![Screenshot from 2022-07-05 10-22-12](https://user-images.githubusercontent.com/1824502/177295867-7ba8cf60-8f61-4227-892f-e5a0477e4146.png)

## MediaLg
![Screenshot from 2022-07-05 10-24-37](https://user-images.githubusercontent.com/1824502/177296301-e066e206-10f7-4a15-a68b-0f772a95f369.png)

## MediaMd
![Screenshot from 2022-07-05 10-23-03](https://user-images.githubusercontent.com/1824502/177295965-69397649-16ca-456a-bc0c-ed507fcb7f44.png)

## MediaSm
![Screenshot from 2022-07-05 10-26-44](https://user-images.githubusercontent.com/1824502/177296700-ca2a853b-c47b-4592-baf4-4bc08a7e1c9c.png)
2022-07-05 12:33:05 +01:00
Baekjun Kim
c4368fc6bc
Display full name (#20171)
The setting `DEFAULT_SHOW_FULL_NAME` promises to use the user's full name everywhere it can be used.

Unfortunately the function `*user_model.User.ShortName()` currently uses the `.Name` instead - but this should also use the `.FullName()`.

Therefore we should make `*user_model.User.ShortName()` base its pre-shortened name on the `.FullName()` function.
2022-07-05 12:30:05 +01:00
Tyrone Yeh
a168609e84
Adjust class for mobile has the problem of double small bells (#20236)
* Adjust class for mobile has the problem of double small bells

* Update templates/base/head_navbar.tmpl

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-07-05 14:12:53 +08:00
Tyrone Yeh
c174bdc494
Adjust template for #20069 smallbell (#20108)
* Adjust template for #20069 smallbell

* Adjust notification Unread Count variable to global and count bell position with mobile

* Adjust bell icon style

* Adjust smallbell to middle

* Avoid using inline styles

* move notificationUnreadCount to a general code block, reduce changed lines

* Solved conflicts

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-07-04 22:44:34 +08:00
Aravinth Manivannan
2921d3c8c9
Add integration tests for the Gitea migration form (#20121)
* tests: integration tests for the Gitea migration form

* use a mix of ` and " instead of backslash

https://github.com/go-gitea/gitea/pull/20121#discussion_r906729415

Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-07-04 14:36:24 +02:00
zeripath
ba0f9274e9
Allow dev i18n to be more concurrent (#20159)
The recent changes to add live-reloading to the i18n translation files made the i18n code totally non-concurrent when using dev. This will make discovering other concurrency related issues far more difficult. This PR fixes these, adds some more comments to the code and slightly restructures a few functions.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-04 12:17:09 +02:00
Steven Kriegler
33f6f91008
Allow enable LDAP source and disable user sync via CLI (#20206)
The current `admin auth` CLI for managing authentication source of type
LDAP via BindDN and Simple LDAP does not allow enabling the respective
source, once disabled via `--not-active`.
The same applies to `--synchronize-users` specifially for LDAP via
BindDN.

These changes add two new flags to LDAP related CLI commands:

- `--active` for both LDAP authentication source types
- `--disable-synchronize-users` for LDAP via BindDN

Signed-off-by: justusbunsi <61625851+justusbunsi@users.noreply.github.com>
2022-07-04 11:21:14 +02:00
Gusted
f9b172db65
Remove GO111MODULE (#20221)
- Given we use go1.18 for this and don't rely on the Go 1.11 modules
behavior(we use the modern `go run` & `go get` which has the correct
behavior by-default).
2022-07-04 11:33:55 +08:00
zeripath
9d9bf66c3b
Update Bluemonday to v1.0.19 (#20199)
The current version of bluemonday is double escaping attributes.

This PR updates bluemonday to the version that fixes this.

(See: microcosm-cc/bluemonday#143 )

Fix #19860

Signed-off-by: Andrew Thornton art27@cantab.net
2022-07-01 20:50:06 +02:00
zeripath
5c9c0b8c1e
Refix indices on actions table (#20158)
Unforunately the previous PR #20035 created indices that were not helpful
for SQLite. This PR adjusts these after testing using the try.gitea.io db.

Fix #20129

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-07-01 17:04:01 +01:00
silverwind
54e7483207
Update default allowed attachment types (#20192)
Synced the list to what is allowed on GitHub currently.
2022-07-01 15:42:20 +02:00
wxiaoguang
7c1f18a2bb
Fix cli command restore-repo: "units" should be splitted to string slice, to match the old behavior and match the dump-repo's behavior (#20183) 2022-07-01 15:47:44 +08:00
wxiaoguang
2eb713bacc [skip ci] Updated translations via Crowdin 2022-07-01 00:10:16 +00:00
wxiaoguang
d6c0aa7f1c
Fix dump-repo git init, fix wrong error type for NullDownloader (#20182)
* Fix `dump-repo` git init

* fix wrong error type for NullDownloader
2022-07-01 07:48:25 +08:00
Lunny Xiao
184a7d4195
Check if project has the same repository id with issue when assign project to issue (#20133)
* Check if project has the same repository id with issue when assign project to issue

* Check if issue's repository id match project's repository id

* Add more permission checking

* Remove invalid argument

* Fix errors

* Add generic check

* Remove duplicated check

* Return error + add check for new issues

* Apply suggestions from code review

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
2022-06-30 23:55:08 +08:00
wxiaoguang
db3355cb1a [skip ci] Updated translations via Crowdin 2022-06-30 00:10:22 +00:00
wxiaoguang
26ec628624 [skip ci] Updated translations via Crowdin 2022-06-29 00:10:11 +00:00
wxiaoguang
76910f213f
Enable spellcheck for EasyMDE, use contenteditable mode (#19776)
Enable spellcheck for EasyMDE, use contenteditable mode.
Rewrite and refactor the ImagePaste code.
2022-06-29 01:52:58 +08:00
Gusted
cdd6371ad4 [skip ci] Updated translations via Crowdin 2022-06-28 00:09:43 +00:00
Gusted
91b21473a6
Add username check to doctor (#20140)
* Add username check to doctor

- Add a new breaking change detector to Gitea's doctor, which checks if
all users still have a valid username according to Gitea. Given from
time-to-time we need to make changes, either due to new routes or due to
security, it's for a instance's admin to check if all users still have a
valid username.

* Fix extra argument

* Apply suggestions from code review

Co-authored-by: Jimmy Praet <jimmy.praet@telenet.be>

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: Jimmy Praet <jimmy.praet@telenet.be>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: delvh <dev.lh@web.de>
2022-06-27 19:45:50 -04:00
Gusted
d55a0b7238
Refactor i18n to locale (#20153)
* Refactor `i18n` to `locale`

- Currently we're using the `i18n` variable naming for the `locale`
struct. This contains locale's specific information and cannot be used
for general i18n purpose, therefore refactoring it to `locale` makes
more sense.
- Ref: https://github.com/go-gitea/gitea/pull/20096#discussion_r906699200

* Update routers/install/install.go
2022-06-27 15:58:46 -05:00
Gusted
b551bc2a08
Remove support for sr-SP (#20155)
- The language doesn't have >= 25% translation on crowdin and therefor
was automatically removed from Gitea.
- Ref: f91092453e
2022-06-27 14:50:30 -05:00
Lunny Xiao
85d960d2a1
Hide notify mail setting ui if not enabled (#20138) 2022-06-28 00:59:47 +08:00
Jorge Ou
81eda36285
Fix custom folder name in customization docs (#20148) 2022-06-27 11:16:51 -05:00
Gusted
9eb6c4a0df
Add missing parameter for error in log message (#20144)
- Adds a `%v` for the last parameter, `err`.

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-06-27 16:52:22 +03:00
Gusted
5371964a4e
Show scrollbar when necessary (#20142)
- Firefox on Windows will unconditionally show scrollbars when you
specify `overflow: scroll`. This is bad behavior, as you don't always
need the scrollbar. Changing the scroll value to auto fixes this issue
and only shows the scrollbar when necessary.
- Resolves #20139

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-27 20:34:20 +08:00
Gusted
1f7c717b59
Add spacing between the properties of the key (#20145)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-27 13:20:29 +08:00
Gusted
0048595811
Remove U2F support (#20141)
- Completely remove U2F support from 1.18.0, 1.17.0 will be the last
release that U2F is somewhat supported. Users who used U2F would already
be warned about using U2F for a while now and should hopefully already
be migrated. But starting 1.18 definitely remove it.
2022-06-26 21:20:58 -05:00
Gusted
5d3f99c7c6
Make better use of i18n (#20096)
* Prototyping

* Start work on creating offsets

* Modify tests

* Start prototyping with actual MPH

* Twiddle around

* Twiddle around comments

* Convert templates

* Fix external languages

* Fix latest translation

* Fix some test

* Tidy up code

* Use simple map

* go mod tidy

* Move back to data structure

- Uses less memory by creating for each language a map.

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Add some comments

* Fix tests

* Try to fix tests

* Use en-US as defacto fallback

* Use correct slices

* refactor (#4)

* Remove TryTr, add log for missing translation key

* Refactor i18n

- Separate dev and production locale stores.
- Allow for live-reloading in dev mode.

Co-authored-by: zeripath <art27@cantab.net>

* Fix live-reloading & check for errors

* Make linter happy

* live-reload with periodic check (#5)

* Fix tests

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-06-26 22:19:22 +08:00
786ee03f57
Merge remote-tracking branch 'upstream/main' 2022-06-25 21:41:59 -05:00
e348477c59
Add some additional info about migrations to FEDERATION.md 2022-06-25 21:37:50 -05:00
Gusted
711cbcce8d
Use neutral language in comments and docs (#20135)
- Replace `his/her` to `their`, as it's more neutral language.
2022-06-25 17:50:12 -05:00
Gusted
a8cdea013d
Fix remove file on initial comment (#20127)
Store the file uuid(which is returned by Gitea in the upload file
response) onto the file object, so it can be used for the remove feature
to specify this file.

Fix #20115
2022-06-25 20:49:56 +01:00
zeripath
2111741a48
Add doctor command to write commit-graphs (#20007)
This PR adds a doctor command to write the commit-graphs for the repositories:

`gitea doctor --run check-commit-graphs --fix`

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-25 20:02:29 +01:00
Daniil Gentili
95383b7a16
Add sitemap support (#18407) 2022-06-25 19:06:01 +02:00
Kyle D
97bfabc745
Use new config options (#20125) 2022-06-24 16:38:19 -04:00
Kyle D
8a3cd58463
Remove depricated queue indexer usage (#20124) 2022-06-24 15:04:30 -04:00
John Olheiser
02eb4b143b
Disable status checks in template if none found (#20088)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-06-24 12:22:08 -05:00
Petr Vaněk
d789d3646c
Fix typos related to ErrTaskDoesNotExist error (#20118)
Fixes: f2a3abc683 ("Move migrating repository from frontend to backend (#6200)")
2022-06-24 15:51:37 +02:00
silverwind
48ef12b27c
Move eslintrc/stylelintrc to non-deprecated extensions (#20110) 2022-06-24 14:09:53 +02:00
zeripath
4909493a9f
Allow manager logging to set SQL (#20064)
This PR adds a new manager command to switch on SQL logging and to turn it off.

```
gitea manager logging log-sql
gitea manager logging log-sql --off
```

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-24 12:49:47 +02:00
Robert Lützner
afea63f4e5
Replace pubkey with privkey in keys_ssh.tmpl (#20112)
If a user wants to verify an SSH public key from their account they have
to sign the randomly generated token with their private key.

Prior to this change the example command prompted to sign the token with
their public key instead.

Signed-off-by: Robert Lützner <robert.luetzner@pm.me>
2022-06-24 12:11:13 +02:00
Lunny Xiao
8575050eba
Update security information to add a public gpg key to make sending encrypted message possible (#20117) 2022-06-24 11:40:01 +02:00
wxiaoguang
55a22d1136
Improve log document (#20097)
* Improve log document

* Update docs/content/doc/help/seek-help.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/help/seek-help.en-us.md

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Use different log names to avoid conflicts

* Update seek-help.en-us.md

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-24 10:56:46 +08:00
Lunny Xiao
d0507efb6a
Fix wrong login requirement routers (#20101) 2022-06-23 12:56:39 +02:00
Jimmy Praet
b8cfd4605f
Respect setting.UI.FeedPagingNum (#20094)
Fixes #20080
2022-06-23 11:50:37 +02:00
Lunny Xiao
3ba09103a4 [skip ci] Updated translations via Crowdin 2022-06-23 00:10:20 +00:00
dachary
30a703c8ef Fix minor wording issue 2022-06-23 04:59:07 +08:00
Lunny Xiao
fd97c4e0ae
Use correct variable for issue count (#20085) 2022-06-22 11:26:32 -05:00
Sandro
e9aa698cf0
Fix alias traversal (#20076)
see https://github.com/yandex/gixy/blob/master/docs/en/plugins/aliastraversal.md

Co-authored-by: 6543 <6543@obermui.de>
2022-06-22 16:15:49 +08:00
Jordan Cech
031f5f7b7c
Update permissions.en-us.md (#20075)
* Update permissions.en-us.md

A few grammar tweaks to make docs a bit more clear.

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/usage/permissions.en-us.md

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
2022-06-21 20:53:53 -04:00
6543
ae27050295
Changelog for 1.16.9 (#20059) (#20063)
* Changelog for 1.16.9 (#20059)

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-06-22 00:59:02 +02:00
6543
f6db650e9d
Release page show all tags in compare dropdown (#20070)
address #19936
2022-06-21 19:42:19 +02:00
24a462a95d
Delete the old example from FEDERATION.md 2022-06-21 11:34:16 -05:00
e090c95c17
Write a FEDERATION.md describing future Gitea federation features 2022-06-21 11:34:01 -05:00
s-hamann
7e733ee904
docs: Mention file extension for issue_template directory (#20057) 2022-06-21 16:08:31 +02:00
SteveTheEngineer
e67e685ed8 [skip ci] Updated translations via Crowdin 2022-06-21 00:10:11 +00:00
a7f32d3382
Finish initial ForgeFed implementation 2022-06-20 15:38:57 -05:00
SteveTheEngineer
1e2c2edab6
Catch the error before the response is processed by goth. (#20000)
The code introduced by #18185 gets the error from response after it was processed by goth.

That is incorrect, as goth (and golang.org/x/oauth) doesn't really care about the error, and it sends a token request with an empty authorization code to the server anyway, which always results in a `oauth2: cannot fetch token: 400 Bad Request` error from goth.
It means that unless the "state" parameter is omitted from the error response (which is required to be present, according to [RFC 6749, Section 4.1.2.1](https://datatracker.ietf.org/doc/html/rfc6749#section-4.1.2.1)) or the page is reloaded (makes the session invalid), a 500 Internal Server Error page will be displayed.
This fixes it by handling the error before the request is passed to goth.
2022-06-20 16:37:54 +01:00
Lunny Xiao
0649c54275
Adjust transaction handling via db.Context (#20031) 2022-06-20 14:38:58 +02:00
Wim
cb50375e2b
Add more linters to improve code readability (#19989)
Add nakedret, unconvert, wastedassign, stylecheck and nolintlint linters to improve code readability

- nakedret - https://github.com/alexkohler/nakedret - nakedret is a Go static analysis tool to find naked returns in functions greater than a specified function length.
- unconvert - https://github.com/mdempsky/unconvert - Remove unnecessary type conversions
- wastedassign - https://github.com/sanposhiho/wastedassign -  wastedassign finds wasted assignment statements.
- notlintlint -  Reports ill-formed or insufficient nolint directives
- stylecheck - https://staticcheck.io/docs/checks/#ST - keep style consistent
  - excluded: [ST1003 - Poorly chosen identifier](https://staticcheck.io/docs/checks/#ST1003) and [ST1005 - Incorrectly formatted error string](https://staticcheck.io/docs/checks/#ST1005)
2022-06-20 12:02:49 +02:00
Gusted
3289abcefc [skip ci] Updated translations via Crowdin 2022-06-20 00:10:43 +00:00
Gusted
02d745827b
Disable federation by default (#20045) 2022-06-20 07:48:17 +08:00
Wim
e91229eefb
Respond with a 401 on git push when password isn't changed yet (#20026)
If the user-agent starts with git and user must change password but
hasn't return a 401 with the message.

It must be a 401, git doesn't seem to show the contents of the error message
when we return a 403

Fixes #19090
2022-06-19 20:23:00 +01:00
Wim
62104b4896
Alter hook_task TEXT fields to LONGTEXT (#20038)
Mysql TEXT has a limit of 64KB, change this to LONGTEXT in mysql only so we can have bigger hook payloads.

Postgresql has unlimited TEXT - https://www.postgresql.org/docs/current/datatype-character.html
Sqlite has unlimited TEXT - https://www.sqlitetutorial.net/sqlite-data-types/#:~:text=The%20maximum%20length%20of%20TEXT,SQLite%20supports%20various%20character%20encodings.

Same issue as #16656 but for hook_task

Fixes #10252, #19679, #3561
2022-06-19 19:47:04 +01:00
zeripath
62cb3c8c85
Simplify and fix migration 216 (#20035)
There appears to be a strange bug whereby the comment_id index can sometimes be missed
or missing from the action table despite the sync2 that should create it in the earlier
part of this migration. However, looking through the code for Sync2 there is no need
for this pre-code to exist and Sync2 should drop/create the indices as necessary.

I think therefore we should simplify the migration to simply be Sync2.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-19 20:07:18 +02:00
d12fd434ba
Add Person and Repository ActivityPub endpoints 2022-06-19 10:39:22 -05:00
wxiaoguang
05a74e6e22
use quoted regexp instead of git fixed-value (#20029) 2022-06-19 12:56:22 +01:00
a1012112796
cc42c6488a
fix delete pull head ref for DeleteIssue (#20032)
* fix delete pull head ref for DeleteIssue

fix #19655

Signed-off-by: a1012112796 <1012112796@qq.com>

* add different help message for delete pull request

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: 6543 <6543@obermui.de>
2022-06-19 18:05:15 +08:00
e86f18a05a
User keypairs and HTTP signatures for ActivityPub federation using go-ap (#19133)
* go.mod: add go-fed/{httpsig,activity/pub,activity/streams} dependency

go get github.com/go-fed/activity/streams@master
go get github.com/go-fed/activity/pub@master
go get github.com/go-fed/httpsig@master

* activitypub: implement /api/v1/activitypub/user/{username} (#14186)

Return informations regarding a Person (as defined in ActivityStreams
https://www.w3.org/TR/activitystreams-vocabulary/#dfn-person).

Refs: https://github.com/go-gitea/gitea/issues/14186

Signed-off-by: Loïc Dachary <loic@dachary.org>

* activitypub: add the public key to Person (#14186)

Refs: https://github.com/go-gitea/gitea/issues/14186

Signed-off-by: Loïc Dachary <loic@dachary.org>

* activitypub: go-fed conformant Clock instance

Signed-off-by: Loïc Dachary <loic@dachary.org>

* activitypub: signing http client

Signed-off-by: Loïc Dachary <loic@dachary.org>

* activitypub: implement the ReqSignature middleware

Signed-off-by: Loïc Dachary <loic@dachary.org>

* activitypub: hack_16834

Signed-off-by: Loïc Dachary <loic@dachary.org>

* Fix CI checks-backend errors with go mod tidy

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Change 2021 to 2022, properly format package imports

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Run make fmt and make generate-swagger

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Use Gitea JSON library, add assert for pkp

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Run make fmt again, fix err var redeclaration

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Remove LogSQL from ActivityPub person test

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Assert if json.Unmarshal succeeds

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Cleanup, handle invalid usernames for ActivityPub person GET request

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Rename hack_16834 to user_settings

Signed-off-by: Anthony Wang <ta180m@pm.me>

* Use the httplib module instead of http for GET requests

* Clean up whitespace with make fmt

* Use time.RFC1123 and make the http.Client proxy-aware

* Check if digest algo is supported in setting module

* Clean up some variable declarations

* Remove unneeded copy

* Use system timezone instead of setting.DefaultUILocation

* Use named constant for httpsigExpirationTime

* Make pubKey IRI #main-key instead of /#main-key

* Move /#main-key to #main-key in tests

* Implemented Webfinger endpoint.

* Add visible check.

* Add user profile as alias.

* Add actor IRI and remote interaction URL to WebFinger response

* fmt

* Fix lint errors

* Use go-ap instead of go-fed

* Run go mod tidy to fix missing modules in go.mod and go.sum

* make fmt

* Convert remaining code to go-ap

* Clean up go.sum

* Fix JSON unmarshall error

* Fix CI errors by adding @context to Person() and making sure types match

* Correctly decode JSON in api_activitypub_person_test.go

* Force CI rerun

* Fix TestActivityPubPersonInbox segfault

* Fix lint error

* Use @mariusor's suggestions for idiomatic go-ap usage

* Correctly add inbox/outbox IRIs to person

* Code cleanup

* Remove another LogSQL from ActivityPub person test

* Move httpsig algos slice to an init() function

* Add actor IRI and remote interaction URL to WebFinger response

* Update TestWebFinger to check for ActivityPub IRI in aliases

* make fmt

* Force CI rerun

* WebFinger: Add CORS header and fix Href -> Template for remote interactions

The CORS header is needed due to https://datatracker.ietf.org/doc/html/rfc7033#section-5 and fixes some Peertube <-> Gitea federation issues

* make lint-backend

* Make sure Person endpoint has Content-Type application/activity+json and includes PreferredUsername, URL, and Icon

Setting the correct Content-Type is essential for federating with Mastodon

* Use UTC instead of GMT

* Rename pkey to pubKey

* Make sure HTTP request Date in GMT

* make fmt

* dont drop err

* Make sure API responses always refer to username in original case

Copied from what I wrote on #19133 discussion: Handling username case is a very tricky issue and I've already encountered a Mastodon <-> Gitea federation bug due to Gitea considering Ta180m and ta180m to be the same user while Mastodon thinks they are two different users. I think the best way forward is for Gitea to only use the original case version of the username for federation so other AP software don't get confused.

* Move httpsig algs constant slice to modules/setting/federation.go

* Add new federation settings to app.example.ini and config-cheat-sheet

* Return if marshalling error

* Make sure Person IRIs are generated correctly

This commit ensures that if the setting.AppURL is something like "http://127.0.0.1:42567" (like in the integration tests), a trailing slash will be added after that URL.

* If httpsig verification fails, fix Host header and try again

This fixes a very rare bug when Gitea and another AP server (confirmed to happen with Mastodon) are running on the same machine, Gitea fails to verify incoming HTTP signatures. This is because the other AP server creates the sig with the public Gitea domain as the Host. However, when Gitea receives the request, the Host header is instead localhost, so the signature verification fails. Manually changing the host header to the correct value and trying the veification again fixes the bug.


* Revert "If httpsig verification fails, fix Host header and try again"

This reverts commit f53e46c721.

The bug was actually caused by nginx messing up the Host header when reverse-proxying since I didn't have the line `proxy_set_header Host $host;` in my nginx config for Gitea.

* Go back to using ap.IRI to generate inbox and outbox IRIs

* use const for key values

* Update routers/web/webfinger.go

* Use ctx.JSON in Person response to make code cleaner

* Revert "Use ctx.JSON in Person response to make code cleaner"

This doesn't work because the ctx.JSON() function already sends the response out and it's too late to edit the headers.

This reverts commit 95aad98897.

* Use activitypub.ActivityStreamsContentType for Person response Content Type

* Limit maximum ActivityPub request and response sizes to a configurable setting

* Move setting key constants to models/user/setting_keys.go

* Fix failing ActivityPubPerson integration test by checking the correct field for username

* Add a warning about changing settings that can break federation

* Add better comments

* Don't multiply Federation.MaxSize by 1<<20 twice

* Add more better comments

* Fix failing ActivityPubMissingPerson test

We now use ctx.ContextUser so the message printed out when a user does not exist is slightly different

* make generate-swagger

For some reason I didn't realize that /templates/swagger/v1_json.tmpl was machine-generated by make generate-swagger... I've been editing it by hand for three months! 🤦

* Move getting the RFC 2616 time to a separate function

* More code cleanup

* Update go-ap to fix empty liked collection and removed unneeded HTTP headers

* go mod tidy

* Add ed25519 to httpsig algorithms

* Use go-ap/jsonld to add @context and marshal JSON

* Change Gitea user agent from the default to Gitea/Version

* Use ctx.ServerError and remove all remote interaction code from webfinger.go
2022-06-19 07:25:12 +02:00
Gusted
909fb6ad20
Backtick table name in generic orphan check (#20019) 2022-06-19 07:26:22 +08:00
wxiaoguang
e4ceaf65fb
Update document to clarify that ALLOWED_DOMAINS/BLOCKED_DOMAINS support wildcard (#20016) 2022-06-18 15:23:06 -04:00
Wim
439ace607d
Return 404 when tag is broken (#20017)
Fixes #19979
2022-06-18 19:08:34 +02:00
wxiaoguang
433443ffa9
Dump should only copy regular files and symlink regular files (#20015) 2022-06-18 22:06:32 +08:00
zeripath
870d7f90e7 [skip ci] Updated translations via Crowdin 2022-06-18 13:10:18 +00:00
zeripath
af7cfdee0e [skip ci] Updated translations via Crowdin 2022-06-18 10:11:27 +00:00
zeripath
90f3365d93
Add fgprof pprof profiler (#20005)
fgprof is a sampling Go profiler that allows you to analyze On-CPU as
well as Off-CPU (e.g. I/O) time together.

Go's builtin sampling CPU profiler can only show On-CPU time, but it's
better than fgprof at that. Go also includes tracing profilers that can
analyze I/O, but they can't be combined with the CPU profiler.

fgprof is designed for analyzing applications with mixed I/O and CPU
workloads. This kind of profiling is also known as wall-clock profiling.

Whilst fgprof can cause significant STW latencies in applications with a
lot of goroutines (> 1-10k), these latencies only occur if the profile
is requested - it doesn't cause a delay by simply being available.

The fgprof profile is mounted on
`http://localhost:6060/debug/fgprof?seconds=3`

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-18 11:04:52 +01:00
zeripath
7fbf002403 [skip ci] Updated translations via Crowdin 2022-06-18 09:10:16 +00:00
zeripath
5d653cc10d
Improve action table indices (#19472) 2022-06-18 04:46:50 -04:00
zeripath
dd1ed35f75
Add dbconsistency checks for Stopwatches (#20010)
It appears possible that stopwatches can become orphaned or have been orphaned in
the past.

This PR adds Orphan checks for Stopwatches.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-18 11:31:00 +08:00
Mohamed Sekour
fd0d481de8
fix push mirrors URL are no longer displayed on the UI (#20011)
* fix push mirrors URL are no longer displayed on the UI

Signed-off-by: Mohamed Sekour <mohamed.sekour@exfo.com>

* Update modules/templates/helper.go

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-18 11:30:26 +08:00
zeripath
8eefe2af45
Empty log queue on flush and close (#19994)
* Empty log queue on flush and close

It is possible for log events to remain in the buffer off the multichannelledlog
and thus not be logged despite close or flush.

This PR simply adds a function to empty the queue before closing or flushing.
(Except when the logger is paused.)

Reference #19982

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

* and do similar for ChannelledLog

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-18 10:33:13 +08:00
zeripath
46e50bcbfc [skip ci] Updated translations via Crowdin 2022-06-18 00:10:15 +00:00
zeripath
ae446b13f9
Stop spurious APIFormat stopwatches logs (#20008)
If there are dangling stopwatches with missing issues there will be repeated
logging of Unable to APIFormat stopwatches. These are unhelpful and instead
we should only log if the error is not an issue not exist error.

And we should also prevent an error on missing issue in GetActiveStopwatch too

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-17 22:47:15 +01:00
zeripath
5d80feb5a6
Fix CountOrphanedLabels in orphan check (#20009)
gitea doctor --run check-db-consistency is currently broken due to an incorrect
and old use of Count() with a string.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-17 22:42:51 +01:00
zeripath
1e9ad8eb21
Write Commit-Graphs in RepositoryDumper (#20004)
When migrating git repositories we should ensure that the commit-graph is written.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2022-06-17 21:19:21 +01:00
zeripath
ea9997a9dd
Add fetch.writeCommitGraph to gitconfig (#20006)
Add fetch.writeCommitGraph to gitconfig to ensure that a commit-graph will be written
on git fetch calls.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-17 21:18:35 +01:00
Lunny Xiao
27ba86d283
move agit dependcy (#19998) 2022-06-17 20:17:12 +02:00
wxiaoguang
719eb4a879
Fix a JS error in initRepoCommitLastCommitLoader's entryMap (#19996) 2022-06-17 17:44:35 +08:00
singuliere
a036507204
gitconfig: set safe.directory = * (#19870)
Allow git push to work when networked file systems with mixed
ownership are used with Gitea docker images >= 1.16.6 or Gitea
binaries running alongside git versions published after 04/2022.

There are circumstances independent of Gitea (networked file systems
with various permission systems) by which the git repositories managed
by Gitea may have mixed owners. It is not a behavior that Gitea have
control over nor is it a problem as long as the permissions for Gitea to
operate are correct. Gitea instances have been operating under these
conditions for a number of years.

It is detected as a potential security risk ( see
GHSA-vw2c-22j4-2fh2
) by the most recent git versions. However, Gitea always runs git
commands with a current directory matching the repository on
which it operates. That makes Gitea immune from this security problem
and it is safe to ignore the mixed owner permission check.

This gitconfig modification is done on a file dedicated to the user
exclusively used by Gitea.

Fixes: #19455

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-06-17 06:49:38 +01:00
Lunny Xiao
bdde56c95c
Fix Readme render bug (#19992)
Fix #19988 

Co-authored-by: zeripath <art27@cantab.net>
2022-06-17 06:48:10 +01:00
Lunny Xiao
1e05adfc3e
Delete duplicated update btn on pull request view page (#19993)
Fix #19987
2022-06-17 05:52:06 +01:00
oGi4i
9068c784c8
Use DisplayName() instead of FullName in Oauth provider (#19991)
Use DisplayName() in Oauth as this provides a fallback if FullName is not set.

Closes #19382
2022-06-16 23:29:54 +01:00
a1012112796
e3e06d13af
fix permission check for delete tag (#19985)
fix #19970

by the way, fix some error response about protected tags.

Signed-off-by: a1012112796 <1012112796@qq.com>
2022-06-16 22:03:03 +02:00
wxiaoguang
89b0aac374 [skip ci] Updated translations via Crowdin 2022-06-16 16:10:29 +00:00
wxiaoguang
157b405753
Remove legacy git code (ver < 2.0), fine tune markup tests (#19930)
* clean git support for ver < 2.0

* fine tune tests for markup (which requires git module)

* remove unnecessary comments

* try to fix tests

* try test again

* use const for GitVersionRequired instead of var

* try to fix integration test

* Refactor CheckAttributeReader to make a *git.Repository version

* update document for commit signing with Gitea's internal gitconfig

* update document for commit signing with Gitea's internal gitconfig

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-16 23:47:44 +08:00
Gusted
70ce051f1a [skip ci] Updated translations via Crowdin 2022-06-16 15:10:36 +00:00
Gusted
36127a3336
Don't prevent overflow on y-as (#19978)
- Fomantic tries to prevent overflowing on the `y/x`-as by default on
stackable menu's on mobile screens. We already solve this issue by
forcing overflow on x as and hide it on y as(due to some issues with
other menu's), since https://github.com/go-gitea/gitea/pull/19486.
- However this edge case does require a y-overflow to show the dropdown,
because you cannot easily adjust this with CSS, once you're fiddling
with overflow's (https://stackoverflow.com/a/6433475). However
interesting behavior is noted
https://css-tricks.com/popping-hidden-overflow/ when you remove the
position: relative, it will suddenly work again. Well because this is
the only solution without redesigning dropdowns, I think we can live
with the side-effect of the dropdown items being full-width instead
"relative" width to their parent.
- Resolves #19976

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-16 22:49:22 +08:00
a1012112796
d05fb6f6c9 [skip ci] Updated translations via Crowdin 2022-06-16 14:10:29 +00:00
a1012112796
a6b7c3646a
fix go to file link for mirror repository (#19983)
the `BaseRepo` not always exit, should
use `Repository`.

Signed-off-by: a1012112796 <1012112796@qq.com>
2022-06-16 20:37:13 +08:00
Gusted
e399f0f5b4
Don't buffer doctor logger (#19982)
- We don't need to buffer the logger with a thousand capacity. It's not
a high-throughput logger, this also caused issue whereby the logger
can't keep up with repeated messages being send(somehow they are lost in
the queue?).
- Resolves #19969

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-16 17:10:33 +08:00
Lunny Xiao
b01dce2a6e
Allow render HTML with css/js external links (#19017)
* Allow render HTML with css/js external links

* Fix bug because of filename escape chars

* Fix lint

* Update docs about new configuration item

* Fix bug of render HTML in sub directory

* Add CSP head for displaying iframe in rendering file

* Fix test

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Some improvements

* some improvement

* revert change in SanitizerDisabled of external renderer

* Add sandbox for iframe and support allow-scripts and allow-same-origin

* refactor

* fix

* fix lint

* fine tune

* use single option RENDER_CONTENT_MODE, use sandbox=allow-scripts

* fine tune CSP

* Apply suggestions from code review

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-06-16 11:33:23 +08:00
Gusted
7d1770cd71
Use correct count for NumOpenIssues (#19980)
- Don't specify the field in `Count` instead use `Cols` for this.
- Call `log.Error` when a error occur.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-16 10:51:34 +08:00
Hugo Hoitink
6473bd333a
In code search, get code unit accessible repos in one (main) query (#19764)
* When non-admin users use code search, get code unit accessible repos in one main query

* Modified some comments to match the changes

* Removed unnecessary check for Access Mode in Collaboration table

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-06-16 02:24:10 +03:00
Gusted
881646520e [skip ci] Updated translations via Crowdin 2022-06-15 22:10:15 +00:00
Gusted
f0ce5470e5
Always try to fetch repo for mirrors (#19975)
- Always give a best-effort to fetching the repositories, if even that
fails indeed give a disconnected mirror found error.
- *Partially* resolves #19928

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-06-15 23:58:44 +08:00
Lauris BH
1f8f9c3826
Remove tab/TabName usage where it's not needed (#19973)
`tab` query argument and `TabName` in context is used only in profile so remove it from all other places where it's not used anymore.
2022-06-15 23:05:32 +08:00
wxiaoguang
9f87b60b46
Fix cli command restore-repo: "units" should be parsed as StringSlice (#19953)
* Fix cli command restore-repo: "units" should be parsed as StringSlice because after  #15790 it's read by c.StringSlice("units").  Before, the "units" were processed by strings.Split
* Add checking for invalid unit names

Co-authored-by: 6543 <6543@obermui.de>
2022-06-15 20:28:03 +08:00
AHOHNMYC
97548d2722
Uppercase first languages letters (#19965) 2022-06-15 12:08:49 +02:00
Lunny Xiao
d91d4db344
Move tests as seperate sub packages to reduce duplicated file names (#19951) 2022-06-15 09:02:00 +02:00
silverwind
b4d420d865
Replace unstyled meter with progress (#19968)
Replace the only `<meter>` element in use with a `<progress>` which is
styled properly. Also slightly adjust colors on it for better contrast.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-15 12:28:24 +08:00
singuliere
f6e2dbaf1e [skip ci] Updated translations via Crowdin 2022-06-15 00:10:14 +00:00
singuliere
460c03ca49 [skip ci] Updated translations via Crowdin 2022-06-14 00:10:10 +00:00
singuliere
1fef9a2d69
Remove singuliere from MAINTAINERS (#19883) 2022-06-13 21:05:41 +01:00
wxiaoguang
0d7eda511f
Fix aria for logo (#19955)
Co-authored-by: 6543 <6543@obermui.de>
2022-06-13 14:46:39 -04:00
Lunny Xiao
ff82a18315
Fix mirror template bug (#19959)
* Fix mirror template bug

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2022-06-13 18:12:59 +02:00
Lunny Xiao
3c6c150740
Add deprecated log when using MySQL with utf8 charset (#19952) 2022-06-13 20:55:08 +08:00
Lunny Xiao
1a9821f57a
Move issues related files into models/issues (#19931)
* Move access and repo permission to models/perm/access

* fix test

* fix git test

* Move functions sequence

* Some improvements per @KN4CK3R and @delvh

* Move issues related code to models/issues

* Move some issues related sub package

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

* Rename some files
2022-06-13 17:37:59 +08:00
yutotnh
3708ca8e28
fix: some typos (#19956) 2022-06-13 15:34:46 +08:00
Lunny Xiao
5f136783d1 [skip ci] Updated translations via Crowdin 2022-06-13 00:10:09 +00:00
Lunny Xiao
110fc57cbc
Move some code into models/git (#19879)
* Move access and repo permission to models/perm/access

* fix test

* Move some git related files into sub package models/git

* Fix build

* fix git test

* move lfs to sub package

* move more git related functions to models/git

* Move functions sequence

* Some improvements per @KN4CK3R and @delvh
2022-06-12 23:51:54 +08:00
wxiaoguang
a9dc9b06e4
Fix signal loop in graceful manager (#19943) 2022-06-12 21:50:18 +08:00
Gusted
796c4eca0b
Prettify number of issues (#17760)
* Prettify number of issues

- Use the PrettyNumber function to add commas in large amount of issues.

* Use client-side formatting

* prettify on both server and client

* remove unused i18n entries

* handle more cases, support other int types in PrettyNumber

* specify locale to avoid issues with node default locale

* remove superfluos argument

* introduce template helper, octicon tweaks, js refactor

* Update modules/templates/helper.go

* Apply some suggestions.

* Add comment

* Update templates/user/dashboard/issues.tmpl

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-12 20:08:23 +08:00
Gusted
0097fbc2ac
Improve file header on mobile (#19945)
- File headers can become quite width, so ensure the file size is not
being wrapped into itself(width + padding-right) and allow the overflow
to be scrolled(overflow-x).
2022-06-12 12:30:22 +03:00
Gusted
edf14202fe
Unify repo settings & show better error (#19828)
* Unify context data
* Actually show invalid url in error
2022-06-12 13:43:27 +08:00
xkcdstickfigure
3898fc5bda [skip ci] Updated translations via Crowdin 2022-06-12 00:10:13 +00:00
xkcdstickfigure
47bb06236d
fixed comment typo (#19944) 2022-06-11 14:54:08 -04:00
6543
a9cc9c0f7a
Auto merge pull requests when all checks succeeded via WebUI (#19648)
Add WebUI part of Auto merge feature

close #19621

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
2022-06-11 16:44:20 +02:00
Lunny Xiao
ce3dd04c63
Fix some mirror bugs (#18649)
* Fix some mirror bugs

* Remove unnecessary code

* Fix lint

* rename stdard url

* Allow more charactors in git ssh protocol url

* improve the detection

* support ipv6 for git url parse

* Fix bug

* Fix template

* Fix bug

* fix template

* Fix tmpl

* Fix tmpl

* Fix parse ssh with interface

* Rename functions name

Co-authored-by: zeripath <art27@cantab.net>
2022-06-11 21:50:14 +08:00
wxiaoguang
88f2e457d8
Fix data-race problems in git module (quick patch) (#19934)
* Fix data-race problems in git module

* use HomeDir instead of setting.RepoRootPath

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-11 11:56:27 +08:00
silverwind
23422f9909 [skip ci] Updated translations via Crowdin 2022-06-11 00:10:12 +00:00
silverwind
527e5bd1b2
Fix copy/paste of empty lines (#19798)
* Fix copy/paste of empty newlines again

Fixes: https://github.com/go-gitea/gitea/issues/19331
Regressed by: https://github.com/go-gitea/gitea/pull/18270

Needed to do another newline addition to the Chroma output HTML to get
copy/paste work again. The previous replacement conditions are probably
obsolete, but as I'm not 100% sure, I opted to keep them.

Specifically, the Chroma HTML change mentioned in
https://github.com/go-gitea/gitea/pull/18270#issuecomment-1013350246
broke our previous newline replacement for such empty lines.

Also included are a few changes to make the test more pleasant to work
with.

* run go mod tidy

* add util.Dedent

* copy in the code

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-06-10 21:45:28 +08:00
silverwind
4d8e9f3b84
Normalize line endings in fomantic build files (#19932)
Ensures consistent line endings to avoid useless diffs because there is
somthing platform-dependant in that build.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-06-10 20:24:02 +08:00
Eekle
4f1fb0f697
Make user profile image show full image on mobile (#19840)
* Make user profile image show full image on mobile
2022-06-10 19:06:34 +08:00
Sandro Santilli
52c2e82813
Custom regexp external issues (#17624)
* Implement custom regular expression for external issue tracking.

Signed-off-by: Alexander Beyn <malex@fatelectrons.org>

* Fix syntax/style

* Update repo.go

* Set metas['regexp']

* gofmt

* fix some tests

* fix more tests

* refactor frontend

* use LRU cache for regexp

* Update modules/markup/html_internal_test.go

Co-authored-by: Alexander Beyn <malex@fatelectrons.org>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-06-10 13:39:53 +08:00
wxiaoguang
5f618248a9
Use Golang 1.18 for Gitea 1.17 release (#19918)
Use Golang 1.18 (as minimal requirement) for Gitea 1.17 release, make sure the Golang version is still actively supported during Gitea 1.17 lifecycle.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-06-10 05:34:41 +02:00
wxiaoguang
a0051634b9
Refactor git module, make Gitea use internal git config (#19732)
* Refactor git module, make Gitea use internal git config, add safe.directory config

* introduce git.InitSimple and git.InitWithConfigSync, make serv cmd use gitconfig

* use HOME instead of GIT_CONFIG_GLOBAL, because git always needs a correct HOME

* fix cmd env in cmd/serv.go

* fine tune error message

* Fix a incorrect test case

* fix configAddNonExist

* fix configAddNonExist logic, add `--fixed-value` flag, add tests

* add configSetNonExist function in case it's needed.

* use configSetNonExist for `user.name` and `user.email`

* add some comments

* Update cmd/serv.go

Co-authored-by: zeripath <art27@cantab.net>

* Update cmd/serv.go

Co-authored-by: zeripath <art27@cantab.net>

* Update modules/git/git.go

Co-authored-by: zeripath <art27@cantab.net>

* Update modules/setting/setting.go

Co-authored-by: zeripath <art27@cantab.net>

* Update modules/git/repo_attribute.go

Co-authored-by: zeripath <art27@cantab.net>

* fix spaces in messages

* use `configSet("core.protectNTFS", ...)` instead of `globalCommandArgs`

* remove GIT_CONFIG_NOSYSTEM, continue to use system's git config

* Update cmd/serv.go

Co-authored-by: zeripath <art27@cantab.net>

* fix merge

* remove code for safe.directory

* separate git.CommonEnvs to CommonGitCmdEnvs and CommonCmdServEnvs

* avoid Golang's data race error

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-10 09:57:49 +08:00
Roger Luo
e26f84a9b7 [skip ci] Updated translations via Crowdin 2022-06-10 00:10:33 +00:00
Roger Luo
2ae45cebbf
Feature: Find files in repo (#15028)
* Create finding files page ui in repo page

* Get tree entries for find repo files.

* Move find files JS to individual file.

* gen swagger.

* Add enry.IsVendor to exclude entries

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-09 14:15:08 +03:00
zeripath
7948cb3149
Prevent NPE whilst migrating if there is a team request review (#19855)
A pr.Reviewer may be nil when migrating from Gitea if this is a team
request review.

We do not migrate teams therefore we cannot map these requests, but we can
migrate user requests.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-09 10:50:05 +08:00
Lauris BH
d087554d81 [skip ci] Updated translations via Crowdin 2022-06-09 00:10:14 +00:00
Lauris BH
f92b7a6331
Add support for rendering terminal output with colors (#19497) 2022-06-09 00:46:39 +03:00
wxiaoguang
8fee7c46c1
Fix viewed images not loading in a PR (#19919)
Close #19651
2022-06-08 18:19:06 +01:00
wxiaoguang
cdb81f32ac
Remove out-dated comments (#19921) 2022-06-08 18:17:44 +01:00
zeripath
ac88f21ecc
Automatically render wiki TOC (#19873)
Automatically add sidebar in the wiki view containing a TOC for the wiki page.
Make the TOC collapsable

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-08 16:59:16 +08:00
André Jaenisch
c1c07e533c
Improve wording on delete access token modal (#19909)
This PR highlights the nature of the destructive action.
It also rewords the action buttons to remove ambiguity.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-06-07 20:28:10 -04:00
Gusted
d78ea362d4 [skip ci] Updated translations via Crowdin 2022-06-08 00:10:16 +00:00
Gusted
59fd864fad
Add breaking email restrictions checker in doctor (#19903)
* Add breaking change check in doctor

- This patch introduces a new kind of doctor type, breaking. This file
is made to register checks that helps with detecting when a breaking
change might impact a Gitea instance.
- For now the only check here(and the reason of creating this) is to
check if all users in the database has a valid email address, which
might not be the case after
https://github.com/go-gitea/gitea/pull/17688. This _simply_ uses the
validation function to detect and report these cases.
- Helps admins with detecting #19897.
- I have no clue which priority should be and IsDefault is true, because
when breaking change happen and we have a doctor check for it, we can
say "run `gitea doctor` to help you with this and maybe you find other
errors 😉".

* Makes no sense tbh

* Fix copyright

* Update modules/doctor/breaking.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-06-07 16:51:33 -04:00
zeripath
d8236f1b16
Ensure minimum mirror interval is reported on settings page (#19895)
* Ensure minimum mirror interval is reported on settings page

Expecting users to guess the minimum mirror interval appears a little unkind.
In this PR we simply change the locale string to include the minimum interval.
This will of course be affected by our current localization framework but...
we can fix that else where.

This PR also includes some fixes for error handling on the settings page as
previously the mirror block amongst others would simply disappear on error.

Fix #3737

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

* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* placate lint

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

* Update options/locale/locale_en-US.ini

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-06-07 13:40:12 -04:00
André Jaenisch
81cf006863
Improve UX on modal for deleting an access token (#19894)
* Improve UX on modal for deleting an access token

Before, both action buttons where coloured on hover. Otherwise they
appeared as ghost buttons. UX tells us, that call to action must not
be displayed as ghost button.

Using red is perceived as warning colour in Western cultures. It was
used for the non-destructive action before. This PR swaps the colour
and turns the cancel button into a filled one, so it is saver to do
nothing then to accidentally delete an access button. We want the
person to do this consciously.

In another iteration the wording here could be improved. See the
associated issue for further details.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>

* Use tabs instead of spaces.

Linter does not complain anymore. I was expecting the formatter to pick
this up but it didn't.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-06-07 12:25:40 -04:00
Eugene
5ab2dcb613
update discord invite (#19907) 2022-06-07 11:40:27 -04:00
Lunny Xiao
dbe415fb91
Only log non ErrNotExist errors in git.GetNote (#19884)
* Fix GetNote

* Only log errors if the error is not ErrNotExist

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-06-07 16:39:50 +08:00
wxiaoguang
23dd0f3456 [skip ci] Updated translations via Crowdin 2022-06-07 00:10:19 +00:00
wxiaoguang
3d9c02a1bb
Update frontend guideline (#19901)
* update frontend guideline

* "Native" => "Vanilla JS", fix typo comma.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-06 10:44:20 -04:00
zeripath
c48706ecde
Make AppDataPath absolute against the AppWorkPath if it is not (#19815)
* Make AppDataPath absolute against the AppWorkPath if it is not

There are multiple repeated issues whereby a non-absolute provided
APP_DATA_PATH causes strange issues.

This PR simply absolutes the APP_DATA_PATH against the AppWorkPath if
its not so. It also ensures that AppWorkPath is also always absolute.

Ref #19367

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

* Add logging

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

* absolute workpath against pwd instead of app path first

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-06 10:43:17 -04:00
Lunny Xiao
26095115f4
Move some repository related code into sub package (#19711)
* Move some repository related code into sub package

* Move more repository functions out of models

* Fix lint

* Some performance optimization for webhooks and others

* some refactors

* Fix lint

* Fix

* Update modules/repository/delete.go

Co-authored-by: delvh <dev.lh@web.de>

* Fix test

* Merge

* Fix test

* Fix test

* Fix test

* Fix test

Co-authored-by: delvh <dev.lh@web.de>
2022-06-06 16:01:49 +08:00
André Jaenisch
ebeb6e7c71
A minimal change to replace data calls with attr as per guidelines (#19900)
This affects the manage topics on a repository.
Namely the done button once changes are made.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-06-06 12:58:53 +08:00
silverwind
df0fb17d04
Modernize JS build scripts (#19824)
- Remove __dirname, use file URLs instead
- Upgrade fabric dependency
- Use fs/promises syntax, this breaks node 12 but we require 14 already

The change in public/img/favicon.svg is not caused by the fabric
upgrade, but it seems it was not properly generated when introduced.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-06 11:27:25 +08:00
Wim
0a8c030600 [skip ci] Updated translations via Crowdin 2022-06-06 00:10:13 +00:00
Wim
d9b50e4fd1
Update MAINTAINERS (#19896)
Added myself as maintainer
[List of PRs](https://github.com/go-gitea/gitea/pulls?q=is%3Apr+author%3A42wim+is%3Aclosed)
2022-06-05 20:55:08 +01:00
André Jaenisch
73382d2132
Add alt text to logo (#19892)
The recommended way is to use the name of the organisation followed
by "logo". however, since this is my first contribution, I am not
entirely sure, whether this is the best approach here.

The organisation is different from the organisation you can create as
part of the application. Instead, it is more related to the site
hosting the instance. Plus, I don't know how to best handle it when
the logo image is swapped out. Therefore, I use plain "Logo" and hope
that the person visiting the site has enough context.

Signed-off-by: André Jaenisch <andre.jaenisch@posteo.de>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-05 17:41:51 +08:00
Martijn de Boer
89a8b3e163
Limit max-height of CodeMirror editors for issue comment and wiki (#18271)
* Make the wiki editor bar sticky for longer wiki edits

On codeberg community it was requested to make the wiki editor toolbar sticky for longer wiki posts, so one wouldn't have to scroll to the top to use it. (Reference; https://codeberg.org/Codeberg/Community/issues/533).

In order to make this happen, the .editor-toolbar class needs to become position: sticky, and we need to fix it's transparent background and border-bottom. Because the bottom disappears, we add it. This makes the border become a double border, because the CodeMirror area defines borders for all. As such I've added a border-top: none, on the wiki write tab for the CodeMirror class.

* Make the issue bar in the issue view sticky for issue #10675

In issue #10675 it's requested to make the issue bar sticky upon scrolling in the issue view. The proposed change changes inline html, which is not desirable. As such I've added the position sticky option to it's container, and fix the background upon scrolling.

* Make linter happy on _repository.less

Fix 0px -> 0 to make the linter happy.

* Make linter happy on _editor.less

Fix 0px -> 0 to make the linter happy.

* Change z-index to the lowest boundary of 1

As per review of @silverwind change the z-index to it's lowest requirement of 1.

* Change z-index to the lowest boundary of 1

As per review of @silverwind change the z-index to it's lowest requirement of 1.

* Revert changes made to wiki editor (unsticky) and add max-height

Fixes the max-height to 85vh, on the proposed 90vh it just came out just slightly too large.
Unstickies the changes from the sticky commits.

* Revert changes for the sticky title editor

Removes the changes as done by the sticky title editor.

* Add max-height definition to CodeMirror-scroll

Add the max-height definition for the CodeMirror-scroll class in order to generalize the changes spoken about in PR #18271

* Remove CodeMirror-scroll definition

Remove the max-height in CodeMirror-scroll definition, in order to generalize it in the CodeMirror less file. As per discussion in #18271.

* fine tune CodeMirror min-height/max-height

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-05 09:09:50 +01:00
Wim
e528e2b435
Implement http signatures support for the API (#17565)
Fixes #12338

This allows use to talk to the API with our ssh certificate (and/or ssh-agent) without needing to fetch an API key or tokens.
It will just automatically work when users have added their ssh principal in gitea.

This needs client code in tea
Update: also support normal pubkeys

ref: https://tools.ietf.org/html/draft-cavage-http-signatures

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-05 08:16:14 +01:00
Lunny Xiao
48be5e77e5
Increment tests time out from 40m to 50m because sometimes the machine is slow (#19887) 2022-06-05 12:24:51 +08:00
Bo-Yi Wu
dadcaa4836
fix(CI/CD): correct CI variable. (#19886)
default value is true for CI variable

see https://docs.drone.io/pipeline/environment/reference/ci/

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-05 10:42:24 +08:00
Gusted
abb7d4ae5d
Fix typo (#19889) 2022-06-04 17:43:25 -04:00
Mai-Lapyst
090d89e0f9
Fixing wrong paging when filtering on the issue dashboard (#19801)
Fixes #19791 by adding an check if filtering after any repo; if yes, simply set the total count for the pageing to the sum of the issue count for each selected repo by utilize `issueCountByRepo`.

Fix #19791
2022-06-04 21:12:14 +01:00
Gusted
744e452185
Move /info outside authorization (#19888)
- To use the web's API to get information about a issue/pull on a
repository, doesn't require authorization(nor that the repository isn't
archived).
- Regressed by: #19318


Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-06-04 21:10:54 +01:00
Lunny Xiao
12c742f8dc
Fix order by parameter (#19849)
Upgrade builder to v0.3.11
Upgrade xorm to v1.3.1 and fixed some hidden bugs.

Replace #19821
Replace #19834
Included #19850

Co-authored-by: zeripath <art27@cantab.net>
2022-06-04 20:18:50 +01:00
zeripath
449ea6005f
Exclude Archived repos from Dashboard Milestones (#19882)
Milestones in archived repos should not be displayed on `/milestones`. Therefore
we should exclude these repositories from milestones page.

Fix #18257

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-04 19:30:01 +01:00
wxiaoguang
d0a2c1e82b
use exact search instead of fuzzy search for branch filter dropdown (#19885) 2022-06-04 17:02:10 +01:00
qwerty287
df9612bb53
Add API to serve blob or LFS file content (#19689)
* Add LFS API

* Update routers/api/v1/repo/file.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Apply suggestions

* Apply suggestions

* Update routers/api/v1/repo/file.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Report errors

* ADd test

* Use own repo for test

* Use different repo name

* Improve handling

* Slight restructures

1. Avoid reading the blob data multiple times
2. Ensure that caching is only checked when about to serve the blob/lfs
3. Avoid nesting by returning early
4. Make log message a bit more clear
5. Ensure that the dataRc is closed by defer when passed to ServeData

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

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-04 21:17:53 +08:00
Paweł Bogusławski
14d96ff7ac
Disable unnecessary mirroring elements (#18527)
* Disable unnecessary mirroring elements

This mod fixes disabling unnecessary mirroring elements.

Related: https://github.com/go-gitea/gitea/pull/16957
Related: https://github.com/go-gitea/gitea/pull/13084
Author-Change-Id: IB#1105104

* Checkbox rendering disabled instead of hiding it

Fixes: 02b45051503d4330da9757ff084c9cc5e6e60d84
Related: https://github.com/go-gitea/gitea/pull/18527#pullrequestreview-878061913
Author-Change-Id: IB#1105104

* Update custom/conf/app.example.ini

Co-authored-by: silverwind <me@silverwind.io>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: silverwind <me@silverwind.io>

* Mirror filter removed only when whole mirroring feature is disabled

Fixes: 02b45051503d4330da9757ff084c9cc5e6e60d84
Related: https://github.com/go-gitea/gitea/pull/18527#discussion_r883268890
Author-Change-Id: IB#1105104

Co-authored-by: silverwind <me@silverwind.io>
2022-06-04 19:42:17 +08:00
wxiaoguang
867b34d5e9 [skip ci] Updated translations via Crowdin 2022-06-04 00:10:09 +00:00
wxiaoguang
694441fec5
Remove customized (unmaintained) dropdown, improve aria a11y for dropdown (#19861)
* Remove customized (unmaintained) dropdown, improve aria a11y for dropdown

* fix repo permission

* use action instead of onChange

* re-order the CSS selector

* fix dropdown behavior for repo permissions, make elements inside menu item non-focusable

* use menu/menuitem instead of combobox/option. use tooltip(data-content) for aria-label, prevent from repeated attaching

* click menu item when pressing Enter

* code format

* fix repo permission

* repo setting: prevent from misleading users when error occurs

* fine tune the repo collaboration access mode dropdown (in case the access mode is undefined in the template)

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-06-03 17:38:26 -04:00
zeripath
1d04e8641d
Set Setpgid on child git processes (#19865)
When Gitea is running as PID 1 git will occassionally orphan child processes leading
to (defunct) processes. This PR simply sets Setpgid to true on these child processes
meaning that these defunct processes will also be correctly reaped.

Fix #19077

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-06-03 15:36:18 +01:00
zeripath
085924b1b3
Allow postgres integration tests to run over unix pipe (#19875) 2022-06-03 02:14:09 -04:00
Lunny Xiao
e09fb30d34
improvement some release related code (#19867) 2022-06-03 02:13:58 -04:00
ttys3
0c759fd4de
feat: add DEFAULT_MERGE_STYLE to repository.pull-request section for repo init (#19751) 2022-06-02 23:45:54 -04:00
zeripath
808a780309 [skip ci] Updated translations via Crowdin 2022-06-03 00:11:14 +00:00
zeripath
e32ab429ff
Prevent NPE on update mirror settings (#19864)
A `repo_model.Mirror` repository field (`.Repo`) will not automatically
be set, but is used without checking in mirror_pull.go:UpdateAddress.
This will cause an NPE.

This PR changes UpdateAddress to use the helper function GetRepository()
helping prevent future NPEs but also changes modules/context/repo.go to
ensure that the Mirror.Repo is set.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-06-02 12:56:32 -04:00
wxiaoguang
6171ea7d31
update documents (#19868) 2022-06-02 00:22:42 -04:00
zeripath
8aaba65eee
Only return valid stopwatches (#19863)
Looking through the logs of try.gitea.io I am seeing a number of reports
of being unable to APIformat stopwatches because the issueID is 0. These
are invalid StopWatches and they represent a db inconsistency.

This PR simply stops sending them to the eventsource.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-06-02 10:36:46 +08:00
zeripath
5283d1ead5 [skip ci] Updated translations via Crowdin 2022-06-02 00:10:13 +00:00
zeripath
bbffddaa8a
Add title attribute to dependencies in sidebar (#19807)
* Add title attribute to dependencies in sidebar

Add the full title as the title attribute on dependencies in
the sidebar.

Fix #19806

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

* as per silverwind

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-06-01 15:08:34 -04:00
zeripath
d002e3da00
Fix spelling mistake in ProcReceive (#19853)
There was a spelling mistake in the ProcReceive handler. This PR fixes
this.
2022-06-01 04:06:31 +01:00
zeripath
730b9a5a62
Ensure responses are context.ResponseWriters (#19843)
In order for web.Wrap to be able to detect if a response has been written
we need to wrap any non-context.ResponseWriters as a such. Otherwise
responses will be incorrectly detected as non-written to and handlers can
double run.

In the case of GZip this handler will change the response to a non-context.RW
and this failure to correctly detect response writing causes fallthrough and
a NPE.

Fix #19839

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-05-31 21:27:44 +01:00
Gusted
0e516949a4
Fix inconsistency in doctor output (#19836)
* Fix inconsistency in doctor output

- Use `logger.Info` instead of `logger.Warn` when no errors were found.

* Update modules/doctor/fix16961.go

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-05-31 14:49:40 -04:00
singuliere
40e87d031f
docs: recommendations to ensure backup consistency and reliability (#19845)
* docs: recommendations to ensure backup consistency and reliability

* s/stooping/stopping/

* Update docs/content/doc/usage/backup-and-restore.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: delvh <dev.lh@web.de>
2022-05-31 14:42:32 -04:00
Thomas Andrade
4a295d4a6c
feat: Add support for extra sshd_config parameters via 'Include' file (#19842)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-05-31 14:42:19 -04:00
GiteaBot
e31c6166ee [skip ci] Updated translations via Crowdin 2022-05-31 00:10:30 +00:00
singuliere
fdc784dbf4
docs: update the ROOT documentation and error messages (#19832)
* docs: update the ROOT documentation and error messages

* The documentation now reflects what happens in the
  setting/repository.go::newRepository function:
  filepath.Join(AppWorkPath, RepoRootPath) was missing.

* The error message displayed when RepoRootPath is not found now
  displays the value of RepoRootPath. Given the complexity of the
  construction of this value, only referring to it in the abstract
  is likely to be misleading to the Gitea admin trying to interpret
  the message.

Co-authored-by: delvh <dev.lh@web.de>
2022-05-31 00:47:55 +02:00
GiteaBot
fe4c846ccb [skip ci] Updated translations via Crowdin 2022-05-30 00:10:14 +00:00
delvh
5976e3e89b Add version hint in the docs when packages are available (#19838)
* Add version hint in the docs when packages are available

* Change italic to bold
2022-05-29 14:10:21 -04:00
Yehonatan Ezron
4cac908255
docs(hacking-on-gitea): fix installation instruction for elasticsearch docker (#19829) 2022-05-29 20:59:25 +03:00
wxiaoguang
e0273bad72
Fix i18n for Link Account button, re-format tmpl (#19835) 2022-05-29 16:19:56 +08:00
GiteaBot
76681883ec [skip ci] Updated translations via Crowdin 2022-05-29 00:10:54 +00:00
Mai-Lapyst
4698a1ec47
Adding button to link accounts from user settings (#19792)
* Adding button to link accounts from user settings

* Only display button to link user accounts when at least one OAuth2 provider is active
2022-05-29 02:03:17 +02:00
Yehonatan Ezron
f2439b7e4c
fix(telegram): fix link bot to release tag (#19830)
* fix(telegram): fix link bot to release tag

* test(webhook): fix matrixPayload Release

* test(webhook): fix TestTelegramPayload Release
2022-05-28 16:44:51 -04:00
Lauris BH
65e0688a5c
Fix raw endpoint PDF file headers (#19825) 2022-05-28 18:10:14 +03:00
singuliere
410df1fbd4
docs: FAQ: the WorkPath can be set from --work-path (#19822) 2022-05-28 16:47:13 +08:00
GiteaBot
cfb4c23a50 [skip ci] Updated translations via Crowdin 2022-05-28 00:10:25 +00:00
Vladimir Yakovlev
b41111bc78
Fix duplicate paragraph in documentation (#19820) 2022-05-27 15:40:00 -04:00
Ondřej Čertík
8720f876c7
Make WIP prefixes case insensitive, e.g. allow Draft as a WIP prefix (#19780)
The issue was that only the actual title was converted to uppercase, but
not the prefix as specified in `WORK_IN_PROGRESS_PREFIXES`. As a result,
the following did not work:

    WORK_IN_PROGRESS_PREFIXES=Draft:,[Draft],WIP:,[WIP]

One possible workaround was:

    WORK_IN_PROGRESS_PREFIXES=DRAFT:,[DRAFT],WIP:,[WIP]

Then indeed one could use `Draft` (as well as `DRAFT`) in the title.
However, the link `Start the title with DRAFT: to prevent the pull request
from being merged accidentally.` showed the suggestion in uppercase; so
it is not possible to show it as `Draft`. This PR fixes it, and allows
to use `Draft` in `WORK_IN_PROGRESS_PREFIXES`.

Fixes #19779.

Co-authored-by: zeripath <art27@cantab.net>
2022-05-26 10:19:24 +01:00
silverwind
9574626a23
Fix follower display on user page (#19805) 2022-05-26 00:29:40 +08:00
IT-AlexKor
0692f437b6
Show source/target branches on PR's list (#19747)
Add ability to show source/target branches for Pull Request's list. It can be useful to see which branches are used in each PR right in the list.

Co-authored-by: Alexey Korobkov <akorobkov@cian.ru>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-05-25 15:33:35 +02:00
istiak101
35d0358c2a
Github style following followers (#19482)
Removed tabbed following and followers from user page and added Github style following followers.
2022-05-25 19:45:45 +08:00
techknowlogick
0cbec3cd37
alpine 3.16 (#19797)
Co-authored-by: 6543 <6543@obermui.de>
2022-05-25 07:42:28 +03:00
zeripath
93ab90743d
Prevent loop if there is an error in GetNotificationCount (#19799)
If the context is cancelled `.NotificationUnreadCount` in a template can
cause an infinite loop with `ctx.ServerError()` being called, which
creates a template that then calls `.NotificationUnreadCount` calling
`GetNotificationCount()` with the cancelled context resulting in an
error that calls `ctx.ServerError`... and so on...

This PR simply stops calling `ctx.ServerError` in the error handler code
for `.NotificationUnreadCount` as we have already started rendering and
so it is too late to call `ctx.ServerError`. Additionally we skip
logging the error if it's a context cancelled error.

Fix #19793

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-05-25 08:51:53 +08:00
silverwind
b24db66a5f
Add 'make tidy' (#19800)
Convenience command to run 'go mod tidy'. The compat flag is set to the
minimum supported go version instead of min version minus one which is
go's default, which eliminated some checksums in go.sum as a result.
2022-05-24 20:19:13 -04:00
wxiaoguang
4266bd924b
Update document to use FHS /usr/local/bin/gitea instead of /app/... for Docker (#19794)
* Update document to use FHS `/usr/local/bin/gitea` instead of `/app/...` in Docker

* Update docs/content/doc/installation/with-docker.zh-cn.md
2022-05-24 14:57:15 +08:00
GiteaBot
7671a3322b [skip ci] Updated translations via Crowdin 2022-05-24 00:10:14 +00:00
Jan-Eric Schober
b65ad70f53
Add the possibility to allow the user to have a favicon which differs from the main logo (#18542)
* Changed the filename of the favicon SVG

This allows the user to have a favicon which differs from the logo.

* Added favicon.svg

This is needed to accommodate the changes for allowing the user to have a differing logo and favicon

* Adjusted page to accommodate what icon is used as favicon

* Added functionality to also generate the favicon.svg via generate-images.js

* Adjusted the description for the new favicon compatibility

Co-authored-by: silverwind <me@silverwind.io>

* Updated generate-images.js to generate favicons from a separate favicons.svg file

This belongs to PR #18542.

* Added description on how custom favicons can be generated

* Replaced space indents with tabs

* Synced changes with current state of the file

* Synced changes with current state of the file

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-05-23 23:54:48 +08:00
GiteaBot
d2a91e5e59 [skip ci] Updated translations via Crowdin 2022-05-23 00:10:14 +00:00
GiteaBot
fa5dec966c [skip ci] Updated licenses and gitignores 2022-05-22 00:10:22 +00:00
zeripath
ffb7ab31f2
Estimate Action Count in Statistics (#19775) 2022-05-21 14:50:50 -04:00
zeripath
468387e9ce
Prevent NPE when cache service is disabled (#19703)
The cache service can be disabled - at which point ctx.Cache will be nil
and the use of it will cause an NPE.

The main part of this PR is that the cache is used for restricting
resending of activation mails and without this we cache we cannot
restrict this. Whilst this code could be re-considered to use the db and
probably should be, I think we can simply disable this code in the case
that the cache is disabled.

There are also several bug fixes in the /nodeinfo API endpoint.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-05-21 22:29:49 +08:00
zeripath
bc4764ffc6
Detect truncated utf-8 characters at the end of content as still representing utf-8 (#19773)
Our character detection algorithm can potentially incorrectly detect utf-8 as iso-8859-x
if there is a truncated character at the end of the partially read file.

This PR changes the detection algorithm to truncated utf8 characters at the end of the
buffer.

Fix #19743

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-05-21 14:06:24 +01:00
silentcodeg
f6c992974e
Add silentcodeg to MAINTAINERS (#19771)
* Add silentcodeg to MAINTAINERS

* add missing trailing g to chat nick

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-21 20:09:37 +08:00
Eekle
876cad0064
Allows repo search to match against "owner/repo" pattern strings (#19754)
* Allows repo search to match against "owner/repo" pattern strings

* Gofumpt

* Adds test case for "owner/repo" style repo search

* With "owner/repo" search terms, prioritise results which match the owner field

* Fixes unquoted SQL string in repo search
2022-05-21 17:15:40 +08:00
silverwind
ba7750d6e7
Update JS dependencies (#19767)
- Update all JS dependencies minus Vue
- Tested mermaid, swagger, build

Co-authored-by: 6543 <6543@obermui.de>
2022-05-20 21:10:03 -04:00
zeripath
a9af93cb21
Nuke the incorrect permission report on /api/v1/notifications (#19761)
The permissions created in convertRepo use a minimal perm.AccessModeRead instead of
correctly computing the permission for the repository. This incorrect permission is
then reported to the user.

I do not believe that reporting the permissions is helpful and therefore I propose
we simply null these out. The user can check their permissions using a different
endpoint.

Fix #19759

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-05-20 18:57:49 +02:00
Lunny Xiao
fd7d83ace6
Move almost all functions' parameter db.Engine to context.Context (#19748)
* Move almost all functions' parameter db.Engine to context.Context
* remove some unnecessary wrap functions
2022-05-20 22:08:52 +08:00
Lunny Xiao
d81e31ad78
Move org functions (#19753)
* Move org functions

* Fix comment
2022-05-20 12:20:51 +02:00
silentcodeg
63f6e6c0bd
[doctor] pq: syntax error at or near "." quote user table name (#19765) 2022-05-20 15:36:34 +08:00
silentcodeg
2c66bd8afd
[doctor] update the help with fix capabilities (#19762)
* [doctor] update the help with fix capabilities
2022-05-20 05:39:52 +02:00
silverwind
ac8bee6aeb
Remove fomantic progress module (#19760)
Replace it with HTML `<progress>` element. The bar won't go green at
100% anymore but I think it's not something that fits stylistically anyways.
2022-05-20 05:04:45 +02:00
wxiaoguang
cc7236e852
Make Ctrl+Enter (quick submit) work for issue comment and wiki editor (#19729)
* Make Ctrl+Enter (quick submit) work for issue comment and wiki editor

* Remove the required `SubmitReviewForm.Type`, empty type (triggered by quick submit) means "comment"

* Merge duplicate code
2022-05-20 04:26:04 +02:00
delvh
3b359b1629
Enable packages by default again (as described by docs) (#19746) 2022-05-20 02:48:42 +02:00
silverwind
9da3d78e74
Replace blue button and label classes with primary (#19763)
* make blue really blue

* replace blue button and label classes with primary

* add --color-blue-dark

* add light color variants, tweak a few colors

* fix colors

* add comment

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-20 00:08:08 +02:00
KN4CK3R
ce52514762
Fix org package owner permissions (#19742)
Old code did not respect owner visibility and the organization access calculation was wrong if the user was not a member.
2022-05-19 17:56:45 +02:00
Guo Y.K
3e5ea9a978
Update base.go (#19739)
use http.StatusTemporaryRedirect(307) when serve avatar directly

browser caches 301 redirections, pre-signed s3 url would expire at some later point

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-05-19 11:20:34 -04:00
silentcodeg
c27268db21
[doctor] do not update User Stars numbers unless --fix (#19750) 2022-05-19 15:46:56 +02:00
delvh
ad551bffc1
Fix incorrect translation key (#19744)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-05-19 09:59:28 +08:00
Eekle
260a28d8d5
Improved ref comment link when origin is body/title (#19741)
* Makes comments in body text/title return the base page URL instead of "" in RefCommentHTMLURL()

* Add comment explaining branch

Co-authored-by: delvh <dev.lh@web.de>
2022-05-18 23:36:49 +02:00
silentcodeg
6a052fba05
[doctor] explain what enable-push-options does (#19740) 2022-05-18 11:04:12 -04:00
silentcodeg
e82db15cfa
Add doctor orphan check for orphaned pull requests without an existing base repo (#19731) 2022-05-18 02:34:32 +02:00
KN4CK3R
9ea9206406
ContainerRegistry - removed Basic Auth header (#19735)
* Removed Basic Auth header.

* Fixed test.
2022-05-17 19:58:42 +08:00
GiteaBot
6d54799bbc [skip ci] Updated translations via Crowdin 2022-05-17 00:10:28 +00:00
6543
af4caca8fb
Add changelog for v1.16.8 (#19724) (#19730)
* Add changelog for v1.16.8 (#19724)

* Add changelog for v1.16.8

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* bump

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-16 17:01:13 -04:00
Gusted
bcf13b670b
Improve commit list/view on mobile (#19712)
- This is a continuation on [the work](https://github.com/go-gitea/gitea/pull/19546) I've done for improving mobile experience on Gitea.
- The current behavior of going trough the commits list is horrible, each individual item gets it's own row and thereby isn't quite compact as it should be on mobile. The commit view's header is in a bit better state, it's quite only that content is overlapping each other.
- This patch fixes those problems. Each row in the commit list table will actually take a row in the UI. The commit view's header has now a better organized way of placing the information.
2022-05-16 18:45:12 +02:00
Gusted
71ca131582
Fix issue overview for teams (#19652)
- Don't use hacky solution to limit to the correct RepoID's, instead use
current code to handle these limits. The existing code is more correct
than the hacky solution.
- Resolves #19636
- Add test-case
2022-05-16 17:49:17 +08:00
zeripath
d494cc3356
Fix nodeinfo caching and prevent NPE if cache non-existent (#19721)
Extract from #19703

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-05-16 15:36:57 +08:00
6543
00a981d341
Update go-chi/cache to utilize Ping() (#19719)
* update gitea.com/go-chi/cache -> v0.2.0

* ajust to new interface

* refactor
2022-05-15 20:43:27 +02:00
John Olheiser
3a245230f4
Disable blank issues (#19717) 2022-05-15 13:45:11 -04:00
f0x52
6680cca07f
clarify what session provider 'db' does (#19713)
* clarify what session provider 'db' does

* Also update session.PROVIDER in app.example.ini

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-16 00:40:29 +08:00
GiteaBot
761d4f40be [skip ci] Updated translations via Crowdin 2022-05-15 00:10:15 +00:00
zuzuviewer
77e9346342
Fix duplicate entry error when add team member (#19702) 2022-05-14 16:30:19 +03:00
6543
b135313c47
[Refactor] convert team(s) to apiTeam(s) (#13745)
* Refactor: teams to api convert

* make org load optional

* more info in tests
2022-05-13 19:27:58 +02:00
Gusted
61f939359d
Use a better OlderThan for DeleteInactiveUsers (#19693)
* Use a better OlderThan for DeleteInactiveUsers

- Currently the OlderThan is zero, for instances that enable or run this
task this could actually delete just new users that still need to
confirm their email. This patch fixes that by setting the default to the
`ActiveCodeLives` setting, which corresponds to the amount of time that
a user can active their account, thus avoiding the issue of deleting
unactivated email users.

* Use correct duration
2022-05-13 14:49:22 +02:00
GiteaBot
cafa2dcb87 [skip ci] Updated translations via Crowdin 2022-05-13 00:10:14 +00:00
silverwind
e45738e3c9
Introduce eslint-plugin-jquery (#19690)
Introduce the plugin that allows us to gradually forbid jQuery code.
I've enabled all rules that already pass.

Next step will be to go through each rule and fix the issues by using
native DOM equivalents, which I think can be done in separate PRs, but
if prefered I could also start here.
2022-05-12 23:51:50 +08:00
wxiaoguang
368baf9e77
Use Vue to refactor pull merge UI (#19650)
* Use Vue to refactor pull merge UI

* add comments

* fix comments

* small fine tune

* fix tests

* adopt new pull default messages

* clean up

Co-authored-by: 6543 <6543@obermui.de>
2022-05-12 21:39:02 +08:00
GiteaBot
d985dcc922 [skip ci] Updated translations via Crowdin 2022-05-12 00:10:15 +00:00
Lunny Xiao
ea38e90e6b
Fix oauth setting list bug (#19682) 2022-05-11 21:06:02 +08:00
6543
f41c2bec4c
Delete user related oauth stuff on user deletion too (#19677)
* delete user related oauth stuff on user deletion too

* extend doctor check-db-consistency
2022-05-11 13:16:35 +02:00
Lunny Xiao
cbd45471b1
Move access and repo permission to models/perm/access (#19350)
* Move access and repo permission to models/perm/access

* Remove unnecessary code
2022-05-11 12:09:36 +02:00
silverwind
8e8e936ada
Tidy up <head> template (#19678)
Neiter `<meta>` nor `<link>` require a closing slash at the end in HTML,
remove it.
2022-05-10 20:05:50 -05:00
silverwind
318f360252
Update go tool dependencies (#19676)
* Update go tool dependencies

Updated all tool dependencies to latest tags, hoping CI will like it.

* fix new lint errors

* handle more strings.Title cases

* remove lint skip
2022-05-10 23:55:54 +02:00
silverwind
3c658dff23
Update JS dependencies (#19675)
* Update JS dependencies

- Update all JS dependencies minus vue and vue-loader
- Adapt to jest 28
- Add new eslint rules
- Tested Mermaid and Swagger-UI

* switch to @happy-dom/jest-environment for faster tests

* bump eslint env to es2022
2022-05-10 21:44:36 +02:00
Gusted
9d0253a9fa
Use better message for consistency check (#19672)
- Don't log the reflect struct, but instead log the ID of the struct.
This improves the error message, as you would actually know which row is
the error.
2022-05-10 16:18:20 +02:00
Lunny Xiao
64a40962cc
Fix new release from tags list UI (#19670) 2022-05-10 15:41:37 +03:00
6543
65ccff54ef
Update go deps (#19665)
* update gitea.com/go-chi/binding
* update github.com/42wim/sshsig
* update github.com/PuerkitoBio/goquery
* update github.com/blevesearch/bleve/v2
* update github.com/caddyserver/certmagic
* update github.com/duo-labs/webauthn
* update github.com/editorconfig/editorconfig-core-go/v2
* update github.com/emirpasic/gods
* update github.com/gliderlabs/ssh
* update github.com/go-chi/cors
* update github.com/go-enry/go-enry/v2
* update github.com/go-git/go-git/v5
* update github.com/go-ldap/ldap/v3
* update github.com/golang-jwt/jwt/v4
* update github.com/google/pprof
* update github.com/klauspost/compress
* update github.com/lib/pq
* update github.com/markbates/goth
* update github.com/minio/minio-go/v7
* update github.com/olivere/elastic/v7
* update github.com/unrolled/render
* update github.com/urfave/cli
* update github.com/xanzy/go-gitlab
* update github.com/yuin/goldmark
* adopt breaking changes of certmagic
2022-05-10 12:32:42 +02:00
singuliere
443675d180
[doctor] Add check/fix for bogus action rows (#19656)
Signed-off-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-05-10 02:49:01 +02:00
GiteaBot
9fc194d2d9 [skip ci] Updated translations via Crowdin 2022-05-10 00:10:16 +00:00
Jack Hay
7e19200e53
Add tooltip to pending PR comments (#19662) 2022-05-09 21:04:27 +02:00
KN4CK3R
3da9dafc60
Add Webfinger endpoint (#19462)
This adds the [Webfinger](https://webfinger.net/) endpoint for federation.

Supported schemes are `acct` and `mailto`. The profile and avatar url are returned as metadata.
2022-05-09 20:20:21 +02:00
Jimmy Praet
a61a47f9a0
Update documentation to disable duration settings with -1 instead of 0 (#19647)
To turn off the notification endpoint polling, the value should be set to -1, not 0.
2022-05-09 18:33:19 +02:00
zeripath
9f5ddca57c
Set the LastModified header for raw files (#18356)
Although the use of LastModified dates for caching of git objects should be
discouraged (as it is not native to git - and there are a LOT of ways this
could be incorrect) - LastModified dates can be a helpful somewhat more human
way of caching for simple cases.

This PR adds this header and handles the If-Modified-Since header to the /raw/
routes.

Fix #18354

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2022-05-09 17:54:51 +02:00
Lunny Xiao
e435283c0f
Don't select join table's columns (#19660)
* Don't select join table

* Add comment
2022-05-09 23:19:16 +08:00
GiteaBot
cd99540cdc [skip ci] Updated translations via Crowdin 2022-05-09 00:10:13 +00:00
KN4CK3R
a9ca4b4100
Calculate filename hash only once (#19654)
* Calculate hash only once.

* remove unused Sha1 template helper function, use ctx.Data["FileNameHash"]

* fix unit tests
2022-05-09 00:29:50 +02:00
Lunny Xiao
9efa47131f
Admin should not delete himself (#19423)
Admin should not be able to delete themselves.

Also partially fix #15449
2022-05-08 21:22:55 +01:00
Lunny Xiao
290cc884f2
Restore reviewed-on message (#19657)
Regression from #18177
2022-05-08 20:13:27 +01:00
Lunny Xiao
4ca1d7547a
Move some helper files out of models (#19355)
* Move some helper files out of models

* Some improvements

Co-authored-by: delvh <dev.lh@web.de>
2022-05-08 18:46:32 +02:00
Lunny Xiao
d4834071da
Repository level enable package or disable (#19323) 2022-05-08 17:51:50 +02:00
6543
6a969681cd
Delete related PullAutoMerge and ReviewState on User/Repo Deletion (#19649)
* delete pullautomerges on repo/user deletion
* delete reviewstates on repo/user deletion
* optimize automerhe code
* add index to reviewstate
2022-05-08 15:46:34 +02:00
Lunny Xiao
4344a64107
Allow custom default merge message with .gitea/default_merge_message/<merge_style>_TEMPLATE.md (#18177)
* Allow custom default merge message with .gitea/MERGE_MESSAGE_<merge_style>_TEMPLATE.md

* Some improvements

* Follow some advices

* Fix bug

* Fix bug

* Fix lint

* Fix close comment

* Fix test

* Fix and docs

* Improve codes

* Update docs and remove unnecessary variables

* return error for GetDefaultMergeMessage

* Fix test

* improve code

* ignore unknow unit type

* return error for GetDefaultMergeMessage

* Update services/pull/merge.go

* Some improvements

* Follow some advices

* Fix bug

* Fix lint

* Improve codes

* Update docs and remove unnecessary variables

* return error for GetDefaultMergeMessage

* improve code

* Handle deleted HeadRepo in GetDefaultMergeMessage

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

* Fix test

* Fix test

Co-authored-by: zeripath <art27@cantab.net>
2022-05-08 20:32:45 +08:00
delvh
5ca224a789
Allow to mark files in a PR as viewed (#19007)
Users can now mark files in PRs as viewed, resulting in them not being shown again by default when they reopen the PR again.
2022-05-07 20:28:10 +02:00
kolaente
59b30f060a
Auto merge pull requests when all checks succeeded via API (#9307)
* Fix indention

Signed-off-by: kolaente <k@knt.li>

* Add option to merge a pr right now without waiting for the checks to succeed

Signed-off-by: kolaente <k@knt.li>

* Fix lint

Signed-off-by: kolaente <k@knt.li>

* Add scheduled pr merge to tables used for testing

Signed-off-by: kolaente <k@knt.li>

* Add status param to make GetPullRequestByHeadBranch reusable

Signed-off-by: kolaente <k@knt.li>

* Move "Merge now" to a seperate button to make the ui clearer

Signed-off-by: kolaente <k@knt.li>

* Update models/scheduled_pull_request_merge.go

Co-authored-by: 赵智超 <1012112796@qq.com>

* Update web_src/js/index.js

Co-authored-by: 赵智超 <1012112796@qq.com>

* Update web_src/js/index.js

Co-authored-by: 赵智超 <1012112796@qq.com>

* Re-add migration after merge

* Fix frontend lint

* Fix version compare

* Add vendored dependencies

* Add basic tets

* Make sure the api route is capable of scheduling PRs for merging

* Fix comparing version

* make vendor

* adopt refactor

* apply suggestion: User -> Doer

* init var once

* Fix Test

* Update templates/repo/issue/view_content/comments.tmpl

* adopt

* nits

* next

* code format

* lint

* use same name schema; rm CreateUnScheduledPRToAutoMergeComment

* API: can not create schedule twice

* Add TestGetBranchNamesForSha

* nits

* new go routine for each pull to merge

* Update models/pull.go

Co-authored-by: a1012112796 <1012112796@qq.com>

* Update models/scheduled_pull_request_merge.go

Co-authored-by: a1012112796 <1012112796@qq.com>

* fix & add renaming sugestions

* Update services/automerge/pull_auto_merge.go

Co-authored-by: a1012112796 <1012112796@qq.com>

* fix conflict relicts

* apply latest refactors

* fix: migration after merge

* Update models/error.go

Co-authored-by: delvh <dev.lh@web.de>

* Update options/locale/locale_en-US.ini

Co-authored-by: delvh <dev.lh@web.de>

* Update options/locale/locale_en-US.ini

Co-authored-by: delvh <dev.lh@web.de>

* adapt latest refactors

* fix test

* use more context

* skip potential edgecases

* document func usage

* GetBranchNamesForSha() -> GetRefsBySha()

* start refactoring

* ajust to new changes

* nit

* docu nit

* the great check move

* move checks for branchprotection into own package

* resolve todo now ...

* move & rename

* unexport if posible

* fix

* check if merge is allowed before merge on scheduled pull

* debugg

* wording

* improve SetDefaults & nits

* NotAllowedToMerge -> DisallowedToMerge

* fix test

* merge files

* use package "errors"

* merge files

* add string names

* other implementation for gogit

* adapt refactor

* more context for models/pull.go

* GetUserRepoPermission use context

* more ctx

* use context for loading pull head/base-repo

* more ctx

* more ctx

* models.LoadIssueCtx()

* models.LoadIssueCtx()

* Handle pull_service.Merge in one DB transaction

* add TODOs

* next

* next

* next

* more ctx

* more ctx

* Start refactoring structure of old pull code ...

* move code into new packages

* shorter names ... and finish **restructure**

* Update models/branches.go

Co-authored-by: zeripath <art27@cantab.net>

* finish UpdateProtectBranch

* more and fix

* update datum

* template: use "svg" helper

* rename prQueue 2 prPatchCheckerQueue

* handle automerge in queue

* lock pull on git&db actions ...

* lock pull on git&db actions ...

* add TODO notes

* the regex

* transaction in tests

* GetRepositoryByIDCtx

* shorter table name and lint fix

* close transaction bevore notify

* Update models/pull.go

* next

* CheckPullMergable check all branch protections!

* Update routers/web/repo/pull.go

* CheckPullMergable check all branch protections!

* Revert "PullService lock via pullID (#19520)" (for now...)

This reverts commit 6cde7c9159a5ea75a10356feb7b8c7ad4c434a9a.

* Update services/pull/check.go

* Use for a repo action one database transaction

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Update services/issue/status.go

Co-authored-by: delvh <dev.lh@web.de>

* Update services/issue/status.go

Co-authored-by: delvh <dev.lh@web.de>

* use db.WithTx()

* gofmt

* make pr.GetDefaultMergeMessage() context aware

* make MergePullRequestForm.SetDefaults context aware

* use db.WithTx()

* pull.SetMerged only with context

* fix deadlock in `test-sqlite\#TestAPIBranchProtection`

* dont forget templates

* db.WithTx allow to set the parentCtx

* handle db transaction in service packages but not router

* issue_service.ChangeStatus just had caused another deadlock :/
it has to do something with how notification package is handled

* if we merge a pull in one database transaktion, we get a lock, because merge infoce internal api that cant handle open db sessions to the same repo

* ajust to current master

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* dont open db transaction in router

* make generate-swagger

* one _success less

* wording nit

* rm

* adapt

* remove not needed test files

* rm less diff & use attr in JS

* ...

* Update services/repository/files/commit.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* ajust db schema for PullAutoMerge

* skip broken pull refs

* more context in error messages

* remove webUI part for another pull

* remove more WebUI only parts

* API: add CancleAutoMergePR

* Apply suggestions from code review

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* fix lint

* Apply suggestions from code review

* cancle -> cancel

Co-authored-by: delvh <dev.lh@web.de>

* change queue identifyer

* fix swagger

* prevent nil issue

* fix and dont drop error

* as per @zeripath

* Update integrations/git_test.go

Co-authored-by: delvh <dev.lh@web.de>

* Update integrations/git_test.go

Co-authored-by: delvh <dev.lh@web.de>

* more declarative integration tests (dedup code)

* use assert.False/True helper

Co-authored-by: 赵智超 <1012112796@qq.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-08 01:05:52 +08:00
KN4CK3R
8adba93498
Hide private repositories in packages (#19584) 2022-05-07 18:21:15 +02:00
Jimmy Praet
38d72d40f1
Only show accessible teams in dashboard dropdown list (#19642)
Fixes #19637
2022-05-07 17:49:43 +02:00
a1012112796
672e5a752d
prevent double click new issue/pull/comment button (#16157)
* prevent double click new issue/pull/comment button

when network is not good, these button maybe
double clicked, then more than one same issues
pulls or comments will be created. this pull
request will fix this bug.

Signed-off-by: a1012112796 <1012112796@qq.com>
2022-05-07 14:24:02 +02:00
Gusted
0eac09e066
Improve reviewing PR UX (#19612) 2022-05-07 01:35:12 -04:00
GiteaBot
5a9c505e14 [skip ci] Updated translations via Crowdin 2022-05-07 00:10:19 +00:00
6543
b890272629
Add Changelog v1.16.7 (#19575) (#19644)
* Add Changelog v1.16.7 (#19575)


Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Gusted <williamzijl7@hotmail.com>

* jup

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-05-07 01:39:14 +02:00
techknowlogick
cab3a8b59d
Set safe dir for git operations in .drone.yml CI (#19641)
Our drone by necessity runs on git repositories not owned by the drone process. Unfortunately this means that git operations and thence CI builds will fail without the `safe.directory` option being set. 

See: https://drone.gitea.io/go-gitea/gitea/54632/2/8
2022-05-06 18:25:18 +01:00
wxiaoguang
994257d266
Add missing sorting column in project_issue table (#19635) 2022-05-06 22:25:59 +08:00
Gusted
3ece9d5794
Simplify IsVendor (#19626)
The changes in this file were upstreamed directly into go-enry as https://github.com/go-enry/go-enry/pull/44
and therefore they are no longer needed.
2022-05-06 10:12:30 +01:00
zeripath
a7f52684cb
Prevent NPE when checking repo units if the user is nil (#19625)
CheckRepoUnitUser should tolerate nil users.

Fix #19613

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-06 11:54:22 +08:00
KN4CK3R
4691e59828
Skip duplicated layers. (#19624) 2022-05-05 23:02:09 +01:00
neon
0483ee8f69
Add "Reference" section to Issue view sidebar (#19609)
* Add "Reference" section to Issue view sidebar

* Removed unneeded tailored CSS, added Fomantic UI classes

* Removed tailored CSS in favour of HTML-only approach

Kindly provided by @Gusted

* Added i18 translation key for reference link string

* Corrected spelling of "References:" to "Reference:" for reference link text

* Removed `Issue.ReferenceLink` in favour of a local template variable
2022-05-05 20:58:37 +02:00
singuliere
b536b65189
GetFeeds must always discard actions with dangling repo_id (#19598)
* GetFeeds must always discard actions with dangling repo_id

See https://discourse.gitea.io/t/blank-page-after-login/5051/12
for a panic in 1.16.6.

* add comment to explain the dangling ID in the fixture

* loadRepoOwner must not attempt to use a nil action.Repo

* make fmt

Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-05-05 11:39:26 -04:00
wxiaoguang
04fc4b7e05
Call MultipartForm.RemoveAll when request finishes (#19606) 2022-05-05 16:13:23 +02:00
wxiaoguang
7b089c465d
Remove RequireHighlightJS field, update plantuml example. (#19615) 2022-05-05 10:53:38 +03:00
GiteaBot
5a75a5463e [skip ci] Updated translations via Crowdin 2022-05-05 00:10:22 +00:00
6543
f034ee6cf0
PullService lock via pullID (#19520)
* lock pull on git&db actions ...

* add TODO notes

* rename prQueue 2 prPatchCheckerQueue

* fmt
2022-05-04 18:06:23 +02:00
ttys3
e933f31426
Add health check endpoint (#18465)
* chore: add health check endpoint

docs: update document about health check

fix: fix up Sqlite3 ping. current ping will success even if the db file is missing

fix: do not expose privacy information in output field

* refactor: remove HealthChecker struct

* Added `/api/healthz` to install routes.

This was needed for using /api/healthz endpoint in Docker healthchecks,
otherwise, Docker would never become healthy if using healthz endpoint
and users would not be able to complete the installation of Gitea.

* Update modules/cache/cache.go

* fine tune

* Remove unnecessary test code. Now there are 2 routes for installation (and maybe more in future)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Marcos de Oliveira <marcossantos@furb.br>
2022-05-04 14:56:20 +03:00
Gusted
3114cd30b8
Only check for non-finished migrating task (#19601)
* Only check for non-finished migrating task

- Only check if a non-finished migrating task exists for a mirror before
fetching the mirror details from the database.
- Resolves #19600
- Regression: #19588

* Clarify function
2022-05-04 12:09:42 +02:00
Eekle
9c04da37d0
Make .cs highlighting legible on dark themes. (#19604) 2022-05-04 16:58:38 +08:00
Gusted
2d40a4a4cd
Fix broken TR on cherrypick page (#19599)
- `repo.filter_branch` isn't a translation key so use
`repo.pulls.filter_branch` which has the correct translation.
2022-05-04 02:48:23 +02:00
Gusted
cc3016f70d
Use correct context in routers/web (#19597)
- Don't use the `APIContext` in the web routers.
2022-05-03 23:38:34 +02:00
6543
92f139d091
Use for a repo action one database transaction (#19576)
... more context

(part of #9307)
2022-05-03 21:46:28 +02:00
wxiaoguang
730420b6b3
Only set CanColorStdout / CanColorStderr to true if the stdout/stderr is a terminal (#19581) 2022-05-03 18:03:34 +02:00
Gusted
982b726b08
Don't fetch Mirror when it's migrating (#19588)
- When a repository is still being migrated, don't try to fetch the
Mirror from the database. Instead skip it. This allows to visit
repositories that are still being migrated and were configured to be
mirrored.
- Resolves #19585
- Regression: #19295

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-03 16:55:17 +03:00
Gwilherm Folliot
b7abb31b7b
Move user password verification after checking his groups on ldap auth (#19587)
In case the binded user can not access its own attributes.

Signed-off-by: Gwilherm Folliot <gwilherm55fo@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-03 20:41:11 +08:00
Lunny Xiao
772ad761eb
Fix some slice problems (incorrect slice length) (#19592) 2022-05-03 17:04:23 +08:00
Gusted
c8ec2261a9
Fix sending empty notifications (#19589)
- Don't send empty notifications on read notifications API.
2022-05-02 21:27:42 -05:00
99rgosse
438646e0b5
Handle the error of a missing blob object fix #19530 (#19552)
* Handle the error of a missing blob object

* Show error in logs

* as per @zeripath

* Add missing error check

* Add missing error check

* Update compare.go

* Use formal code

* Update compare.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-05-02 18:46:50 +02:00
wxiaoguang
c18d8d6968
Remove legacy +build: constraint (#19582)
Go 1.17 and later use modern `//go:build` constraints, the old `// +build:` constraints should be removed.
2022-05-02 23:22:45 +08:00
6543
e2a3f3d259
Federation: return useful statistic information for nodeinfo (#19561)
Add statistic information for total user count, active user count, issue count and comment count for `/nodeinfo`
2022-05-02 21:35:45 +08:00
wxiaoguang
509d811243
Upgrade required git version to 2.0 (#19577)
* Upgrade required git version to 2.0

* update document
2022-05-02 20:30:24 +08:00
Vladimir Smagin
0ba3ada866
add smtp password to install page (#17564)
* add smtp password to install page

* Update routers/install/install.go

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-05-02 16:45:23 +08:00
wxiaoguang
71bafa0263
ignore DNS error when doing migration allow/block check (#19566)
Co-authored-by: 6543 <6543@obermui.de>
2022-05-02 12:02:17 +08:00
GiteaBot
05234adfa8 [skip ci] Updated translations via Crowdin 2022-05-02 00:10:25 +00:00
6543
d8905cb623
Dont overwrite err with nil & rename PullCheckingFuncs to reflect there usage (#19572)
- dont overwrite err with nil unintentionaly
- rename CheckPRReadyToMerge to CheckPullBranchProtections
- rename prQueue to prPatchCheckerQueue

from #9307

Co-authored-by: delvh <dev.lh@web.de>
2022-05-02 01:54:44 +02:00
Gusted
3725fa28cc
Improve UI on mobile (#19546)
Start making the mobile experience not painful and be actually usable. This contains a few smaller changes to enhance this experience.

- Submit buttons on the review forms aren't columns anymore and are now allowed to be displayed on one row.
- The label/milestone & New Issue buttons were given each own row even tough, there's enough place to do it one the same row. This commit fixes that.
- The issues+Pull tab on repo's has a third item besides the label/milestone & New Issue buttons, the search bar. On desktop there's enough place to do this on one row, for mobile it isn't, currently it was using for each item a new row. This commits fixes that by only giving the searchbar a new row and have the other two buttons on the same row.
- The notification table will now be show a scrollbar instead of overflow.
- The repo buttons(Watch, Star, Fork) on mobile were showing quite big and the SVG wasn't even displayed on the same line, if the count of those numbers were too high it would even overflow. This commit removes the SVG, as there isn't any place to show them on the same row and allows them to have a new row if the counts of those buttons are high.
- The admin page can show you a lot of interesting information, on mobile the System Status + Configuration weren't properly displayed as the margin's were too high. This commit fixes that by reducing the margin to a number that makes sense on mobile.
- Fixes to not overflow the tables but instead force them to be scrollable.
- When viewing a issue or pull request, the comments aren't full-width but instead 80% and aligned to right, on mobile this is a annoyance as there isn't much width to begin with. This commits fixes that by forcing full-width and removing the avatars on the left side and instead including them inline in the comment header.
2022-05-01 18:11:21 +02:00
qwerty287
ac6c338428
Add API to check if team has repo access (#19540)
* Add API to check if team has repo access

* Add test case
2022-05-01 17:39:04 +02:00
99rgosse
edff571aa9
Avoid MoreThanOne Error (#19557) 2022-05-01 03:09:59 +02:00
GiteaBot
094c8fdc87 [skip ci] Updated licenses and gitignores 2022-05-01 00:25:27 +00:00
Gusted
c0a6309a5f
Simplify loops to copy (#19569)
- Simplify two loops into `copy` statements.
2022-05-01 01:53:56 +02:00
6543
1597e2da3e
Use middleware to open gitRepo (#19559) 2022-04-30 16:32:01 +02:00
Ivan Fedorov
d23f220343
Added X-Mailer header to outgoing emails (#19562)
- It's a non-standard mentioned in https://www.ietf.org/rfc/rfc2076.html#section-3.4
- This header makes emails filtering easier
2022-04-30 15:40:55 +02:00
6543
8d34c2fab9
fix #19545 (#19563) 2022-04-30 20:50:56 +08:00
GiteaBot
bf7258be9c [skip ci] Updated translations via Crowdin 2022-04-30 00:10:15 +00:00
Jimmy Praet
5aebc4f000
Respect DefaultUserIsRestricted system default when creating new user (#19310)
* Apply DefaultUserIsRestricted in CreateUser

* Enforce system defaults in CreateUser

Allow for overwrites with CreateUserOverwriteOptions

* Fix compilation errors

* Add "restricted" option to create user command

* Add "restricted" option to create user admin api

* Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed

* Revert "Respect default setting.Service.RegisterEmailConfirm and setting.Service.RegisterManualConfirm where needed"

This reverts commit ee95d3e8dc9e9fff4fa66a5111e4d3930280e033.
2022-04-29 15:38:11 -04:00
silverwind
219c87e7d8
Mute link in diff header (#19556)
Followup to https://github.com/go-gitea/gitea/pull/19534. Make the link
render in color only on hover.
2022-04-29 17:39:27 +03:00
Florin Hillebrand
ad6d08d155
Add API to query collaborators permission for a repository (#18761)
Targeting #14936, #15332

Adds a collaborator permissions API endpoint according to GitHub API: https://docs.github.com/en/rest/collaborators/collaborators#get-repository-permissions-for-a-user to retrieve a collaborators permissions for a specific repository.

### Checks the repository permissions of a collaborator. 

`GET` `/repos/{owner}/{repo}/collaborators/{collaborator}/permission`

Possible `permission` values are `admin`, `write`, `read`, `owner`, `none`.

```json
{
  "permission": "admin",
  "role_name": "admin",
  "user": {}
}
```

Where `permission` and `role_name` hold the same `permission` value and `user` is filled with the user API object. Only admins are allowed to use this API endpoint.
2022-04-29 14:24:38 +02:00
KN4CK3R
e5c6c001c5
Permalink files In PR diff (#19534) 2022-04-29 12:26:52 +02:00
parnic
3e2bba0803
Fix Pull Request comment filename word breaks (#19535)
* Fix word breaks in Chrome

This fixes word wrapping on the filename for a comment on a PR. A previous commit fixed this problem in Firefox, but not Chrome.

Fixes #16248

* Don't break Outdated badge

This prevents the Outdated badge on a PR from wrapping in the middle of the word for a comment on a long filename.

* Move word break to recommended element

* Add overflow-wrap per PR review

* Update web_src/less/helpers.less

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-04-29 12:30:54 +03:00
Gusted
334707fee9
Don't error when branch's commit doesn't exist (#19547)
* Don't error when branch's commit doesn't exist

- If one of the branches no longer exists, don't throw an error, it's possible that the branch was destroyed during the process. Simply skip it and disregard it.
- Resolves #19541

* Don't send empty objects

* Use more minimal approach
2022-04-29 16:44:40 +08:00
GiteaBot
53829b84f0 [skip ci] Updated translations via Crowdin 2022-04-29 00:10:15 +00:00
wxiaoguang
a51efb4c2c
Support hostname:port to pass host matcher's check #19543 (#19543)
hostmatcher: split the hostname from the `hostname:port` string, use the correct hostname to do the match.
2022-04-29 01:39:50 +08:00
qwerty287
8eb1cd9264
Add "Allow edits from maintainer" feature (#18002)
Adds a feature [like GitHub has](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request-from-a-fork) (step 7).
If you create a new PR from a forked repo, you can select (and change later, but only if you are the PR creator/poster) the "Allow edits from maintainers" option.
Then users with write access to the base branch get more permissions on this branch:
* use the update pull request button
* push directly from the command line (`git push`)
* edit/delete/upload files via web UI
* use related API endpoints

You can't merge PRs to this branch with this enabled, you'll need "full" code write permissions.

This feature has a pretty big impact on the permission system. I might forgot changing some things or didn't find security vulnerabilities. In this case, please leave a review or comment on this PR.

Closes #17728

Co-authored-by: 6543 <6543@obermui.de>
2022-04-28 17:45:33 +02:00
Gusted
92dfbada37
Better describe what /repos/{owner}/{repo}/raw/{filepath} returns on 200 (#19542)
- Set on the description that it returns the raw file content.
- Resolves #19514
2022-04-28 09:57:56 -05:00
6543
06e4687cec
more context for models (#19511)
make more usage of context, to have more db transaction in one session

(make diff of  #9307 smaller)
2022-04-28 13:48:48 +02:00
zeripath
332b2ecd21
Prevent intermittent race in attribute reader close (#19537)
There is a potential rare race possible whereby the c.running channel could
be closed twice. Looking at the code I do not see a need for this c.running
channel and therefore I think we can remove this. (I think the c.running
might have been some attempt to prevent a hang but the use of os.Pipes should
prevent that.)

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-04-28 11:19:33 +08:00
Gusted
ca4b920bbc
Make repository file list useable on mobile (#19515)
* Make repository file list useable on mobile

- When you're browsing a repository on mobile, you're met by a giant
block called the "repository file list". The current design is not
useable for mobile and is a big annoyance while browsing a repo on
mobile. This PR removes that annoyance by making it more suitable design
when on mobile.
- Adds HTML for the commit/file time to align it vertically(noticeable
on mobile, not on PC).
- Show all information horizontally and not vertically.
- Remove the last commit message of the file, there isn't enough space
on mobile to place this anywhere, so we're not trying to make a
best-effort here and instead just not display it.

* Remove unnecessary `!important`

* Fix broken HTML

* Simplify code
2022-04-28 03:59:49 +02:00
John Olheiser
3e8aa42a1b
Update image URL for Discord webhook (#19536)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-04-27 20:23:27 -05:00
GiteaBot
960b813a33 [skip ci] Updated translations via Crowdin 2022-04-28 00:10:43 +00:00
Gusted
b5383590de
Fix 64-bit atomic operations on 32-bit machines (#19531)
- Doing 64-bit atomic operations on 32-bit machines is a bit tricky by
golang, as they can only be done under certain set of
conditions(https://pkg.go.dev/sync/atomic#pkg-note-BUG).
- This PR fixes such case whereby the conditions weren't met, it moves
the int64 to the first field of the struct, which will 64-bit operations
happening on this property on 32-bit machines.
- Resolves #19518
2022-04-27 10:32:04 -05:00
YISH
af09136b95
Fix upgrade.sh script error with su -c (#19483)
* Fix scirpt err with `su -c`, add env auto loading.

* Update upgrade.sh

* Update upgrade.sh

* Update contrib/upgrade.sh

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-04-26 23:30:29 -04:00
Lunny Xiao
5651c650c0
When view _Siderbar or _Footer, just display once (#19501)
Co-authored-by: zeripath <art27@cantab.net>
2022-04-26 19:24:20 -04:00
Lunny Xiao
2728f0c213
Fix migrate release from github (#19510)
* Fix migrate release from github

* Fix bug
2022-04-26 19:24:06 -04:00
zeripath
41fcf7b7de
Prevent dangling archiver goroutine (#19516)
Within doArchive there is a service goroutine that performs the
archiving function.  This goroutine reports its error using a `chan
error` called `done`. Prior to this PR this channel had 0 capacity
meaning that the goroutine would block until the `done` channel was
cleared - however there are a couple of ways in which this channel might
not be read.

The simplest solution is to add a single space of capacity to the
goroutine which will mean that the goroutine will always complete and
even if the `done` channel is not read it will be simply garbage
collected away.

(The PR also contains two other places when setting up the indexers
which do not leak but where the blocking of the sending goroutine is
also unnecessary and so we should just add a small amount of capacity
and let the sending goroutine complete as soon as it can.)

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

Co-authored-by: 6543 <6543@obermui.de>
2022-04-26 19:22:26 -04:00
Gusted
3fbaa79c6e
Don't let repo clone URL overflow (#19517)
- Apparently `<input>` elements differ from other elements have a size
attribute that act as a `min-width` CSS property, this causes a overflow
on mobile. By setting this size to `1` it doesn't try to force a
min-width and nicely shrink down.
2022-04-26 19:22:11 -04:00
parnic
cdab46220d
Add commit status popup to issuelist (#19375)
This gets the necessary data to the issuelist for it to support a clickable commit status icon which pops up the full list of commit statuses related to the commit. It accomplishes this without any additional queries or fetching as the existing codepath was already doing the necessary work but only returning the "last" status. All methods were wrapped to call the least-filtered version of each function in order to maximize code reuse.

Note that I originally left `getLastCommitStatus()` in `pull.go` which called to the new function, but `make lint` complained that it was unused, so I removed it. I would have preferred to keep it, but alas.

The only thing I'd still like to do here is force these popups to happen to the right by default instead of the left. I see that the only other place this is popping up right is on view_list.tmpl, but I can't figure out how/why right now.

Fixes #18810
2022-04-26 23:40:01 +01:00
Paweł Bogusławski
0b38084baa
Disable unnecessary GitHooks elements (#18485)
* Disable unnecessary GitHooks elements

This mod fixes disabling unnecessary GitHooks elements.

Related: https://github.com/go-gitea/gitea/pull/13129
Author-Change-Id: IB#1115251
2022-04-26 22:10:11 +01:00
Pawel Boguslawski
85579dcab5
Disable unnecessary GitHooks elements
This mod fixes disabling unnecessary GitHooks elements.

Related: https://github.com/go-gitea/gitea/pull/13129
Author-Change-Id: IB#1115251
2022-04-26 22:06:58 +01:00
Gusted
076eaad743
Improve dashboard's repo list performance (#18963)
* Improve dashboard's repo list performance

- Avoid a lot of database lookups for all the repo's, by adding a
undocumented "minimal" mode for this specific task, which returns the
data that's only needed by this list which doesn't require any database
lookups.
- Makes fetching these list faster.
- Less CPU overhead when a user visits home page.

* Refactor javascript code + fix Fork icon

- Use async in the function so we can use `await`.
- Remove `archivedFilter` check for count, as it doesn't make sense to
  show the count of repos when you can't even see them(as they are
  filited away).

* Add `count_only`

* Remove uncessary code

* Improve comment

Co-authored-by: delvh <dev.lh@web.de>

* Update web_src/js/components/DashboardRepoList.js

Co-authored-by: delvh <dev.lh@web.de>

* Update web_src/js/components/DashboardRepoList.js

Co-authored-by: delvh <dev.lh@web.de>

* By default apply minimal mode

* Remove `minimal` paramater

* Refactor count header

* Simplify init

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-04-26 16:34:30 -04:00
Gusted
89eec15dd9
By default force vertical tabs on mobile (#19486)
* By default force vertical tabs on mobile

- While experimenting with using vertical tabs instead of horizontal
tabs on gitea for a better mobile experience, I made a recent
PR(https://github.com/go-gitea/gitea/pull/19468) in order to see if
there was any objections to this new behavior for the repo headers(one
of the most annoying horizontal tabs). This PR had no objections and
even a user commenting that this change is brilliant.
- This PR now improves upon the previous PR by making this the de-facto
behavior for all menu's on mobile. The only exemption is the navbar
which also uses the menu but caught some layout errors with the changes.

* Fix organisation

* Fix repo/wiki buttons

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-04-26 16:31:58 -04:00
Lunny Xiao
d71df01077
Refactor readme file renderer (#19502)
* Refactor readme file renderer

* improve
2022-04-26 16:31:15 -04:00
KN4CK3R
e4274f640c
Allow package dump skipping (#19506)
* Added addReader to support verbose.

* Allow skipping packages.

* Updated docs.

* Update cmd/dump.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-04-26 16:30:51 -04:00
zeripath
6dd36379f2
Unset git author/committer variables when running integration tests (#19512)
TestAPIGitTag (and likely others) will fail if the running environment contains
GIT_AUTHOR_NAME and other env variables like it.

This PR simply unsets these when running the integration tests.

Fix #14247

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-04-26 16:28:45 -04:00
parnic
2347c9ebbe
Allow commit status popup on /pulls page (#19507)
* Allow commit status popup on /pulls page

The /pulls page doesn't contain a "repository" element, so the early-out here was preventing the commit status popup hook from working. However, the only thing the .repository element is being used for here is determining whether the popup should be on the right or on the left, so we don't actually need the element to exist for the hook to work.

Pull request #19375 allows the statuses on /pulls pages to appear clickable, but this commit is required to make the popup actually work there.

* Move commit statuses popup hook to dedicated func

* Add missing import
2022-04-26 21:09:46 +02:00
John Olheiser
3c140f0d42
Use router param for filepath in GetRawFile (#19499)
* Use router param for filepath

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move TreePath back into RepoRefForAPI

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-04-26 12:15:45 -05:00
Lunny Xiao
6cc8aed737
Fix two typos (#19504) 2022-04-26 18:01:42 +02:00
Lunny Xiao
03eba32bd9
Add a new menu in file view to open blame view and fix blame view select range bug (#19500) 2022-04-26 13:54:40 +03:00
wxiaoguang
fef26c159c
Fix two UI bugs: JS error in imagediff.js, 500 error in diff/compare.tmpl
Co-authored-by: 6543 <6543@obermui.de>
2022-04-26 11:14:01 +08:00
GiteaBot
741c55b4ea [skip ci] Updated translations via Crowdin 2022-04-26 00:10:13 +00:00
Gusted
4e912a61c8
Improve Stopwatch behavior (#18930)
- Don't send empty stopwatch over and over again, only send once.
- Stop interval to update stopwatch's timer when there is no more stopwatch.
2022-04-25 22:45:22 +02:00
6543
1ebb30e41b
Pass gitRepo down to GetRawDiff, since its used for main repo and wiki (#19461)
as per https://github.com/go-gitea/gitea/pull/19449#issuecomment-1105283931

pass gitRepo down to GetRawDiff, since its used for main repo and wiki
2022-04-25 20:45:18 +02:00
Lunny Xiao
7c164d5a91
Use queue instead of memory queue in webhook send service (#19390) 2022-04-25 20:03:01 +02:00
jklippel
257cea654c
add a directory prefix gitea-src-VERSION to release-tar-file (#19396)
Use a directory prefix instead on creating the tar file. Fixes: #19066
2022-04-26 00:41:07 +08:00
6543
ddbbe6e15c
User specific repoID or xorm builder conditions for issue search (#19475)
* extend models.IssuesOptions to have more specific repo filter options

* use new options

* unrelated refactor

* rm RepoIDs
2022-04-25 16:06:24 +02:00
6543
fe274c148b
Add notags to fetch (#19487) 2022-04-25 15:07:08 +02:00
Lunny Xiao
fc002860d8
Simplify the code to get issue count (#19380)
* Simple the code to get issue count

* Improve codes
2022-04-25 15:04:42 +08:00
6543
2ec2baf248
use IsLoopback (#19477)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-04-25 13:55:12 +08:00
GiteaBot
5e4134b117 [skip ci] Updated translations via Crowdin 2022-04-25 00:10:29 +00:00
ktprograms
ef164d33c2
Add RSS Feed buttons to Repo, User and Org pages (#19370) 2022-04-24 22:03:39 +02:00
Pilou
ebb23967dc
[doctor] authorized-keys: fix displayed check name (#19464)
The registered check name is authorized-keys, not authorized_keys.
2022-04-24 20:06:33 +02:00
GiteaBot
0abd8b0abc [skip ci] Updated translations via Crowdin 2022-04-24 00:10:14 +00:00
Gusted
1f05417805
Use horizontal tabs for repo header on mobile (#19468)
* Use horizontal tabs for repo header on mobile

- The current behavior of the repo header on mobile is to display them
vertically column-by-column. I've only experience annoyance due to this
while trying to visit gitea instanced on mobile. This commit changes
this behavior to use horizontal tabs, it uses less tabs and doesn't
bloat 60% of your mobile screen with the repo headers.
- A small fix added in this commit is to give some space around the repo
buttons, current behavior is that they are too "close" to the repo
title.

* Fix lint
2022-04-23 18:56:33 +02:00
GiteaBot
9550e5a23e [skip ci] Updated translations via Crowdin 2022-04-23 00:10:15 +00:00
Gusted
240b3aa218
Mark TemplateLoading error as "UnprocessableEntity" (#19445)
- Don't return Internal Server error if the user provide incorrect label
template, instead return UnprocessableEntity.
- Resolves #19399
2022-04-22 19:19:55 +02:00
zeripath
0dcc74a8a7
Prevent dangling cat-file calls (goroutine alternative) (#19454)
If an `os/exec.Command` is passed non `*os.File` as an input/output, go
will create `os.Pipe`s and wait for their closure in `cmd.Wait()`.  If
the code following this is responsible for closing `io.Pipe`s or other
handlers then on process death from context cancellation the `Wait` can
hang.

There are two possible solutions:

1. use `os.Pipe` as the input/output as `cmd.Wait` does not wait for these.
2. create a goroutine waiting on the context cancellation that will close the inputs.

This PR provides the second option - which is a simpler change that can
be more easily backported.

Closes #19448

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-04-22 17:20:04 +02:00
GiteaBot
0dfc2e55ea [skip ci] Updated translations via Crowdin 2022-04-22 00:10:36 +00:00
Gusted
ebe569a268
Set correct PR status on 3way on conflict checking (#19457)
* Set correct PR status on 3way on conflict checking

- When 3-way merge is enabled for conflict checking, it has a new
interesting behavior that it doesn't return any error when it found a
conflict, so we change the condition to not check for the error, but
instead check if conflictedfiles is populated, this fixes a issue
whereby PR status wasn't correctly on conflicted PR's.
- Refactor the mergeable property(which was incorrectly set and lead me this
bug) to be more maintainable.
- Add a dedicated test for conflicting checking, so it should prevent
future issues with this.

* Fix linter
2022-04-21 22:55:45 +01:00
Gusted
3ec1b6c223
Fix logging of Transfer API (#19456)
- Use the correct fullname's in tracing calls.
- Return correct function name in error.

Co-authored-by: 6543 <6543@obermui.de>
2022-04-22 00:05:53 +08:00
6543
c764355676
RepoAssignment ensure to close before overwrite (#19449)
* check if GitRepo already open and close if

* only run RepoAssignment once

* refactor context helper for api to open GitRepo
2022-04-21 17:17:57 +02:00
techknowlogick
225044e656
node12 is EOL (#19451)
* node12 is EOL

* fix lockfile
2022-04-20 21:17:39 -04:00
6543
725731cb6e
Add Changelog v1.16.6 (#19339) (#19450)
* Add Changelog v1.16.6 (#19339)

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>

* bump version

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-04-20 21:17:23 -04:00
Gusted
f4c1aa75be
Fix DELETE request for non-existent public key (#19443)
- Add a return for the first "block" of errors, which fixes the double
error messages.
- Add a return for `externallyManaged`.
- Resolves #19398
2022-04-21 03:08:30 +02:00
GiteaBot
f7a8e5c8f2 [skip ci] Updated translations via Crowdin 2022-04-21 00:10:26 +00:00
Gusted
23d37673bd
Don't panic on ErrEmailInvalid (#19441)
- Don't panic on `ErrEmailInvalid`, this was caused due that we were
trying to force `ErrEmailCharIsNotSupported` interface, which panics.
- Resolves #19397
2022-04-20 23:39:30 +02:00
zeripath
1e319ba41a
When dumping trim the standard suffices instead of a random suffix (#19440)
* When dumping trim the standard suffices instead of a random suffix

Instead of using the `path.Ext()` to trim the last "extension" suffix, just iterate
through the supported suffices and trim those.

Fix #19424

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

* fix enum with to have correct supported types only

Co-authored-by: 6543 <6543@obermui.de>
2022-04-20 20:53:34 +02:00
zeripath
a7f0ce6207
Add uploadpack.allowAnySHA1InWant to allow --filter=blob:none with older git clients (#19430)
Older git clients need uploadpack.allowAnySHA1InWant if partial cloning is allowed.

Fix #19118

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-04-20 17:52:16 +02:00
Gusted
5e68fe7d37
Don't allow merging PR's which are being conflict checked (#19357)
* Don't allow merging PR's which are being conflict checked

- When a PR is still being conflict checked, don't allow the PR to be
merged(the merge button could already be visible before e.g. a new
commit was pushed to the PR).
- Relevant(should prevent such issue from happening) #19352

Co-authored-by: delvh <dev.lh@web.de>
2022-04-20 16:43:15 +02:00
Campbell He
f2229e0566
doc: add brief intro on using traefik as reverse-proxy (#19432) 2022-04-20 16:08:23 +02:00
qwerty287
ae6a52440a
Fix panic in team repos API (#19431)
* Fix panic in team repos API

* Fix pagination

* fmt
2022-04-20 18:43:26 +08:00
zeripath
409ff55a29
When updating mirror repo intervals by API reschedule next update too (#19429)
When a mirror repo interval is updated by the UI it is rescheduled with that interval
however the API does not do this. The API also lacks the enable_prune option.

This PR adds this functionality in to the API Edit Repo endpoint.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-04-20 09:20:53 +01:00
wxiaoguang
a56fcdfa8f
Fix nil error when some pages are rendered outside request context (#19427) 2022-04-19 19:30:09 -04:00
KN4CK3R
18727df73a
Add Helm Chart registry (#19406) 2022-04-19 12:55:35 -04:00
GiteaBot
b74322dfce [skip ci] Updated translations via Crowdin 2022-04-18 00:10:09 +00:00
GiteaBot
490065b93b [skip ci] Updated licenses and gitignores 2022-04-17 00:10:24 +00:00
Stephen J. Fuhry
695c4b4b0e
upgrade postgres refrence to 14 (#19416) 2022-04-16 11:59:56 -04:00
chavacava
deffe9e525
Fix datarace in gitea_uploader.go (#19409) 2022-04-15 22:50:09 +08:00
Gusted
9053096f1f
Fix double blob-hunk (#19404)
- Don't show the blob-hunk twice.
2022-04-15 19:43:38 +08:00
Lunny Xiao
b8911fb456
Use a struct as test options (#19393)
* Use a struct as test options

* Fix name

* Fix test
2022-04-14 21:58:21 +08:00
delvh
4dabc212c7
Disallow selecting the text of buttons (#19330)
Introduce a CSS class `.unselectable`
2022-04-14 16:57:19 +08:00
GiteaBot
3255ba9305 [skip ci] Updated translations via Crowdin 2022-04-13 00:10:15 +00:00
ktprograms
4396d0e7c9
Note where frontend files are located in docs (#19379)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-04-12 16:36:24 -04:00
Chongyi Zheng
f029b9ae4f
Document 409 error returned by repos/migrate api (#19376)
* Document 409 error returned by repos/migrate api

* Generate swagger spec

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-04-12 16:13:07 +08:00
Gusted
0d3d9675c6
Fix middleware function's placements for some /user/... (#19377)
- Add reqSignIn to `/user/task/{task}` as it specific to a logged in user currently not-logged in user could cause a NPE.
- Move `/user/stopwatch` & `/user/search` middleware before the actual function is called, because functions are executed in order and currently hadn't any effect and could as well cause a NPE due to that.
- Remove `/user/active` reqSignIn middleware, because when you want to active a account you're not "signed in" so it doesn't make sense to add that middleware.
2022-04-12 10:02:58 +08:00
delvh
d139c23967
Fix panic in teams API when requesting members (#19360) 2022-04-11 20:49:49 +08:00
Gusted
ee769f7459
Add logic to switch between source/rendered on Markdown (#19356)
Adds a button to switch between the source blob and the rendered markdown.
2022-04-10 23:01:35 +08:00
KN4CK3R
6d51b9f615
Fixed registry host value. (#19363) 2022-04-10 19:57:36 +08:00
GiteaBot
72479bff89 [skip ci] Updated translations via Crowdin 2022-04-10 00:10:15 +00:00
KN4CK3R
c003491cfb
Allow package linking to private repository (#19348)
* Display private repos too.

* lint

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-04-09 23:57:37 +08:00
wxiaoguang
d906858847
Use "main" as default branch name (#19354)
* Use "main" as default branch name

* fix test code
2022-04-08 23:26:48 -05:00
Lunny Xiao
1dfa26e00e
Move milestone to models/issues/ (#19278)
* Move milestone to models/issues/

* Fix lint

* Fix test

* Fix lint

* Fix lint
2022-04-08 17:11:15 +08:00
wxiaoguang
84ceaa98bd
Refactor CSRF protection modules, make sure CSRF tokens can be up-to-date. (#19337)
Do a refactoring to the CSRF related code, remove most unnecessary functions.
Parse the generated token's issue time, regenerate the token every a few minutes.
2022-04-08 13:21:05 +08:00
Lunny Xiao
3c3d49899f
Remove dependent on session auth for api/v1 routers (#19321)
* Remove dependent on session auth for api/v1 routers

* Remove unnecessary session on API context

* remove missed header

* fix test

* fix missed api/v1
2022-04-08 06:22:10 +02:00
6543
75f8534c3a
API: Search Issues, dont show 500 if filter result in empty list (#19244)
* remove error who is none

* use setupSessionNoLimit instead of setupSessionWithLimit when no pagination

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-04-08 04:39:03 +02:00
GiteaBot
c6531de3f5 [skip ci] Updated translations via Crowdin 2022-04-08 00:17:39 +00:00
Lunny Xiao
783a021889
Never use /api/v1 from Gitea UI Pages (#19318)
Reusing `/api/v1` from Gitea UI Pages have pros and cons.
Pros:
1) Less code copy

Cons:
1) API/v1 have to support shared session with page requests.
2) You need to consider for each other when you want to change something about api/v1 or page.

This PR moves all dependencies to API/v1 from UI Pages.

Partially replace #16052
2022-04-07 20:59:56 +02:00
GiteaBot
bb7e0619c3 [skip ci] Updated translations via Crowdin 2022-04-07 00:17:35 +00:00
原俊杰
184302665f
Show ssh command directly in template instead of i18n translation (#19335)
* add missing space for generate ssh token command

Signed-off-by: Junjie Yuan <yuan@junjie.pro>

* Do not use i18n for ssh command

* Remove unnecessary settings.ssh_token_code

* Revert locale_zh-CN.ini

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-04-06 19:35:04 +08:00
KN4CK3R
5e242e021b
Package registry changes (#19305)
* removed debug logs
* fixed SELECT
* removed unneeded error type
* use common SearchVersions method
* remove empty container upload versions
* return err
2022-04-06 03:32:09 +02:00
GiteaBot
8ddcd37f13 [skip ci] Updated translations via Crowdin 2022-04-06 00:17:36 +00:00
Gusted
e20952a9ec
Add ENABLE_SSH_LOG to debugging problems (#19316)
- Add this option to the debugging problems section. So users that are
trying to debug SSH-related problems will get the errors logged from `cmd/serv.go`
2022-04-05 16:41:56 -04:00
Gusted
606e33d38a
Warn on SSH connection for incorrect configuration (#19317)
* Warn on SSH connection for incorrect configuration

- When `setting.RepoRootPath` cannot be found(most likely due to
incorrect configuration) show "Gitea: Incorrect configuration" on the
client-side to help easier with debugging the problem.

* Update cmd/serv.go

Co-authored-by: delvh <dev.lh@web.de>

* Don't leak configuration

* Update cmd/serv.go

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-04-05 16:28:10 -04:00
techknowlogick
d4f4e95c63
escape fake link 2022-04-05 13:30:07 -04:00
techknowlogick
48dc88acd0
Allow custom redirect for landing page (#19324)
* Allow custom redirect for landing page

* Update modules/setting/setting.go

Co-authored-by: delvh <dev.lh@web.de>

* fix lint

* one option

Co-authored-by: delvh <dev.lh@web.de>
2022-04-05 12:16:01 -04:00
GiteaBot
5ae875a1ae [skip ci] Updated translations via Crowdin 2022-04-05 00:17:38 +00:00
GiteaBot
256204befa [skip ci] Updated translations via Crowdin 2022-04-04 00:17:51 +00:00
Steven
be9ef15f8a
Fix links to packages documentation (#19315) 2022-04-04 00:22:01 +08:00
wxiaoguang
d242511e86
Remove legacy unmaintained packages, refactor to support change default locale (#19308)
Remove two unmaintained vendor packages `i18n` and `paginater`. Changes:
* Rewrite `i18n` package with a more clear fallback mechanism. Fix an unstable `Tr` behavior, add more tests.
* Refactor the legacy `Paginater` to `Paginator`, test cases are kept unchanged.

Trivial enhancement (no breaking for end users):
* Use the first locale in LANGS setting option as the default, add a log to prevent from surprising users.
2022-04-03 17:46:48 +08:00
GiteaBot
27c34dd011 [skip ci] Updated translations via Crowdin 2022-04-03 00:17:41 +00:00
zeripath
7b4c3c7bb1
Prevent intermittent NPE in queue tests (#19301)
There appears to be an intermittent NPE in queue tests relating to the deferred
shutdown/terminate functions.

This PR more formally asserts that shutdown and termination occurs before starting
and finishing the tests but leaves the defer in place to ensure that if there is an
issue shutdown/termination will occur.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-04-02 15:59:04 +08:00
Lunny Xiao
cf5d4a7230
Upgrade xorm/builder from v0.3.9 to v0.3.10 (#19296)
xorm/builder v0.3.10 add support to EXISTS and NOT EXISTS.
2022-04-02 04:14:14 +08:00
Peter Gardfjäll
43ff92e122
An attempt to sync a non-mirror repo must give 400 (Bad Request) (#19300)
* An attempt to sync a non-mirror repo must give 400 (Bad Request)

* add missing return statement

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-04-01 14:29:57 -04:00
wxiaoguang
4f27c28947
Remove legacy unknwon/com package (#19298)
Follows: #19284
* The `CopyDir` is only used inside test code
* Rewrite `ToSnakeCase` with more test cases
* The `RedisCacher` only put strings into cache, here we use internal `toStr` to replace the legacy `ToStr`
* The `UniqueQueue` can use string as ID directly, no need to call `ToStr`
2022-04-02 00:34:57 +08:00
Norwin
4c5cb1e2f2
Improve package registry docs (#19273)
* Improve package registry docs

* move new content down

* add hint re upload a package

* wording, formatting

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-04-01 23:31:40 +08:00
Peter Gardfjäll
58c9d12933
A pull-mirror repo should be marked as such on creation (#19295)
Right now, a pull-mirror repo does not get marked as such until *after* the
mirroring completes. In the meantime, it will show up (in API and UI) as a
regular repo.
2022-04-01 22:14:36 +08:00
wxiaoguang
65f17bfc31
Refactor legacy unknwon/com package, improve golangci lint (#19284)
The main purpose is to refactor the legacy `unknwon/com` package.
1. Remove most imports of `unknwon/com`, only `util/legacy.go` imports the legacy `unknwon/com`
2. Use golangci's depguard to process denied packages
3. Fix some incorrect values in golangci.yml, eg, the version should be quoted string `"1.18"`
4. Use correctly escaped content for `go-import` and `go-source` meta tags
5. Refactor `com.Expand` to our stable (and the same fast) `vars.Expand`, our `vars.Expand` can still return partially rendered content even if the template is not good (eg: key mistach).
2022-04-01 16:47:50 +08:00
wxiaoguang
5b7466053d
Skip frontend ROOT_URL check on installation page, remove unnecessary global var (#19291)
Skip `checkAppUrl` message on installation page because the ROOT_URL is not determined yet
Move global var `supportedDbTypeNames` into `install.Init` as a local var
2022-04-01 16:00:26 +08:00
Lunny Xiao
89b9d42f08
Fix broken of team create (#19288)
* Fix broken of team create

* Update models/organization/team.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-04-01 14:05:31 +08:00
wxiaoguang
124b072f0b
Remove git.Command.Run and git.Command.RunInDir* (#19280)
Follows #19266, #8553, Close #18553, now there are only three `Run..(&RunOpts{})` functions.
 * before: `stdout, err := RunInDir(path)`
 * now: `stdout, _, err := RunStdString(&git.RunOpts{Dir:path})`
2022-04-01 10:55:30 +08:00
Lunny Xiao
3a73645502
Performance improvement for add team user when org has more than 1000 repositories (#19227)
* performance improvement for add team user when org has more than 1000 repositories

* Fix bug

* Fix bug
2022-04-01 09:53:18 +08:00
GiteaBot
ba2592c380 [skip ci] Updated translations via Crowdin 2022-04-01 00:17:38 +00:00
silverwind
1eb0da58c3
Update JS dependencies (#19281)
- Upgrade all JS dependencies minus vue and vue-loader
- Adapt to breaking change of octicons
- Update eslint rules
- Tested Swagger UI, sortablejs and prod build
2022-04-01 02:15:46 +02:00
KN4CK3R
08d199245a
Fix container download counter (#19287)
* Increment counter on manifest download.

* Refactor GetPackageFileStream method.
2022-04-01 01:08:32 +02:00
Kevin Burke
242d71035a
go.mod: update kevinburke/ssh_config to v1.2.0 (#19286)
Previously if you tried to read a HostName in a config file that
looked like this:

```
Host github
    HostName github.com        # This is the host for code review
```

DefaultUserSettings.Get("HostName") would return "github.com        ",
which I think is unintuitive and unexpected.

This behavior is fixed in v1.2 which would return "github.com" in the
above example.
2022-04-01 00:05:57 +02:00
Lunny Xiao
420851ca1f
Fix global packages enabled avaiable (#19276)
Fix #19275
2022-03-31 19:31:53 +02:00
zeripath
c88547ce71
Add Goroutine stack inspector to admin/monitor (#19207)
Continues on from #19202.

Following the addition of pprof labels we can now more easily understand the relationship between a goroutine and the requests that spawn them. 

This PR takes advantage of the labels and adds a few others, then provides a mechanism for the monitoring page to query the pprof goroutine profile.

The binary profile that results from this profile is immediately piped in to the google library for parsing this and then stack traces are formed for the goroutines.

If the goroutine is within a context or has been created from a goroutine within a process context it will acquire the process description labels for that process. 

The goroutines are mapped with there associate pids and any that do not have an associated pid are placed in a group at the bottom as unbound.

In this way we should be able to more easily examine goroutines that have been stuck.

A manager command `gitea manager processes` is also provided that can export the processes (with or without stacktraces) to the command line.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-31 19:01:43 +02:00
6543
9c349a4277
Move checks for pulls before merge into own function (#19271)
This make checks in one single place so they dont differ and maintainer can not forget a check in one place while adding it to the other .... ( as it's atm )

Fix:
* The API does ignore issue dependencies where Web does not
* The API checks if "IsSignedIfRequired" where Web does not - UI probably do but nothing will some to craft custom requests
* Default merge message is crafted a bit different between API and Web if not set on specific cases ...
2022-03-31 16:53:08 +02:00
zeripath
f6145a69c4
Restore user autoregistration with email addresses (#19261)
Unfortunately #18789 disabled autoregistration using email addresses as they would
be shortcut to email address does not exist.

This PR attempts to restore autoregistration by allowing an unknown email address
to percolate through to the autoregistration path of UserSignin.

Fix #19256

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-31 15:20:25 +02:00
Peter Gardfjäll
e28cc79c92
Improve sync performance for pull-mirrors (#19125)
This addresses https://github.com/go-gitea/gitea/issues/18352

It aims to improve performance (and resource use) of the `SyncReleasesWithTags` operation for pull-mirrors.

For large repositories with many tags, `SyncReleasesWithTags` can be a costly operation (taking several minutes to complete). The reason is two-fold:
    
1. on sync, every upstream repo tag is compared (for changes) against existing local entries in the release table to ensure that they are up-to-date.
    
2. the procedure for getting _each tag_ involves a series of git operations    
    ```bash
     git show-ref --tags -- v8.2.4477
     git cat-file -t 29ab6ce9f36660cffaad3c8789e71162e5db5d2f
     git cat-file -p 29ab6ce9f36660cffaad3c8789e71162e5db5d2f
     git rev-list --count 29ab6ce9f36660cffaad3c8789e71162e5db5d2f
     ```    

     of which the `git rev-list --count` can be particularly heavy.
    
This PR optimizes performance for pull-mirrors. We utilize the fact that a pull-mirror is always identical to its upstream and rebuild the entire release table on every sync and use a batch `git for-each-ref .. refs/tags` call to retrieve all tags in one go.
    
For large mirror repos, with hundreds of annotated tags, this brings down the duration of the sync operation from several minutes to a few seconds. A few unscientific examples run on my local machine:

- https://github.com/spring-projects/spring-boot (223 tags)
  - before: `0m28,673s`
  - after: `0m2,244s`
- https://github.com/kubernetes/kubernetes (890 tags)
  - before: `8m00s`
  - after: `0m8,520s`
- https://github.com/vim/vim (13954 tags)
  - before: `14m20,383s`
  - after: `0m35,467s`

 

I added a `foreachref` package which contains a flexible way of specifying which reference fields are of interest (`git-for-each-ref(1)`) and to produce a parser for the expected output. These could be reused in other places where `for-each-ref` is used.  I'll add unit tests for those if the overall PR looks promising.
2022-03-31 14:30:40 +02:00
wxiaoguang
b877504b03
Refactor git.Command.Run*, introduce RunWithContextString and RunWithContextBytes (#19266)
This follows 
* https://github.com/go-gitea/gitea/issues/18553

Introduce `RunWithContextString` and `RunWithContextBytes` to help the refactoring. Add related unit tests. They keep the same behavior to save stderr into err.Error() as `RunInXxx` before.

Remove `RunInDirTimeoutPipeline` `RunInDirTimeoutFullPipeline` `RunInDirTimeout` `RunInDirTimeoutEnv`  `RunInDirPipeline`  `RunInDirFullPipeline`  `RunTimeout`, `RunInDirTimeoutEnvPipeline`, `RunInDirTimeoutEnvFullPipeline`, `RunInDirTimeoutEnvFullPipelineFunc`.

Then remaining `RunInDir` `RunInDirBytes` `RunInDirWithEnv` can be easily refactored in next PR with a simple search & replace:
* before: `stdout, err := RunInDir(path)`
* next: `stdout, _, err := RunWithContextString(&git.RunContext{Dir:path})`

Other changes:
1. When `timeout <= 0`, use default. Because `timeout==0` is meaningless and could cause bugs. And now many functions becomes more simple, eg: `GitGcRepos` 9 lines to 1 line. `Fsck` 6 lines to 1 line.
2. Only set defaultCommandExecutionTimeout when the option `setting.Git.Timeout.Default > 0`
2022-03-31 13:56:22 +02:00
Lunny Xiao
d4f84f1c93
Move reaction to models/issues/ (#19264)
* Move reaction to models/issues/

* Fix test

* move the function

* improve code

* Update models/issues/reaction.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-31 17:20:39 +08:00
Gusted
43332a483f
Update reserved usernames list (#18438)
Adding additional usernames which are already routes, remove unused ones.
In future, avoid reserving names as much as possible, use `/-/` in path instead.
2022-03-31 12:02:13 +08:00
Gusted
ba5f2acb9c
Configure OpenSSH log level via Environment in Docker (#19274)
Introduce a new environment variable: SSH_LOG_LEVEL
2022-03-31 11:15:36 +08:00
wxiaoguang
c83168104b
Use a more general (and faster) method to sanitize URLs with credentials (#19239)
Use a more general method to sanitize URLs with credentials: Simple and intuitive / Faster /  Remove all credentials in all URLs
2022-03-31 10:25:40 +08:00
GiteaBot
84038f33f4 [skip ci] Updated translations via Crowdin 2022-03-31 00:18:20 +00:00
Norwin
9cbeab440e
fix link to package registry docs (#19268) 2022-03-30 15:17:05 -04:00
Justin Sievenpiper
a2c20a6cab
Add Redis Sentinel Authentication Support (#19213)
Gitea was not able to supply any authentication parameters to it. So this brings support to do that, along with some light extraction of a couple of bits into some separate functions for easier testing.

I looked at other libraries supporting similar RedisUri-style connection strings (e.g. Lettuce), but it looks like this type of configuration is beyond what would typically be done in a connection string. Since gitea doesn't have configuration options for manually specifying all this redis connection detail, I went ahead and just chose straightforward names for these new parameters.
2022-03-30 21:12:02 +02:00
KN4CK3R
1d332342db
Add Package Registry (#16510)
* Added package store settings.

* Added models.

* Added generic package registry.

* Added tests.

* Added NuGet package registry.

* Moved service index to api file.

* Added NPM package registry.

* Added Maven package registry.

* Added PyPI package registry.

* Summary is deprecated.

* Changed npm name.

* Sanitize project url.

* Allow only scoped packages.

* Added user interface.

* Changed method name.

* Added missing migration file.

* Set page info.

* Added documentation.

* Added documentation links.

* Fixed wrong error message.

* Lint template files.

* Fixed merge errors.

* Fixed unit test storage path.

* Switch to json module.

* Added suggestions.

* Added package webhook.

* Add package api.

* Fixed swagger file.

* Fixed enum and comments.

* Fixed NuGet pagination.

* Print test names.

* Added api tests.

* Fixed access level.

* Fix User unmarshal.

* Added RubyGems package registry.

* Fix lint.

* Implemented io.Writer.

* Added support for sha256/sha512 checksum files.

* Improved maven-metadata.xml support.

* Added support for symbol package uploads.

* Added tests.

* Added overview docs.

* Added npm dependencies and keywords.

* Added no-packages information.

* Display file size.

* Display asset count.

* Fixed filter alignment.

* Added package icons.

* Formatted instructions.

* Allow anonymous package downloads.

* Fixed comments.

* Fixed postgres test.

* Moved file.

* Moved models to models/packages.

* Use correct error response format per client.

* Use simpler search form.

* Fixed IsProd.

* Restructured data model.

* Prevent empty filename.

* Fix swagger.

* Implemented user/org registry.

* Implemented UI.

* Use GetUserByIDCtx.

* Use table for dependencies.

* make svg

* Added support for unscoped npm packages.

* Add support for npm dist tags.

* Added tests for npm tags.

* Unlink packages if repository gets deleted.

* Prevent user/org delete if a packages exist.

* Use package unlink in repository service.

* Added support for composer packages.

* Restructured package docs.

* Added missing tests.

* Fixed generic content page.

* Fixed docs.

* Fixed swagger.

* Added missing type.

* Fixed ambiguous column.

* Organize content store by sha256 hash.

* Added admin package management.

* Added support for sorting.

* Add support for multiple identical versions/files.

* Added missing repository unlink.

* Added file properties.

* make fmt

* lint

* Added Conan package registry.

* Updated docs.

* Unify package names.

* Added swagger enum.

* Use longer TEXT column type.

* Removed version composite key.

* Merged package and container registry.

* Removed index.

* Use dedicated package router.

* Moved files to new location.

* Updated docs.

* Fixed JOIN order.

* Fixed GROUP BY statement.

* Fixed GROUP BY #2.

* Added symbol server support.

* Added more tests.

* Set NOT NULL.

* Added setting to disable package registries.

* Moved auth into service.

* refactor

* Use ctx everywhere.

* Added package cleanup task.

* Changed packages path.

* Added container registry.

* Refactoring

* Updated comparison.

* Fix swagger.

* Fixed table order.

* Use token auth for npm routes.

* Enabled ReverseProxy auth.

* Added packages link for orgs.

* Fixed anonymous org access.

* Enable copy button for setup instructions.

* Merge error

* Added suggestions.

* Fixed merge.

* Handle "generic".

* Added link for TODO.

* Added suggestions.

* Changed temporary buffer filename.

* Added suggestions.

* Apply suggestions from code review

Co-authored-by: Thomas Boerger <thomas@webhippie.de>

* Update docs/content/doc/packages/nuget.en-us.md

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Thomas Boerger <thomas@webhippie.de>
2022-03-30 16:42:47 +08:00
wxiaoguang
2bce1ea986
Show messages for users if the ROOT_URL is wrong, show JavaScript errors (#18971)
* ROOT_URL issues: some users did wrong to there app.ini config, then:
    * The assets can not be loaded (AppSubUrl != "" and users try to access http://host:3000/)
    *The ROOT_URL is wrong, then many URLs in Gitea are broken.
Now Gitea show enough information to users.

* JavaScript error issues, there are many users affected by JavaScript errors, some are caused by frontend bugs, some are caused by broken customized templates. If these JS errors can be found at first time, then maintainers do not need to ask about how bug occurs again and again.

* Some people like to modify the `head.tmpl`, so we separate the script part to `head_script.tmpl`, then it's much safer.

* use specialized CSS class "js-global-error", end users still have a chance to hide error messages by customized CSS styles.
2022-03-30 13:52:24 +08:00
GiteaBot
ea8622d454 [skip ci] Updated translations via Crowdin 2022-03-30 00:17:38 +00:00
6543
3e88af898a
Make git.OpenRepository accept Context (#19260)
* OpenRepositoryCtx -> OpenRepository
* OpenRepository -> openRepositoryWithDefaultContext, only for internal usage
2022-03-30 03:13:41 +08:00
zeripath
889a8c268c
Use full output of git show-ref --tags to get tags for PushUpdateAddTag (#19235)
Strangely #19038 appears to relate to an issue whereby a tag appears to
be listed in `git show-ref --tags` but then does not appear when `git
show-ref --tags -- short_name` is called.

As a solution though I propose to stop the second call as it is
unnecessary and only likely to cause problems.

I've also noticed that the tags calls are wildly inefficient and aren't using the common cat-files - so these have been added.

I've also noticed that the git commit-graph is not being written on mirroring - so I've also added writing this to the migration which should improve mirror rendering somewhat. 

Fix #19038

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2022-03-29 19:12:33 +02:00
zeripath
1eebbf23f0
When conflicts have been previously detected ensure that they can be resolved (#19247)
There is yet another problem with conflicted files not being reset when
the test patch resolves them.

This PR adjusts the code for checkConflicts to reset the ConflictedFiles
field immediately at the top. It also adds a reset to conflictedFiles
for the manuallyMerged and a shortcut for the empty status in
protectedfiles.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-29 18:42:34 +02:00
John Olheiser
66f2210fec
More commit info from API (#19252)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-29 10:47:44 -05:00
Lunny Xiao
74731c3a5a
Move some issue methods as functions (#19255)
* Move some issue methods as functions

* Fix bug
2022-03-29 16:57:33 +02:00
Lunny Xiao
bd97736b9c
Move project files into models/project sub package (#17704)
* Move project files into models/project sub package

* Fix test

* Fix test

* Fix test

* Fix build

* Fix test

* Fix template bug

* Fix bug

* Fix lint

* Fix test

* Fix import

* Improve codes

Co-authored-by: 6543 <6543@obermui.de>
2022-03-29 22:16:31 +08:00
John Olheiser
ea6efba9b3
Granular webhook events in editHook (#19251)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2022-03-29 13:55:00 +02:00
zeripath
97625b44e7
Provide configuration to allow camo-media proxying (#12802)
* Provide configuration to allow camo-media proxying

Fix #916

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-29 10:27:37 +02:00
Lunny Xiao
76aa33d884
Move init repository related functions to modules (#19159)
* Move init repository related functions to modules

* Fix lint

* Use ctx but db.DefaultContext

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-29 15:23:45 +08:00
Lunny Xiao
b06b9a056c
Move organization related structs into sub package (#18518)
* Move organization related structs into sub package

* Fix test

* Fix lint

* Move more functions into sub packages

* Fix bug

* Fix test

* Update models/organization/team_repo.go

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

* Apply suggestions from code review

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

* Fix fmt

* Follow suggestion from @Gusted

* Fix test

* Fix test

* Fix bug

* Use ctx but db.DefaultContext on routers

* Fix bug

* Fix bug

* fix bug

* Update models/organization/team_user.go

* Fix bug

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-29 14:29:02 +08:00
wxiaoguang
d4c789dfc1
Refactor repo clone button and repo clone links, fix JS error on empty repo page (#19208)
The last PR about clone buttons introduced an JS error when visiting an empty repo page:
* https://github.com/go-gitea/gitea/pull/19028
* `Uncaught ReferenceError: isSSH is not defined`, because the variables are scoped and doesn't share between sub templates.

This:
1. Simplify `templates/repo/clone_buttons.tmpl` and make code clear
2. Move most JS code into `initRepoCloneLink`
3. Remove unused `CloneLink.Git`
4. Remove `ctx.Data["DisableSSH"] / ctx.Data["ExposeAnonSSH"] / ctx.Data["DisableHTTP"]`, and only set them when is is needed (eg: deploy keys / ssh keys)
5. Introduce `Data["CloneButton*"]` to provide data for clone buttons and links
6. Introduce `Data["RepoCloneLink"]` for the repo clone link (not the wiki)
7. Remove most `ctx.Data["PageIsWiki"]` because it has been set in the `/wiki` middleware
8. Remove incorrect `quickstart` class in `migrating.tmpl`
2022-03-29 05:21:30 +02:00
zeripath
90e0a402c1
Show last cron messages on monitor page (#19223)
As discussed on #19221 we should store the results of the last task message on the
crontask and show them on the monitor page.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-29 02:31:07 +01:00
zeripath
e69b7a92ed
Allow API to create file on empty repo (#19224)
This PR adds the necessary work to make it possible to create files on empty
repos using the API.

Fix #10993

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-28 21:48:41 +02:00
Lunny Xiao
54961f3ac9
Use goproxy.io instead of goproxy.cn (#19242) 2022-03-28 20:01:07 +03:00
Pilou
893c8938fc
New cron task: delete old system notices (#19219)
Add a new cron task which deletes the old system notices.
2022-03-28 13:54:59 +01:00
Lunny Xiao
6526733a58
Let web and API routes have different auth methods group (#19168)
* remove the global methods but create dynamiclly

* Fix lint

* Fix windows lint

* Fix windows lint

* some improvements

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-28 12:46:28 +08:00
zeripath
d6fa138e7c
Only send webhook events to active system webhooks and only deliver to active hooks (#19234)
There is a bug in the system webhooks whereby the active state is not checked when
webhooks are prepared and there is a bug that deactivating webhooks do not prevent
queued deliveries.

* Only add SystemWebhooks to the prepareWebhooks list if they are active
* At the time of delivery if the underlying webhook is not active mark it
as "delivered" but with a failed delivery so it does not get delivered.

Fix #19220

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-28 11:17:21 +08:00
GiteaBot
04601d22f5 [skip ci] Updated translations via Crowdin 2022-03-28 00:17:27 +00:00
zeripath
d3dbdbe6c5
Prevent intermittent failures in RepoIndexerTest (2) (#19229)
So whilst #19225 fixes one issue it caused another. We need to initialise the Git
module first.

Related #19225
Fix #19162

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

Co-authored-by: 6543 <6543@obermui.de>
2022-03-27 17:54:51 -04:00
Norwin
42fe076084
Fix contrib/upgrade.sh (#19222)
* fix idempotency of script (eg when aborting the downloads)
* improve readability (user facing variables first, definitions next, statements last)
* improve dependency checks
* fix ignored $giteaversion variable
* more logging
* print usage string on incorrect usage
2022-03-27 18:48:08 +01:00
zeripath
d2ca021df0
Touch mirrors on even on fail to update (#19217)
* Touch mirrors on even on fail to update

If a mirror fails to be synchronised it should be pushed to the bottom of the queue
of the awaiting mirrors to be synchronised. At present if there LIMIT number of
broken mirrors they can effectively prevent all other mirrors from being synchronized
as their last_updated time will remain earlier than other mirrors.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-27 15:40:17 +01:00
Lunny Xiao
c29fbc6d23
Hide sensitive content on admin panel progress monitor (#19218)
Sanitize urls within git process descriptions.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-03-27 12:54:09 +01:00
zeripath
41b60d94db
Do not include global arguments in process manager (#19226)
The git command by default adds a number of global arguments. These are not
helpful to be displayed in the process manager and so should be skipped for
default process descriptions.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-27 10:09:56 +01:00
zeripath
793ce9dacf
Prevent intermittent failures in RepoIndexerTest (#19225)
The RepoIndexerTest is failing with considerable frequency due to a race inherrent in
its design. This PR adjust this test to avoid the reliance on waiting for the populate
repo indexer to run and forcibly adds the repo to the queue. It then flushes the queue.

It may be worth separating out the tests somewhat by testing the Index function
directly away from the queue however, this forceful method should solve the current
problem.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-27 15:05:01 +08:00
Abheek Dhawan
f316582458
Set the default branch for repositories generated from templates (#19136)
* Set the default branch for repositories generated from templates
* Allows default branch to be set through the API for repos generated from templates
* Update swagger API template
* Only set default branch to the one from the template if not specified
* Use specified default branch if it exists while generating git commits

Fix #19082 

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-03-27 03:56:28 +01:00
GiteaBot
71a5aaef32 [skip ci] Updated licenses and gitignores 2022-03-27 00:17:35 +00:00
zeripath
acb9fc5f8e
Make cron task no notice on success (#19221)
Change all cron tasks to make them no notice on success default. Instead if a user
wants notices on success they need to add NOTICE_ON_SUCCESS=true instead.

 ## ⚠️ BREAKING ⚠️

This changes the cron config so that notices on success are no longer set by default
and breaks NO_SUCCESS_NOTICE settings. Instead users who want notices on success
must set NOTICE_ON_SUCCESS=true instead.

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

* Update custom/conf/app.example.ini

Co-authored-by: Norwin <noerw@users.noreply.github.com>

Co-authored-by: Norwin <noerw@users.noreply.github.com>
2022-03-26 21:13:04 +00:00
zeripath
70628bd870
Add auto logging of goroutine pid label (#19212)
* Add auto logging of goroutine pid label

This PR uses unsafe to export the hidden runtime_getProfLabel function from the
runtime package and then casts the result to a map[string]string.

We can then interrogate this map to get the pid label from the goroutine allowing
us to log it with any logging request.

Reference #19202

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-26 20:04:36 +00:00
gesangtome
c1198284bc
Check go and nodejs version by go.mod and package.json (#19197)
* Check go and nodejs version by go.mod and package.json 
* Update Go official site URL 

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-26 18:39:31 +08:00
KN4CK3R
59b867dc2d
Add ContextUser to http request context (#18798)
This PR adds a middleware which sets a ContextUser (like GetUserByParams before) in a single place which can be used by other methods. For routes which represent a repo or org the respective middlewares set the field too.

Also fix a bug in modules/context/org.go during refactoring.
2022-03-26 17:04:22 +08:00
Nulo
f36701c702
Set OpenGraph title to DisplayName in profile pages (#19206)
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-03-25 20:15:13 +02:00
zeripath
5fe764b1eb
Add pprof labels in processes and for lifecycles (#19202)
Use pprof labelling to help identify goroutines with stacks.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-25 12:47:12 +00:00
GiteaBot
e48f3b0527 [skip ci] Updated translations via Crowdin 2022-03-25 00:17:35 +00:00
Robert Kaussow
909804b717
Bump goldmark to v1.4.11 (#19201)
* Bump goldmark to v1.4.11

* add testcase

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-03-24 11:47:37 -04:00
dependabot[bot]
def545676f
Bump minimist from 1.2.5 to 1.2.6 (#19194) 2022-03-24 00:29:55 -04:00
6543
6fc6e14957
Changelog for 1.16.5 (#19189) (#19192)
* Changelog for 1.16.5 (#19189)

* bump version
2022-03-24 03:04:12 +01:00
Gusted
a5f2894071
Fix showing issues in your repositories (#18916)
- Make a restriction on which issues can be shown based on if you the user or team has write permission to the repository.
- Fixes a issue whereby you wouldn't see any associated issues with a specific team on a organization if you wasn't a member(fixed by zeroing the User{ID} in the options).
- Resolves #18913
2022-03-23 23:57:09 +01:00
MeIchthys
f7883a6aec
Update issue_no_dependencies description (#19112)
To be more consistent and concise we could change the issue_no_dependencies from: `This issue currently doesn't have any dependencies. ` to `No dependencies set.` like we do for the due date and others.

Co-authored-by: delvh <dev.lh@web.de>
2022-03-23 16:46:50 +00:00
zeripath
0b1686b67a
Prevent redirect to Host (2) (#19175)
Unhelpfully Locations starting with `/\` will be converted by the
browser to `//` because ... well I do not fully understand. Certainly
the RFCs and MDN do not indicate that this would be expected. Providing
"compatibility" with the (mis)behaviour of a certain proprietary OS is
my suspicion. However, we clearly have to protect against this.

Therefore we should reject redirection locations that match the regular
expression: `^/[\\\\/]+`

Reference #9678

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-23 16:12:36 +00:00
Andrew Thornton
81b5bef55a
Prevent start panic due to missing DotEscape function
Unfortunately #19169 causing a panic at startup in prod mode. This was hidden by dev
mode because the templates are compiled dynamically there. The issue is that DotEscape
is not in the original FuncMap at the time of compilation which causes a panic.

Ref #19169

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-23 16:08:27 +00:00
a1012112796
0eff23dae0
Fix compare link in active feeds for new branch (#19149)
When a new branch is pushed the old SHA is always listed as the empty sha and thus the compare link that is created does not work correctly. 

Therefore when creating the compare link for new branches:

1. Attempt to get the parent of the first commit and use that as the basis 
for the compare link.
2. If this is not possible make a comparison to the default branch
3. Finally if that is not possible simply do not show a compare link.

However, there are multiple broken compare links remaining therefore, in order for these to not break we will simply make the compare link redirect to the default branch.

Fix #19144

Signed-off-by: a1012112796 <1012112796@qq.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-03-23 13:40:12 +00:00
a1012112796
d8f578412e
Redirect .wiki/* ui link to /wiki (#18831)
Redirect .wiki/* ui link to /wiki

fix #18590

Signed-off-by: a1012112796 <1012112796@qq.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-03-23 13:29:18 +00:00
zeripath
5248232c44
Try to prevent autolinking of displaynames by email readers (#19169)
Unfortunately many email readers will (helpfully) detect url or url-like names and
automatically create links to them, even in HTML emails. This is not ideal when
usernames can have dots in them.

This PR tries to prevent this behaviour by sticking ZWJ characters between dots and
also set the meta tag to prevent format detection.

Not every email template has been changed in this way - just the activation emails but
it may be that we should be setting the above meta tag in all of our emails too.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-23 12:34:20 +00:00
KN4CK3R
3f280f89e7
Update HTTP status codes to modern codes (#18063)
* 2xx/3xx/4xx/5xx -> http.Status...
* http.StatusFound -> http.StatusTemporaryRedirect
* http.StatusMovedPermanently -> http.StatusPermanentRedirect
2022-03-23 12:54:07 +08:00
wxiaoguang
395117d301
Remove the Go version in UI, add a link on Gitea Version to show config details (Go/Git version) (#19173)
This PR mainly helps maintainers to save time from asking the issue reporters to get the correct version.

There are so many reporters that have difficulty to get the correct Gitea version. Some of they just report Go version.

The Go version doesn't help debug except in very limited circumstances. Instead, there is a new link on the Gitea version, the link is for the admin/config page which shows all version information, including Gitea, Go, Git, it could help more.
2022-03-23 01:15:54 +00:00
GiteaBot
db6080f4f8 [skip ci] Updated translations via Crowdin 2022-03-23 00:24:20 +00:00
zeripath
3f71ab9a12
Clean paths when looking in Storage (#19124)
* Clean paths when looking in Storage

Ensure paths are clean for minio aswell as local storage.

Use url.Path not RequestURI/EscapedPath in storageHandler.

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

* Apply suggestions from code review

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-03-22 17:02:26 -04:00
zeripath
d2c165811a
Use the new/choose link for New Issue on project page (#19172)
Extend issues/new/choose to pass the project id and change New Issue
link on project page to use new/choose

Fix #19170

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-22 19:54:24 +00:00
zeripath
461068cfa1
Ensure that setting.LocalURL always has a trailing slash (#19171)
Fix #19166

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-22 16:59:57 +00:00
wxiaoguang
7a550b3af2
Use ctx instead of db.DefaultContext in some packages(routers/services/modules) (#19163)
* Remove `db.DefaultContext` usage in routers, use `ctx` directly

* Use `ctx` directly if there is one, remove some `db.DefaultContext` in `services`

* Use ctx instead of db.DefaultContext for `cmd` and some `modules` packages

* fix incorrect context usage
2022-03-22 16:22:54 +01:00
wxiaoguang
2b55422cd7
Fix the bug: deploy key with write access can not push (#19010)
Use DeployKeyID to replace the IsDeployKey, then CanWriteCode uses the DeployKeyID to check the write permission.
2022-03-22 17:29:07 +08:00
KN4CK3R
80fd25524e
Renamed ctx.User to ctx.Doer. (#19161)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-22 15:03:22 +08:00
Robin
5495ba7660
[docs] Enhance container selection in docker dump (#14292)
* Enhance container selection in docker dump

The problem with the previous query was, that it sometimes selected multiple containers, which make the command file with a hard to understand message. Now, use '^...$' to make sure a regex full match.
2022-03-22 13:50:31 +08:00
Norwin
77d1c7bf2f
Cleanup protected branches when deleting users & teams (#19158)
* Clean up protected_branches when deleting user

fixes #19094

* Clean up protected_branches when deleting teams

* fix issue

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-03-22 09:09:45 +08:00
delvh
bfe2e3d562
Reorder issue templates and automatically add labels (#18875)
* Reorder bug-report.yaml

* Add bug label on bug-report.yaml

* Add feature label on feature-request.yaml

* Reorder ui.bug-report.yaml

* Apply suggestions

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2022-03-21 20:00:25 +08:00
zeripath
b05b40180f
Use IterateBufferSize whilst querying repositories during adoption check (#19140)
The adoption page checks directories to see if they are repositories by querying the
db on a per user basis. This can lead to problems if a user has a large number of
repositories or putative repositories.

This PR changes the buffering to check the db in IterataeBufferSize batches instead.

Fix #19137

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-21 09:09:42 +01:00
Sasha Melentyev
c604c9ae66
Add 1.18 (#19151)
Co-authored-by: 6543 <6543@obermui.de>
2022-03-21 11:22:34 +08:00
GiteaBot
572c63d237 [skip ci] Updated translations via Crowdin 2022-03-21 00:24:03 +00:00
Gusted
49c5fc565c
Fix NPE /repos/issues/search when not signed in (#19154)
- Don't panic when on
`/repos/issues/search?{created,assigned,mentioned,review_requested}=true`
when client didn't pass any authentication.
- Resolves #19115
2022-03-20 22:04:51 +01:00
GiteaBot
83a2f79d5d [skip ci] Updated licenses and gitignores 2022-03-20 00:24:18 +00:00
Abheek Dhawan
f96e8be41f
Use custom favicon when viewing static files if it exists (#19130)
Redirect `/favicon.ico` to `/assets/img/favicon.png`.

Fix #19109
2022-03-19 19:53:31 +00:00
zeripath
3322f4d7cc
not send notification emails to inactive users (part 2) (#19142)
Unfortunately fixing changes to `mail_issue.go` did not get included in #19131.

We also need to not send issue comment mails to deactivated users.

Fix #18950

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-19 16:20:03 +00:00
zeripath
2d21d2af9e
Make migrations SKIP_TLS_VERIFY apply to git too (#19132)
Make SKIP_TLS_VERIFY apply to git data migrations too through adding the `-c http.sslVerify=false` option to the git clone command.

Fix #18998

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-19 14:16:38 +00:00
zeripath
fb08d2b3fd
Do not send notification emails to inactive users (#19131)
Emails should not be sent to inactive users except for Activate and ResetPassword
messages.

Fix #18950

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-19 20:45:44 +08:00
6543
60fbaa9068
remove not needed (#19128) 2022-03-18 20:17:57 +01:00
zeripath
fda5b9fc3e
Add warning to set SENDMAIL_ARGS to -- (#19102)
Even with #17688 email addresses that contain an initial `-` may still be present in the db and it may in future still be possible to imagine a situation whereby initial `-` are repermitted.

This PR simply updates the documentation to warn users to set their SENDMAIL_ARGS with a terminal `--` to prevent this possibility email addresses being interpreted as options.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-18 15:19:02 +01:00
zeripath
7fc5fd6415
Do not send activation email if manual confirm is set (#19119)
If the mailer is configured then even if Manual confirm is set an activation email
is still being sent because `handleUserCreated` is not checking for this case.

Fix #17263

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-18 17:57:07 +08:00
silverwind
929b07fe45
Update tool dependencies (#19120)
- Use tag over hash for all tool dependencies
- Update them to latest released versions
2022-03-18 10:17:56 +08:00
Otto Richter (fnetX)
04fcf23ea3
Delete related notifications on issue deletion too (#18953)
* use .Decr for issue comment counting

* Remove notification on issue removal
2022-03-17 23:04:09 +01:00
6543
45f8d97131
nit fix (#19116) 2022-03-17 20:04:36 +02:00
Aravinth Manivannan
fa73cbf5a7
Store the foreign ID of issues during migration (#18446)
Storing the foreign identifier of an imported issue in the database is a prerequisite to implement idempotent migrations or mirror for issues. It is a baby step towards mirroring that introduces a new table.

At the moment when an issue is created by the Gitea uploader, it fails if the issue already exists. The Gitea uploader could be modified so that, instead of failing, it looks up the database to find an existing issue. And if it does it would update the issue instead of creating a new one. However this is not currently possible because an information is missing from the database: the foreign identifier that uniquely represents the issue being migrated is not persisted. With this change, the foreign identifier is stored in the database and the Gitea uploader will then be able to run a query to figure out if a given issue being imported already exists.

The implementation of mirroring for issues, pull requests, releases, etc. can be done in three steps:

1. Store an identifier for the element being mirrored (issue, pull request...) in the database (this is the purpose of these changes)
2. Modify the Gitea uploader to be able to update an existing repository with all it contains (issues, pull request...) instead of failing if it exists
3. Optimize the Gitea uploader to speed up the updates, when possible.

The second step creates code that does not yet exist to enable idempotent migrations with the Gitea uploader. When a migration is done for the first time, the behavior is not changed. But when a migration is done for a repository that already exists, this new code is used to update it.

The third step can use the code created in the second step to optimize and speed up migrations. For instance, when a migration is resumed, an issue that has an update time that is not more recent can be skipped and only newly created issues or updated ones will be updated. Another example of optimization could be that a webhook notifies Gitea when an issue is updated. The code triggered by the webhook would download only this issue and call the code created in the second step to update the issue, as if it was in the process of an idempotent migration.

The ForeignReferences table is added to contain local and foreign ID pairs relative to a given repository. It can later be used for pull requests and other artifacts that can be mirrored. Although the foreign id could be added as a single field in issues or pull requests, it would need to be added to all tables that represent something that can be mirrored. Creating a new table makes for a simpler and more generic design. The drawback is that it requires an extra lookup to obtain the information. However, this extra information is only required during migration or mirroring and does not impact the way Gitea currently works.

The foreign identifier of an issue or pull request is similar to the identifier of an external user, which is stored in reactions, issues, etc. as OriginalPosterID and so on. The representation of a user is however different and the ability of users to link their account to an external user at a later time is also a logic that is different from what is involved in mirroring or migrations. For these reasons, despite some commonalities, it is unclear at this time how the two tables (foreign reference and external user) could be merged together.

The ForeignID field is extracted from the issue migration context so that it can be dumped in files with dump-repo and later restored via restore-repo.

The GetAllComments downloader method is introduced to simplify the implementation and not overload the Context for the purpose of pagination. It also clarifies in which context the comments are paginated and in which context they are not.

The Context interface is no longer useful for the purpose of retrieving the LocalID and ForeignID since they are now both available from the PullRequest and Issue struct. The Reviewable and Commentable interfaces replace and serve the same purpose.

The Context data member of PullRequest and Issue becomes a DownloaderContext to clarify that its purpose is not to support in memory operations while the current downloader is acting but is not otherwise persisted. It is, for instance, used by the GitLab downloader to store the IsMergeRequest boolean and sort out issues.

---
[source](https://lab.forgefriends.org/forgefriends/forgefriends/-/merge_requests/36)

Signed-off-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-03-17 18:08:35 +01:00
MeIchthys
a7de80db0d
Remove italics for due_date_not_set (#19113)
To be more consistent with other `repo.issues.x` formatting, we can remove the italics from `dute_date_not_set`.
2022-03-17 17:43:10 +02:00
GiteaBot
cc6ff74253 [skip ci] Updated translations via Crowdin 2022-03-17 00:24:18 +00:00
Fredrik Ekre
df31ac0e09
Fixed log path in fail2ban documentation (#19103)
This updates the log path in the [gitea-docker] jail configuration
to match the path in the [gitea] jail, which was updated in #13726.
2022-03-16 12:39:13 -04:00
techknowlogick
0b15a729cf
rm .sample hooks which aren't used (#19101) 2022-03-16 10:33:07 +00:00
techknowlogick
ed1d95c55d
use go1.18 to build gitea (#19099)
* use go1.18 to build gitea& update min go version to 1.17

* bump in a few more places

* add a few simple tests for isipprivate

* update go.mod

* update URL to https://go.dev/dl/

* golangci-lint

* attempt golangci-lint workaround

* change version

* bump fumpt version

* skip strings.title test

* go mod tidy

* update tests as some aren't private??

* update tests
2022-03-16 00:08:31 -04:00
silverwind
fe9626af29
Use go run for tool dependencies, require go 1.17 (#18874)
This ensures the tools only run in the versions we've tested and it also
does not polute PATH with those tools so they are truly isolated. This
syntax of `go run` requires go 1.17, so the minimum version is set
accordingly.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-03-15 22:50:26 -04:00
Gusted
6ab4a96855
Update golang.org/x/crypto (#19097)
* Update golang.org/x/crypto

- Update dependency to include fix for CVE.
- See https://groups.google.com/g/golang-announce/c/-cp44ypCT5s/m/wmegxkLiAQAJ?utm_medium=email&utm_source=footer

* Fix deprecation notice

* Remove workaround

- Introduced in https://github.com/go-gitea/gitea/pull/17281
- Fixed in x/crypto:
- 5d542ad81a
- & 3147a52a75

* Update Kex Algorithms

- Use standardized name for curve22519-sha256. 9b076918e3
- Prefer SHA256 version over SHA1 version. e4b3678e5f
2022-03-16 02:59:53 +01:00
KN4CK3R
c88f2e2acc
Handle email address not exist. (#19089) 2022-03-15 10:18:39 +01:00
6543
2ba72cedbe
Frontport Changelogs (#19088)
* Frontport Changelogs

* bump version in docs
2022-03-14 23:18:01 +01:00
Lunny Xiao
18033f49ba
Restrict email address validation (#17688)
This didn't follow the RFC but it's a subset of that. I think we should narrow the allowed chars at first and discuss more possibility in future PRs.
2022-03-14 18:39:54 +01:00
Lunny Xiao
49db87a035
Fix lfs bug (#19072)
* Fix lfs bug
2022-03-14 16:18:27 +01:00
GiteaBot
3ad6cf2069 [skip ci] Updated translations via Crowdin 2022-03-14 00:11:34 +00:00
mscherer
35541f853b
Fix documentation and #19065 (#19067) 2022-03-13 18:30:58 +01:00
6543
bc0d2c8ada
RSS/Atom support for Repos (#19055)
* support for repos
* refactor
* advertise the feeds via meta tags
* allow feed suffix and feed header
* optimize performance
2022-03-13 17:40:47 +01:00
GiteaBot
780cf76f6e [skip ci] Updated licenses and gitignores 2022-03-13 00:11:52 +00:00
Norwin
9cca834aac
Feeds: render markdown to html (#19058)
* feeds: render markdown to html
2022-03-12 23:05:12 +01:00
GiteaBot
a0c043f5c6 [skip ci] Updated translations via Crowdin 2022-03-12 00:11:48 +00:00
zeripath
a223bc8765
Prevent 500 when there is an error during new auth source post (#19041)
Fix #19036

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-10 23:40:43 +01:00
zeripath
886b1de949
Update the webauthn_credential_id_sequence in Postgres (#19048)
* Update the webauthn_credential_id_sequence in Postgres

There is (yet) another problem with v210 in that Postgres will silently allow preset
ID insertions ... but it will not update the sequence value.

This PR simply adds a little step to the end of the v210 migration to update the
sequence number.

Users who have already migrated who find that they cannot insert new
webauthn_credentials into the DB can either run:

```bash
gitea doctor recreate-table webauthn_credential
```

or

```bash
./gitea doctor --run=check-db-consistency --fix
```

which will fix the bad sequence.

Fix #19012

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-10 23:04:55 +01:00
zeripath
a0db075f21
If rendering has failed due to a net.OpError stop rendering (attempt 2) (#19049)
Unfortunately #18642 does not work because a `*net.OpError` does not implement
the `Is` interface to make `errors.Is` work correctly - thus leading to the
irritating conclusion that a `*net.OpError` is not a `*net.OpError`.

Here we keep the `errors.Is` because presumably this will be fixed at
some point in the golang main source code but also we add a simply type
cast to also check.

Fix #18629

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-10 20:23:15 +00:00
6543
ba470a85dd
use xorm builder for models.getReviewers() (#19033)
* xorm builder

* dedup code
2022-03-10 19:12:10 +01:00
6543
cc98737ca8
RSS/Atom support for Orgs (#17714)
part of #569
2022-03-10 15:54:51 +01:00
Norwin
5fdd30423e
Fix flag validation (#19046)
Regression from #5785
2022-03-10 10:11:26 +00:00
zeripath
75eb6cc9c1
Improve SyncMirrors logging (#19045)
Yet another issue has come up where the logging from SyncMirrors does not provide
enough context. This PR adds more context to these logging events.

Related #19038

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-10 10:09:48 +00:00
zeripath
1314f38b59
fix pam authorization (#19040)
https://huntr.dev/bounties/8d221f92-b2b1-4878-bc31-66ff272e5ceb/

Co-authored-by: ysf <34326+ysf@users.noreply.github.com>
2022-03-10 10:00:05 +08:00
GiteaBot
7443213707 [skip ci] Updated translations via Crowdin 2022-03-10 00:11:57 +00:00
Lunny Xiao
2448c5ad8b
Upgrading binding package (#19034)
Fix #18855
2022-03-09 18:06:58 +00:00
wxiaoguang
c21735b49a
Ensure isSSH is set whenever DISABLE_HTTP_GIT is set (#19028)
When DISABLE_HTTP_GIT is set we should always show the SSH button
2022-03-09 12:42:29 +08:00
Otto Richter (fnetX)
ea46142bce
Add button for issue deletion (#19032)
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-03-09 01:38:11 +01:00
YISH
ddf7f1319f
Fix script compatiable with OpenWrt (#19000)
* Fix compatibility of upgrade.sh in openwrt and add service init script for openwrt.

* Apply suggestions from code review

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: zeripath <art27@cantab.net>

* Update contrib/upgrade.sh

Co-authored-by: Norwin <noerw@users.noreply.github.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-03-08 17:58:14 -05:00
Norwin
eceab9e26f
Allow users to self-request a PR review (#19030)
The review request feature was added in https://github.com/go-gitea/gitea/pull/10756,
where the doer got explicitly excluded from available reviewers. I don't see a
functionality or security related reason to forbid this case.

As shown by GitHubs implementation, it may be useful to self-request a review,
to be reminded oneselves about reviewing, while communicating to team mates that a
review is missing.

Co-authored-by: delvh <dev.lh@web.de>
2022-03-08 22:48:47 +01:00
wxiaoguang
e73c5fd698
Fix wrong scopes caused by empty scope input (#19029) 2022-03-08 19:56:40 +01:00
Roger Luo
bbce905b6a
Feature: show issue assignee on project board (#15232)
* Show assignees in project boards.
2022-03-09 00:42:28 +08:00
techknowlogick
1546580f9e
bump go deps (#19021)
* update gitea.com/go-chi/binding

* update gitea.com/go-chi/cache

* update github.com/42wim/sshsig

* update github.com/PuerkitoBio/goquery

* update github.com/blevesearch/bleve/v2

* update github.com/caddyserver/certmagic

* update github.com/denisenkom/go-mssqldb

* update github.com/duo-labs/webauthn

* update github.com/dustin/go-humanize

* update github.com/editorconfig/editorconfig-core-go/v2

* update github.com/ethantkoenig/rupture

* update github.com/go-chi/chi/v5

* update github.com/go-git/go-git/v5

* update github.com/go-ldap/ldap/v3

* update github.com/go-redis/redis/v8

* update github.com/go-swagger/go-swagger

* update github.com/gogs/chardet

* update github.com/golang-jwt/jwt/v4

* update github.com/hashicorp/go-version

* update github.com/jaytaylor/html2text

* update github.com/klauspost/compress

* update github.com/lib/pq

* update github.com/markbates/goth

* update github.com/mattn/go-sqlite3

* update github.com/mholt/archiver/v3

* update github.com/microcosm-cc/bluemonday

* update github.com/minio/minio-go/v7

* update github.com/msteinert/pam

* update github.com/niklasfasching/go-org

* update github.com/olivere/elastic/v7

* update github.com/prometheus/client_golang

* update github.com/quasoft/websspi

* update github.com/stretchr/testify

* update github.com/unknwon/i18n

* update github.com/unrolled/render

* update github.com/xanzy/go-gitlab

* update github.com/yuin/goldmark

* update github.com/yuin/goldmark-highlighting

* update github.com/yuin/goldmark-meta

* post make vendor

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

* add make vendor back into update_dependencies.sh

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

* Update update_dependencies.sh

* Update contrib/update_dependencies.sh

Co-authored-by: zeripath <art27@cantab.net>

* update mvdan.cc/xurls/v2

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-08 19:15:30 +08:00
zeripath
8ddb5490e8
Don't show context cancelled errors in attribute reader (#19006)
Fix #18997

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-03-08 08:30:14 +00:00
zeripath
78b38a5ccc
Set rel="nofollow noindex" on new issue links (#19023)
Fix #19018

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-03-07 17:08:05 -05:00
techknowlogick
9c5696e428
update to correct stable version 2022-03-07 02:03:06 -05:00
GiteaBot
98f54081d6 [skip ci] Updated translations via Crowdin 2022-03-07 00:11:49 +00:00
singuliere
cc643284de
Add Index to comment for migrations and mirroring (#18806)
Comments have an id (see Gitea[0], GitLab[1], GitHub[2], etc.), and the
comment migration format must represent it during migrations so that
it can be used during mirroring or incremental migrations.

[0] https://try.gitea.io/api/swagger#/issue/issueGetComment
[1] https://docs.gitlab.com/ee/api/discussions.html#get-single-issue-discussion-item
[2] https://docs.github.com/en/rest/reference/issues#get-an-issue-comment

Signed-off-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-03-06 20:00:41 +01:00
Lunny Xiao
b24e8d38af
Support ignore all santize for external renderer (#18984)
* Support ignore all santize for external renderer

* Update docs

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

* Fix doc

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: 6543 <6543@obermui.de>
2022-03-06 16:41:54 +08:00
wxiaoguang
3e28fa72ce
Fix EasyMDE error when input Enter (#19004)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-06 01:53:34 +08:00
Lunny Xiao
814750e647
Fix update hint bug (#18996) 2022-03-04 20:59:29 +00:00
wxiaoguang
997deecbfa
Fix the editor height in review box (#19003)
Fix the height problem in  https://github.com/go-gitea/gitea/pull/18862#issuecomment-1059329539

I have tested this fix.

# Screenshots

### Min-height

<img width="1138" alt="image" src="https://user-images.githubusercontent.com/2114189/156811831-93d4d31a-1b0a-4c4c-a7b4-fafc706133d6.png">

### Max-height

<img width="1126" alt="image" src="https://user-images.githubusercontent.com/2114189/156811889-10ae41de-c63b-45e7-9d89-21a1ed29e58b.png">
2022-03-04 20:57:26 +00:00
mscherer
95c8d53d28
Add a "admin user generate-access-token" subcommand (#17722)
* Add a "admin user generate-access-token" subcommand

Fixes #17721

* Update cmd/admin.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* Update cmd/admin.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* Fix code to match new interfaces

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-03-04 19:53:35 +00:00
Otto Richter (fnetX)
e46a8c90ea
Fix potential assignee query for repo (#18994)
* Fix potential assignee query for repo

* Add tests for `GetRepoAssignees`

- As per https://github.com/go-gitea/gitea/pull/18994#issuecomment-1058506640

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-04 18:29:12 +00:00
Jimmy Praet
5184c83f6b
Add config option to disable "Update branch by rebase" (#18745) 2022-03-04 03:30:49 -05:00
Gusted
3c7201682c
Update go-enry to v2.8.0 (#18993)
- It was reported in the Matrix channel that Chroma [has support](d402102976)
for the Fennel language, go-enry only added detection support for this
[in v2.7.2](0affa3ccca).

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-03-04 01:56:31 +01:00
techknowlogick
286355c754
homebrew updates via cron 2022-03-03 15:59:26 -05:00
eladyn
7a893dab39
ignore missing comment for user notifications (#18954)
* ignore missing comment for user notifications

* instead fix bug in notifications model

* use local variable instead

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-03-03 16:18:26 +01:00
6543
e800bc0cf4
allow overwrite artifacts for github releases (#18987) 2022-03-03 15:28:41 +01:00
6543
eddd2fb242
fix & refactor (#18973)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-03 19:51:13 +08:00
KN4CK3R
f3cbdee38e
Don't clean up hardcoded tmp (#18983)
* Don't clean up hardcoded `tmp`.

* Fixed import.
2022-03-02 23:50:29 +01:00
6543
efd10f1ab4
git backend ignore replace objects (#18979)
* git backend ignore replace objects

* comment
2022-03-02 20:13:19 +00:00
Lunny Xiao
04971c33a3
Improve the deletion of issue (#18945)
Co-authored-by: 6543 <6543@obermui.de>
2022-03-02 18:38:56 +01:00
KN4CK3R
f8898c30dc
Add note to GPG key response if user has no keys (#18961)
* Prevent invalid key response.

* Display note instead of 404 response.

* Fixed test.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-03-02 11:32:18 -05:00
Marco Blessing
df9802ca61
adds restore docs for docker based instances (#18844)
* adds docke restore section

* fix typo

* Update docs/content/doc/usage/backup-and-restore.en-us.md

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* fix container id placeholder

* adds restore help for docker-rootless

* restore yml autoformater quotes

Co-authored-by: Marco Blessing <marco.blessing@komm.one>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-03-02 11:20:00 -05:00
wxiaoguang
dd712b77f7
Refactor admin user filter query parameters (#18965)
Only pass `status_filter` on admin page
Use a more general method to pass query parameters, remove hard-coded keys
2022-03-02 16:30:14 +01:00
Gusted
a14b6f3aae
Refactor mirror code & fix StartToMirror (#18904)
* Use MirrorID instead of RepoID

- Use the MirrorID as index(SQL uses `id` column not the `repo_id`).
Passes the Mirror ID's into the Sync functions.

* Check for MirrorID == 0

* Fix `StartToMirror` + refactor

* Update services/mirror/mirror.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-03-02 15:43:11 +08:00
Gusted
a90041d71a
Send 404 on /{org}.gpg (#18959) 2022-03-01 20:37:32 -05:00
6543
1f45d1e130
Accounts with WebAuthn only (no TOTP) now exist ... fix code to handle that case (#18897) 2022-03-02 01:24:31 +01:00
Lunny Xiao
38f6322164
Fix lfs management setting (#18946)
Fix #18782
2022-03-01 23:14:27 +00:00
Otto Richter (fnetX)
aee0fa68a7
Fix admin user list pagination (#18957) 2022-03-01 20:21:37 +01:00
Otto Richter (fnetX)
062fd4c217
[API] Allow removing issues (#18879)
Add new feature to delete issues and pulls via API

Co-authored-by: fnetx <git@fralix.ovh>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-03-01 01:20:15 +01:00
René Schaar
6859b69198
Refactor SecToTime() function (#18863)
- Add helper method to reduce redundancy
- Expand the scope from displaying days to years
- Reduce irrelevance by not displaying small units (hours, minutes, seconds) when bigger ones apply (years)
2022-02-28 23:57:20 +01:00
Lunny Xiao
b75ad7b87f
Improve mirror iterator (#18928)
* Improve mirror iterator

* fix test
2022-02-28 20:41:06 +01:00
Lunny Xiao
59959ab222
Fix login with email panic when email is not exist (#18941) 2022-02-28 18:33:33 +01:00
zeripath
4697735c8d
Adjust error for already locked db and prevent level db lock on malformed connstr (#18923)
This PR adjusts the error returned when there is failure to lock the level db, and
permits a connections to the same leveldb where there is a different connection string.

Reference #18921
Reference #18917

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-27 19:45:06 +00:00
Gusted
548adb94b4
Avoid database lookups for DescriptionHTML (#18924)
* Avoid database lookups for `DescriptionHTML`

- Don't Compose meta's for DescriptionHTML, they are only needed in
order to correctly format and show issue's but it's highly unlikely that
a repository description will refer to a local issue.

Using 125 Connections for 5 seconds: on `/explore/repos`(which is the most
noticeable usage by this function's database lookups):

Before:

Statistics        Avg      Stdev        Max
  Reqs/sec       569.41     506.05    2715.00
  Latency      214.27ms    16.60ms   294.84ms
  HTTP codes:
    1xx - 0, 2xx - 2974, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
  Throughput:    27.17MB/s

After:

Statistics        Avg      Stdev        Max
  Reqs/sec      1585.04     789.84    4144.56
  Latency       78.89ms    15.89ms   206.94ms
  HTTP codes:
    1xx - 0, 2xx - 7975, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
  Throughput:    73.85MB/s

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2022-02-27 18:51:34 +01:00
Gusted
79c7219be8
Update go-org to v1.6.1 (#18932)
- v1.6.0 has a inconsistency with the proxy and github's tagged version,
updating to v1.6.1 should fix this issue.
- Resolves #18864
2022-02-27 16:56:44 +00:00
Gusted
f56bba1a78
Fix trace log to show value instead of pointers (#18926)
- Fixes a issue with a trace of repo.Units whereby it would show the pointers.

Before:
![image](https://user-images.githubusercontent.com/25481501/155876811-036bf40e-db89-4e09-ac00-0c78ce3f5bef.png)

After:
![image](https://user-images.githubusercontent.com/25481501/155885102-16c9cf29-314b-4f32-bcee-80e332f63dec.png)
2022-02-27 15:49:22 +00:00
Norwin
c9da11c6b2
Add announcement steps to release-howto (#18896)
* add announcements steps to release-howto

* Also add homebrew update
2022-02-27 15:48:09 +00:00
Gusted
af9da8139a
Fix <strong> html in translation (#18929) 2022-02-27 15:46:45 +00:00
qwerty287
1563a45623
Fix page and missing return on unadopted repos API (#18848)
* Fix page and missing return on unadopted repos API

Page must be 1 if it's not specified and it should return after sending an internal server error.

* Allow ignore pages

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-27 20:17:42 +08:00
GiteaBot
3ba9dcf4b4 [skip ci] Updated licenses and gitignores 2022-02-27 00:16:04 +00:00
Gusted
962725cdbb
Allow adminstrator teams members to see other teams (#18918)
* Allow adminstrator teams to see other teams

- Allow team members with adminstrator access, to view other teams.
- Resolves #18885
2022-02-26 21:12:01 +01:00
JonRB
aa60cd91b2
Update nginx reverse proxy docs (#18922)
Add additional config lines for the set_header to forward additional information (eg the IP)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-26 19:32:09 +01:00
Gusted
bf2867dec2
Don't treat BOM escape sequence as hidden character. (#18909)
* Don't treat BOM escape sequence as hidden character.

- BOM sequence is a common non-harmfull escape sequence, it shouldn't be
shown as hidden character.
- Follows GitHub's behavior.
- Resolves #18837

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-02-26 16:48:23 +00:00
silverwind
329b959160
Remove CodeMirror dependencies (#18911)
EasyMDE already loads all the modes and plugins it needs, so there is no reason for neither the webpack dependency nor the vendored copy
2022-02-26 23:47:52 +08:00
Gusted
6d55a132a5
Uncapitalize errors (#18915)
- See: https://github.com/golang/go/wiki/CodeReviewComments#error-strings

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-26 20:15:32 +08:00
silverwind
fa0e2d60c2
Disable service worker by default (#18914)
The service worker causes a lot of issues with JS errors after instance
upgrades while not bringing any real performance gain over regular HTTP
caching.

Disable it by default for this reason. Maybe later we can remove it
completely, as I simply see no benefit in having it.
2022-02-26 18:14:23 +08:00
KN4CK3R
5b0cdd6155
Set is_empty in fixtures (#18869) 2022-02-26 01:15:25 -05:00
Gusted
33e19c8004
Don't update email for organisation (#18905)
- Fix regression caused by: f1b1472632
- Don't try to insert a email for Organisation(as they don't have one).
- Resolves #18891

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-26 10:38:08 +08:00
Alexander Neumann
fd273b05b9
Correctly link URLs to users/repos with dashes, dots or underscores (#18890)
* Add tests for references with dashes

This commit adds tests for full URLs referencing repos names and user
names containing a dash.

* Extend regex to match URLs to repos/users with dashes
2022-02-26 00:26:43 +01:00
KN4CK3R
9d7a431b71
Set is_private in fixtures. (#18868)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-25 16:22:20 -05:00
Lunny Xiao
36d31d521d
Fix team management UI (#18886)
Co-authored-by: 6543 <6543@obermui.de>
2022-02-25 16:19:54 -05:00
silverwind
65689f6b37
Update JS dependencies (#18898)
- Updated all JS dependencies minus Vue (update 2 to 3 requires a ton of
  work and is probably blocked by dependencies)
- Tested editor, swagger-ui
2022-02-25 15:08:35 -05:00
Lunny Xiao
a5e8daee73
Fix migration v210 (#18892) 2022-02-25 15:04:59 +01:00
singuliere
49cab2b01f
migrations: add test for importing pull requests in gitea uploader (#18752)
* logs: add the buffer logger to inspect logs during testing

Signed-off-by: Loïc Dachary <loic@dachary.org>

* migrations: add test for importing pull requests in gitea uploader

Signed-off-by: Loïc Dachary <loic@dachary.org>

* for each git.OpenRepositoryCtx, call Close

* Content is expected to return the content of the log

* test for errors before defer

Co-authored-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-25 17:20:50 +08:00
Jimmy Praet
e4ef61ee0f
BeforeSourcePath should point to base commit (#18799)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-25 14:46:15 +08:00
zeripath
f1c6cf7c51
Prevent Stats Indexer reporting error if repo dir missing (#18870)
Repositories missing their directory should not report an error from the stats
indexer.

Close #18847

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-24 23:22:09 -05:00
GiteaBot
2f2f11e45d [skip ci] Updated translations via Crowdin 2022-02-25 00:16:08 +00:00
Lunny Xiao
6621710deb
Fix update user (#18878) 2022-02-24 19:29:10 +01:00
Lunny Xiao
f1b1472632
Fix ldap user sync missed email in email_address table (#18786)
* Fix ldap user sync missed email in email_address table

* Fix test
2022-02-24 14:13:59 +08:00
zeripath
cb41f5cae1
Update assignees check to include any writing team and change org sidebar (#18680)
Following the merging of #17811 teams can now have differing write and readonly permissions, however the assignee list will not include teams which have mixed perms.

Further the org sidebar is no longer helpful as it can't describe these mixed permissions situations.

Fix #18572

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-23 22:07:05 +00:00
Kyle D
f7085f718b
Set max text height to prevent overflow (#18862)
Sets a max height for review text boxes to prevent a very annoying bug where users cannot access the "submit" button.

Before:
![image](https://user-images.githubusercontent.com/12700993/155253001-e1dab086-aaf3-4338-889d-6a861728274a.png)

After:
![image](https://user-images.githubusercontent.com/12700993/155253144-5b9a3547-9582-412f-867f-41a45a14a0fe.png)

Interestingly, I don't see this bug on Firefox.
2022-02-23 20:17:14 +00:00
silverwind
2b9df564b8
Lock gofumpt to v0.3.0 and run it (#18866)
We can't depend on `latest` version of gofumpt because the output will
not be stable across versions. Lock it down to the latest version
released yesterday and run it again.
2022-02-23 20:16:07 +00:00
Lunny Xiao
2b5e013430
Fix ldap edit bug (#18856)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-02-22 17:07:04 -05:00
Gusted
c918521d01
Fix behavior or checkbox submission. (#18851) 2022-02-22 14:43:11 -05:00
zeripath
704bdf89a2
Don't report signal: killed errors in serviceRPC (#18850)
Fix #18849

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-22 16:32:25 +08:00
Lunny Xiao
dc988eae0c
Fix bug for get user by email (#18833)
Co-authored-by: zeripath <art27@cantab.net>
2022-02-21 22:20:34 +08:00
singuliere
54dd0fc88b
migrations: remove dead code in gitea uploader (#18725)
When migrating, g.issues is a map with all issues created during the
migration. If an issue is not found in g.issues when inserting a
comment or a review, it cannot exist in the database and trying to get
it via GetIssueByIndex() will always fail and return an error.

Signed-off-by: singuliere <singuliere@autistici.org>
2022-02-21 14:00:05 +01:00
GiteaBot
15a4b1d42b [skip ci] Updated translations via Crowdin 2022-02-21 00:15:46 +00:00
Wim
a387636b9a
Show fullname on issue edits and gpg/ssh signing info (#18827)
Show missing full names when configured to do so

Co-authored-by: zeripath <art27@cantab.net>
2022-02-20 19:50:11 +00:00
zeripath
e039b76a6f
Update go-org to 1.6.0 (#18824)
Fix #14074

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-20 13:01:35 +00:00
Lunny Xiao
00be0c1b21
Fix login with email for ldap users (#18800)
`authenticator.Authenticate` has assume the login name is not an email, but `username` maybe an email. So when we find the user via email address, we should use `user.LoginName` instead of `username` which is an email address.
2022-02-20 10:28:58 +00:00
GiteaBot
d5a4c5530a [skip ci] Updated licenses and gitignores 2022-02-20 00:16:03 +00:00
zeripath
83c9035971
Immediately Hammer if second kill is sent (#18823)
Currently Gitea will wait for HammerTime or nice shutdown if kill -1 or kill -2
is sent. We should just immediately hammer if there is a second kill.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-19 16:36:25 +00:00
zeripath
4b3ebda0e7
Fix panic in EscapeReader (#18820)
There is a potential panic due to a mistaken resetting of the length parameter when
multibyte characters go over a read boundary.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-19 15:25:31 +00:00
Lunny Xiao
931c2f40e7
Put buttons back in org dashboard (#18817)
Fix #18523
2022-02-19 12:08:12 +00:00
KN4CK3R
159c3f48af
Generate coverage with sqlite. (#18813) 2022-02-19 10:28:43 +08:00
Nicolas Ferrari
41aa49d910
Update on-cloud-provider.md (#18807) 2022-02-18 23:26:00 +08:00
Johan Van de Wauw
0cc2675c44
Fix ldap loginname (#18789)
* Use email_address table to check user's email when login with email adress

* Update services/auth/signin.go

* Fix test

* Fix test

* Fix logging in with ldap username != loginname

* Fix if user does not exist yet

* Make more clear this is loginName

* Fix formatting

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-02-18 17:33:00 +08:00
CommanderRoot
1ab88da0e4
Replace deprecated String.prototype.substr() with String.prototype.slice() (#18796)
String.prototype.substr() is deprecated (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr) so we replace it with the slice() method which works similarily but isn't deprecated.

Signed-off-by: Tobias Speicher <rootcommander@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-18 14:50:36 +08:00
Lunny Xiao
a7b9d44d88
Fix problem when self-assign notification (#18797) 2022-02-18 14:06:57 +08:00
silverwind
6767798eef
Move editorconfig-checker to lint-backend and remove JS wrapper (#18793)
* Move editorconfig-checker to lint-backend

It makes more sense there as templates are considered backend code.

* User golang version of the tool

* remove dependency
2022-02-18 12:33:58 +08:00
GiteaBot
833f291c40 [skip ci] Updated translations via Crowdin 2022-02-18 00:16:14 +00:00
Ghanem
185646723c
Fix redirect when using lowercase reponame (#18775)
* Previously,  `GET {username}/{reponame}/raw///file-path` (the middle two slashes are blank to get the default branch) when the repo name has uppercase letters, e.g., https://try.gitea.io/AbdulrhmnGhanem/CH330_Hardware, using a lowercase version of the name redirected to the correct URL
* In other words both
   * `GET https://try.gitea.io/AbdulrhmnGhanem/CH330_Hardware/raw///images/back.png`
   * `GET https://try.gitea.io/AbdulrhmnGhanem/ch330_hardware/raw///images/back.png`
were redirecting to ` GET https://try.gitea.io/AbdulrhmnGhanem/CH330_Hardware/raw/branch/master/images/back.png`
This isn't the case after  #17551. Specifically because of this [line](cbd5eecd14/modules/context/repo.go (L860)).
2022-02-18 00:11:27 +08:00
Lunny Xiao
397d2ac303
Move deletebeans into models/db (#18781) 2022-02-17 16:37:48 +08:00
silverwind
bd71245c53
Allow mermaid render error to wrap (#18790) 2022-02-17 15:42:43 +08:00
zeripath
3a29a23cdc
Attempt to fix the webauthn migration again - part 3 (#18770)
v208.go is seriously broken as it misses an ID() check. We need to no-op and remigrate all of the u2f keys.

See #18756

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-16 21:03:58 +00:00
Lunny Xiao
f48771ae78
Fix template bug of LFS lock (#18784) 2022-02-16 11:22:25 -05:00
silverwind
616146f904
Various Mermaid improvements (#18776)
* Various Mermaid improvments

- Render into iframe for improved security
- Use built-in dark theme instead of color inversion
- Remove flexbox attributes, resulting in more consistent size rendering
- Update API usage and update to latest version

* restart ci

* misc tweaks

* remove unneccesary declaration

* make it work without allow-same-origin, add loading=lazy

* remove loading attribute, does not seem to work

* rename variable

* skip roundtrip to DOM for rendering

* don't guess chart height

* update comment to make it clear it's intentional

* tweak

* replace deprecated 'scrolling' property

* remove unused css file

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-16 11:28:29 +08:00
GiteaBot
1eb6bb9028 [skip ci] Updated translations via Crowdin 2022-02-16 00:16:06 +00:00
René Schaar
609c91665e
Fix display time of milestones (#18753)
* Fix display time of milestones

* Move the SecToTime function

From the models/issue_stopwatch.go file to the modules/util package

* Rename the sec_to_time file

* Updated formatting

* Include copyright notice in sec_to_time.go

* Apply PR review suggestions

- Update copyright notice dates to 2022
- Change `1 day 3h 5min 7s` to `1d 3h 5m 7s`

* Rename hrs var and combine conditions

* Update unit tests to match new time pattern

Changed `1min` to `1m`

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-16 00:50:10 +08:00
GiteaBot
2be49dee71 [skip ci] Updated translations via Crowdin 2022-02-15 00:15:56 +00:00
zeripath
4482f62a26
Prevent dangling GetAttribute calls (#18754)
It appears possible that there could be a hang due to unread data from the
repo-attribute command pipes. This PR simply closes these during the defer.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-14 18:03:56 +01:00
Lunny Xiao
5348e198db
Add example to render html files (#18736)
* Add example to render html files

* Use class in example

Co-authored-by: zeripath <art27@cantab.net>
2022-02-14 21:56:17 +08:00
wxiaoguang
ecc3954db0
Fix a broken link in commits_list_small.tmpl (#18763) 2022-02-14 19:19:07 +08:00
Lunny Xiao
08fe6f8c7e
Fix broken cancel button link on patch page (#18718)
* Fix broken cacnel button link on patch page

* remove treepath="patch" elsewhere too

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

Co-authored-by: zeripath <art27@cantab.net>
2022-02-14 09:18:55 +00:00
Lunny Xiao
581a563cac
Ignore the migrate if u2f_registration is not exist (#18760) 2022-02-14 08:13:17 +00:00
GiteaBot
27af864cc2 [skip ci] Updated translations via Crowdin 2022-02-14 00:16:00 +00:00
zeripath
32599bf060
Increase the size of the webauthn_credential credential_id field (#18739)
Unfortunately credentialIDs in u2f are 255 bytes long which with base32 encoding
becomes 408 bytes. The default size of a xorm string field is only a VARCHAR(255)

This problem is not apparent on SQLite because strings get mapped to TEXT there.

Fix #18727

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-13 21:19:12 +00:00
Lunny Xiao
1b1658d887
Fix isempty detection of git repository (#18746)
* Fix isempty detection of git repository

* Fix IsEmpty check
2022-02-14 00:01:23 +08:00
GiteaBot
f1d8030310 [skip ci] Updated translations via Crowdin 2022-02-13 00:16:01 +00:00
flozzone
a39287cd4e
Send mail to issue/pr assignee/reviewer also when OnMention is set (#18707)
I want to address #17892, where emails notifications are not sent to assignees (issue and PR) and reviewers (PR) when they have the email setting Only email on mention enabled.

From the user experience perspective, when a user gets a issue/PR assigned or a PR review request, he/she would expect to be implicitly mentioned since the assignment or request is personal and targeting a single person only. Thus I see #17892 as a bug. Could we therefore mark this ticket as such?

The changed code just explicitly checks for the EmailNotificationsOnMention setting beside the existing EmailNotificationsEnabled check. Too rude?

@lunny mentioned a mock mail server for tests, is there something ready. How could I make use of it?

#12774 (comment)

Fix #17892
2022-02-12 07:17:34 +00:00
silverwind
2ddff74a54
Reduce CI go module downloads, add make targets (#18708)
The CI currently downloads all go modules in each pipeline step because
go modules reside outside the project directory. Fix this by introducing
a volume for the `/go` directory [1] so modules are only downloaded once per
pipeline using a new `deps-backend` make target.

For completeness, I also included new `deps` and `deps-frontend` targets
and the frontend one is also triggered explicitly on CI where needed.

[1] https://docs.drone.io/pipeline/kubernetes/examples/language/golang/#dependencies
2022-02-12 07:08:53 +00:00
zeripath
4e57bd1d30
Add number in queue status to monitor page (#18712)
Add number in queue status to the monitor page so that administrators can
assess how much work is left to be done in the queues.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-02-12 13:31:26 +08:00
Jimmy Praet
9444135ff5
Fix source code line highlighting (#18729)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-02-12 05:00:24 +00:00
Lunny Xiao
91ac65db5e
Fix forked repositories missed tags (#18719)
* Fix forked repositories missed tags

* Add missed close

* Use ctx

Co-authored-by: 6543 <6543@obermui.de>
2022-02-12 11:18:06 +08:00
GiteaBot
5aa4eeb180 [skip ci] Updated translations via Crowdin 2022-02-12 00:16:01 +00:00
Lunny Xiao
12d2d5aedc
Fix release typo (#18728) 2022-02-11 14:08:17 -05:00
Lunny Xiao
e0688995ef
Display template path of current page in dev mode (#18717)
* Display template path of current page in dev mode

* improve code

* Update templates/base/footer_content.tmpl

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
2022-02-12 01:08:22 +08:00
zeripath
c86ecaebae
Separate the details links of commit-statuses in headers (#18661) 2022-02-11 23:29:58 +08:00
Sven Seeberg
832ce406ae
Add LDAP group sync to Teams, fixes #1395 (#16299)
* Add setting for a JSON that maps LDAP groups to Org Teams.
* Add log when removing or adding team members.
* Sync is being run on login and periodically.
* Existing group filter settings are reused.
* Adding and removing team members.
* Sync not existing LDAP group.
* Login with broken group map JSON.
2022-02-11 22:24:58 +08:00
Martin Scholz
26718a785a
Change git.cmd to RunWithContext (#18693)
Change all `cmd...Pipeline` commands to `cmd.RunWithContext`.

#18553

Co-authored-by: Martin Scholz <martin.scholz@versasec.com>
2022-02-11 13:47:22 +01:00
zeripath
393ea86ae1
Always set PullRequestWorkInProgressPrefixes in PrepareViewPullInfo (#18713)
Move setting PullRequestWorkInProgressPrefixes to the start of PrepareViewPullInfo.

Fix #18706

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-11 08:02:53 +00:00
zeripath
b2b3225bd1
Prevent double encoding of branch names in delete branch (#18714)
* Prevent double encoding of branch names in delete branch

There is a double encoding issue in branch template whereby the branch name
ends up double encoded.

Fix #18709

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

* and tag name

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

* And fix #18704

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-11 13:02:04 +08:00
GiteaBot
f9e7edc5d9 [skip ci] Updated translations via Crowdin 2022-02-11 00:16:26 +00:00
zeripath
165ab17a03
Attempt to improve docs (yet again) (#18687)
* Attempt to improve docs (yet again)

Attempt to make the passthrough docs clearer.
Add some more faq entries

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

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Update docs/content/doc/installation/with-docker.en-us.md

* Update docs/content/doc/installation/with-docker.en-us.md

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-02-10 19:20:06 +00:00
zeripath
6d11a31aef
Make the proformas clearer that we need DEBUG logs (#18700)
It is ridiculous how few of our bug reporter are giving us DEBUG level logs.
This has to change and I think the proforma is not making it clear enough that
they have to give us these logs.

This PR changes the issue proformas to tell people to give us these logs.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-10 17:11:58 +00:00
Gusted
581d29ec1d
Update SSH Server crypto settings (#18697)
- Use a better and more curated list of Ciphers and KeyExchanges, these roughly follows OpenSSH's default.
- Remove some cryptography values which were deprecated.
2022-02-10 17:04:16 +01:00
Lunny Xiao
0c70b4c211
Fix bug for version update hint (#18701)
Co-authored-by: silverwind <me@silverwind.io>
2022-02-10 15:37:10 +01:00
zeripath
7489d96db6
Fix issue with docker-rootless shimming script (#18690) 2022-02-10 01:15:06 -05:00
singuliere
bc8e19ece1
tests: remove redundant comparison in repo dump/restore (#18660)
It is a leftover forgotten in https://github.com/go-gitea/gitea/pull/18621

Signed-off-by: singuliere <singuliere@autistici.org>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-10 10:41:05 +08:00
GiteaBot
e034d3a710 [skip ci] Updated translations via Crowdin 2022-02-10 00:16:23 +00:00
Paweł Bogusławski
c917f2df9b
Disable unnecessary OpenID/OAuth2 elements (#18491)
This mod fixes disabling unnecessary OpenID elements.

Related: https://github.com/go-gitea/gitea/pull/13129
Author-Change-Id: IB#1115256
2022-02-09 20:33:36 +00:00
zeripath
eb748f5f3c
Add apply-patch, basic revert and cherry-pick functionality (#17902)
This code adds a simple endpoint to apply patches to repositories and
branches on gitea. This is then used along with the conflicting checking
code in #18004 to provide a basic implementation of cherry-pick revert.

Now because the buttons necessary for cherry-pick and revert have 
required us to create a dropdown next to the Browse Source button
I've also implemented Create Branch and Create Tag operations.

Fix #3880 
Fix #17986 

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-09 20:28:55 +00:00
Bruno Raoult
439ad34c71
C preprocessor colors improvement (#18671)
* C preprocessor colors improvement

Fixes #18670

* Update web_src/less/chroma/light.less

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

* typo

missing semi

* add color for #include filenames

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-09 20:02:06 +00:00
Hugo Hoitink
5579345549
Update object repo with the migrated repository (#18684)
When migrating a repository (from GitHub) using the API (**POST** `repos/migrate`), the Code Indexer is not updated. Searching in the user interface will not return any results.

When migrating the same repository using **+/New Migration** in the web interface, the search index is updated and searching works as expected.

Caused by the fact that object `repo` is never updated with the migrated repo so `setting.Indexer.RepoIndexerEnabled && !repo.IsEmpty` in `modules/notification/indexer/indexer.go:NotifyMigrateRepository` always evaluates to `false`.

Tested with gitea:1.16.1, MariaDB:10, Breve in `Run Mode: Dev`.
2022-02-09 19:20:44 +00:00
zeripath
2f76608221
Prevent security failure due to bad APP_ID (#18678)
WebAuthn may cause a security exception if the provided APP_ID is not allowed for the
current origin. Therefore we should reattempt authentication without the appid
extension.

Also we should allow [u2f] as-well as [U2F] sections.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-09 15:37:58 +08:00
GiteaBot
4160aff86e [skip ci] Updated translations via Crowdin 2022-02-09 00:16:04 +00:00
Gusted
ae0d8d94df
Let MinUnitAccessMode return correct perm (#18675)
- Don't let `TypeExternalTracker` or `TypeExternalWiki` influence the
minimal permission, as they won't be higher than read. So even if all
the other ones are write, these 2 will ensure that's not higher than
read.
- Partially resolves #18572 (Point 1,2,5?)

Co-authored-by: zeripath <art27@cantab.net>
2022-02-08 21:16:17 +00:00
zeripath
f8b21ac04a
Simplify Boost/Pause logic (#18673)
* Simplify Boost/Pause logic

#18658 has added a check to see if we need to boost because there is still work to do
however the check is slightly complex and not ideal. There's no point boosting if
the queue is paused or can't scale. Therefore merge the two selects into one and add
a check to p.paused.

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

* And on resume add a zeroboost if necessary

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

* simplify

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2022-02-08 13:53:34 -05:00
Lunny Xiao
c14ca34d57
update the comparison documents (#18669)
* update the comparison documents

* Remove U2f
2022-02-08 11:00:13 -05:00
zeripath
df44017328
Restart zero worker if there is still work to do (#18658)
* Restart zero worker if there is still work to do

It is possible for the zero worker to timeout before all the work is finished.
This may mean that work may take a long time to complete because a worker will only
be induced on repushing.

Also ensure that requested count is reset after pulls and push mirror sync requests and add some more trace logging to the queue push.

Fix #18607

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-08 14:02:32 +00:00
Viktor Suprun
4d939845d2
Added auto-save whitespace behavior if it changed manually (#15566) 2022-02-08 14:15:04 +08:00
Cristian Le
60f203385e
Support custom ACME provider (#18340)
* Added ACMECAURL option to support custom ACME provider. Closes #18306
* Refactor setting.go https settings, renamed options and variables, and documented app.example.ini
* Refactored runLetsEncrypt to runACME
* Improved documentation
2022-02-08 13:45:35 +08:00
wxiaoguang
a60e8be8d1
Refactor i18n, use Locale to provide i18n/translation related functions (#18648)
* remove unnecessary web context data fields, and unify the i18n/translation related functions to `Locale`
* in development, show an error if a translation key is missing
* remove the unnecessary loops `for _, lang := range translation.AllLangs()` for every request, which improves the performance slightly
* use `ctx.Locale.Language()` instead of `ctx.Data["Lang"].(string)`
* add more comments about how the Locale/LangType fields are used
2022-02-08 11:02:30 +08:00
Gusted
7b25a010c8
Only request write when necessary (#18657)
* Only request write when necessary

- Only request write for `INTERNAL_TOKEN_URI` when no token was found.
- Resolves #18655

* Fix perm

* Update setting.go

* Update setting.go

* Update setting.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2022-02-08 09:34:37 +08:00
GiteaBot
8422b1c55c [skip ci] Updated translations via Crowdin 2022-02-08 00:15:59 +00:00
Clar Fon
99d14f6051
Add separate SSH_USER config option (#17584)
Co-authored-by: zeripath <art27@cantab.net>
2022-02-07 16:56:45 -05:00
Clar Fon
9911b66aea
Be more lenient with label colors (#17752)
Accept 12-bit color specifications.
2022-02-07 21:21:02 +00:00
singuliere
3a91f845e8
remove redundant call to UpdateRepoStats during migration (#18591)
There is no need to call UpdateRepoStats in the InsertIssues and
InsertPullRequests function. They are only called during migration by
the CreateIssues and CreateReviews methods of the gitea uploader.

The UpdateRepoStats function will be called by the Finish method of
the gitea uploader after all reviews and issues are inserted. Calling
it before is therefore redundant and the associated SQL requests are
not cheap.

The statistics tests done after inserting an issue or a pull request
are also removed. They predate the implementation of UpdateRepoStats,
back when the calculation of the statistics was an integral part of
the migration function. The UpdateRepoStats is now tested
independantly and these tests are no longer necessary.

Signed-off-by: singuliere <singuliere@autistici.org>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-02-07 10:43:08 -05:00
singuliere
5faf055097
more repo dump/restore tests, including pull requests (#18621)
The tests were refactored so that all YAML files content are checked,
unless an exception is set (for instance for the Updated field which
is automatically updated by the database and cannot be expected to be
identical over a dump/restore/dump round.

This approach helps catch more errors where fields are added in the
migration files because they do not need to be added to the tests to
be verified.

It also helps as a reminder of what is left to be implemented, such as
the the Assignees field in issues.

A helper is added to keep the tests DRY and facilitate their
maintenance.

Signed-off-by: Loïc Dachary <loic@dachary.org>

Co-authored-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-07 15:11:55 +01:00
wxiaoguang
47c1b623dd
No longer show the db-downgrade SQL in production (#18653)
* make messages more friendly
2022-02-07 12:04:12 +02:00
wxiaoguang
c2a3e38194
Fix the missing i18n key for update checker (#18646) 2022-02-07 15:43:53 +08:00
Gusted
f393bc82cb
Update gitea-vet (#18640)
* Update gitea-vet

- Update gitea-vet to include latest 2 changes
7c98703580...master

* Tidy up go.sum

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2022-02-06 21:45:00 +00:00
Gusted
9712f7d622
Future proof for 1.18 (#18644)
- Update json-iterator/go to handle 1.18's new memory model with slices.
- Don't panic while running gitea with go 1.18
2022-02-06 20:38:14 +00:00
Norwin
6ada05940e
Add contrib/upgrade.sh (#18286)
Adds an upgrade script that automates upgrading installations on Linux from binary releases, so people don't need to reinvent the wheel. Hopefully this leads to less questions about how to upgrade, and consequently less Gitea instances running unmaintained versions in the wild.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2022-02-06 21:07:52 +01:00
zeripath
a6e657e999
If rendering has failed due to a net.OpError stop rendering (#18642)
When a net.OpError occurs during rendering the underlying connection is essentially
dead and therefore attempting to render further data will only cause further errors.

Therefore in serverErrorInternal detect if the passed in error is an OpError and
if so do not attempt any further rendering.

Fix #18629

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-06 20:28:25 +01:00
6543
3043eb36bf
Delete old git.NewCommand() and use it as git.NewCommandContext() (#18552) 2022-02-06 20:01:47 +01:00
silverwind
8ae5e6d7fd
Update JS dependencies (#18636) 2022-02-06 12:53:29 -05:00
a1012112796
da41820a60
fix commits_list_small.tmpl (#18641)
Signed-off-by: a1012112796 <1012112796@qq.com>
2022-02-06 16:58:32 +00:00
silverwind
37ead26e36
Fix make fmt and make fmt-check (#18633)
* Run 'make fmt'

'make fmt' currently produces this change, I'm not sure how CI did not
fail on it, I made sure I have `mvdan.cc/gofumpt@latest`.

* Fix 'make fmt-check'

`make fmt-check` did not run all commands that `make fmt` did, resulting
in missed diffs. Fix that by just depending on the `fmt` target.

Includes: https://github.com/go-gitea/gitea/pull/18633

* Make gitea-fmt work with -l and -d and integrate gofumpt

This implements -l, -w and -d with gitea-fmt and merges gofumpt.

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

* as per silverwind

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

* Apply suggestions from code review

* use -l instead of -d for fmt-check

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-02-06 16:44:30 +01:00
Lunny Xiao
7b6c1f809f
Frontport of changelog for v1.16.1 (#18615)
* Add changelog for v1.16.1

* Update 1.16.1
2022-02-06 21:38:20 +08:00
Gusted
7a42e35741
Pass correct context (#18638)
- Pass the correct context into `db.GetEngine()`.
- Introduced in: https://github.com/go-gitea/gitea/pull/18604
2022-02-06 12:05:07 +00:00
singuliere
ce8eb20a00
comments on migrated issues/prs must link to the comment ID (#18630)
Instead of the issue ID which is not a valid anchor.

Signed-off-by: singuliere <singuliere@autistici.org>
2022-02-06 10:59:12 +00:00
singuliere
8bd89ca294
preserve users if restoring a repository on the same Gitea instance (#18604)
When calling DumpRepository and RestoreRepository on the same Gitea
instance, the users are preserved: all labels, issues etc. belong to
the external user who is, in this particular case, the local user.

Dead code verifying g.gitServiceType.Name() == "" (i.e. plain git) is
removed. The function is never called because the plain git downloader
does not migrate anything that is associated to a user, by definition.

Errors returned by GetUserIDByExternalUserID are no longer ignored.

The userMap is used when the external user is not kown, which is the
most common case. It was only used when the external user exists
which happens less often and, as a result, every occurence of an
unknown external user required a SQL query.

Signed-off-by: Loïc Dachary <loic@dachary.org>

Co-authored-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-06 17:05:29 +08:00
zeripath
9419dd2b62
Stop logging an error when notes are not found (#18626)
This is an unnecessary logging event.

Fix #18616

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-06 15:11:35 +08:00
GiteaBot
3b33507c73 [skip ci] Updated licenses and gitignores 2022-02-06 00:16:02 +00:00
zeripath
7ba1b7112f
Only attempt to flush queue if the underlying worker pool is not finished (#18593)
* Only attempt to flush queue if the underlying worker pool is not finished

There is a possible race whereby a worker pool could be cancelled but yet the
underlying queue is not empty. This will lead to flush-all cycling because it
cannot empty the pool.

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

* Apply suggestions from code review

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-02-05 20:51:25 +00:00
Kyle D
a51d2114c7
quote MAKE to prevent path expansion with space error (#18622)
Pretty minor change to prevent error when `$(MAKE)` path is expanded with a space in the path. 

```bash
$ TAGS="bindata sqlite sqlite_unlock_notify" make build
/usr/bin/sh: -c: line 0: syntax error near unexpected token `('
/usr/bin/sh: -c: line 0: `C:/Program Files (x86)/GnuWin32/bin/make -v | head -n 1'
```

I believe Program Files (x86) is the default path for GNU make on windows
2022-02-05 18:31:57 +00:00
zeripath
933e819165
Ensure that blob-excerpt links work for wiki (#18587)
It appears that the blob-excerpt links do not work on the wiki - likely since their
introduction.

This PR adds support for the wiki on these links.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-05 18:26:12 +00:00
Gusted
aa23f477b7
Use CryptoRandomBytes instead of CryptoRandomString (#18439)
- Switch to use `CryptoRandomBytes` instead of `CryptoRandomString`, OAuth's secrets are copied pasted and don't need to avoid dubious characters etc.
- `CryptoRandomBytes` gives ![2^256 = 1.15 * 10^77](https://render.githubusercontent.com/render/math?math=2^256%20=%201.15%20\cdot%2010^77) `CryptoRandomString` gives ![62^44 = 7.33 * 10^78](https://render.githubusercontent.com/render/math?math=62^44%20=%207.33%20\cdot%2010^78) possible states.
- Add a prefix, such that code scanners can easily grep these in source code.
- 32 Bytes + prefix
2022-02-04 18:03:15 +01:00
zeripath
88939a5663
Remove the spurious space in the .ui.right additional selector (#18605)
Somehow a spurious space sneaked in to #18538
this PR simply removes it.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-04 15:53:43 +00:00
zeripath
3c7374106e
Ensure commit-statuses box is sized correctly in headers (#18538)
* Ensure commit-statuses box is sized correctly in headers

When viewing commits as commits the commit-status box will be fixed at 30px in height
due to being forced to be this size by a fomantic selector. This PR simply adds a
few more selectors to force this to have height auto.

Fix #18498

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

* Update web_src/less/_repository.less

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-02-04 23:21:51 +08:00
GiteaBot
319d191afc [skip ci] Updated translations via Crowdin 2022-02-04 00:16:04 +00:00
zeripath
1ab44cb01d
Prevent merge messages from being sorted to the top of email chains (#18566)
* Prevent merge messages from being sorted to the top of email chains

Gitea will currrently resend the same message-id for the closed/merged/reopened
messages for issues. This will cause the merged message to leap to the top of an
email chain and become out of sync.

This PR adds specific suffices for these actions.

Fix #18560

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

* add test

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-03 18:01:16 -05:00
zeripath
9f9ca0aae4
Fix pushing to 1-x-dev docker tag (#18578)
* Fix pushing to 1-x-dev docker tag

It appears that #18551 and #18573 have a mistake in that raymond does not have
an {{else}} on {{#equal}}. This PR notes that Sprig has a hasPrefix function
and so we use this with another if.

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

* Fix pushing to 1-x-dev docker tag (part 2)

Although we now have the manifest working, we need to create the images.

Here we adjust the .drone.yml to force building of the images

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

* Fix pushing to 1-x-dev docker tag

OK now we have the images building we should make sure that the main ones stays
dev and the release/v* ones become *-dev-*

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

* Apply suggestions from code review
2022-02-03 22:44:51 +01:00
Gusted
cafd19c1a3
Replace sync.Map with normal maps (#18584)
* Replace `sync.Map` with normal maps

- These maps aren't being used in any kind of concurrent read/write and
thus don't need `sync.Map` and can instead use normal maps.
- Special thanks to dachary.
- Added in: https://github.com/go-gitea/gitea/pull/6290

* Remove unannounced feature
2022-02-03 21:18:18 +02:00
Sambhav Saggi
e2bbbc4876
Fix oauth docs usage for 2fa (#18581) 2022-02-03 17:00:34 +00:00
silverwind
90b4d385dd
Update .gitattributes for .tmpl files (#18576)
There are a few .tmpl files outside the templates directory. Match these
as well by using `*.tmpl` glob in `.gitattributes`. Also, sort the file
alphabetically.
2022-02-03 15:30:26 +00:00
zeripath
1c5afd17ee
Prevent panic on prohibited user login with oauth2 (#18562)
There was an unfortunate regression in #17962 where following detection of the
UserProhibitLogin error the err is cast to a pointer by mistake.

This causes a panic due to an interface error.

Fix #18561

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-03 10:44:18 +00:00
zeripath
104c547d61
Fix manifest.tmpl (#18573)
A spurious {{/if}} appeared on the manifest.tmpl - this PR simply
removes this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-03 09:51:01 +00:00
zeripath
bc77b28d9d
Make docker gitea/gitea:v1.16-dev etc refer to the latest build on that branch (#18551)
* Make docker gitea/gitea:v1.16-dev etc refer to the latest build on that branch

One of the problems with our current docker tagging is that although we
have strict version tags, latest and dev we do not have a way for docker
users to track the current release branch. This PR simply suggests that
we use the 1.x-dev tag for these and we build and push these. This will
give users who want or need unreleased bug fixes the option of tracking
the pre-release version instead of simply jumping to dev.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-03 09:47:27 +01:00
fnetX (aka fralix)
c8c591073b
Add dropdown icon to template loading dropdown (#18564)
Fixes #15679 and the dupe of it: Fixes #16364.

Also removes a comment that links to a gogs forum thread.
2022-02-03 08:13:22 +00:00
zeripath
76e3111596
Collaborator trust model should trust collaborators (#18539)
* Collaborator trust model should trust collaborators

There was an unintended regression in #17917 which leads to only
repository admin commits being trusted. This PR restores the old logic.

Fix #18501

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-02 11:10:06 +01:00
zeripath
92e81e97e8
Detect conflicts with 3way merge (#18536)
* Detect conflicts with 3way merge

Unforunately git apply --3way reports conflicts differently than standard patches
resulting in conflicts being missed.

Adjust the conflict detection code to account for this different error reporting.

Fix #18514

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

* and three-way failed

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-02 12:46:10 +08:00
GiteaBot
5469e61a8e [skip ci] Updated translations via Crowdin 2022-02-02 00:16:04 +00:00
zeripath
f192b905b8
Update 1.16.0 changelog to set #17846 as breaking (#18533)
Unfortunately #17846 was determined to be breaking due to affecting ssh passthrough
however, this discovery happened after the changelog was created. Update the
Changelog to mark this as breaking.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-02-01 17:09:32 -05:00
Michael Kriese
de05d71b40
In docker rootless use $GITEA_APP_INI if provided (#18524) 2022-02-01 20:18:57 +00:00
techknowlogick
24d39ee6b7
revert to node14 for snapcraft 2022-02-01 15:10:55 -05:00
Gusted
d3b31cc1ee
Add GetUserTeams (#18499)
* COrrect use `UserID` in `SearchTeams`

- Use `UserID` in the `SearchTeams` function, currently it was useless
to pass such information. Now it does a INNER statement to `team_user`
which obtains UserID -> TeamID data.
- Make OrgID optional.
- Resolves #18484

* Seperate searching specific user

* Add condition back

* Use correct struct type

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-02-01 14:09:24 -05:00
confusedsushi
f6f4e1ddb9
Fix review excerpt (#18502)
Currently the "File Changed" tab of a PR is somehow broken. This is also true for the current release 1.16.0.

When you are on the "File Changed" tab, and want to look at code excerpt before or after the code changes, the layout breaks. You can test this on try.gitea.io here: https://try.gitea.io/testnotexisting/magic_enum/pulls/2/files

The problem occurs for the unified view and for the split view.

Kind of the same problem was there for commenting a line of code, this was fixed in #18321 and #18403.

For consistency, I changed the solution of #18321, I removed the ``colspan`` and instead added a ``<td>``. The goal was to have code similarly with the split view.

Also the separator line in the split view was in the wrong column, this was fixed too.* more consistent unified review comment

Fix #18516

Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-02-01 19:08:33 +00:00
silverwind
99e1e30b0b
Update JS dependencies, fix lint (#18389)
- Update all JS dependencies, including a security issue in mermaid
- Fix new linter errors related to value-keyword-case
- Tested Mermaid and Swagger

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-02-01 13:21:08 -05:00
singuliere
367894adc8
add test coverage for original author conversion during migrations (#18506)
* add test coverage for original author conversion during migrations

And create a function to factorize a code snippet that is repeated
five times and would otherwise be more difficult to test and maintain
consistently.

Signed-off-by: Loïc Dachary <loic@dachary.org>

* fix variable scope and int64 formatting

* add missing calls to remapExternalUser and fix misplaced %d

Co-authored-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-02-01 13:20:28 -05:00
6543
6f6b8491da
add gitea-fmt back (#18526) 2022-02-01 12:43:09 -05:00
Gusted
bb5f859ec0
Fix non-ASCII search on database (#18437)
Use `ToASCIIUpper` for SQLite database on issues search, this because `UPPER(x)` on SQLite only transforms ASCII letters. Resolves #18429
2022-02-01 20:59:25 +08:00
Gusted
7f2530e004
Use "read" value for General Access (#18496)
- Currently the `.Team.AccessMode` is being used when editing a team, if
you want to admin -> General Access, the value of General Access is
"admin" which is incorrect.
- Resolves #18483 (First bug mentioned)

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-02-01 16:41:43 +08:00
Viktor Kuzmin
80048c091a
Fix for AvatarURL database type (#18487) 2022-02-01 00:40:23 -05:00
Gusted
f87d5ea9ee
Remove go 1.15 support (#18511)
- Remove support for go 1.15(go.mod already requires go 1.16).

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2022-02-01 10:46:45 +08:00
GiteaBot
1de5028394 [skip ci] Updated translations via Crowdin 2022-02-01 00:16:43 +00:00
Gusted
22d266350d
Use ImagedProvider for gplus oauth2 provider (#18504)
Use `ImagedProvider` for gplus' oauthv2 provider, as the image isn't "gplus.png" but "google.png".

Resolves #18494
2022-02-01 01:02:56 +01:00
techknowlogick
70e614b9da
build with node16 in snap (#18508) 2022-01-31 17:52:12 -05:00
techknowlogick
115e4772cc
point to s3 endpoint directly (#18497)
Co-authored-by: 6543 <6543@obermui.de>
2022-01-31 17:39:39 -05:00
zeripath
7d452558f0
Fix OAuth Source Edit Page (#18495)
* Fix OAuth Source Edit Page to ensure restricted and group settings are set
* Also tolerate []interface in the groups

Fix #18432

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-31 20:41:11 +00:00
GiteaBot
db7c3ecc1f [skip ci] Updated translations via Crowdin 2022-01-31 00:05:29 +00:00
Gusted
72256c16a8
Prevent NPE on partial match of compare URL and allow short SHA1 compare URLs (#18472)
* Don't panic & allow shorter sha1

- Don't panic when the full regex isn't matched and allow the usage of a
shorter sha1 being used.
- Resolves #18471

* Update modules/markup/html.go

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-01-31 01:48:47 +02:00
techknowlogick
b2250d2fb3
upload to github & s3 at same time (#18475) 2022-01-30 17:40:44 -05:00
zeripath
342c6917e2
Add a few more comments to the CONTRIBUTING.md document (#18469)
* Explain how to title your Backport PR
* Advise that the first comment in a PR should explain the PR
* Include information about BREAKING changes
* Include information about backports/frontports
* Add reference command for creating backports
* Add reference commandline for creating large characters
* Add information about updating docs/config.yaml
* Update year in the copyright

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-30 19:56:48 +01:00
zeripath
f9b27d2d46
Frontport changelog 1.16.0 (#18468) (#18470)
Frontport #18468

Frontport changelog for 1.16, frontport 1.15.11 changelog and update config.yaml

 ## [1.16.0](https://github.com/go-gitea/gitea/releases/tag/v1.16.0) - 2022-01-30

* BREAKING
  * Remove golang vendored directory (#18277)
  * Paginate releases page & set default page size to 10 (#16857)
  * Only allow webhook to send requests to allowed hosts (#17482)
* SECURITY
  * Disable content sniffing on `PlainTextBytes` (#18359) (#18365)
  * Only view milestones from current repo (#18414) (#18417)
  * Sanitize user-input on file name (#17666)
  * Use `hostmatcher` to replace `matchlist` to improve blocking of bad hosts in Webhooks (#17605)
* FEATURES
  * Add/update SMTP auth providers via cli (#18197)
  * Support webauthn (#17957)
  * Team permission allow different unit has different permission (#17811)
  * Implement Well-Known URL for password change (#17777)
  * Add support for ssh commit signing (#17743)
  * Allow Loading of Diffs that are too large (#17739)
  * Add copy button to markdown code blocks (#17638)
  * Add .gitattribute assisted language detection to blame, diff and render (#17590)
  * Add `PULL_LIMIT` and `PUSH_LIMIT` to cron.update_mirror task (#17568)
  * Add Reindex buttons to repository settings page (#17494)
  * Make SSL cipher suite configurable (#17440)
  * Add groups scope/claim to OIDC/OAuth2 Provider (#17367)
  * Add simple update checker to Gitea (#17212)
  * Migrated Repository will show modifications when possible (#17191)
  * Create pub/priv keypair for federation (#17071)
  * Make LDAP be able to skip local 2FA (#16954)
  * Add nodeinfo endpoint for federation purposes (#16953)
  * Save and view issue/comment content history (#16909)
  * Use git attributes to determine generated and vendored status for language stats and diffs (#16773)
  * Add migrate from Codebase (#16768)
  * Add migration from GitBucket (#16767)
  * Add OAuth2 introspection endpoint (#16752)
  * Add proxy settings and support for migration and webhook (#16704)
  * Add microsoft oauth2 providers (#16544)
  * Send registration email on user autoregistration (#16523)
  * Defer Last Commit Info (#16467)
  * Support unprotected file patterns (#16395)
  * Add migrate from OneDev (#16356)
  * Add option to update pull request by `rebase` (#16125)
  * Add RSS/Atom feed support for user actions (#16002)
  * Add support for corporate WeChat webhooks (#15910)
  * Add a simple way to rename branch like gh (#15870)
  * Add bundle download for repository (#14538)
  * Add agit flow support in gitea (#14295)
* API
  * Add MirrorUpdated field to Repository API type (#18267)
  * Adjust Fork API to allow setting a custom repository name (#18066)
  * Add API to manage repo tranfers (#17963)
  * Add API to get file commit history (#17652)
  * Add API to get issue/pull comments and events (timeline) (#17403)
  * Add API to get/edit wiki (#17278)
  * Add API for get user org permissions (#17232)
  * Add HTML urls to notification API (#17178)
  * Add API to get commit diff/patch (#17095)
  * Respond with updated notifications in API (#17064)
  * Add API to fetch git notes (#16649)
  * Generalize list header for API (#16551)
  * Add API Token Cache (#16547)
  * Allow Token API calls be authorized using the reverse-proxy header (#15119)
* ENHANCEMENTS
  * Make the height of the editor in Review Box smaller (4 lines as GitHub) (#18319)
  * Return nicer error if trying to pull from non-existent user (#18288)
  * Show pull link for agit pull request also (#18235)
  * Enable partial clone by default (#18195)
  * Added replay of webhooks (#18191)
  * Show OAuth callback error message (#18185)
  * Increase Salt randomness (#18179)
  * Add MP4 as default allowed attachment type (#18170)
  * Include folders into size cost (#18158)
  * Remove `/email2user` endpoint (#18127)
  * Handle invalid issues (#18111)
  * Load EasyMDE/CodeMirror dynamically, remove RequireEasyMDE (#18069)
  * Support open compare page directly (#17975)
  * Prefer "Hiragino Kaku Gothic ProN" in system-ui-ja (#17954)
  * Clean legacy SimpleMDE code (#17926)
  * Refactor install page (db type) (#17919)
  * Improve interface when comparing a branch which has created a pull request (#17911)
  * Allow default branch to be inferred on compare page (#17908)
  * Display issue/comment role even if repo archived (#17907)
  * Always set a message-id on mails (#17900)
  * Change `<a>` elements to underline on hover (#17898)
  * Render issue references in file table (#17897)
  * Handle relative unix socket paths (#17836)
  * Move accessmode into models/perm (#17828)
  * Fix some org style problems (#17807)
  * Add List-Unsubscribe header (#17804)
  * Create menus for organization pages (#17802)
  * Switch archive URL code back to href attributes (#17796)
  * Refactor "refs/*" string usage by using constants (#17784)
  * Allow forks to org if you can create repos (#17783)
  * Improve install code to avoid low-level mistakes. (#17779)
  * Improve ellipsis buttons (#17773)
  * Add restrict and no-user-rc to authorized_keys (#17772)
  * Add copy Commit ID button in commits list (#17759)
  * Make `bind` error more readable (#17750)
  * Fix navbar on project view (#17749)
  * More pleasantly handle broken or missing git repositories (#17747)
  * Use `*PushUpdateOptions` as receiver (#17724)
  * Remove unused `user` paramater (#17723)
  * Better builtin avatar generator (#17707)
  * Cleanup and use global style on popups (#17674)
  * Move user/org deletion to services (#17673)
  * Added comment for changing issue ref (#17672)
  * Allow admins to change user avatars (#17661)
  * Only set `data-path` once for each file in diff pages (#17657)
  * Add icon to vscode clone link (#17641)
  * Add download button for file viewer (#17640)
  * Add pagination to fork list (#17639)
  * Use a standalone struct name for Organization (#17632)
  * Minor readability patch. (#17627)
  * Add context support for GetUserByID (#17602)
  * Move merge-section to `> .content` (#17582)
  * Remove NewSession method from db.Engine interface (#17577)
  * Move unit into models/unit/ (#17576)
  * Restrict GetDeletedBranchByID to the repositories deleted branches (#17570)
  * Refactor commentTags functionality (#17558)
  * Make Repo Code Indexer an Unique Queue (#17515)
  * Simplify Gothic to use our session store instead of creating a different store (#17507)
  * Add settings to allow different SMTP envelope from address (#17479)
  * Properly determine CSV delimiter (#17459)
  * Hide label comments if labels were added and removed immediately (#17455)
  * Tune UI alignment for nav bar notification icon, avatar image, issue label (#17438)
  * Add appearance section in settings (#17433)
  * Move key forms before list and add cancel button (#17432)
  * When copying executables to the docker chmod them (#17423)
  * Remove deprecated `extendDefaultPlugins` method of svgo (#17399)
  * Fix the click behavior for <tr> and <td> with [data-href] (#17388)
  * Refactor update checker to use AppState (#17387)
  * Improve async/await usage, and sort init calls in `index.js` (#17386)
  * Use a variable but a function for IsProd because of a slight performance increment (#17368)
  * Frontend refactor, PascalCase to camelCase, remove unused code (#17365)
  * Hide command line merge instructions when user can't push (#17339)
  * Move session to models/login (#17338)
  * Sync gitea app path for git hooks and authorized keys when starting (#17335)
  * Make the Mirror Queue a queue (#17326)
  * Add "Copy branch name" button to pull request page (#17323)
  * Fix repository summary on mobile (#17322)
  * Split `index.js` to separate files (#17315)
  * Show direct match on top for user search (#17303)
  * Frontend refactor: move Vue related code from `index.js` to `components` dir, and remove unused codes. (#17301)
  * Upgrade chi to v5 (#17298)
  * Disable form autofill (#17291)
  * Improve behavior of "Fork" button (#17288)
  * Open markdown image links in new window (#17287)
  * Add hints for special Wiki pages (#17283)
  * Move add deploy key form before the list and add a cancel button (#17228)
  * Allow adding multiple issues to a project  (#17226)
  * Add metrics to get issues by repository (#17225)
  * Add specific event type to header (#17222)
  * Redirect on project after issue created (#17211)
  * Reference in new issue modal: dont pre-populate issue title (#17208)
  * Always set a unique Message-ID header (#17206)
  * Add projects and project boards in exposed metrics (#17202)
  * Add metrics to get issues by label (#17201)
  * Add protection to disable Gitea when run as root (#17168)
  * Don't return binary file changes in raw PR diffs by default (#17158)
  * Support sorting for project board issuses (#17152)
  * Force color-adjust for markdown checkboxes (#17146)
  * Add option to copy line permalink (#17145)
  * Move twofactor to models/login (#17143)
  * Multiple tokens support for migrating from github (#17134)
  * Unify issue and PR subtitles (#17133)
  * Make Requests Processes and create process hierarchy. Associate OpenRepository with context. (#17125)
  * Fix problem when database id is not increment as expected (#17124)
  * Avatar refactor, move avatar code from `models` to `models.avatars`, remove duplicated code (#17123)
  * Re-allow clipboard copy on non-https sites (#17118)
  * DBContext is just a Context (#17100)
  * Move login related structs and functions to models/login (#17093)
  * Add SkipLocal2FA option to pam and smtp sources (#17078)
  * Move db related basic functions to models/db (#17075)
  * Fixes username tagging in "Reference in new issue" (#17074)
  * Use light/dark theme based on system preference (#17051)
  * Always emit the configuration path (#17036)
  * Add `AbsoluteListOptions` (#17028)
  * Use common sessioner for API and Web (#17027)
  * Fix overflow label in small view (#17020)
  * Report the associated filter if there is an error in LDAP (#17014)
  * Add "new issue" btn on project (#17001)
  * Add doctor dbconsistency check for release and attachment (#16978)
  * Disable Fomantic's CSS tooltips (#16974)
  * Add Cache-Control to avatar redirects (#16973)
  * Make mirror feature more configurable (#16957)
  * Add skip and limit to git.GetTags (#16897)
  * Remove ParseQueueConnStr as it is unused (#16878)
  * Remove unused Fomantic sidebar module (#16853)
  * Allow LDAP Sources to provide Avatars (#16851)
  * Remove Dashboard/Home button from the navbar (#16844)
  * Use conditions but not repo ids as query condition (#16839)
  * Add user settings key/value DB table (#16834)
  * Add buttons to allow loading of incomplete diffs (#16829)
  * Add information for migrate failure (#16803)
  * Add EdDSA JWT signing algorithm (#16786)
  * Add user status filter to admin user management page (#16770)
  * Add Option to synchronize Admin & Restricted states from OIDC/OAuth2 along with Setting Scopes (#16766)
  * Do not use thin scrollbars on Firefox (#16738)
  * Download LFS in git and web workflow from minio/s3 directly (SERVE_DIRECT) (#16731)
  * Compute proper foreground color for labels (#16729)
  * Add edit button to wiki sidebar and footer (#16719)
  * Fix migration svg color (#16715)
  * Add link to vscode to repo header (#16664)
  * Add filter by owner and team to issue/pulls search endpoint (#16662)
  * Kanban colored boards (#16647)
  * Allow setting X-FRAME-OPTIONS (#16643)
  * Separate open and closed issue in metrics (#16637)
  * Support direct comparison (git diff a..b) as well merge comparison (a…b) (#16635)
  * Add setting to OAuth handlers to skip local 2FA authentication (#16594)
  * Make PR merge options more intuitive (#16582)
  * Show correct text when comparing commits on empty pull request (#16569)
  * Pre-fill suggested New File 'name' and 'content' with Query Params (#16556)
  * Add an abstract json layout to make it's easier to change json library (#16528)
  * Make Mermaid.js limit configurable (#16519)
  * Improve 2FA autofill (#16473)
  * Add modals to Organization and Team remove/leave (#16471)
  * Show tag name on dashboard items list (#16466)
  * Change default cron schedules from @every 24h to @midnight (#16431)
  * Prevent double sanitize (#16386)
  * Replace `list.List` with slices (#16311)
  * Add configuration option to restrict users by default (#16256)
  * Move login out of models (#16199)
  * Support pagination of organizations on user settings pages (#16083)
  * Switch migration icon to svg (#15954)
  * Add left padding for chunk header of split diff view (#13397)
  * Allow U2F 2FA without TOTP (#11573)
* BUGFIXES
  * GitLab reviews may not have the updated_at field set (#18450) (#18461)
  * Fix detection of no commits when the default branch is not master (#18422) (#18423)
  * Fix broken oauth2 authentication source edit page (#18412) (#18419)
  * Place inline diff comment dialogs on split diff in 4th and 8th columns (#18403) (#18404)
  * Fix restore without topic failure (#18387) (#18400)
  * Fix commit's time (#18375) (#18392)
  * Fix partial cloning a repo (#18373) (#18377)
  * Stop trimming preceding and suffixing spaces from editor filenames (#18334)
  * Prevent showing webauthn error for every time visiting `/user/settings/security` (#18386)
  * Fix mime-type detection for HTTP server (#18370) (#18371)
  * Stop trimming preceding and suffixing spaces from editor filenames (#18334)
  * Restore propagation of ErrDependenciesLeft (#18325)
  * Fix PR comments UI (#18323)
  * Use indirect comparison when showing pull requests (#18313)
  * Replace satori/go.uuid with gofrs/uuid (#18311)
  * Fix commit links on compare page (#18310)
  * Don't show double error response in git hook (#18292)
  * Handle missing default branch better in owner/repo/branches page (#18290)
  * Fix CheckRepoStats and reuse it during migration (#18264)
  * Prevent underline hover on cards (#18259)
  * Don't delete branch if other PRs with this branch are open (#18164)
  * Require codereview to have content (#18156)
  * Allow admin to associate missing LFS objects for repositories (#18143)
  * When attempting to subscribe other user to issue report why access denied (#18091)
  * Add option to convert CRLF to LF line endings for sendmail (#18075)
  * Only create pprof files for gitea serv if explicitly asked for (#18068)
  * Abort merge if head has been updated before pressing merge (#18032)
  * Improve TestPatch to use git read-tree -m and implement git-merge-one-file functionality (#18004)
  * Use JSON module instead of stdlib json (#18003)
  * Fixed issue merged/closed wording (#17973)
  * Return nicer error for ForcePrivate (#17971)
  * Fix overflow in commit graph (#17947)
  * Prevent services/mailer/mailer_test.go tests from deleteing data directory (#17941)
  * Use disable_form_autofill on Codebase and Gitbucket (#17936)
  * Fix a panic in NotifyCreateIssueComment (caused by string truncation) (#17928)
  * Fix markdown URL parsing (#17924)
  * Apply CSS Variables to all message elements (#17920)
  * Improve checkBranchName (#17901)
  * Update chi/middleware to chi/v5/middleware (#17888)
  * Fix position of label color picker colors (#17866)
  * Fix ListUnadoptedRepositories incorrect total count (#17865)
  * Remove whitespace inside rendered code `<td>` (#17859)
  * Make Co-committed-by and co-authored-by trailers optional (#17848)
  * Fix value of User.IsRestricted when oauth2 user registration (#17839)
  * Use new OneDev /milestones endpoint (#17782)
  * Prevent deadlock in TestPersistableChannelQueue (#17717)
  * Simplify code for writing SHA to name-rev (#17696)
  * Fix database deadlock when update issue labels (#17649)
  * Add warning for BIDI characters in page renders and in diffs (#17562)
  * Fix ipv6 parsing for builtin ssh server (#17561)
  * Multiple Escaping Improvements (#17551)
  * Fixes #16559 - Do not trim leading spaces for tab delimited (#17442)
  * Show client-side error if wiki page is empty (#17415)
  * Fix context popup error (#17398)
  * Stop sanitizing full name in API (#17396)
  * Fix issue close/comment buttons on mobile (#17317)
  * Fix navbar UI (#17235)
  * Fix problem when database id is not increment as expected (#17229)
  * Open the DingTalk link in browser (#17084)
  * Remove heads pointing to missing old refs (#17076)
  * Fix commit status index problem (#17061)
  * Handle broken references in mirror sync (#17013)
  * Fix for create repo page layout (#17012)
  * Improve LDAP synchronization efficiency (#16994)
  * Add repo_id for attachment (#16958)
  * Clean-up HookPreReceive and restore functionality for pushing non-standard refs (#16705)
  * Remove duplicate csv import in modules/csv/csv.go (#16631)
  * Improve SMTP authentication and Fix user creation bugs  (#16612)
  * Fixed emoji alias not parsed in links (#16221)
  * Calculate label URL on API  (#16186)
* TRANSLATION
  * Fix mispelling of starred as stared (#17465)
  * Re-separate the color translation strings (#17390)
  * Enable Malayalam, Greek, Persian, Hungarian & Indonesian by default (#16998)
* BUILD
  * Add lockfile-check (#18285)
  * Don't store assets modified time into generated files (#18193)
  * Use shadowing script for docker (#17846)
* MISC
  * Update JS dependencies (#17611)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-30 19:22:16 +01:00
zeripath
e5ec7a086f
Warn at startup if the provided SCRIPT_TYPE is not on the PATH (#18467)
Several users run Gitea in situations whereby `bash` is not available.
If the `SCRIPT_TYPE` is not changed this will cause hooks to fail.
A simple test to check if the provided type is on the PATH should be
sufficient to warn them about this problem.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-30 16:33:36 +00:00
6543
246902cd63
use next gen codecov uploader (#18443) 2022-01-30 03:21:15 +01:00
GiteaBot
74dcdadf08 [skip ci] Updated licenses and gitignores 2022-01-30 00:28:19 +00:00
zeripath
be77ede954
Change some logging levels (#18421)
* Change some logging levels

* PlainTextWithBytes - 4xx/5xx this should just be TRACE
* notFoundInternal - the "error" here is too noisy and should be DEBUG
* WorkerPool - Worker pool scaling messages are normal and should be DEBUG

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-29 20:52:37 +00:00
Aravinth Manivannan
e19b9653ea
GitLab reviews may not have the updated_at field set (#18450)
* GitLab reviews may not have the updated_at field set

Fallback to created_at if that the case and to time.Now() if it is
also missing.

Fixes: 18434

* use assert.WithinDuration

Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-01-29 18:33:20 +01:00
zeripath
2ad74a503d
Attempt to prevent intermittent failure TestGit/xxx/BranchProtectMerge/MergePR (#18451)
One of the repeated intermittent failures we see in testing is a failure due to
branches not being ready to merge.

Prior to the immediate queue implementation we would attempt to flush all the queues
and this would prevent the issue. However, the immediate queue is not flushable so
the flushall is not successful at preventing this.

This PR proposes an alternative solution - wait some time and try again up to 5 times.

If this fails then there is a genuine issue and we should fail.

Related #17719

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-29 15:35:36 +00:00
zeripath
b34923d919
Update Goldmark to Goldmark 1.4.4 (#18420)
* Update Goldmark to Goldmark 1.4.4
* nolint the deprecation

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-29 21:17:21 +08:00
zeripath
f7b152f126
Ensure git tag tests and others create test repos in tmpdir (#18447)
* Ensure git tag tests and other create test repos in tmpdir

There are a few places where tests appear to reuse testing repos which
causes random CI failures.

This PR simply changes these tests to ensure that cloning always happens
into new temporary directories.

Fix #18444

* Change log root for integration tests to use the REPO_TEST_DIR

There is a potential race in the drone integration tests whereby test-mysql etc
will start writing to log files causing make test-check fail.

Fix #18077

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-29 12:41:44 +00:00
zeripath
92b715e0f2
Attempt to prevent the deadlock in the QueueDiskChannel Test again (#18415)
* Attempt to prevent the deadlock in the QueueDiskChannel Test again

This time we're going to adjust the pause tests to only test the right
flag.

* Only switch off pushback once we know that we are not pushing anything else
* Ensure full redirection occurs
* More nicely handle a closed datachan
* And handle similar problems in queue_channel_test

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-29 11:37:08 +00:00
GiteaBot
726715fcfb [skip ci] Updated translations via Crowdin 2022-01-29 00:28:21 +00:00
silverwind
19b017f398
Use explicit jQuery import, remove unused eslint globals (#18435)
- Don't rely on globals (window.$) for jQuery import
- Remove eslint globals no longer in use
2022-01-28 21:00:11 +00:00
Gusted
7b04c97b7b
Fix typo (#18436)
As title

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2022-01-28 21:56:31 +08:00
Lauris BH
604ce77628
Allow to filter repositories by language in explore, user and organization repositories lists (#18430) 2022-01-28 13:29:04 +02:00
Lunny Xiao
401e5c8174
Fix broken when no commits and default branch is not master (#18422)
* Fix broken when no commits and default branch is not master

* Fix IsEmpty check

* Improve codes

* Add timeout
2022-01-28 10:51:16 +08:00
GiteaBot
668718c67e [skip ci] Updated translations via Crowdin 2022-01-28 00:28:20 +00:00
Lauris BH
8038610a42
Automatically pause queue if index service is unavailable (#15066)
* Handle keyword search error when issue indexer service is not available

* Implement automatic disabling and resume of code indexer queue
2022-01-27 10:30:51 +02:00
GiteaBot
2649eddcf0 [skip ci] Updated translations via Crowdin 2022-01-27 00:28:24 +00:00
zeripath
9a75c2741d
Only view milestones from current repo (#18414)
The endpoint /{username}/{reponame}/milestone/{id} is not currently restricted to
the repo. This PR restricts the milestones to those within the repo.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-26 20:01:35 +00:00
Aravinth Manivannan
3bb028cc46
Validate migration files (#18203)
JSON Schema validation for data used by Gitea during migrations

Discussion at https://forum.forgefriends.org/t/common-json-schema-for-repository-information/563

Co-authored-by: Loïc Dachary <loic@dachary.org>
2022-01-26 10:45:51 +01:00
wxiaoguang
49dd906753
Use base32 for 2FA scratch token (#18384)
* Use base32 for 2FA scratch token
* rename Secure* to Crypto*, add comments
2022-01-26 12:10:10 +08:00
GiteaBot
4889ab52de [skip ci] Updated translations via Crowdin 2022-01-26 00:28:46 +00:00
zeripath
de61e5f9a0
Fix broken oauth2 authentication source edit page (#18412)
It appears that there was a broken merge of the edit.tmpl page during the merge
of #16594 - I am not entirely sure how this happened as the PR was correct.

This PR fixes the broken template.

Fix #18388

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-26 01:23:46 +01:00
zeripath
713985b1a4
Prevent deadlocks in persistable channel pause test (#18410)
* Prevent deadlocks in persistable channel pause test

Because of reuse of the old paused/resumed channels in this test there
was a potential for deadlock. This PR ensures that the channels are always
reobtained.

It further adds some control code to detect hangs in future - and it
ensures that the pausing warning is not shown on shutdown.

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

* do not warn but do pause

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-26 01:09:57 +02:00
Gusted
b53fd5ff90
Bump golangci-lint version (#18411)
- Bump golangci-lint version to v1.44.0 (no new linter errors detected)
2022-01-26 00:09:49 +02:00
6543
80adbebbc8
Unexport git.GlobalCommandArgs (#18376)
Unexport the git.GlobalCommandArgs variable.
2022-01-25 18:15:58 +00:00
zeripath
93250bfe27
Place inline diff comment dialogs on split diff in 4th and 8th columns (#18403)
Fix #18391
Fix #18320

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-25 12:18:30 +00:00
Lauris BH
6392f4691a
API: Return primary language and repository language stats API URL (#18396) 2022-01-25 08:33:40 +02:00
Lauris BH
9628a76ce6
Update to work with latest VS Code go debugger (#18397) 2022-01-25 05:00:55 +00:00
Lunny Xiao
a717265e47
Fix restore without topic failure (#18387)
Co-authored-by: zeripath <art27@cantab.net>
2022-01-25 10:44:12 +08:00
GiteaBot
8053b60b4f [skip ci] Updated translations via Crowdin 2022-01-25 00:28:50 +00:00
zeripath
ab7f701671
Make WrappedQueues and PersistableChannelUniqueQueues Pausable (#18393)
Implements the Pausable interface on WrappedQueues and PersistableChannelUniqueQueues

Reference #15928

Signed-off-by: Andrew Thornton art27@cantab.net
2022-01-24 22:54:35 +00:00
Gusted
43c6b27716
Fix commit's time (#18375)
* Fix commit's time

- Use the Committer's `when` as the CommitDate will be modified when the
commit is being moved around in the git tree(e.g. being rebased on top
of newer commits). The Author's `when` is created once and never touched
again.

* Update templates/repo/view_list.tmpl

* Commmt unstaged

* Add fallback

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-25 00:11:40 +02:00
wxiaoguang
9837773f0e
Prevent showing webauthn error for every time visiting /user/settings/security (#18385) 2022-01-24 14:57:01 -05:00
wxiaoguang
5506cb92da
Refactor webhooks i18n (#18380) 2022-01-24 19:36:54 +08:00
GiteaBot
4bfd749fc5 [skip ci] Updated translations via Crowdin 2022-01-24 00:28:24 +00:00
Gusted
c2e13fb763
Fix partial cloning a repo (#18373)
- Pass the Global command args into serviceRPC.
- Fixes error with partial cloning.
- Add partial clone test
- Include diff

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-23 22:19:32 +01:00
Gusted
5e5740af69
Switch to non-deprecation setting (#18358)
* Switch to non-deprecation setting
  (Avoid by-default: "Deprecated fallback `[server]` `LFS_CONTENT_PATH` present. Use `[lfs]` `PATH` instead. This fallback will be removed in v1.18.0")

* Update all references
2022-01-23 20:02:29 +01:00
zeripath
8472884cef
Update the SSH passthrough documentation (#18366) 2022-01-23 12:25:25 -05:00
Gusted
e36f0b6add
Don't underline commit status icon on hover (#18372)
- Don't underline the commit status icon, as it isn't a link per-se.
2022-01-23 17:02:15 +00:00
Dr. Tobias Quathamer
3349fd8f79
Add packagist webhook (#18224)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-23 21:46:30 +08:00
wxiaoguang
87141b908d
Fix mime-type detection for HTTP server (#18370)
Bypass the unstable behavior of Golang's mime.TypeByExtension
2022-01-23 20:19:49 +08:00
Lunny Xiao
35fdefc1ff
Always use git command but not os.Command (#18363) 2022-01-23 00:57:52 -05:00
Lunny Xiao
f066b293ac
Add deprecated for LFS_CONTENT_PATH on zh-cn docs (#18362)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-23 13:03:26 +08:00
GiteaBot
e040eca727 [skip ci] Updated translations via Crowdin 2022-01-23 00:28:40 +00:00
Gusted
1ddfa596c8
Make gitea, gitea-vet future-proof (#18361)
* Make gitea, gitea-vet future-proof

- Ref: https://gitea.com/gitea/gitea-vet/pulls/18

* Correct order

Co-authored-by: zeripath <art27@cantab.net>
2022-01-22 21:59:34 +00:00
zeripath
a82fd98d53
Pause queues (#15928)
* Start adding mechanism to return unhandled data

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

* Create pushback interface

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

* Add Pausable interface to WorkerPool and Manager

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

* Implement Pausable and PushBack for the bytefifos

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

* Implement Pausable and Pushback for ChannelQueues and ChannelUniqueQueues

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

* Wire in UI for pausing

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

* add testcases and fix a few issues

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

* fix build

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

* prevent "race" in the test

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

* fix jsoniter mismerge

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

* fix conflicts

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

* fix format

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

* Add warnings for no worker configurations and prevent data-loss with redis/levelqueue

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

* Use StopTimer

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-22 21:22:14 +00:00
Gusted
27ee01e1e8
Disable content sniffing on PlainTextBytes (#18359)
- Disable the browser's function to "sniff" for the content-type on the
provided plain text, this will prevent the possible usage of
user-controlled data being sent, which could be malicious.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-22 13:32:35 -05:00
6543
6ad7a5376a
Update github.com/duo-labs/webauthn (#18357) 2022-01-22 18:01:40 +01:00
wxiaoguang
5ff899d5ac
Fix route wrap (#18360) 2022-01-22 15:05:22 +00:00
GiteaBot
f91092453e [skip ci] Updated translations via Crowdin 2022-01-22 00:28:20 +00:00
qwerty287
1f40933d38
Add config options to hide issue events (#17414)
* Add config option to hide issue events
Adds a config option `HIDE_ISSUE_EVENTS` to hide most issue events (changed labels, milestones, projects...) on the issue detail page.
If this is true, only the following events (comment types) are shown:
* plain comments
* closed/reopned/merged
* reviews

* Make configurable using a list

* Add docs

* Add missing newline

* Fix merge issues

* Allow changes per user settings

* Fix lint

* Rm old docs

* Apply suggestions from code review

* Use bitsets

* Rm comment

* fmt

* Fix lint

* Use variable/constant to provide key

* fmt

* fix lint

* refactor

* Add a prefix for user setting key

* Add license comment

* Add license comment

* Update services/forms/user_form_hidden_comments.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* check len == 0

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2022-01-21 18:59:26 +01:00
silverwind
108f1aab5c
Add js vendor directory to .gitattributes (#18350) 2022-01-21 23:42:38 +08:00
GiteaBot
6c7084cbee [skip ci] Updated translations via Crowdin 2022-01-21 00:30:19 +00:00
zeripath
44deae8f3d
Refactor jwt.StandardClaims to RegisteredClaims (#18344)
* Refactor jwt.StandardClaims to RegisteredClaims

go-jwt/jwt has deprecated the StandardClaims interface to use RegisteredClaims
instead. This PR migrates to use this new format.

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

* Apply suggestions from code review

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gusted <williamzijl7@hotmail.com>
2022-01-20 22:52:56 +01:00
6543
54e9ee37a7
format with gofumpt (#18184)
* gofumpt -w -l .

* gofumpt -w -l -extra .

* Add linter

* manual fix

* change make fmt
2022-01-20 18:46:10 +01:00
Gusted
1d98d205f5
Enable deprecation error for v1.17.0 (#18341)
Co-authored-by: Andrew Thornton <art27@cantab.net>
2022-01-20 18:00:38 +01:00
Gusted
16d378fefc
Use correct translation key for errors (#18342)
- Noted by:
https://github.com/go-gitea/gitea/issues/17876#issuecomment-1017503614
2022-01-20 15:18:46 +00:00
wxiaoguang
5bf8d5445e
Refactor Router Logger (#17308)
Make router logger more friendly, show the related function name/file/line.

[BREAKING]
This PR substantially changes the logging format of the router logger. If you use this logging for monitoring e.g. fail2ban you will need to update this to match the new format.
2022-01-20 19:41:25 +08:00
Jelle Hulter
bbd30787d3
Updated Chroma to v0.10.0 (#18270) 2022-01-20 17:59:15 +08:00
zeripath
7427b81fec
Change initial TrustModel to committer (#18335) 2022-01-19 21:41:59 -05:00
Gusted
6c0fe1f3ec
refactor httplib (#18338)
- Remove a lot of unused code(most if not all were introduced in gogs
for webhooks usages).

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2022-01-19 19:31:39 -05:00
zeripath
5cb0c9aa0d
Propagate context and ensure git commands run in request context (#17868)
This PR continues the work in #17125 by progressively ensuring that git
commands run within the request context.

This now means that the if there is a git repo already open in the context it will be used instead of reopening it.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-19 23:26:57 +00:00
Grzegorz Alibożek
4563148a61
Upgrade Alpine from 3.13 to 3.15 (#18050)
* Upgrade alpine to 3.15

* Add executability test to entrypoint for too old dockers

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

* Update docker/rootless/usr/local/bin/docker-entrypoint.sh

Co-authored-by: zeripath <art27@cantab.net>
2022-01-19 16:55:17 -05:00
GiteaBot
b7c6457648 [skip ci] Updated translations via Crowdin 2022-01-19 21:28:43 +00:00
zeripath
6b0a71230d
Stop trimming preceding and suffixing spaces from editor filenames (#18334)
* Stop trimming preceding and suffixing spaces from editor filenames

In #5702 it was decided to trim preceding and suffixed spaces aswell as / from
editing file filenames. This was because at this point in time the url-safety of
Gitea was much poorer.

We can now drop this requirement and file editing should work correctly.

Fix #18176

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-19 21:03:15 +00:00
GiteaBot
c68f1281f6 [skip ci] Updated translations via Crowdin 2022-01-19 20:29:22 +00:00
silverwind
f19f53c077
Left-Align text in Unicode warning boxes (#18331)
Wrapped text is more readable when left-aligned.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2022-01-19 19:25:08 +00:00
zeripath
6779d9726f
Only warn on bidi but still escape non-bidi (#18333)
Fix #18324

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-19 19:24:15 +00:00
wxiaoguang
6fba174606
Fix incorrect OAuth message (#18332)
As the title,

Fix #18327
2022-01-19 19:05:06 +00:00
GiteaBot
531b6d60e1 [skip ci] Updated translations via Crowdin 2022-01-19 18:28:18 +00:00
techknowlogick
4a6bae59c0
Changelog for 1.16.0-rc1 (#18309)
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2022-01-19 18:08:23 +01:00
zeripath
4a20eadfd7
Restore propagation of ErrDependenciesLeft (#18325)
Unfortunately #17643 prevented all propagation of ErrDependenciesLeft meaning
that dependency errors that prevent closing of issues get swallowed.

This PR restores propagation of the error but instead swallows the error in the
places where it needs to be swallowed.

Fix #18223

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-19 00:26:42 +01:00
wxiaoguang
84f8ef3df6
Fix PR comments UI (#18323)
Closes:
* Review comment cannot be edited #17768
* Changing PR Comment Resolved State Disables Further Changes #18315
2022-01-19 01:28:38 +08:00
wxiaoguang
11b4827791
Make the height of the editor in Review Box smaller (4 lines as GitHub) (#18319)
And shrink the height of Dropzone.
2022-01-19 00:57:57 +08:00
Gusted
9dcf0bf6ec
Fix commit links on compare page (#18310)
* Fix commit links on compare page

- Use the correct repo link for each commit(the headrepo). As for
compare pages were baserepo != headrepo, it wouldn't have the correct
link.

Co-authored-by: zeripath <art27@cantab.net>
2022-01-18 16:12:10 +00:00
silverwind
8156e0f855
Update JS dependencies, remove eslint-plugin-github (#18317)
- Update all JS dependencies
- Add new lint rules
- Regenerate SVGs
- Tested Monaco and Mermaid
* Remove eslint-plugin-github
2022-01-18 23:01:36 +08:00
Peter Gardfjäll
89a3214352
Add MirrorUpdated field to Repository API type (#18267)
Add the last update time to the repository api type.

Close #18266
2022-01-18 13:18:30 +00:00
zeripath
68b59d8966
replace satori/go.uuid with gofrs/uuid (#18311)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-18 11:04:24 +00:00
JonRB
483409716d
Place inline diff comment dialogs in the 4th column. (#18321)
Comment dialogs for inline comments should appear in 4th column (not 3rd column), this PR changes the column that the inline review comment is associated with.

This problem has occurred due to an unrecognised conflict between #17562 and #17315. 

Fix as zeripath suggested in #18320

Fix #18320 

Co-authored-by: zeripath <art27@cantab.net>
2022-01-18 10:28:45 +00:00
zeripath
089b4e6a45
Use indirect comparison when showing pull requests (#18313)
When generating the commits list and number of files changed for PRs and
compare we should use "..." always not "..".

Fix #18303

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-18 07:45:43 +00:00
zeripath
a7ee4d507a
Prevent ambiguous column error in organizations page (#18314)
Explicitly set the table for the org_id column queries on the organizations pages.

Fix #18229

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-18 07:45:14 +00:00
zeripath
851b54ba9f
Correctly upload LFS files (#18316)
We need to use the cached .gitattributes file for checking if a file
should be stored in the lfs.

Fix #18297

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-18 07:44:30 +00:00
GiteaBot
eed8633fb0 [skip ci] Updated translations via Crowdin 2022-01-18 00:31:56 +00:00
a1012112796
8581e2f4ec
update description about vendoring in CONTRIBUTING.md (#18280)
* update description about vendoring in CONTRIBUTING.md

follow #18277

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update CONTRIBUTING.md

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* fix and readd test-vendor step

* remove vendor from .gitattributes @silverwind

* simplify go mod check

Signed-off-by: a1012112796 <1012112796@qq.com>

* Revert "remove vendor from .gitattributes @silverwind"

This reverts commit 4789e704cb7a2c80934e4a4cd31efb161e6c8666.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2022-01-17 13:39:07 -05:00
Aravinth Manivannan
076cead40d
Fix CheckRepoStats and reuse it during migration (#18264)
The CheckRepoStats function missed the following counters:

- label num_closed_issues & num_closed_pulls
- milestone num_closed_issues & num_closed_pulls

The update SQL statements for updating the repository
num_closed_issues & num_closed_pulls fields were repeated in three
functions (repo.CheckRepoStats, migrate.insertIssues and
models.Issue.updateClosedNum) and were moved to a single helper.

The UpdateRepoStats is implemented and called in the Finish migration method so that it happens immediately instead of wating for the
CheckRepoStats to run.

Signed-off-by: Loïc Dachary loic@dachary.org

---
[source](https://lab.forgefriends.org/forgefriends/forgefriends/-/merge_requests/34)
2022-01-17 19:31:58 +01:00
silverwind
7dde39a6db
Minor tweak to tag list (#18295)
Slightly reduce the font size and padding in the tags table, it seemed a bit too big to me.
2022-01-17 14:26:35 +01:00
a1012112796
43a22c6a21
show pull link for agit pull request also (#18235) 2022-01-17 13:56:43 +08:00
GiteaBot
bd7680f450 [skip ci] Updated translations via Crowdin 2022-01-17 00:28:33 +00:00
silverwind
212e81f11d
Add some .ignore entries (#18296)
Exclude node_modules and minified files from search tools like `rg` and `ag`.
2022-01-16 17:26:15 +00:00
Ben Niemann
2871e58a01
Remove unneeded debug messages to stdout. (#18298)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-16 23:42:06 +08:00
zeripath
52bfb7f012
Handle missing default branch better in owner/repo/branches page (#18290)
This PR more nicely handles a missing default branch in owner/repo/branches

Fix #18265

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-16 22:59:16 +08:00
wxiaoguang
4d0a72a271
Revert "Prevent possible XSS when using jQuery (#18289)" (#18293)
This reverts commit 661d3d28e9.
2022-01-16 11:19:26 +00:00
a1012112796
72b3681648
not show double error response in git hook (#18292)
if return a error message to cli, it will print it
to stderr which is duplicate with our code (line 82
in same file). so user will see two line same
error message in git output. I think it's not mecessary,
so suggerst not return error message to cli. Thanks.

Signed-off-by: a1012112796 <1012112796@qq.com>
2022-01-16 09:32:32 +00:00
zeripath
7960c96c19
Remove accidental debugging in blob_excerpt.tmpl (#18287)
* Remove accidental debugging in blob_excerpt.tmpl

Unfortunately it appears that a small bit of debugging code was left in blob_excerpt.tmpl
This breaks diff expansion causing #18281.

Fix #18281

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-16 09:31:41 +00:00
Gusted
661d3d28e9
Prevent possible XSS when using jQuery (#18289)
In the case of misuse or misunderstanding from a developer whereby,
if `sel` can receive user-controlled data, jQuery `$(sel)` can lead to the
creation of a new element. Current usage is using hard-coded selectors
in the templates, but nobody prevents that from expanding to
user-controlled somehow.
2022-01-16 13:14:32 +08:00
zeripath
4b4884ce88
Return nicer error if trying to pull from non-existent user (#18288)
* Return nicer error if trying to pull from non-existent user

Gitea serv will currently return an 500 if we try to pull from a repository where
the owner does not exist.

This PR checks for the UserNotExist Error when checking for the user and will
return a NotFound error instead.

Fix #18225
2022-01-16 11:44:11 +08:00
GiteaBot
a15353dc00 [skip ci] Updated translations via Crowdin 2022-01-16 00:28:39 +00:00
Jan Tojnar
a38ab71b20
docs: mention client_max_body_size affects LFS (#18291) 2022-01-15 17:26:01 -05:00
silverwind
0ed9b006e8
Add lockfile-check (#18285)
* Add lockfile-check

This check runs `npm install` which will rewrite the lockfile in case it
is inconsistent with package.json. This check detects this and will fail
the CI in such a case.
2022-01-15 21:06:29 +01:00
zeripath
d7c2a2951c
Webauthn nits (#18284)
This contains some additional fixes and small nits related to #17957 

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-15 17:52:56 +01:00
Gusted
e239d354c9
Update package-lock.json (#18283)
- NPM didn't like that package-lock.json was out-of-sync, webpack
throwed some errors as well with building.
- Follow-up for: #18278
2022-01-15 15:25:25 +01:00
wxiaoguang
aa1e8f6a74
Upgrade EasyMDE to 2.16.1 (#18278) 2022-01-15 11:20:47 +01:00
techknowlogick
84145e45c5
Remove golang vendored directory (#18277)
* rm go vendor

* fix drone yaml

* add to gitignore
2022-01-14 18:16:05 -05:00
zeripath
2b16ca7c77
Changelog for 1.15.10 (#18274) (#18276)
* Changelog for 1.15.10 (#18274)

[1.15.10](https://github.com/go-gitea/gitea/releases/tag/v1.15.10) - 2022-01-14

* BUGFIXES
  * Fix inconsistent PR comment counts (#18260) (#18261)
  * Fix release link broken (#18252) (#18253)
  * Fix update user from site administration page bug (#18250) (#18251)
  * Set HeadCommit when creating tags (#18116) (#18173)
  * Use correct translation key for error messages due to max repo limits (#18135 & #18153) (#18152)
  * Fix purple color in suggested label colors (#18241) (#18242)
* SECURITY
  * Bump mermaid from 8.10.1 to 8.13.8 (#18198) (#18206)

* update docs/config.yaml

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

Co-authored-by: Richard Mahn <richmahn@users.noreply.github.com>
2022-01-14 15:02:37 -05:00
Lunny Xiao
35c3553870
Support webauthn (#17957)
Migrate from U2F to Webauthn

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-14 16:03:31 +01:00
GiteaBot
8808293247 [skip ci] Updated translations via Crowdin 2022-01-14 00:29:34 +00:00
Gusted
d413a1f8a4
Improve the comment for 2FA filter in admin panel (#18017)
Replace TODO with explanation

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-13 21:32:28 +01:00
Norwin
696521b33b
fix regression from #16075 (#18260)
we don't want reviews to count towards comments, as this needs changes
in other components as well (eg repo stats cron job, etc).

Co-authored-by: 6543 <6543@obermui.de>
2022-01-14 00:50:43 +08:00
silverwind
f635d60344
Prevent underline hover on cards (#18259)
Prevent a undesired underline effect on hovered cards.

This was regressed by #17898.
2022-01-13 14:33:04 +00:00
Lunny Xiao
dd135c6258
Fix release link broken (#18252)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-13 15:14:53 +02:00
Aravinth Manivannan
69a28299e2
migrations: a deadline at January 1st, 1970 is valid (#18237)
* migrations: a deadline at January 1st, 1970 is valid

Do not change the deadline value if it is set to January 1st, 1970.

Setting the deadline to year 9999 when it is zero (which is equal to
January 1st, 1970) modifies a deadline set to January 1st, 1970 which
is a valid date. In addition, setting a date in year 9999 will be
converted to a null date in some cases.

Signed-off-by: Loïc Dachary <loic@dachary.org>

* tests: set milestone.deadline_unix in fixtures

The value of deadline_unix must be set to 253370764800 (i.e. 9999-01-01) in
fixtures, otherwise it will be inserted as null which leads to
unexpected errors. For instance, DumpRepository will store a null
deadline_unix as 0 (i.e. 1970-01-01) and RestoreRepository will change
it to 9999-01-01.

Signed-off-by: Loïc Dachary <loic@dachary.org>

Co-authored-by: Loïc Dachary <loic@dachary.org>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-13 14:03:30 +08:00
wxiaoguang
eaf09a5368
Fix documents for development and bug report (#18249) 2022-01-13 10:58:46 +08:00
Zoran Peričić
17b2079f3e
Add/update SMTP auth providers via cli (#18197)
Allow adding/updating SMTP authentication source via CLI using:
- gitea admin  auth add-smtp 
- gitea admin  auth update-smtp

Signed-off-by: Zoran Peričić <zpericic@netst.org>
2022-01-12 22:54:53 +00:00
6543
ff00b8688b
Fix NPE on try to get tag reference via API (#18245)
* fix npe

* rm gitRepo from Tag
2022-01-12 20:37:46 +00:00
Lunny Xiao
67d73882f4
Fix update user bug (#18250) 2022-01-12 21:58:09 +08:00
M. Zhou
ba9e4e2570
[doc] https-setup: explain relative paths for {CERT,KEY}_FILE fields. (#18244)
Closes: https://github.com/go-gitea/gitea/issues/14401
2022-01-11 23:18:28 -05:00
Bo-Yi Wu
ee8718e452
chore: remove unnecessary section (#18209)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2022-01-11 18:27:32 -05:00
silverwind
72cced1f3e
Fix purple color in suggested label colors (#18241)
This looks like a typo that was introduced when these colors were added,
causing what is supposed to be purple show up as green.
2022-01-11 12:11:40 -06:00
zeripath
09d2029b6c
Prevent NPE when viewing non-rendered files (#18234)
Fix #18231

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-11 18:18:52 +01:00
Lunny Xiao
0857c197a0
Fix collobration template (#18232) 2022-01-11 12:33:47 +00:00
Andrey Esin
c0ed869e0f
Fix identation typo in doc installation with Docker (#18233) 2022-01-11 19:33:42 +08:00
GiteaBot
ed6757ecdc [skip ci] Updated translations via Crowdin 2022-01-11 00:28:42 +00:00
luzpaz
af92473920
Fix source typos (#18227)
Follow-up to #18219
2022-01-10 23:46:26 +08:00
luzpaz
8c647bf0f6
Fix various typos (#18219)
Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby,te,unknwon`

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-10 17:32:37 +08:00
Gusted
242dddfcb7
Remove ioutil (#18222)
- Don't use `ioutil` package anymore as it doesn't anything special
anymore since Go 1.16:

```
// As of Go 1.16, the same functionality is now provided
// by package io or package os, and those implementations
// should be preferred in new code.
```

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-10 09:48:13 +08:00
GiteaBot
60b945565d [skip ci] Updated translations via Crowdin 2022-01-10 00:28:05 +00:00
Greg Myers
79791ba4ac
Fix typos in docs/content (#18215) 2022-01-09 19:53:03 +08:00
GiteaBot
de578bff8c [skip ci] Updated licenses and gitignores 2022-01-09 00:28:45 +00:00
capvor
3a0dee01ed
In the Organization member page, 2fa column is too narrow for Simplified Chinese and Chinese Traditional. (#18213)
Expand 2fa column and Narrow the last column.
2022-01-09 00:21:10 +08:00
Lunny Xiao
23f5a34c89
Fix new team (#18212)
fix regression from #17811
2022-01-08 15:19:36 +00:00
wxiaoguang
70d7475356
Fix EasyMDE image paste bug during refactoring (#18207) 2022-01-08 21:33:32 +08:00
delvh
4f7764561a
Sort locales according to their names (#18211)
* Sort locales according to their names

* Fix documentation and sort case insensitive
2022-01-08 12:18:39 +00:00
zeripath
832f987d80
Restore setting of ctx.Repo.Mirror (#18205)
In #17933 repoAssignment no longer sets the ctx.Repo.Mirror field meaning that
attempting change mirror settings results in an NPE. This PR simply restores this.

Either we should remove this field or, we should set it. At present it seems simplest
to set it instead of going looking in the Data for the value although converting the
context to a bag of things may be the correct approach in the future.

Fix #18204

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-08 10:03:51 +08:00
GiteaBot
69a4bd02f0 [skip ci] Updated translations via Crowdin 2022-01-08 00:28:35 +00:00
KN4CK3R
e30b20dc68
Show OAuth callback error message (#18185)
* Show callback error message.

* lint

* Use error code to display a message.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-07 21:02:09 +00:00
silverwind
3dbdf36d95
Fix CSS specificity issue with easymde's css (#18201)
* Fix CSS specificity issue with easymde's css

PR #18069 introduced a regression in certain overwritten editor styles
because the dynamic loading of easymde.min.css causes its's style to
apply after our supposed override styles.

Solve this by bundling the styles into index.css. We should later aim to
completely replace easymde.min.css completely with our own styles so there
are no more conflicts.

* Update web_src/js/features/comp/EasyMDE.js

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-07 16:41:31 +08:00
silverwind
80705cf4b4
Fix mermaid rendering in milestone dashboard (#18202)
Fixes: https://github.com/go-gitea/gitea/issues/18200
2022-01-07 11:49:27 +08:00
Lunny Xiao
a1c12fb0b3
Don't store assets modified time into generated files (#18193) 2022-01-06 21:33:17 -05:00
zeripath
21ed4fd8da
Add warning for BIDI characters in page renders and in diffs (#17562)
Fix #17514

Given the comments I've adjusted this somewhat. The numbers of characters detected are increased and include things like the use of U+300 to make à instead of à and non-breaking spaces.

There is a button which can be used to escape the content to show it.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Gwyneth Morgan <gwymor@tilde.club>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2022-01-07 02:18:52 +01:00
GiteaBot
ee60f27aec [skip ci] Updated translations via Crowdin 2022-01-07 00:28:31 +00:00
dependabot[bot]
36a0f4e418
Bump mermaid from 8.13.4 to 8.13.8 (#18198)
Bumps [mermaid](https://github.com/knsv/mermaid) from 8.13.4 to 8.13.8.
- [Release notes](https://github.com/knsv/mermaid/releases)
- [Changelog](https://github.com/mermaid-js/mermaid/blob/develop/docs/CHANGELOG.md)
- [Commits](https://github.com/knsv/mermaid/compare/8.13.4...8.13.8)

---
updated-dependencies:
- dependency-name: mermaid
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-01-06 15:17:27 -05:00
yearski
0acc6a4e92
fix location for custom/options/license (#18194) 2022-01-06 01:29:53 -05:00
Gusted
4b3bfd7e89
Enable partial clone by default (#18195)
- Enable partial clones(which are by default disabled from git) by
default, unless configured otherwise.
- Resolves #18190
2022-01-06 06:38:38 +01:00
zeripath
1514e13bb8
Add option to convert CRLF to LF line endings for sendmail (#18075)
It appears that several versions of sendmail require that the mail is sent to them with
LF line endings instead of CRLF endings - which of course they will then convert back
to CRLF line endings to comply with the SMTP standard.

This PR adds another setting SENDMAIL_CONVERT_CRLF which will pass the message writer
through a filter. This will filter out and convert CRLFs to LFs before writing them
out to sendmail.

Fix #18024

Signed-off-by: Andrew Thornton <art27@cantab.net>
2022-01-06 01:43:45 +01:00
KN4CK3R
bf7b083cfe
Add replay of webhooks. (#18191) 2022-01-05 15:00:20 -06:00
wxiaoguang
a38ba634a4
Load EasyMDE/CodeMirror dynamically, remove RequireEasyMDE (#18069)
This PR makes frontend load EasyMDE/CodeMirror dynamically, and removes `RequireEasyMDE`.
2022-01-05 13:17:25 +01:00
6543
0572c78938
refactoring nits (#18188)
* no octal for time values

* rm artifact from refactoring

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-05 07:27:53 +01:00
Lunny Xiao
6da078d616
slight optimization for default avatar (#18187)
* slight optimization

* Update comment

Co-authored-by: 6543 <6543@obermui.de>
2022-01-05 07:00:32 +01:00
6543
ec6cc38c6c
code.gitea.io/sdk/gitea v0.14.0 -> v0.15.1 (#18186) 2022-01-05 05:51:12 +01:00
Lunny Xiao
8760af752a
Team permission allow different unit has different permission (#17811)
* Team permission allow different unit has different permission

* Finish the interface and the logic

* Fix lint

* Fix translation

* align center for table cell content

* Fix fixture

* merge

* Fix test

* Add deprecated

* Improve code

* Add tooltip

* Fix swagger

* Fix newline

* Fix tests

* Fix tests

* Fix test

* Fix test

* Max permission of external wiki and issues should be read

* Move team units with limited max level below units table

* Update label and column names

* Some improvements

* Fix lint

* Some improvements

* Fix template variables

* Add permission docs

* improve doc

* Fix fixture

* Fix bug

* Fix some bug

* fix

* gofumpt

* Integration test for migration (#18124)

integrations: basic test for Gitea {dump,restore}-repo
This is a first step for integration testing of DumpRepository and
RestoreRepository. It:

runs a Gitea server,
dumps a repo via DumpRepository to the filesystem,
restores the repo via RestoreRepository from the filesystem,
dumps the restored repository to the filesystem,
compares the first and second dump and expects them to be identical

The verification is trivial and the goal is to add more tests for each
topic of the dump.

Signed-off-by: Loïc Dachary <loic@dachary.org>

* Team permission allow different unit has different permission

* Finish the interface and the logic

* Fix lint

* Fix translation

* align center for table cell content

* Fix fixture

* merge

* Fix test

* Add deprecated

* Improve code

* Add tooltip

* Fix swagger

* Fix newline

* Fix tests

* Fix tests

* Fix test

* Fix test

* Max permission of external wiki and issues should be read

* Move team units with limited max level below units table

* Update label and column names

* Some improvements

* Fix lint

* Some improvements

* Fix template variables

* Add permission docs

* improve doc

* Fix fixture

* Fix bug

* Fix some bug

* Fix bug

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Aravinth Manivannan <realaravinth@batsense.net>
2022-01-05 11:37:00 +08:00
Aravinth Manivannan
12ad6dd0e3
Integration test for migration (#18124)
integrations: basic test for Gitea {dump,restore}-repo
This is a first step for integration testing of DumpRepository and
RestoreRepository. It:

runs a Gitea server,
dumps a repo via DumpRepository to the filesystem,
restores the repo via RestoreRepository from the filesystem,
dumps the restored repository to the filesystem,
compares the first and second dump and expects them to be identical

The verification is trivial and the goal is to add more tests for each
topic of the dump.

Signed-off-by: Loïc Dachary <loic@dachary.org>
2022-01-04 20:24:27 +01:00
Patrick DeVivo
d228d346c4
Update TODOs badge to reflect new default branch (#18182)
* Update `TODOs` badge to reflect `main` as default branch

* update `README_ZH.md` as well
2022-01-04 10:46:32 -06:00
Gusted
623c93ff46
Increase Salt randomness (#18179)
- The current implementation of `RandomString` doesn't give you a most-possible unique randomness. It gives you 6*`length` instead of the possible 8*`length` bits(or as `length`x bytes) randomness. This is because `RandomString` is being limited to a max value of 63, this in order to represent the random byte as a letter/digit.
- The recommendation of pbkdf2 is to use 64+ bit salt, which the `RandomString` doesn't give with a length of 10, instead of increasing 10 to a higher number, this patch adds a new function called `RandomBytes` which does give you the guarentee of 8*`length` randomness and thus corresponding of `length`x bytes randomness.
- Use hexadecimal to store the bytes value in the database, as mentioned, it doesn't play nice in order to convert it to a string. This will always be a length of 32(with `length` being 16).
- When we detect on `Authenticate`(source: db) that a user has the old format of salt, re-hash the password such that the user will have it's password hashed with increased salt.

Thanks to @zeripath for working out the rouge edges from my first commit 😄.

Co-authored-by: lafriks <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2022-01-04 15:13:52 +00:00
Gusted
165346c15c
Add MP4 as default allowed attachment type (#18170) 2022-01-04 04:36:47 +01:00
GiteaBot
0848c716bf [skip ci] Updated translations via Crowdin 2022-01-04 00:28:34 +00:00
Gusted
74a5d49e86
Include folders into size cost (#18158)
- Include folders for the disk consumption size, they should be included
as they are also saved on the disk :)
- Have a more accurate picture of the size of a repo.
- Mostly they are the size of the file system's block size. E.g. 4Kb on
Linux.
2022-01-03 23:24:12 +00:00
a1012112796
637c3ec5d8
Don't delete branch if other PRs with this branch are open (#18164)
fix #18149

Signed-off-by: a1012112796 <1012112796@qq.com>
2022-01-03 20:45:58 +01:00
Gusted
650a50a7ba
Remove unused route "/tasks/trigger" (#18160)
ref: https://github.com/go-gitea/gitea/pull/18160#issuecomment-1004091325
2022-01-03 18:23:43 +01:00
wxiaoguang
48aab263d1
Fix EasyMDE validation (#18161) 2022-01-03 17:53:53 +01:00
Lunny Xiao
8eec403068
Fix bug (#18168) 2022-01-03 18:06:46 +02:00
Aravinth Manivannan
ade41f3f04
tests: add coverage for models migration helpers (#18162)
They were previously not covered at all, either by integration tests or unit tests.

This PR also fixes a bug where the `num_comments` field was incorrectly set to include all types of comments.

It sets num_closed_issues: 0 as default in milestone unit test fixtures. If they are not set, Incr("num_closed_issues") will be a noop because the field is null.
2022-01-03 23:35:01 +08:00
GiteaBot
f499f23039 [skip ci] Updated translations via Crowdin 2022-01-03 00:28:34 +00:00
Gusted
496acbe9e5
Require codereview to have content (#18156)
- Report a validityError when the codeReview have no comment.
- Resolves #18151
- Refactor
2022-01-02 23:31:03 +01:00
Bo-Yi Wu
948949f429
chore(lint): use golangci-lint to call revive and misspell checker. (#18145)
replace revive and misspell with golangci-lint

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2022-01-02 19:30:40 +00:00
6543
766cb481f7
Update owners for 2022 (#18155) 2022-01-02 10:54:49 -06:00
Lunny Xiao
de8e3948a5
Refactor auth package (#17962) 2022-01-02 21:12:35 +08:00
wxiaoguang
e61b390d54
Unify and simplify TrN for i18n (#18141)
Refer: https://github.com/go-gitea/gitea/pull/18135#issuecomment-1003246099

Now we have a unique and simple `TrN`, and make the fix of PR #18135 also use the better `TrN` logic.
2022-01-02 04:33:57 +01:00
Gusted
88da7a7174
Use correct user when determining max repo limits for error messages (#18153)
- Use the correct user(`owner` instead of `ctx.User`) to get the maxCreationLimit.
2022-01-02 02:38:07 +00:00
singuliere
5d4ee44ed3
Add singuliere to MAINTAINERS (#18148)
Signed-off-by: singuliere <singuliere@autistici.org>
2022-01-02 02:12:13 +01:00
GiteaBot
6a3611cc3d [skip ci] Updated licenses and gitignores 2022-01-02 00:28:42 +00:00
qwerty287
7db2f110ad
Add API to get issue/pull comments and events (timeline) (#17403)
* Add API to get issue/pull comments and events (timeline)
Adds an API to get both comments and events in one endpoint with all required data.
Closes go-gitea/gitea#13250

* Fix swagger

* Don't show code comments (use review api instead)

* fmt

* Fix comment

* Time -> TrackedTime

* Use var directly

* Add logger

* Fix lint

* Fix test

* Add comments

* fmt

* [test] get issue directly by ID

* Update test

* Add description for changed refs

* Fix build issues + lint

* Fix build

* Use string enums

* Update swagger

* Support `page` and `limit` params

* fmt + swagger

* Use global slices

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2022-01-01 22:12:25 +08:00
Lunny Xiao
549fd03c0e
Upgrade certmagic from v0.14.1 to v0.15.2 (#18138) 2022-01-01 17:43:44 +08:00
Lunny Xiao
e9c9a35a61
Upgrade certmagic from v0.14.1 to v0.15.2 (#18138) 2022-01-01 17:43:28 +08:00
wxiaoguang
385dc6a992
Allow admin to associate missing LFS objects for repositories (#18143)
This PR reworked the Find pointer files feature in Settings -> LFS page.

When a LFS object is missing from database but exists in LFS content store, admin can associate it to the repository by clicking the Associate button.

This PR is not perfect (because the LFS module itself should be improved too), it's just a nice-to-have feature to help users recover their LFS repositories (eg: database was lost / table was truncated)
2022-01-01 17:05:31 +08:00
Lunny Xiao
25a290e320
Upgrade bleve from v2.0.6 to v2.3.0 (#18132) 2022-01-01 16:26:27 +08:00
singuliere
1a4e2bfcd1
tests: s/GITEA_UNIT_TESTS_VERBOSE/GITEA_UNIT_TESTS_LOG_SQL/ (#18142)
The GITEA_UNIT_TESTS_VERBOSE variable is an undocumented variable
introduced in 2017 (see 1028ef2def)
whose sole purpose has been to log SQL statements when running unit
tests.

It is renamed for clarity and a warning is displayed for backward
compatibility for people and scripts that know about it.

The documentation is updated to reflect this change.
2022-01-01 04:31:24 +01:00
singuliere
fb2dc95623
services/repository: fix ListUnadoptedRepositories incorrect total count (#17865)
The total count returned by ListUnadoptedRepositories is incorrectly
calculated.

The code snippet within ListUnadoptedRepositories used to verify
unadopted repositories is repeated three times in the function. It is
moved in the checkUnadoptedRepositories function and a unit test is
added to verify it works as expected.

A unit test is added to verify the total count returned by
ListUnadoptedRepositories is as expected.

Signed-off-by: singuliere <singuliere@autistici.org>
2022-01-01 10:52:00 +08:00
wxiaoguang
c99b8efba2
Improve document for developers: Windows CGO, unit test option (#18140) 2021-12-31 22:21:11 +08:00
zeripath
431e482e3f
Reset the conflicted files list in testpatch (#18139)
Although #18004 will seriously reduce the likelihood of finding
conflicts in the first place - one bug was introduced whereby the
conflicted files status was not being reset properly. This leads to
conflicted PRs remaining conflicted when the conflict has been resolved.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-31 20:33:55 +08:00
Gusted
7eb380baa4
Use correct translation key (#18135)
- Resolves #18122

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-31 16:43:03 +08:00
GiteaBot
a3d685077f [skip ci] Updated translations via Crowdin 2021-12-31 00:28:31 +00:00
6543
ffaebb1a84
[Frontport] Changelog v1.15.9 (#18136)
* Changelog ## [1.15.9](https://github.com/go-gitea/gitea/releases/tag/v1.15.9) - 2021-12-30

* docs: bump version
2021-12-30 19:54:46 +02:00
KN4CK3R
67d7ad681a
Fix wrong redirect on org labels (#18128) 2021-12-30 07:44:42 +01:00
Lunny Xiao
626b10794f
Fix performance regression when user has many organization (#18125) 2021-12-30 13:03:40 +08:00
Tony
e0b41f8c37
docs: add various ways to install from package (#18120)
zh-cn

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-30 12:28:56 +08:00
KN4CK3R
658a636afe
Removed unused method. (#18129)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-30 11:56:12 +08:00
GiteaBot
ccb7978538 [skip ci] Updated translations via Crowdin 2021-12-30 00:28:34 +00:00
KN4CK3R
211f0c32d2
Removed unused endpoint. (#18127) 2021-12-29 17:57:30 -05:00
Lunny Xiao
8ce1b539b1
Use conditions but not repo ids as query condition (#16839)
* Use conditions but not repo ids as query condition

* Improve the performance of pulls/issue

* Remove duplicated code

* fix lint

* Fix bug

* Fix stats

* More fixes

* Fix build

* Fix lint

* Fix test

* Fix build

* Adjust the logic

* Merge

* Fix conflicts

* improve the performance

* Add comments for the query conditions functions

* Some improvements
2021-12-29 21:02:12 +08:00
KN4CK3R
8fa97a25f0
Set HeadCommit when creating tags. (#18116)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-29 19:40:57 +08:00
DuckDuckWhale
72f9050689
Fix: unstable sort skips/duplicates issues across pages (#18094)
When viewing issues in sorted order, some issues are duplicated across
pages and some are missing.  This is caused by the lack of tie-breakers
in database queries, making pagination inconsistent.
2021-12-29 11:12:19 +08:00
Gusted
e4e3df6c66
Handle invalid issues (#18111)
* Handle invalid issues

- When you hover over a issue reference, and the issue doesn't exist, it
will just hang on the loading animation.
- This patch fixes that by showing them the pop-up with a "Error
occured" message.

* Add I18N

* refactor

* fix comment for lint

* fix unit test for i18n

* fix unit test for i18n

* add comments

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-28 21:28:27 +08:00
GiteaBot
d2fac636d1 [skip ci] Updated translations via Crowdin 2021-12-27 00:28:36 +00:00
wxiaoguang
38d81cdd01
Fix documents for Windows development (#18109)
* Fix documents for Windows development
2021-12-26 23:27:18 +08:00
Gusted
a2afd38f25
Enable linter [rule.modifies-value-receiver] and refactor RoleDescriptor (#18093) 2021-12-26 22:56:14 +08:00
Rolf Kaiser
4da2eabd7f
doc: clarify INSTALL_LOCK behavior (#17945) 2021-12-26 11:25:42 +08:00
GiteaBot
13d002a755 [skip ci] Updated translations via Crowdin 2021-12-26 00:28:42 +00:00
zjjhot
e34632bb53
Add issue hyperlinks in the webhook of wechatwork (#18102)
Co-authored-by: zjj <2031381130@qq.com>
2021-12-25 21:30:09 +08:00
wxiaoguang
31a2bf29ed
Fix a navbar UI bug in Safari (#18092) 2021-12-24 23:42:01 +02:00
zeripath
16adaaeaa3
Instead of using routerCtx just escape the url before routing (#18086)
A consequence of forcibly setting the RoutePath to the escaped url is that the
auto routing to endpoints without terminal slashes fails (Causing #18060.) This
failure raises the possibility that forcibly setting the RoutePath causes other
unexpected behaviors too.

Therefore, instead we should simply pre-escape the URL in the process registering
handler. Then the request URL will be properly escaped for all the following calls.

Fix #17938
Fix #18060
Replace #18062
Replace #17997

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-25 00:50:49 +08:00
wxiaoguang
26070eb818
When the git repository on storage is changed, the repository modal should also be updated (#18088)
User would keep seeing an empty repo if:
* An error occurs during the first git pushing/receiving
* A user replaces the Gitea's empty repository manually
Fix: when a user is viewing the repository web page, if the repoModal.IsEmpty is true, we check the git repository again to detect whether it is really empty.

However: the IsEmpty flag is deeply broken and should be removed. For example it's possible for a repository to be non-empty by that flag but still 500 because there are no branches - only tags -or the default branch is non-extant as it has been 0-pushed.
2021-12-24 23:36:26 +08:00
Aravinth Manivannan
c7151c2fb6
- name: new parameter in CreateForkOption to give the forked repository (#18066)
a custom name, intended to be used when there's a name conflict
- When a fork request results in a name conflict, HTTP 409: Conflict is
  returned instead of 500
- API documentation for the above mentioned changes

Signed-off-by: realaravinth <realaravinth@batsense.net>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-12-24 22:43:00 +08:00
zeripath
532383d7dd
When attempting to subscribe other user to issue report why access denied (#18091)
Fix #18090

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-24 21:47:42 +08:00
Lunny Xiao
d7770539f6
Improve interface when comparing a branch which has created a pull request (#17911)
* Improve interface when comparing a branch which has created a pull request

* Take the note back
2021-12-24 12:14:42 +00:00
qwerty287
7cc44491fa
Add API to manage repo tranfers (#17963) 2021-12-23 23:26:52 -05:00
qwerty287
5754080eb9
Fix various typos of software names (#18083)
* `git` -> `Git`
* `Github` and `github` -> `GitHub`
* `crowdin` -> `Crowdin`
* `git-lfs` -> `Git LFS`
* `githooks`, `git hooks`, `git-hooks` -> `Git Hooks`
* `discord` -> `Discord`
* `2fa` -> `2FA`
* `gitlab` and `Gitlab` -> `GitLab`
* `web hook` -> `webhook`
* `linux` -> `Linux`
* `sqlite` -> `SQLite`
* `MYSQL` and `mysql` -> `MySQL`
* rename refs to `master` branch -> `main`
* Fix English grammar
2021-12-24 11:56:57 +08:00
zeripath
a5df7ba6bf
Prevent NPE if gitea uploader fails to open url (#18080)
If http.Get() returns an error return nil and err before attempting to
use the broken file.

Thanks to walker xiong for spotting this bug.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-23 16:27:33 +00:00
zeripath
ffc08c1914
Do not read or write git reference files directly (#18079)
Git will and can pack references into packfiles and therefore if you write/read the
files directly you will get false results. Instead you should use update-ref and
show-ref. To that end I have created three new functions in git/repo_commit.go that
will do this correctly.

Related #17191

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-23 21:44:00 +08:00
99rgosse
e0cf3d86c4
Migrated Repository will show modifications when possible (#17191)
* Read patches to get history
2021-12-23 16:32:29 +08:00
zeripath
ba6efb105a
Quote references to the user table in consistency checks (#18072)
Although #17487 ensured that the table was quoted in the join it missed that the
query part of the check also needed to be quoted.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-22 23:52:57 +00:00
zeripath
d097fd6be6
Only create pprof files for gitea serv if explicitly asked for (#18068) 2021-12-22 11:48:12 -05:00
zeripath
62dcf1a6fb
Add NotFound handler (#18062)
PR #17997 means that urls with terminal '/' are no longer immediately mapped
to the url without a terminal slash. However, it has revealed that the NotFound handler
appears to have been lost.

This PR adds back in a NotFound handler that simply redirects to a path without the
terminal slash or runs the NotFound handler.

Fix #18060

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-22 10:39:28 +00:00
qwerty287
a9ed1c5c7c
Add API to get file commit history (#17652)
Adds an API endpoint `api/v1/repos/{owner}/{repo}/git/history/{filepath}` to get the commits affecting the given file or directory.

Closes https://github.com/go-gitea/gitea/issues/16206 and closes https://github.com/go-gitea/gitea/issues/16703
2021-12-22 06:17:33 +00:00
GiteaBot
d155ffc610 [skip ci] Updated translations via Crowdin 2021-12-22 00:28:37 +00:00
mscherer
cb05d3a23a
Add List-Unsubscribe header (#17804)
Fixes #13283

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-21 22:53:03 +00:00
Gusted
7be82f4af8
Avoid running go vet twice (#18059) 2021-12-21 13:22:33 -05:00
6543
7821370c0b
[Frontport] Changelog v1.15.8 (#18052)
* Changelog v1.15.8

* bump version
2021-12-21 16:08:48 +08:00
Gusted
273bef1be3
Fix continuance tests (#18027) 2021-12-20 22:12:27 -05:00
techknowlogick
d8ae769dda
update docker image to latest go version (#18048) 2021-12-20 22:11:10 -05:00
zeripath
7cc7f0ed75
TestRepository_GetTag intermittently panics due to an NPE (#18043)
There are repeated panics in tests due to TestRepository_GetTag failing
to run properly.  This happens when we attempt to reset the internal
repo for a tag which has failed to load. The problem is - the panic that
this is causing is preventing us from finding what the real error is.

This PR simply moves the failure out so we have a chance to see what
really is failing.

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-21 11:10:16 +08:00
zeripath
bef93abd49
Ensure that git repository is closed before transfer (#18049)
Repository Transfer requires that the repository directory is renamed - which
is not possible on Windows if the git repository is open.

Fix #17885

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-21 10:01:58 +08:00
GiteaBot
be91df42d1 [skip ci] Updated translations via Crowdin 2021-12-21 00:28:39 +00:00
mscherer
57d0461ac7
Make test work with different default branch config (#18038)
* Make test work with different default branch config

On a system configured with a different default branch name, doGitInitTestRepository
will create a repository with a branch named differently, and so further tests
would break:

  --- FAIL: TestGit/HTTP/PushCreate/SuccessfullyPushAndCreateTestRepository (0.02s)
      git_helper_for_declarative_test.go:167:
          	Error Trace:	git_helper_for_declarative_test.go:167
          	Error:      	Received unexpected error:
          	            	exit status 1 - error: src refspec master does not match any
          	            	error: failed to push some refs to 'http://127.0.0.1:3003/user2/repo-tmp-push-create-http.git'
          	Test:       	TestGit/HTTP/PushCreate/SuccessfullyPushAndCreateTestRepository
  git_test.go:587:
      	Error Trace:	git_test.go:587
      	Error:      	Received unexpected error:
      	            	repository does not exist [id: 0, uid: 0, owner_name: user2, name: repo-tmp-push-create-http]
      	Test:       	TestGit/HTTP/PushCreate

* Update integrations/git_helper_for_declarative_test.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-12-20 20:55:05 +00:00
silverwind
3f34f09537
Extract CodeMirror styles (#17960)
- Extract CodeMirror-related styles to separate files
- Generalize CodeMirror styles where possible
- Improve fullscreen and side-by-side mode for dark theme

Co-authored-by: 6543 <6543@obermui.de>
2021-12-20 20:07:49 +00:00
6543
660c30db80
Migration 204 use Sync2 (#18044)
* format nit

* Sync2
2021-12-20 18:58:38 +01:00
zeripath
0ac845042e
Move POST /{username}/action/{action} to simply POST /{username} (#18045)
The current code unfortunately requires that `action` be a reserved
repository name as it prevents posts to change the settings for
action repositories. However, we can simply change action handler
to work on POST /{username} instead.

Fix #18037

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-20 17:18:26 +00:00
Lunny Xiao
ce840bb177
Fix delete u2f keys modal (#18040) 2021-12-20 14:49:06 +00:00
zeripath
bcc13f3889
Reset Session ID on login (#18018)
* Reset Session ID on login

When logging in the SessionID should be reset and the session cleaned up.

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

* with new session.RegenerateID function

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

* update go-chi/session

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

* Ensure that session id is changed after oauth data is set and between account linking pages too

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

* placate lint

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

* as per review

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-20 22:12:26 +08:00
Vitaly Zhuravlev
2cd1479e77
Add grafana gitea-mixin (#17758)
This PR adds gitea-mixin, configurable Grafana dashboards (and potentially prometheus alerts+recording rules) based on Gitea [metrics](https://docs.gitea.io/en-us/config-cheat-sheet/#metrics-metrics).

The overview dashboard is described using jsonnet and grafonnet library: https://grafana.github.io/grafonnet-lib/

Mixins help to define dashboard and alerts as code so they can be collaboratively improved by the users.

![image](https://user-images.githubusercontent.com/14870891/142862822-fe57b384-c74a-4103-8548-033e92f90751.png)

__
## Generate config files

You can manually generate dashboards, but first you should install some tools:

```bash
go get github.com/jsonnet-bundler/jsonnet-bundler/cmd/jb
go get github.com/google/go-jsonnet/cmd/jsonnet
# or in brew: brew install go-jsonnet
```

For linting and formatting, you would also need `mixtool` and `jsonnetfmt` installed. If you
have a working Go development environment, it's easiest to run the following:

```bash
go get github.com/monitoring-mixins/mixtool/cmd/mixtool
go get github.com/google/go-jsonnet/cmd/jsonnetfmt
```

The files in `dashboards_out` need to be imported
into your Grafana server.  The exact details will be depending on your environment.

Edit `config.libsonnet` (for example, list of Gitea metrics to be shown under stats can be adjusted). if required and then build JSON dashboard files for Grafana:

```bash
make
```


For more about mixins, please see:
https://github.com/monitoring-mixins/docs
https://www.youtube.com/watch?v=GDdnL5R_l-Y* add gitea mixin

* remove alerts/rules

* gitea-mixin: add interval factor of 1/2 to remove duplicated change events

* gitea-mixin: fix changes panel, add aggregation interval for changes panel

* gitea-mixin: add totals singlestat

* gitea mixin: switch change graph to timeseries type

* add color overrides for issue labels

* bump grafonnet version

* gitea-mixin: convert graphs to timeseries

* gitea-mixin:  make fmt

* gitea-mixin: add .PHONE in Makefile

* gitea-mixin: add time configration

* gitea-mixin: make fmt and collapse addPanel grid

* gitea-mixin: add static ids for shared panels

* gitea-mixin: add flags showIssuesByRepository, showIssuesByLabel to show/hide corresponding panels

* gitea-mixin: update aggregation interval

* gitea-mixin: update defaults

* gitea-mixin: update panel names

* rename dir to gitea-monitoring-mixin

* gitea-mixin: add gitea_issues_open, gitea_issues_closed metrics

* gitea-mixin: update visible name for datasource

* gitea-mixin: update README

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-12-20 07:52:33 +00:00
Gusted
ff2fd08228
Simplify parameter types (#18006)
Remove repeated type declarations in function definitions.
2021-12-20 04:41:31 +00:00
zeripath
25677cdc5b
Update chroma (#18033)
Update chroma to 0.9.4

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-20 02:49:38 +00:00
zeripath
fb5f7791ef
Prevent off-by-one error on comments on newly appended lines (#18029)
* Prevent off-by-one error on comments on newly appended lines

There was a bug in CutDiffAroundLine whereby if a file without a terminal new line
has a patch which appends lines to it and a comment is placed on one of those lines
the comment diff will be a line out of place.

This fixes CutDiffAroundLine to simply ignore the missing terminal newline - however,
we should really improve this rendering to add a marker to say that there was a
previously missing terminal newline.

Fix #17875

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-20 02:15:49 +00:00
zeripath
e4e411821d
Abort merge if head has been updated before pressing merge (#18032)
* Abort merge if head has been updated before pressing merge

It is possible that a PR head may be pushed to between the merge page being shown
and the merge button being pressed. Pass the current expected head in as a parameter
and cancel the merge if it has changed.

Fix #18028

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

* adjust swagger

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

* fix test

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

* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-20 08:32:54 +08:00
techknowlogick
b24a965b81
no need for docker image mirror (#18031)
Co-authored-by: zeripath <art27@cantab.net>
2021-12-19 16:53:15 -05:00
zeripath
147e42239f
Stop printing 03d after escaped characters in logs (#18030)
Strangely a weird bug was present in the log escaping code whereby any escaped
character would gain 03d - this was due to a mistake in the format string where
it should have read %03o but read instead %o03d. This has led to spurious 03d
trailing characters on these escaped characters!

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-19 21:00:22 +00:00
zeripath
1c7db70835
Reset locale on login (#18023)
* Reset locale on login

Fix #18020

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

* Update routers/web/user/auth.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
2021-12-19 13:31:43 +00:00
Wim
6fe756dc93
Add support for ssh commit signing (#17743)
* Add support for ssh commit signing

* Split out ssh verification to separate file

* Show ssh key fingerprint on commit page

* Update sshsig lib

* Make sure we verify against correct namespace

* Add ssh public key verification via ssh signatures

When adding a public ssh key also validate that this user actually
owns the key by signing a token with the private key.

* Remove some gpg references and make verify key optional

* Fix spaces indentation

* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Update templates/user/settings/keys_ssh.tmpl

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Update options/locale/locale_en-US.ini

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Update models/ssh_key_commit_verification.go

Co-authored-by: Gusted <williamzijl7@hotmail.com>

* Reword ssh/gpg_key_success message

* Change Badsignature to NoKeyFound

* Add sign/verify tests

* Fix upstream api changes to user_model User

* Match exact on SSH signature

* Fix code review remarks

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-12-19 00:37:18 -05:00
zeripath
f1e85622da
Improve TestPatch to use git read-tree -m and implement git-merge-one-file functionality (#18004)
The current TestPatch conflict code uses a plain git apply which does not properly
account for 3-way merging. However, we can improve things using `git read-tree -m` to
do a three-way merge then follow the algorithm used in merge-one-file. We can also use 
`--patience` and/or `--histogram` to generate a nicer diff for applying patches too.

Fix #13679
Fix #6417

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-19 05:19:25 +01:00
GiteaBot
487ce3b49e [skip ci] Updated licenses and gitignores 2021-12-19 00:29:01 +00:00
silverwind
9296baf65a
Change <a> elements to underline on hover (#17898)
Fomantic brings a opinionated style that removed underline on mouse
hover which I think is important UX to have.

This re-enables the underline in the Fomantic config and fixes a few
cases where underline was deemed disruptive.
2021-12-18 05:29:00 +00:00
GiteaBot
8662ff68da [skip ci] Updated translations via Crowdin 2021-12-18 00:28:35 +00:00
Lunny Xiao
b300e3f485
Support open compare page directly (#17975)
* Support open compare page directly

* simple code

* Some improvements

Co-authored-by: 6543 <6543@obermui.de>
2021-12-17 22:20:27 +00:00
qwerty287
4cbc865d83
Add option to define refs in issue templates (#17842)
Adds a markdown header option `ref` that allows you to set the ref the issue should belong.
2021-12-17 21:29:09 +00:00
Gusted
4bbbf35654
Fix outType on gitea dump (#18000)
- Force to output the dump file to use the given `--type`.
- Resolves #17959
2021-12-17 13:38:45 +00:00
Lunny Xiao
a6d4a8546a
Fix rename notification bug (#18008) 2021-12-17 14:24:47 +08:00
zeripath
d29b689f81
Ensure complexity, minlength and ispwned are checked on password setting (#18005)
It appears that there are several places that password length, complexity and ispwned
are not currently been checked when changing passwords. This PR adds these.

Fix #17977

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-17 10:03:39 +08:00
Gusted
dab28c7049
Use JSON module instead of stdlib json (#18003) 2021-12-17 09:15:02 +08:00
zeripath
8354670708
Prevent hang in git cat-file if repository is not a valid repository and other fixes (#17991)
This PR contains multiple fixes. The most important of which is:

* Prevent hang in git cat-file if the repository is not a valid repository 
    
    Unfortunately it appears that if git cat-file is run in an invalid
    repository it will hang until stdin is closed. This will result in
    deadlocked /pulls pages and dangling git cat-file calls if a broken
    repository is tried to be reviewed or pulls exists for a broken
    repository.

    Fix #14734
    Fix #9271
    Fix #16113

Otherwise there are a few small other fixes included which this PR was initially intending to fix:

* Fix panic on partial compares due to missing PullRequestWorkInProgressPrefixes
* Fix links on pulls pages  due to regression from #17551 - by making most /issues routes match /pulls too - Fix #17983
* Fix links on feeds pages due to another regression from #17551 but also fix issue with syncing tags - Fix #17943
* Add missing locale entries for oauth group claims
* Prevent NPEs if ColorFormat is called on nil users, repos or teams.
2021-12-16 19:01:14 +00:00
zeripath
6e7d28cf3a
Prevent double decoding of % in url params (#17997)
There was an unfortunate regression in #14293 which has led to the double decoding
of url parameter elements if they contain a '%'. This is due to an issue
with the way chi decodes its RoutePath. In detail the problem lies in
mux.go where the routeHTTP path uses the URL.RawPath or even the
URL.Path instead of the escaped path to do routing.

This PR simply forcibly sets the routePath to that of the EscapedPath.

Fix #17938

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-16 17:40:18 +00:00
zeripath
e0e3ba6c12
Add Reindex buttons to repository settings page (#17494)
This PR adds reindexing request buttons to the repository settings page.

Fix #3796

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-16 23:55:12 +08:00
silverwind
3a3cbcfdf0
Set correct language for Dockerfile variants (#17999) 2021-12-16 04:52:01 -05:00
Caellion
e79272ab20
Fix TemplateRepo no longer in models.repo (#17993)
* Fixes error 500 that appears when trying to browse code of a repository generated from template

* forgot to update comment

* Update models/repo/repo.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>

* Update repo.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-16 15:12:50 +08:00
silverwind
cc129d2ca2
Make AvatarRenderedSizeFactor configurable and set it to 3 (#17951)
Save a bit of bandwidth by only requesting 3-times the rendered avatar
size. Factor 4 is only really beneficial on a handful of mobile phones
and I don't think they are the primary device we design for.

Configurability contributed by zeripath.

Fixes: https://github.com/go-gitea/gitea/pull/17422
Fixes: https://github.com/go-gitea/gitea/issues/16287

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-16 10:18:38 +08:00
GiteaBot
e78ee73d71 [skip ci] Updated translations via Crowdin 2021-12-16 00:28:34 +00:00
KN4CK3R
b748acf2a0
Fixed emoji alias not parsed in links (#16221)
* Do not skip links.

* Restrict text in links to emojis.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-12-15 23:49:12 +00:00
silverwind
f58e687a83
Shorten page title in file view (#17987)
Move the more relevant sections of the page title earlier which make it
possible to distinguish multiple tabs from each other when tab width is
limited.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-15 15:50:11 +08:00
wxiaoguang
4da1d97810
Refactor HTTP request context (#17979) 2021-12-15 14:59:57 +08:00
qwerty287
9d943bf374
Add missing X-Total-Count and fix some related bugs (#17968)
* Add missing `X-Total-Count` and fix some related bugs

Adds `X-Total-Count` header to APIs that return a list but doesn't have it yet.
Fixed bugs:
* not returned after reporting error (39eb82446c/routers/api/v1/user/star.go (L70))
* crash with index out of bounds, API issue/issueSubscriptions

I also found various endpoints that return lists but do not apply/support pagination yet:
```
/repos/{owner}/{repo}/issues/{index}/labels
/repos/{owner}/{repo}/issues/comments/{id}/reactions
/repos/{owner}/{repo}/branch_protections
/repos/{owner}/{repo}/contents
/repos/{owner}/{repo}/hooks/git
/repos/{owner}/{repo}/issue_templates
/repos/{owner}/{repo}/releases/{id}/assets
/repos/{owner}/{repo}/reviewers
/repos/{owner}/{repo}/teams
/user/emails
/users/{username}/heatmap
```
If this is not expected, an new issue should be opened.

Closes #13043

* fmt

* Update routers/api/v1/repo/issue_subscription.go

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

* Use FindAndCount

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
Co-authored-by: 6543 <6543@obermui.de>
2021-12-15 13:39:34 +08:00
GiteaBot
790e6cfeec [skip ci] Updated translations via Crowdin 2021-12-15 00:25:11 +00:00
KN4CK3R
bfe597c7b0
Use non-expiring key. (#17984) 2021-12-14 15:02:20 -05:00
zeripath
0981ec30c3
Add Option to synchronize Admin & Restricted states from OIDC/OAuth2 along with Setting Scopes (#16766)
* Add setting to OAuth handlers to override local 2FA settings

This PR adds a setting to OAuth and OpenID login sources to allow the source to
override local 2FA requirements.

Fix #13939

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

* Fix regression from #16544

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

* Add scopes settings

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

* fix trace logging in auth_openid

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

* add required claim options

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

* Move UpdateExternalUser to externalaccount

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

* Allow OAuth2/OIDC to set Admin/Restricted status

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

* Allow use of the same group claim name for the prohibit login value

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

* fixup! Move UpdateExternalUser to externalaccount

* as per wxiaoguang

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

* add label back in

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

* adjust localisation

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

* placate lint

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-12-14 16:37:11 +08:00
zeripath
b4782e24d2
Return nicer error for ForcePrivate (#17971) 2021-12-14 00:08:09 -05:00
KN4CK3R
8e9140dd69
Fixed wording. (#17973)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-14 09:45:39 +08:00
GiteaBot
bd475f5c9d [skip ci] Updated translations via Crowdin 2021-12-14 00:25:09 +00:00
zeripath
eba07867ef
Prevent deadlock in create issue (#17970) 2021-12-13 17:59:39 -05:00
dependabot[bot]
39eb82446c
Bump swagger-ui-dist from 4.1.2 to 4.1.3 (#17965) 2021-12-12 22:57:35 -05:00
qwerty287
c3eea2f8af
Improve behavior of "Fork" button (#17288)
* Improbe behaviour of fork button

* Apply suggestions from code review

* Remove old lines

* Apply suggestions

* Fix test

* Remove unnecessary or

* Update templates/repo/header.tmpl

Co-authored-by: silverwind <me@silverwind.io>

* Add comment

* Fix situation if you can't fork but don't have forks

* Fix lint

* Apply changes from #17783

* fmt

* fmt

* Apply tweaks

Co-authored by: silverwind <me@silverwind.io>

* Rm dupl css

* Fix build

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-13 09:59:09 +08:00
rinsuki
e0118b0d9b
Prefer "Hiragino Kaku Gothic ProN" in system-ui-ja (#17954) 2021-12-13 00:04:18 +01:00
Lunny Xiao
5723240490
Some repository refactors (#17950)
* some repository refactors

* remove unnecessary code

* Fix test

* Remove unnecessary banner
2021-12-12 23:48:20 +08:00
GiteaBot
0a7e8327a0 [skip ci] Updated licenses and gitignores 2021-12-12 00:25:18 +00:00
wxiaoguang
6d4172987e
Fix markdown URL parsing (#17924)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-12-11 19:21:36 +02:00
silverwind
379a5241c6
Fix overflow in commit graph (#17947)
* Fix overflow in commit graph

Limit commit message to 50% width. This is rather crude but should work
for common use cases with not too-long author names.

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

* Make it work with dynamic width

* use span

* use explicit none

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-11 16:12:18 +02:00
zeripath
f550e356d6
Prevent services/mailer/mailer_test.go tests from deleteing data directory (#17941)
Running `make test-backend` will delete `data/` due to reloading the configuration and resetting the appdatapath.

This PR removes this unnecessary config reload but also adds extra code in to the unittest main to prevent its cleanup from deleting the wrong directory.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-10 19:43:28 +00:00
Lunny Xiao
3ca5dc7e32
Move keys to models/asymkey (#17917)
* Move keys to models/keys

* Rename models/keys -> models/asymkey

* change the missed package name

* Fix package alias

* Fix test

* Fix docs

* Fix test

* Fix test

* merge
2021-12-10 16:14:24 +08:00
wxiaoguang
0a9fcf63a4
Clean legacy SimpleMDE code (#17926)
Since we are using EasyMDE now, we do not need to keep the SimpleMDE code anymore.

This PR removes all legacy SimpleMDE code, and makes some related changes:
* `createCommentEasyMDE` can accept native DOM element, and it doesn't need `jQuery.data` to store EasyMDE editor object (as discussed about the frontend guideline).
* introduce `getAttachedEasyMDE` to get the attached EasyMDE editor object, it's easier to find all the usage of EasyMDE.
* rename variable names from `$simplemde` to `easyMDE`, the `$` was incorrect because it is a EasyMDE editor, not a jQuery object.

With this PR, it will be easier to do more refactoring or replacing EasyMDE with other editors.
2021-12-10 10:51:27 +08:00
Lunny Xiao
719bddcd76
Move repository model into models/repo (#17933)
* Some refactors related repository model

* Move more methods out of repository

* Move repository into models/repo

* Fix test

* Fix test

* some improvements

* Remove unnecessary function
2021-12-10 09:27:50 +08:00
GiteaBot
fb8166c6c6 [skip ci] Updated translations via Crowdin 2021-12-10 00:25:26 +00:00
wxiaoguang
c7e23401a3
Fix a panic in NotifyCreateIssueComment (caused by string truncation) (#17928)
* Fix a panic in NotifyCreateIssueComment (caused by string truncation)

* more unit tests

* refactor

* fix some edge cases

* use SplitStringAtByteN for comment content
2021-12-09 05:41:17 +00:00
GiteaBot
183175263d [skip ci] Updated translations via Crowdin 2021-12-09 00:25:09 +00:00
qwerty287
d2d9bc846e
Use disable_form_autofill on Codebase and Gitbucket (#17936)
Removes the old fake input on the Codebase migration screen, and adds the disable_form_autofill
2021-12-08 22:33:14 +00:00
zeripath
9e6e1dc950
Improve checkBranchName (#17901)
The current implementation of checkBranchName is highly inefficient
involving opening the repository, the listing all of the branch names
checking them individually before then using using opened repo to get
the tags.

This PR avoids this by simply walking the references from show-ref
instead of opening the repository (in the nogogit case).

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-08 19:08:16 +00:00
Garionion
b59875aa12
allways set a message-id on mails (#17900)
* allways set a message-id on mails
* Add unit tests for mailer & Message-ID

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-08 15:34:23 +08:00
Anbraten
0ff18a808c
Support sorting for project board issuses (#17152)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-08 14:57:18 +08:00
wxiaoguang
4cbe792562
Remove unnecessary X-Remote HTTP header in AJAX request (#17932) 2021-12-08 14:18:07 +08:00
wxiaoguang
a6f961fba4
Refactor install page (db type) (#17919)
* Refactor install page (db type)

* set correct default DB HOST for different DB TYPE
* remove legacy TiDB from documents
* unify the usage of DB TYPE, in code we only use "mysql". "MySQL" is only shown to users for friendly name.

* Gitea can use TiDB via MySQL protocol

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-07 13:44:08 +08:00
GiteaBot
b30870ef8b [skip ci] Updated translations via Crowdin 2021-12-07 00:25:13 +00:00
John Olheiser
eb69c7ec8c
Allow default branch to be inferred on compare page (#17908)
* Allow default branch to be inferred

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add test for inferred default branch

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-06 11:04:07 -06:00
silverwind
12a42baa5e
Apply CSS Variables to all message elements (#17920)
Fixes #17918. Applies color variables to all ui message on both themes.
The colorization on .segment is a customization not present in fomantic
ui, only used on user/repo/org delete pages.
2021-12-06 23:49:30 +08:00
Lunny Xiao
dcdb4873c8
Move repo archiver to models/repo (#17913)
* Move repo archiver to models/repo

* Move archiver service into services/repository/

* Fix imports

* Fix test

* Fix test
2021-12-06 15:19:28 +08:00
mscherer
f49d160447
Replace "unix" by "http+unix" for PROTOCOL (#17771) 2021-12-05 23:46:11 -05:00
Gusted
9d6208965c
Fix loading content history on show more (#17819)
* Fix loading content history on show more

- Call `initRepoIssueContentHistory` so that the newly loaded issues
also get their content history.
- Resolves #17767

* apply history to show diff too

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-12-06 11:57:51 +08:00
techknowlogick
6255ff8c6b
update xgo to use 1.17 (#17915) 2021-12-05 19:48:38 -05:00
GiteaBot
6c34f6b954 [skip ci] Updated translations via Crowdin 2021-12-06 00:24:54 +00:00
wxiaoguang
11d519b385
Test cache during init (#17852) 2021-12-06 00:24:57 +08:00
Lunny Xiao
b4a32afec1
Display issue/comment role even if repo archived (#17907) 2021-12-05 17:04:02 +02:00
GiteaBot
98d903a3c6 [skip ci] Updated licenses and gitignores 2021-12-05 00:25:15 +00:00
wxiaoguang
a1dca00974
fix i18n (#17906) 2021-12-04 23:24:10 +08:00
silverwind
8d85a62e4d
Fix svg colors in file list table (#17903)
* Fix svg colors in file list table

Turns out this can be fixed by just removing rules. Directory and file
icons have other rules that still make them color correctly.

* tweak color on file icons

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-04 21:17:22 +08:00
silverwind
f7094c8161
Update JS dependencies, adjust eslint config (#17904)
- Update all JS dependencies to latest versions
- Add new lint rules, enable es2022 eslint parser features
- Disable github/no-then, I feel the rule was too restricting
2021-12-04 14:43:14 +08:00
GiteaBot
c7c723c548 [skip ci] Updated translations via Crowdin 2021-12-04 00:26:13 +00:00
wxiaoguang
aa79738a66
Fix the bug: no wiki page can be created if the repo didn't have any page yet. (#17894) 2021-12-03 20:46:11 +01:00
singuliere
1a78e23355
tests: more integration tests for notifications (#17845)
Verify that multiple status-types are taken into account as expected.

Refs: https://github.com/go-gitea/gitea/issues/16796
2021-12-03 20:20:41 +01:00
silverwind
4f81c7dffe
Render issue references in file table (#17897)
Fixes #17887
2021-12-04 00:15:53 +08:00
wxiaoguang
5f22e2dfb2
Improve seek-help documents (#17895)
* Add pprof information to seek-help documents 
* Improve zh-cn and zh-tw documents
2021-12-03 21:04:32 +08:00
n
6791aae8de
Add hints for special Wiki pages (#17283)
* Add UI hints to create a Wiki sidebar and footer
2021-12-03 15:28:54 +08:00
KN4CK3R
6ceef87671
Removed SizeFmt. (#17890)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-12-03 11:33:34 +08:00
6543
03ec9e5060
Changelog for v1.15.7 (#17871) (#17889)
* Changelog for v1.15.7 (#17871)

* Changelog for v1.15.7

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>

* update version in docs

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-12-02 20:49:59 -05:00
GiteaBot
365b16cde1 [skip ci] Updated translations via Crowdin 2021-12-03 00:25:09 +00:00
KN4CK3R
87be76213a
Add migrate from Codebase (#16768)
This PR adds [Codebase](https://www.codebasehq.com/) as migration source.

Supported:
- Milestones
- Issues
- Pull Requests
- Comments
- Labels
2021-12-02 23:24:02 +01:00
zeripath
957c3fcb59
Update chi/middleware to chi/v5/middleware (#17888)
Fix #17880


Co-authored-by: Lauris BH <lauris@nix.lv>
2021-12-02 21:58:08 +01:00
delvh
4646c7c52d
Use fmt.Sprintf correctly (#17886) 2021-12-02 20:36:50 +01:00
KN4CK3R
fbf3208229
Added missing data- prefix. (#17884) 2021-12-03 00:36:00 +08:00
Lunny Xiao
4f98e82427
Check if column exist before rename if exist, just return with no error (#17870)
* Check if column exist before rename if exist, just return with no error

* Also check if errors column exist

* Add comment for migration

* Fix sqlite test
2021-12-02 21:17:24 +08:00
mscherer
34b5436ae1
Refactor various strings (#17784)
Fixes #16478

Co-authored-by: Gusted <williamzijl7@hotmail.com>

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-12-02 15:28:08 +08:00
a1012112796
ba57e30f13
fix 500 error while use a reserved name in org rename (#17878)
fix #17876

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-12-02 10:43:43 +08:00
GiteaBot
7026a30fdc [skip ci] Updated translations via Crowdin 2021-12-02 00:25:09 +00:00
zeripath
7d0629adf8
Use shadowing script for docker (#17846)
Too many docker users are caught out by the default location for the
app.ini file being environment dependent so that when they docker exec
into the container the gitea commands do not work properly and require
additional -c arguments to correctly pick up the configuration.

This PR simply shadows the gitea binary using variants of the FHS
compatible script to make the command gitea have the default locations
by default.

Fix #14468
Reference #17497
Reference #12082
Reference #8941
... amongst others ...
Replace #17501

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-12-01 18:08:27 +00:00
wxiaoguang
042cac5fed
Improve install code to avoid low-level mistakes. (#17779)
* Improve install code to avoid low-level mistakes.

If a user tries to do a re-install in a Gitea database, they gets a warning and double check.
When Gitea runs, it never create empty app.ini automatically.

Also some small (related) refactoring:

* Refactor db.InitEngine related logic make it more clean (especially for the install code)
* Move some i18n strings out from setting.go to make the setting.go can be easily maintained.
* Show errors in CLI code if an incorrect app.ini is used.
* APP_DATA_PATH is created when installing, and checked when starting (no empty directory is created any more).
2021-12-01 15:50:01 +08:00
GiteaBot
a3517d8668 [skip ci] Updated translations via Crowdin 2021-12-01 00:25:14 +00:00
silverwind
3fd502cca8
Rework commit page header (#17849)
- Remove blue background and use regular header styling
- Use flexbox on author and signature segments
- Add shield-type icons besides gpg key, replacing icon font icons
- Ensure author and signature line are same height
- Remove erronous green background on arc-green signature line
- Turn signing colors into CSS variables
- Consolidate the two warning states into one

Co-authored-by: zeripath <art27@cantab.net>
2021-12-01 01:40:17 +02:00
zeripath
01087e9eef
Make Requests Processes and create process hierarchy. Associate OpenRepository with context. (#17125)
This PR registers requests with the process manager and manages hierarchy within the processes.

Git repos are then associated with a context, (usually the request's context) - with sub commands using this context as their base context.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-30 20:06:32 +00:00
silverwind
d894c90b70
Fix position of label color picker colors (#17866) 2021-11-30 17:54:00 +00:00
singuliere
64b7d0de8e
docs: modules do not rely on models, services do (#17861)
services: provide some services for users, usually use
database (models) modules: provide some basic functions without
database, eg: code parser, etc The major difference is services use
database, while modules don’t.

Signed-off-by: singuliere <singuliere@autistici.org>
2021-11-30 11:56:12 +00:00
silverwind
9ecfc54a8f
Refactor commit graph styling to use css variables (#17860)
- Use common variables for colors and font
- Alter graph color 5 to provide enough contrast on both themes
2021-11-30 10:47:18 +08:00
GiteaBot
eb8513a690 [skip ci] Updated translations via Crowdin 2021-11-30 00:25:14 +00:00
silverwind
4a6bd60df0
Remove whitespace inside rendered code <td> (#17859)
This extra whitespace caused isses in Firefox where it would copy a
extra space character at the start and the end. Additionally, in Chrome,
the text selection indicated a spaced on the end of the selection where
there was none. Both issues are fixed with the removal of whitespace.
2021-11-30 00:01:56 +02:00
fnetX (aka fralix)
830ab75ce0
Switch archive URL code back to href attributes (#17796)
* Add fallback href link
* Switch async archive generation to use href links
* Edit all templates to use href instead of data-url for archives
* Add consistent rel="nofollow" as per wxiaoguang
2021-11-29 21:50:43 +08:00
zeripath
b5a9ee94fd
Make Co-committed-by and co-authored-by trailers optional (#17848)
This PR adds another option to app.ini make co-committed-by and co-authored-by trailers
optional on a per server basis.

Fix #17194

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-29 07:09:55 +00:00
qwerty287
3fec2cb3d3
Fix various typos in docs (#17844) 2021-11-28 18:43:18 -05:00
Lunny Xiao
9defddb286
Move more model into models/user (#17826)
* Move more model into models/user

* Remove unnecessary comment

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-28 22:11:58 +08:00
qwerty287
b1df890951
Docs: replace gitea with Gitea (#17838)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-28 21:28:30 +08:00
Lunny Xiao
1fee11d69a
Move accessmode into models/perm (#17828) 2021-11-28 12:58:28 +01:00
qwerty287
24a8d54bfb
Disable ref selection dropdown if you don't have permissions to use it (#17837)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-28 12:13:13 +08:00
Galen Suen
fbadc1a198
Fix value of User.IsRestricted to default setting when oauth2 user auto registration; (#17839) 2021-11-28 11:27:48 +08:00
zeripath
72d82c5b6f
Handle relative unix socket paths (#17836)
Make relative unix sockets absolute by making them absolute against the AppWorkPath

Fix #17833

## ⚠️ BREAKING ⚠️ 

Prior to this PR relative unix sockets would have been asserted to be relative to the current working directory that gitea, gitea serv, hook and manager etc were running in. Hooks and Serv would have failed to work properly under this situation so we expect that although this is a technically breaking change the previous situation was already broken.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-27 20:22:03 +00:00
mscherer
04c55e97a2
Fix code formating (#17830)
* fix formatter, format imports first, then go fmt
2021-11-27 19:59:51 +08:00
Gabriel Vasile
2e8fc5b034
Replace regex usage for MIME parsing (#17831)
MIME types can have multiple optional parameters, eg:
    video/webm; codecs="w/e codec"; charset="binary"
This commit replaces the usage of regex for getting the "type/subtype"
with mime.ParseMediaType.
2021-11-27 19:12:43 +08:00
GiteaBot
789d251ae4 [skip ci] Updated translations via Crowdin 2021-11-27 00:25:11 +00:00
mscherer
1f0dab2116
Implement Well-Known URL for password change (#17777)
* Implement Well-Known URL for password change

Fixes #11804
2021-11-26 22:55:11 +08:00
Jimmy Praet
fcc11253ac
Add archived label for code search results in archived repo's (#17817)
* Add archived label for code search results in archived repo's

* Remove trailing whitespace

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-11-26 16:49:31 +08:00
Lunny Xiao
371ebce252
Fix database inconsistent when admin change user email (#17549) 2021-11-25 20:56:16 -05:00
GiteaBot
f23851f690 [skip ci] Updated translations via Crowdin 2021-11-26 00:25:09 +00:00
Lunny Xiao
6c21961462
org settings -> webhook/labels/deletion should also active the menu (#17809) 2021-11-25 23:15:58 +08:00
KN4CK3R
e8f1f09132
Fixed org styles. (#17807)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-25 21:05:04 +08:00
wxiaoguang
edd37e9d4a
Fix org webchatwork webhook (#17810) 2021-11-25 04:25:25 -05:00
ThetaDev
af901a4ca9
Detect dark theme via css variable (#17800)
* detect dark theme via css variable
* minor refactor, add documentation

If your custom theme is considered a dark theme, set the global css variable `--is-dark-theme` to `true`.
This allows gitea to adjust the Monaco code editor's theme accordingly.
2021-11-25 15:14:48 +08:00
qwerty287
e0f81b4ef4
Allow forks to org if you can create repos (#17783) 2021-11-25 13:03:03 +08:00
Gusted
4b4997c73e
Use correct user on releases (#17806)
- Use the provided `doer` instead of `rel.Publisher`. The code will also
run on edited releases and deleted ones, which isn't necessary done by
`rel.Publisher`.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-25 12:17:16 +08:00
GiteaBot
4f99697888 [skip ci] Updated translations via Crowdin 2021-11-25 00:25:19 +00:00
Lunny Xiao
49933c7fb0
Create menus for organization pages (#17802)
* Create menus for organization pages

* Fix frontend lint

* Fix frontend lint
2021-11-25 00:12:54 +08:00
silverwind
71ed96b0d5
Preserve color when inverting emojis (#17797)
Fixes: https://github.com/go-gitea/gitea/issues/17795
2021-11-24 20:42:03 +08:00
Lunny Xiao
a666829a37
Move user related model into models/user (#17781)
* Move user related model into models/user

* Fix lint for windows

* Fix windows lint

* Fix windows lint

* Move some tests in models

* Merge
2021-11-24 17:49:20 +08:00
Gusted
4e7ca946da
Use *PushUpdateOptions as receiver (#17724) 2021-11-24 04:08:13 -05:00
Lunny Xiao
c97d66d23c
Move repofiles from modules/repofiles to services/repository/files (#17774)
* Move repofiles from modules to services

* rename services/repository/repofiles -> services/repository/files

* Fix test

Co-authored-by: 6543 <6543@obermui.de>
2021-11-24 15:56:24 +08:00
qwerty287
754fdd8f9c
Fix visibility of org avatars (#17789)
* Fix visibility of org avatar

* more clear syntax

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-24 11:51:08 +08:00
Gusted
21f4401f3e
Use correct Sender on webhook change title (#17791)
As title, thanks to @mscherer for pointing out the incorrect code.
2021-11-24 10:47:03 +08:00
GiteaBot
3d996c85a5 [skip ci] Updated translations via Crowdin 2021-11-24 00:25:19 +00:00
KN4CK3R
429ef43793
Use new OneDev /milestones endpoint (#17782)
OneDev changed the API which fails every build at the moment.
2021-11-23 20:28:06 +01:00
techknowlogick
2dae5b715c
Fix keys test (#17776) 2021-11-23 08:12:02 +00:00
zeripath
188fd2dd1a
Add PULL_LIMIT and PUSH_LIMIT to cron.update_mirror task (#17568) 2021-11-22 22:09:35 -05:00
silverwind
9450410ff7
Improve ellipsis buttons (#17773)
* Improve ellipsis buttons

- Remove icon font usage
- Add aria-expanded attribute

* rename function to match

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-22 21:44:38 -05:00
mscherer
e595986458
Harden authorized keys a bit more (#17772)
sshd(8) list restrict as a future-proof way to restrict feature
enabled in ssh. It is supported since OpenSSH 7.2, out since
2016-02-29.

OpenSSH will ignore unknown options (see sshauthopt_parse in
auth-options.c), so it should be safe to add the option and
no-user-rc.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-22 21:44:26 -05:00
velengel
a1f5c7bfce
Add copy Commit ID button in commits list (#17759)
* fix: implement commit id copy to clipboard

* fix: remove abundant attributes / consider edge-case

* fix: locale_en fixed

* fix: use ui button

* tune copy button

* fix: button size

* Fix merge

Co-authored-by: Ysmr-Ry <ryo.yossy@live.jp>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-22 21:44:10 -05:00
Lunny Xiao
b2daa7e203
Add documentation for backend development (#17512)
* Add documentation for backend development

* Update backend guidline

* More sections

* Add modules/setting and modules/git

* Uniform gitea as Gitea

* some improvements

* some improvements
2021-11-23 10:10:18 +08:00
GiteaBot
c79cc2d3e8 [skip ci] Updated translations via Crowdin 2021-11-23 00:31:08 +00:00
zeripath
1dbc58f742
More pleasantly handle broken or missing git repositories (#17747)
* More pleasantly handle broken or missing git repositories

In #17742 it was noted that there a completely invalid git repository underlying a
repo on gitea.com. This happened due to a problem during a migration however, it
is not beyond the realms of possibility that a corruption could occur to another
user.

This PR adds a check to RepoAssignment that will detect if a repository loading has
failed due to an absent git repository. It will then show a page suggesting the user
contacts the administrator or deletes the repository.

Fix #17742

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

* Update options/locale/locale_en-US.ini

Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-22 22:32:16 +00:00
Lunny Xiao
baed01f247
Remove unnecessary attributes of User struct (#17745)
* Remove unnecessary functions of User struct

* Move more database methods out of user struct

* Move more database methods out of user struct

* Fix template failure

* Fix bug

* Remove finished FIXME

* remove unnecessary code
2021-11-22 23:21:55 +08:00
Lunny Xiao
c2ab19888f
Support pagination of organizations on user settings pages (#16083)
* Add pagination for user setting orgs
* Use FindOrgs instead of GetOrgsByUserID
* Remove unnecessary functions and fix test
* remove unnecessary code
2021-11-22 21:51:45 +08:00
Gusted
ed23a6c397
Make bind error more readable (#17750)
- Add the related fieldNames into the response JSON, such that the developer can figure out what's going on.
- Related:
https://github.com/go-gitea/gitea/issues/17126#issuecomment-937848295
2021-11-22 21:05:29 +08:00
Jimmy Praet
a3efd048a7
Improvements to content history (#17746)
* Improvements to content history

* initialize content history when making an edit to an old item created before the introduction of content history
* show edit history for code comments on pull request files tab

* Fix a flaw in keepLimitedContentHistory
Fix a flaw in keepLimitedContentHistory, the first and the last should never be deleted

* Remove obsolete eager initialization of content history
2021-11-22 20:20:16 +08:00
wxiaoguang
49b2cb998b
Fix project board bug and improve documents (#17753)
* the project board was broken, this PR fixes it, and refactor the code, and we prevent the uncategorized column from being dragged.
* improve the frontend guideline (as discussed in https://github.com/go-gitea/gitea/pull/17699)
2021-11-22 19:40:17 +08:00
Gusted
8244cfb8eb
Fix navbar on project view (#17749)
- Shows that the project nav item is active when you're viewing a project.
2021-11-22 18:57:05 +08:00
Gusted
58ff86ed4d
Exclude from watching tests (#17744) 2021-11-22 05:17:21 -05:00
techknowlogick
499b05da22
Add user settings key/value DB table (#16834) 2021-11-22 04:47:23 -05:00
silverwind
a159c3175f
Add new JS linter rules (#17699)
* Add new JS linter rules

Adds a few useful rules from eslint-plugin-github. Notable changes:

- Forbid dataset usage, its camel-casing behaviour makes it hard to
  grep for attributes.
- Forbid .then() and .catch(), we should generally prefer await for new
  code. For rare cases where they are useful, a eslint-disable-line
  directive can be set.
- Add docs js to linting

* also enable github/array-foreach

* small tweak

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-22 16:19:01 +08:00
Gusted
7743f13bed
Use f variant to parse formatting (#17751)
As title.
2021-11-22 14:18:31 +08:00
GiteaBot
55e9228866 [skip ci] Updated translations via Crowdin 2021-11-22 00:24:56 +00:00
zeripath
8511eec4d4
Allow Loading of Diffs that are too large (#17739)
* Allow Loading of Diffs that are too large

This PR allows the loading of diffs that are suppressed because the file
is too large. It does not handle diffs of files which have lines which
are too long.

Fix #17738

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-22 00:51:08 +08:00
Lunny Xiao
d710af6669
Remove NewSession method from db.Engine interface (#17577)
* Remove NewSession method from db.Engine interface

* Fix bug

* Some improvements

* Fix bug

* Fix test

* Use XXXBean instead of XXXExample
2021-11-21 23:41:00 +08:00
Lunny Xiao
0add627182
Fix close issue but time watcher still running (#17643)
* Fix close issue but time watcher still running

* refactor stopwatch codes

* Fix test

* Fix test

* Fix typo

* Fix test
2021-11-21 17:11:48 +08:00
GiteaBot
ab09296d37 [skip ci] Updated licenses and gitignores 2021-11-21 00:25:17 +00:00
zeripath
0fa41b6dc4
Reset locale on login (#17734)
When logging in reset the user's locale to ensure that it matches their
preferred locale.

Fix #15612

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-20 21:32:37 +00:00
zeripath
f8ec43dbc7
Extract constant names out for the ReverseProxy and Basic authentication methods (#17735)
In order to reduce load on the GC extract out the constant names of the Basic and ReverseProxy methods.

As mentioned in https://github.com/go-gitea/gitea/pull/15119#discussion_r730352176

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-20 23:33:18 +08:00
zeripath
931d0cf854
Enable show more files in diff for git <2.31 (#17733)
Unfortunately due to a misread on my behalf I missed that git diff only learned
--skip-to in version 2.31.0. Thus this functionality was not working on older versions
of git.

This PR adds a handler that simply allows for us to skip reading the diffs until
we find the correct file to skip to.

Fix #17731

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-20 13:50:00 +00:00
zeripath
0d69e64e03
Make a.add-code-comment click handler an event handler (#17737)
Instead of directly attaching the add-code-comment on click handler to
the a.add-code-comment elements - make this an event handler on the
document instead.

Fix #17736

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-20 20:12:59 +08:00
wxiaoguang
013fb73068
Use hostmatcher to replace matchlist, improve security (#17605)
Use hostmacher to replace matchlist.

And we introduce a better DialContext to do a full host/IP check, otherwise the attackers can still bypass the allow/block list by a 302 redirection.
2021-11-20 17:34:05 +08:00
zeripath
c96be0cd98
Make SSL cipher suite configurable (#17440) 2021-11-20 01:12:43 -05:00
Gusted
9f14fe43c6
Fix correct usage of teams (#17732)
- `.Teams` isn't a field on the User type, thus using the seperate
loaded teams.
- Add a space between `PathEscape` and argument.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-20 11:13:24 +08:00
GiteaBot
52869ef386 [skip ci] Updated translations via Crowdin 2021-11-20 00:25:08 +00:00
wxiaoguang
a8fd76557b
Better builtin avatar generator (#17707)
This PR fixes the builtin avatar generator.

1. The random background color makes some images very dirty. So now we only use white background for avatars.
2. We use left-right mirror avatars to satisfy #14799
3. Fix a small padding error in the algorithm
2021-11-20 01:10:41 +08:00
zeripath
38347aa16f
Add settings to allow different SMTP envelope from address (#17479)
* Add settings to allow different SMTP envelope from address

Sometimes it may be advisable to hide or alias the from address on an SMTP mail
envelope. This PR adds two new options to the mailer to allow setting of an overriding
from address.

Fix #17477

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-19 23:35:20 +08:00
Paweł Bogusławski
d4e281bc02
Allow Token API calls be authorized using the reverse-proxy header (#15119)
* API calls authorized with HTTP header

This mod allows API calls to be authorized with HTTP header
when ENABLE_REVERSE_PROXY_AUTHENTICATION is enabled. Without
it user authenticated by reverse proxy is able to access
gitea UI but not API which is inconsistent.

Author-Change-Id: IB#1107572

* Fixed API calls authorized with HTTP header

Only reqBasicAuth is modified to allow reverse proxy
auth as alternative and reqToken is left untouched.

Fixes: dc952c063206d11504085ddea966f121e796a04c
Author-Change-Id: IB#1107572

* Reverse proxy API auth separated in docs

Related: https://github.com/go-gitea/gitea/pull/15119#discussion_r621322127
Author-Change-Id: IB#1107572

* Reverse proxy API auth separated in docs

Related: https://github.com/go-gitea/gitea/pull/15119#discussion_r621322127
Author-Change-Id: IB#1107572

* Reverse proxy API auth separated

Related: https://github.com/go-gitea/gitea/pull/15119#discussion_r621322127
Author-Change-Id: IB#1107572

* ReverseProxyAuth removed from swagger

ReverseProxyAuth removed from swagger as in upstream's suggestion.

Related: https://github.com/go-gitea/gitea/pull/15119#pullrequestreview-692180940
Author-Change-Id: IB#1107572

* ReverseProxyAuth API authorization fixed

Related: https://github.com/go-gitea/gitea/pull/15119#issuecomment-868465099
Author-Change-Id: IB#1107572

* ReverseProxyAuth API authorization fixed

Related: https://github.com/go-gitea/gitea/pull/15119#issuecomment-868465099
Author-Change-Id: IB#1107572
2021-11-19 22:54:44 +08:00
Lunny Xiao
fc3d082609
Move attachment into models/repo/ (#17650)
* Move attachment into models/repo/

* Fix test

* Fix bug
2021-11-19 21:39:57 +08:00
Lunny Xiao
7a03473159
Use a standalone struct name for Organization (#17632)
* Use a standalone struct name for Organization

* recover unnecessary change

* make the code readable

* Fix template failure

* Fix template failure

* Move HasMemberWithUserID to org

* Fix test

* Remove unnecessary user type check

* Fix test

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-19 19:41:40 +08:00
KN4CK3R
a09b40de8d
Prevent double sanitize (#16386)
* Prevent double sanitize.
* Use SanitizeReaderToWriter.

At the moment `actualRender` uses `SanitizeReader` to sanitize the output. But `SanitizeReader` gets called in `markup.render` too so the output gets sanitized twice.

I moved the `SanitizeReader` call into `RenderRaw` because this method does not use `markup.render`. I would like to remove the `RenderRaw`/`RenderRawString` methods too because they are only called from tests, the fuzzer and the `/markup/raw` api endpoint. This endpoint is not in use so I think we could remove them. If we really in the future need a method to render markdown without PostProcessing we could achieve this with a more flexible `renderer.NeedPostProcess` method.
2021-11-19 18:46:47 +08:00
Gusted
381e131fc8
Added comment for changing issue ref (#17672)
* Added comment for changing issue ref
- Add a comment when someone changes the ref(erence?) of a issue.
2021-11-19 17:54:31 +08:00
Gusted
00448ebe91
Remove unused user paramater (#17723)
As title
2021-11-19 08:37:13 +00:00
wxiaoguang
e4b95de388
Prepare and check test env during CI (#17725)
This PR should resolve the permission problems during CI, if the uid doesn't match, a more clear message is shown.

*  CI fails with unknown permission problems #17710

The new drone step dependencies:

(root)prepare-test-env -> (gitea)build -> (gitea)test
2021-11-19 13:58:34 +08:00
Lunny Xiao
9361b65f54
Fix bug when project board get open issue number (#17703)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-19 12:00:18 +08:00
Gusted
96ec656cf1
perf: sent data-path once for each file (#17657)
- Don't sent it with each line, instead send it at the top-element for each file.
- Related:
https://github.com/go-gitea/gitea/pull/17618#issuecomment-968192761

2.5K Additions:
No-Patch:
Unified: 2.14 MB (2.14 MB size)
Split: 2.59 MB (2.59 MB size)

Patch:
Unified: 2.10 MB (2.10 MB size) (-1.8%)
Split: 2.55 MB (2.55 MB size) (-1.5%)
2021-11-19 10:28:27 +08:00
zeripath
a85e75b2b1
Prevent deadlock in TestPersistableChannelQueue (#17717)
* Prevent deadlock in TestPersistableChannelQueue

There is a potential deadlock in TestPersistableChannelQueue due to attempting to
shutdown the test queue before it is ready.

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

* prevent npe

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-19 01:13:25 +00:00
GiteaBot
72b0882a45 [skip ci] Updated translations via Crowdin 2021-11-19 00:25:46 +00:00
KN4CK3R
f34151bdb2
Move user/org deletion to services (#17673) 2021-11-19 01:42:27 +08:00
wxiaoguang
55be5fe339
Refactor repo-legacy.js, remove messy global variables. Fix errors. (#17646)
Refactor repo-legacy.js, remove messy global variables. Fix errors.
Fix an error in Sortable
Fix a incorrect call assignMenuAttributes from the template
2021-11-19 00:45:00 +08:00
99rgosse
e1d655991b
Fix Migrate Description (#17692)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-18 23:28:10 +08:00
Gusted
c3e020ca34
Add pagination to fork list (#17639)
- Resolves #14574
- Adds the necessary code to have pagination working in the forks list of
a repo. The code is mostly in par with the stars/watcher implementation.
2021-11-18 22:45:56 +08:00
Gusted
257b7171c3
Fix possible panic (#17694)
- The code will get the first and second character `link[{0,1]]`.
However in a rare case the `link` could have 1 character and thus the
`link[1]` will create a panic.
2021-11-18 21:25:56 +08:00
Gusted
d1f5584039
Simplify code for wrting SHA to name-rev (#17696) 2021-11-18 04:50:22 -05:00
zeripath
878c2ce6e6
Prevent NPE due to missing repo in regression in #17551 (#17697) 2021-11-18 03:18:12 -05:00
Lunny Xiao
1f1ae57139
Move task from modules to services (#17680) 2021-11-18 14:47:57 +08:00
Lunny Xiao
3c3855a05c
Move user functions into user.go (#17659)
* Move user functions into user.go

* Fix test
2021-11-18 13:58:42 +08:00
silverwind
6874fe90e5
Cleanup and use global style on popups (#17674)
* Cleanup and use global style on popups

- Fix typo 'poping' to 'popping'
- Remove most inline 'data-variation' attributes
- Initialize all popups with 'inverted tiny' variation

* misc tweaks

* rename to .tooltip, use jQuery

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-18 11:26:50 +08:00
Gusted
c98dd7a3e0
Remove unnecessary variable assignments (#17695)
* Remove unnecessary variable assignments

As title

* enable ineffassign

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-18 09:33:06 +08:00
GiteaBot
b01f6c1a8c [skip ci] Updated translations via Crowdin 2021-11-18 00:25:14 +00:00
KN4CK3R
ea42d3c04e
Fixed commit count. (#17698)
Added "Tag" label.
Unified branch, tag and commit name.
2021-11-17 23:50:17 +00:00
zeripath
3c4724d70e
Add .gitattribute assisted language detection to blame, diff and render (#17590)
Use check attribute code to check the assigned language of a file and send that in to
chroma as a hint for the language of the file.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-17 20:37:00 +00:00
Lunny Xiao
81a4fc7528
Return 400 but not 500 when request archive with wrong format (#17691) 2021-11-17 14:47:35 -05:00
Gusted
d8a8961b99
Sanitize user-input on file name (#17666)
* Sanitize user-input on file name

- Sanitize user-input before it get passed into the DOM.
- Prevent things like "<iframe onload=alert(1)></iframe>" from being
executed. This isn't a XSS attack as the server seems to be santizing
the path as well.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-17 18:08:25 +00:00
Lunny Xiao
5233051e64
Move some functions into services/repository (#17677) 2021-11-17 23:17:31 +08:00
wxiaoguang
750a8465f5
A better go code formatter, and now make fmt can run in Windows (#17684)
* go build / format tools
* re-format imports
2021-11-17 20:34:35 +08:00
Lunny Xiao
29cc169d20
Fix bug when read mysql database max lifetime (#17682) 2021-11-17 18:59:23 +08:00
Lunny Xiao
95d3266bee
Move user follow and openid into models/user/ (#17613)
* Move UserRedirect into models/user/

* Fix lint & test

* Fix lint

* Fix lint

* remove nolint comment

* Fix lint

* Move user follow and openid into models/user

* Ignore the lint

* Ignore the lint

* Fix test

* ignore stutters lint on UserOpenID
2021-11-17 17:58:31 +08:00
Gusted
adda27668b
Enable bidichk (#17610)
- https://github.com/breml/bidichk

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-11-17 16:47:28 +08:00
Lunny Xiao
e3da8c1e88
fix migrations documents (#17679)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-17 15:17:37 +08:00
Gusted
21f6c0be08
Update golangci-lint in Makefile (#17647)
* Update golangci-lint in Makefile

- Partially resolvess #17596
- Download specific version(v1.43.0) by default.
- If current installed version is older than the minium version, it will
download the mininium required version.
- Update the install script to avoid deprecated error
`golangci/golangci-lint err this script is deprecated, please do not use
it anymore. check https://github.com/goreleaser/godownloader/issues/207`

* Simplify golangci-lint version check

* Fix version conversion

* Add version that's downloading

Co-authored-by: zeripath <art27@cantab.net>

* Consistency

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-17 13:41:01 +08:00
Lunny Xiao
42670e6b1c
Set unit test timeout to 20 minutes (#17664)
* Set unit test timeout to 15 minutes

* Update Makefile

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-16 21:54:05 -05:00
rstular
8fdc5247de
Update for reverse proxying static resources (#17670)
Gitea fetches static resources from /assets, so nginx configuration has to be updated accordingly.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-16 21:53:15 -05:00
GiteaBot
171f2d066e [skip ci] Updated translations via Crowdin 2021-11-17 00:25:11 +00:00
qwerty287
3be156f66a
Allow admins to change user avatars (#17661)
Adds the avatar change panel to the edit user page (bottom) and allows admins to change it this way

Co-authored-by: Gusted <williamzijl7@hotmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-11-16 19:13:13 +00:00
zeripath
bbffcc3aec
Multiple Escaping Improvements (#17551)
There are multiple places where Gitea does not properly escape URLs that it is building and there are multiple places where it builds urls when there is already a simpler function available to use this.
    
This is an extensive PR attempting to fix these issues.

1. The first commit in this PR looks through all href, src and links in the Gitea codebase and has attempted to catch all the places where there is potentially incomplete escaping.
2. Whilst doing this we will prefer to use functions that create URLs over recreating them by hand.
3. All uses of strings should be directly escaped - even if they are not currently expected to contain escaping characters. The main benefit to doing this will be that we can consider relaxing the constraints on user names and reponames in future. 
4. The next commit looks at escaping in the wiki and re-considers the urls that are used there. Using the improved escaping here wiki files containing '/'. (This implementation will currently still place all of the wiki files the root directory of the repo but this would not be difficult to change.)
5. The title generation in feeds is now properly escaped.
6. EscapePound is no longer needed - urls should be PathEscaped / QueryEscaped as necessary but then re-escaped with Escape when creating html with locales Signed-off-by: Andrew Thornton <art27@cantab.net>

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-16 18:18:25 +00:00
Lunny Xiao
7e1ae38097
Move migrations into services and base into modules/migration (#17663)
* Move migrtions into services and base into modules/migration

* Fix imports

* Fix lint
2021-11-16 23:25:33 +08:00
Lunny Xiao
48ccd325a1
Move some functions into services/repository (#17660) 2021-11-16 21:30:11 +08:00
Gusted
447428f446
Remove superfluous argument (#17667)
As title.
2021-11-16 19:36:03 +08:00
wxiaoguang
81926d61db
Decouple unit test, remove intermediate unittestbridge package (#17662)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-16 16:53:21 +08:00
silverwind
23bd7b1211
Add copy button to markdown code blocks (#17638)
* Add copy button to markdown code blocks

Done mostly in JS because I think it's better not to try getting buttons
past the markup sanitizer.

* add svg module tests

* fix sanitizer regexp

* remove outdated comment

* vertically center button in issue comments as well

* add comment to css

* fix undefined on view file line copy

* combine animation less files

* Update modules/markup/markdown/markdown.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* add test for different sizes

* add cloneNode and add tests for it

* use deep clone

* remove useless optional chaining

* remove the svg node cache

* unify clipboard copy string and i18n

* remove unused var

* remove unused localization

* minor css tweaks to the button

* comment tweak

* remove useless attribute

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-16 16:16:05 +08:00
Lunny Xiao
d789670894
Migrating wiki don't require token, so we should move it out of the require form (#17645)
* Migrating wiki don't require token, so we should move it out of the require form

* Fix lint
2021-11-16 14:17:21 +08:00
silverwind
6f7082ff56
Fix GitBucket icon (#17644)
Partial fix for https://github.com/go-gitea/gitea/issues/17642.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-16 12:24:22 +08:00
wxiaoguang
6292603215
Fix database deadlock when update issue labels (#17649)
This fix updates issue labels one by one, and won't cause database deadlock.
In future, we can use a batch API to update all changed labels by one request.
2021-11-16 10:21:13 +08:00
GiteaBot
3a60e0ad89 [skip ci] Updated translations via Crowdin 2021-11-16 00:25:21 +00:00
KN4CK3R
ff9564a679
Changed migration text. (#17654) 2021-11-15 18:12:09 -05:00
Gusted
ab1379743e
Fix nil checking on typed interface (#17598)
* Fix nil checking on typed interface

- Partially resoles #17596
- Resolves SA4023 errors.
- Ensure correctly that typed interface are nil.

* Remove unnecessary code

`NewBleveIndexer` will never return nil, even on errors.

* Patch `NewBleveIndexer`

* Fix low-level functions

* Remove deadcode

* Fix GetSession

* Close Elastic search when err isn't nil

* Update elastic_search.go

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-15 21:16:11 +08:00
Gusted
253d9e4158
Remove unnecassary calls to filepath.Join (#17608)
- Partialy resolvess #17596
- Resolves `badCall` errors from go-critic `badCall: suspicious Join on
1 argument`
- When only 1 argument is passed into `filepath.Join`, it won't do
anything special other than `filepath.Clean(...)` will be applied over
it.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-11-15 14:02:53 +08:00
Gusted
562785ef4e
Add download button for file viewer (#17640)
- Resolves #17286
- Use the `download` attribute such that the browser will natively
initate a download dialog for the given URL.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-15 09:05:12 +08:00
GiteaBot
10db864c66 [skip ci] Updated translations via Crowdin 2021-11-15 00:24:54 +00:00
缘生
83a04e42cc
fix typo (#17614) 2021-11-14 17:32:48 -05:00
silverwind
cd32b84811
Add icon to vscode clone link (#17641) 2021-11-14 16:48:26 -05:00
KN4CK3R
42ea0023a3
Add migration from GitBucket (#16767)
This PR adds [GitBucket](https://gitbucket.github.io/) as migration source.

Supported:
- Milestones
- Issues
- Pull Requests
- Comments
- Reviews
- Labels

There is no public usable instance so no integration tests added.
2021-11-14 20:11:10 +01:00
Gusted
d2163df6a0
Fix offBy1 errors (#17606)
* Fix offBy1 errors

- Partially resolves #17596
- Resolve errors from go-critic `offBy1: Index() can return -1; maybe
you wanted to do Index()+1`.

* Match golang spec

* Remove comments

* Update migrations.go

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-14 10:11:49 +02:00
Gusted
8eddb75508
perf: only generate data-comment-url once (#17618) 2021-11-14 00:28:57 -05:00
GiteaBot
424959e07c [skip ci] Updated licenses and gitignores 2021-11-14 00:26:06 +00:00
zeripath
bab95c3a86
Correctly handle failed migrations (#17575)
* Correctly handle failed migrations

There is a bug in handling failed migrations whereby the migration task gets decoupled
from the migration repository. This leads to a failure of the task to get deleted with
the repository and also leads to the migration failed page resulting in a ISE.

This PR removes the zeroing out of the task id from the migration but also makes
the migration handler tolerate missing tasks much nicer.

Fix #17571

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-13 19:28:50 +08:00
Michael Grigoryan
47448083a1
Minor readability patch. (#17627) 2021-11-12 18:27:18 -05:00
wxiaoguang
df64fa4865
Decouple unit test code from business code (#17623) 2021-11-12 22:36:47 +08:00
wxiaoguang
7f802631c5
Fix some incorrect async functions, improve frontend document. (#17597) 2021-11-12 20:37:45 +08:00
Lunny Xiao
0db7a32b92
unbind the CheckConsistency for some structs so that they can be moved to sub packages easier (#17612)
* unbind the CheckConsistency for some structs so that they can be moved to sub packages easier

* Fix functions name

* Fix typo
2021-11-12 08:56:45 +08:00
Lunny Xiao
90eb9fb889
Move EmailAddress & UserRedirect into models/user/ (#17607)
* Move EmailAddress into models/user/

* Fix test

* rename user_mail to user_email

* Fix test

* Move UserRedirect into models/user/

* Fix lint & test

* Fix lint

* Fix lint

* remove nolint comment

* Fix lint
2021-11-11 15:03:30 +08:00
Gusted
492e1c2fbd
Refactor commentTags functionality (#17558)
* feat: Allow multiple tags on comments

- Allow for multiples tags(Currently Poster + {Owner, Writer}).
- Utilize the Poster tag within the commentTag function and remove the
checking from templates.
- Use bitwise on CommentTags to enable specific tags.
- Don't show poster tag(view_content.tmpl) on the initial issue comment.

* Change parameters naming

* Change function name

* refactor variable wording

* Merge 'master' branch into 'tags-comments' branch

* Change naming

* `tag` -> `role`

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-11 14:29:30 +08:00
Gusted
a4dc0c5a82
Remove golint as linter (#17609)
- Partialy resolvess #17596
- In the newer versions of `golangci-lint`, golint is  deprecated and
replaced by the `revive` linter. Thus removing the `golint` linter is a
good idea, as we're already using the `revive` linter which covers all
the current `golint` cases.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-11 13:28:45 +08:00
silverwind
433e81aecf
Update JS dependencies (#17611)
- Update monaco, adapting to breaking changes
- Update dropzone, adapting to breaking changes
- Update linters, fix new issues, disable opinionated stylelint rules
- Rebuild SVGs and images
- Tested Dropzone and Monaco

Replaces: https://github.com/go-gitea/gitea/pull/17574
2021-11-11 09:52:16 +08:00
Lunny Xiao
0e189eecaa
Move oauth2 error to oauth2 service package (#17603) 2021-11-11 01:51:09 +08:00
Lunny Xiao
43bbc54783
Fix 500 when a comment was deleted which has a notification (#17550)
* Fix 500 when a comment was deleted which has a notification

* Tolerate missing Comment in other places too

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-10 13:48:45 +08:00
Lunny Xiao
33fca2b537
Move webhook into models/webhook/ (#17579) 2021-11-10 13:13:16 +08:00
KN4CK3R
edbaa5d3f0
Added GetUserByIDCtx. (#17602)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-09 22:21:01 -05:00
GiteaBot
465fb4169e [skip ci] Updated translations via Crowdin 2021-11-10 00:25:15 +00:00
Lunny Xiao
99b2858e62
Move unit into models/unit/ (#17576)
* Move unit into models/unit/

* Rename unit.UnitType as unit.Type
2021-11-09 20:57:58 +01:00
wxiaoguang
b6b1e71665
tune sqlite3 message (#17601) 2021-11-09 13:55:24 -05:00
Andrey Nering
aa4355ba1f
Remove me from the maintainers (#17599)
I haven't being involved in a while.
2021-11-09 22:40:16 +08:00
Lunny Xiao
d6d147c2c4
Fix 500 when review pull request with anonymous (#17594) 2021-11-09 13:14:12 +00:00
Gusted
062b051687
Move merge-section to > .content (#17582)
* Move `> .merge-section` to `> .content` scope

- Fixes a issue that started from
https://github.com/go-gitea/gitea/pull/17317
- Move `> .merge-section` to the `> .content` scope.
- Resolves #17480

* Move `.merge-section` back to outside scope

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-11-09 19:56:15 +08:00
wxiaoguang
a5b4720b91
Update User model comments about permissions (#17583) 2021-11-09 18:42:58 +08:00
wxiaoguang
bb71ceeeb2
Improve async/await usage, and sort init calls in index.js (#17386)
* clean up async/await, and sort init calls in `index.js
* use `const _promise` to indicate that we do not need await an async function
2021-11-09 17:27:25 +08:00
Gusted
3a693bd18c
Use provided database Engine (#17595)
- Don't get the engine from `db.DefaultContext`, instead use the
provided one which is passed as paramater `e`.
2021-11-09 08:54:46 +00:00
Lunny Xiao
03de593402
Fix bug on detect issue/comment writer (#17591) 2021-11-09 15:44:12 +08:00
Kamil Domański
021df29623
Allow U2F 2FA without TOTP (#11573)
This change enables the usage of U2F without being forced to enroll an TOTP authenticator.
The `/user/auth/u2f` has been changed to hide the "use TOTP instead" bar if TOTP is not enrolled.

Fixes #5410
Fixes #17495
2021-11-08 23:47:19 +01:00
Gusted
a3f9e9234c
Fix stats upon searching issues (#17566)
* Fix stat chunks searching

- Fixes a issue whereby the given chunk of issueIDs wasn't respected and
thus the returned results where not the correct results.

* Add tests

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-11-08 23:14:46 +02:00
Gusted
640f0e1ddf
Only allow returned deleted branche to be on repo (#17570)
- This will only allow `GetDeletedBranchByID` to return deletedBranch
which are on the repo, and thus don't return a deletedBranch from
another repo.
- This just should prevent possible bugs in the futher when a code is
passing the wrong ID into this function.
2021-11-08 23:45:37 +08:00
Gusted
ebaf4c48ea
Avoid double imports (#17569)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-08 09:04:13 +02:00
zeripath
513951bc16
Remove appSubUrl from pasted images (#17572)
* Remove appSubUrl from pasted images

Since we fixed the url base for the links in repositories we no longer need to add
the appsuburl to pasted image links.

Fix #17057

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-08 14:27:40 +08:00
wxiaoguang
d168f0498b
Fix documents for ALLOWED_HOST_LIST, its default value differs between 1.15 and 1.16 (#17530)
* fix documents for ALLOWED_HOST_LIST, its default value differs between 1.15 and 1.16
2021-11-08 11:25:41 +08:00
Gusted
9d97cf3a71
Add @Gusted to maintainers filer (#17581) 2021-11-07 14:23:39 -05:00
Gusted
30515f2df3
Make ParsePatch more robust (#17573) 2021-11-07 12:52:50 -05:00
Lunny Xiao
69b61d4373
Fix bug on admin subcommand (#17533)
* Fix bug on admin subcommand

* Add signals for all initDB

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-11-07 11:11:27 +08:00
GiteaBot
c9110eb5e4 [skip ci] Updated translations via Crowdin 2021-11-07 00:25:43 +00:00
Wim
bd613c704c
Fix ipv6 parsing for builtin ssh server (#17561) 2021-11-06 14:23:32 +08:00
Yuwei Ba
5e0cf4b82e
Update locale_en-US.ini (#17553) 2021-11-05 15:23:55 -04:00
zeripath
dbdaa713c9
Escape issue titles in comments list (#17555)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-05 22:56:40 +08:00
Gusted
bc6df18fb3
Use correct defaultValue for stracktrace (#17552) 2021-11-05 13:25:05 +02:00
Lunny Xiao
a161c2ca58
Fix zero created time bug on commit api (#17546)
Fix #17543
2021-11-05 05:30:46 +00:00
GiteaBot
de9625e485 [skip ci] Updated translations via Crowdin 2021-11-05 00:25:11 +00:00
Lunny Xiao
fed8e01ca1
Fix database keyword quote problem on migration v161 (#17522)
* support rerun migration v161

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-11-05 00:47:01 +02:00
qwerty287
e5b48dcac4
Hide label comments if labels were added and removed immediately (#17455)
* Hide label comments if labels were added and removed immediately

* Add comment and rename var

* Fix unit test

* Add test case

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-04 22:51:30 +08:00
delvh
d6f4820967
Show correct "No" icon (#17537) 2021-11-04 10:09:03 +08:00
zeripath
a5bcf1994f
Use exec -a in the FHS compliant script (#17513) 2021-11-03 04:13:07 -04:00
SahAssar
118fbd9436
Fix list for options under cli->user->admin->create (#17382)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-11-03 13:27:35 +08:00
a1012112796
12938dd35f
hide note message for pull request template (#17529)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2021-11-02 22:43:16 -05:00
zeripath
9d855bd6a1
Simplify Gothic to use our session store instead of creating a different store (#17507)
* Simplify Gothic to use our session store instead of creating a different store

We have been using xormstore to provide a separate session store for our OAuth2 logins
however, this relies on using gorilla context and some doubling of our session storing.
We can however, simplify and simply use our own chi-based session store. Thus removing
a cookie and some of the weirdness with missing contexts.

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

* as per review

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

* as per review

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

* Handle MaxTokenLength

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

* oops

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-11-03 08:33:54 +08:00
zeripath
95da01c5cd
Add QueryEscape to general funcmap (#17526)
QueryEscape was only added to the text funcmap. Add this to the main template funcmap
too.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-02 23:00:30 +08:00
Lunny Xiao
e69521f029
fix email with + when active (#17518)
Co-authored-by: zeripath <art27@cantab.net>
2021-11-02 06:26:13 +00:00
zeripath
cb9c8184c9
Make Repo Code Indexer an Unique Queue (#17515)
The functioning of the code indexer queue really only makes sense as an unique queue
and doing this allows use to simplify the indexer data to simply delete the data if
the repo is no longer in the db.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-11-02 11:14:24 +08:00
Renato Caldas
e2995ef515
docs: add SSH passthrough instructions to with-docker-rootless (#17505) (#17508)
The passthrough is based upon AuthorizedKeysCommand and a custom shell wrapper that forwards commands to the container over the docker pipe.
2021-11-01 12:34:12 +00:00
wxiaoguang
599ff1c054
Only allow webhook to send requests to allowed hosts (#17482) 2021-11-01 16:39:52 +08:00
zeripath
4e8a81780e
Stop double encoding blame commit messages (#17498)
The call to html.EscapeString in routers/web/repo/blame.go:renderBlame is extraneous
as the commit message is now rendered by the template. The template will correctly
escape strings - therefore we are currently double escaping.

This PR fixes this.

Fix #17492

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-31 10:25:24 +02:00
GiteaBot
1ff944f698 [skip ci] Updated licenses and gitignores 2021-10-31 00:25:12 +00:00
Richard Mahn
40c8451b7d
Properly determine CSV delimiter (#17459)
* Fixes #16558 CSV delimiter determiner

* Fixes #16558 - properly determine CSV delmiiter

* Moves quoteString to a new function

* Adds big test with lots of commas for tab delimited csv

* Adds comments

* Shortens the text of the test

* Removes single quotes from regexp as only double quotes need to be searched

* Fixes spelling

* Fixes check of length as it probalby will only be 1e4, not greater

* Makes sample size a const, properly removes truncated line

* Makes sample size a const, properly removes truncated line

* Fixes comment

* Fixes comment

* tests for FormatError() function

* Adds logic to find the limiter before or after a quoted value

* Simplifies regex

* Error tests

* Error tests

* Update modules/csv/csv.go

Co-authored-by: delvh <dev.lh@web.de>

* Update modules/csv/csv.go

Co-authored-by: delvh <dev.lh@web.de>

* Adds comments

* Update modules/csv/csv.go

Co-authored-by: delvh <dev.lh@web.de>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2021-10-30 23:50:40 +08:00
Lunny Xiao
63c0dc89ef
Rename db Engines related functions (#17481)
* Rename db Engines related functions

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-30 22:32:11 +08:00
zeripath
76a3190b8a
Quote the table name in CountOrphanedObjects (#17487)
CountOrphanedObjects needs to quote the table it is joining with as this table may
be `user`.

Fix #17485

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-30 10:17:40 +01:00
GiteaBot
f5bb788c4e [skip ci] Updated translations via Crowdin 2021-10-30 00:25:09 +00:00
zeripath
e6e3b212b3
Run Migrate in Install rather than just SyncTables (#17475)
* Run Migrate in Install rather than just SyncTables

The underlying problem in #17328 appears to be that users are re-running the install
page during upgrades. The function that tests and creates the db did not intend for
this and thus instead the migration scripts being run - a simple sync tables occurs.

This then causes a weird partially migrated DB which causes, in this release cycle,
the duplicate column in task table error. It is likely the cause of some weird
partial migration errors in other cycles too.

This PR simply ensures that the migration scripts are also run at this point too.

Fix #17328

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-29 09:23:10 +01:00
GiteaBot
9733b60430 [skip ci] Updated translations via Crowdin 2021-10-29 00:25:11 +00:00
zeripath
157de0f1c1
Update docs/config.yaml to 1.15.6 (#17472)
Update the version in docs/config.yaml to 1.15.6

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-28 21:44:33 +08:00
qwerty287
f46e67b519
Move key forms before list and add cancel button (#17432)
* Move GPG form before list and add cancel button
* Move SSH form before list and add cancel button

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-28 18:55:48 +08:00
qwerty287
54243eed8d
Fix login redirection links (#17451)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-10-28 18:09:25 +08:00
zeripath
141d1a2aa5
Changelog 1.15.6 (#17457) (#17468)
Frontport #17457

 ## [1.15.6](https://github.com/go-gitea/gitea/releases/tag/v1.15.6) - 2021-10-28

* BUGFIXES
  * Prevent panic in serv.go with Deploy Keys (#17434) (#17435)
  * Fix CSV render error (#17406) (#17431)
  * Read expected buffer size (#17409) (#17430)
  * Ensure that restricted users can access repos for which they are members (#17460) (#17464)
  * Make commit-statuses popup show correctly (#17447) (#17466)
* TESTING
  * Add integration tests for private.NoServCommand and private.ServCommand (#17456) (#17463)
2021-10-28 10:22:27 +01:00
zeripath
3fc465ba5e
Fix mispelling of starred as stared (#17465)
There was a recent spelling mistake added to the locale file where stared was used
instead of starred.

This PR changes this to starred.

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

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-28 15:05:00 +08:00
zeripath
0b4a8be26b
Ensure that restricted users can access repos for which they are members (#17460)
There is a small bug in the way that repo access is checked in
repoAssignment: Accessibility is checked by checking if the user has a
marked access to the repository instead of checking if the user has any
team granted access.

This PR changes this permissions check to use HasAccess() which does the
correct test. There is also a fix in the release api ListReleases where
it should return draft releases if the user is a member of a team with
write access to the releases.

The PR also adds a testcase.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-28 10:54:40 +08:00
wxiaoguang
2b2eb5d0ad
make commit-statuses popup can be shown correctly. (#17447)
Close #17443

Maybe we do not need to backport this PR, the bug doesn't break daily usage.

After the fix, the commit statuses popup can show a lot of lines with scroll bars:

![image](https://user-images.githubusercontent.com/2114189/139026160-f01b484c-6207-494a-a190-a6dd184ceb2b.png)
2021-10-28 02:34:18 +01:00
zeripath
4f00de1458
Add integration tests for private.NoServCommand and private.ServCommand (#17456)
modules/private/serv.go has two major functions that are missing testcases to ensure
that Deploy and normal SSH keys work correctly.

This PR adds some basic integration tests for these.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-28 08:32:59 +08:00
qwerty287
01fc24c78c
Add appearance section in settings (#17433)
* Add appearance section in settings

* Fix lint

* Fix lint

* Apply suggestions from code review

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-10-27 23:40:08 +08:00
wxiaoguang
89beceeb9a
Fix a UI error when folding a file content in a commit view (#17446) 2021-10-27 19:11:56 +08:00
David Jimenez
a462fcaac8
Show client-side error if wiki page is empty (#17415)
* fix: show client-side error if wiki page is empty

Implement a JS, client-side validation workaround for a bug in the upstream
editor library SimpleMDE which breaks HTML5 client-side validation when
a wiki page is submitted.

This allows native, client-side errors to appear if
the text editor contents are empty.

See upstream bugfix report: https://github.com/sparksuite/simplemde-markdown-editor/issues/324

Signed-off-by: David Jimenez <dvejmz@sgfault.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-10-27 12:33:22 +08:00
Richard Mahn
8f9ac439ca
Fixes #16559 - Do not trim leading spaces for tab delimited (#17442)
* Fixes #16559 - Do not trim leading spaces for tab delimited

* Adds back semicolon delimited test

* Fixes linting

* Adds nolint directive to test because uses strings starting with spaces

Co-authored-by: zeripath <art27@cantab.net>
2021-10-26 16:46:56 -05:00
wxiaoguang
6e2c64f27a
Fix docker rootless build (#17441) 2021-10-26 17:21:01 +01:00
wxiaoguang
b428b0f0ed
Tune UI alignment for nav bar notification icon, avatar image, issue label (#17438) 2021-10-26 15:29:48 +03:00
Lunny Xiao
812a9daab9
Upgrade go-github to v39 (#17437) 2021-10-26 08:19:21 +01:00
zeripath
849356deaf
Prevent panic in serv.go with Deploy Keys (#17434)
Unfortunately there was a regression in #17373 which missed that the user is not
for deploy keys. This leads to a panic when pushing with deploy keys.

Fix #17412

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-26 01:24:19 +02:00
zeripath
0277603878
chmod executables when copying to the docker (#17423)
Run chmod on the executables and the entrypoint when copying them to the
docker in dockerfile.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: delvh <dev.lh@web.de>
2021-10-25 20:32:03 +02:00
wxiaoguang
649e1d0dc2
Upgrade webpack to 5.59.1 to resolve the waitFor bug with watch-frontend (#17428)
Webpack < 5.59 has a bug, which makes watch-frontend fail when editing .less files.
2021-10-25 19:54:25 +08:00
wxiaoguang
a961666c38
fix markdown checkbox rendering (#17425) 2021-10-25 09:40:38 +02:00
wxiaoguang
7c951fdd4a
In many cases user avatar link should be an absolute URL with http host (#17420) 2021-10-25 13:01:16 +08:00
qwerty287
3676fafdac
Add API to get/edit wiki (#17278)
* Add API to get/edit wiki

* Add swagger docs, various improvements

* fmt

* Fix lint and rm comment

* Add page parameter

* Add pagination to pages

* Add tests

* fmt

* Update func names

* Update error handling

* Update type name

* Fix lint

* Don't delete Home

* Update func name

* Update routers/api/v1/repo/wiki.go

Co-authored-by: delvh <dev.lh@web.de>

* Remove unnecessary check

* Fix lint

* Use English strings

* Update integrations/api_wiki_test.go

Co-authored-by: delvh <dev.lh@web.de>

* Update func and test names

* Remove unsed check and avoid duplicated error reports

* Improve error handling

* Return after error

* Document 404 error

* Update swagger

* Fix lint

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Document file encoding

* fmt

* Apply suggestions

* Use convert

* Fix integration test

* simplify permissions

* unify duplicate key Title/Name

* improve types & return UTC timestamps

* improve types pt.2

- add WikiPageMetaData.LastCommit
- add WikiPageMetaData.HTMLURL
- replace WikiPageMetaData.Updated with .LastCommit.Committer.Created

also delete convert.ToWikiPage(), as it received too many arguments and
only had one callsite anyway. sorry for bad advice earlier 🙃

* WikiPage.Content is base64 encoded

* simplify error handling in wikiContentsByName()

* update swagger

* fix & DRY findWikiRepoCommit() error handling

ListWikiPages() previously wrote error twice when repo wiki didn't exist

* rename Content -> ContentBase64

* Fix test

* Fix tests

* Update var name

* suburl -> sub_url

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Norwin <git@nroo.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-25 11:43:40 +08:00
GiteaBot
843bc9deeb [skip ci] Updated translations via Crowdin 2021-10-25 00:25:06 +00:00
KN4CK3R
44f2c27d28
Fix CSV render error (#17406)
closed #17378 

Both errors from #17378 were caused by  #15175.

Problem 1 (error with added file):
`ToUTF8WithFallbackReader` creates a `MultiReader` from a `byte[2048]` and the remaining reader. `CreateReaderAndGuessDelimiter` tries to read 10000 bytes from this reader but only gets 2048 because that's the first reader in the `MultiReader`. Then the `if size < 1e4` thinks the input is at EOF and just returns that.

Problem 2 (error with changed file):
The blob reader gets defer closed. That was fine because the old version reads the whole file into memory. Now with the streaming version the close needs to defer after the method.
2021-10-25 00:42:32 +02:00
KN4CK3R
f99d50fc9f
Read expected buffer size (#17409)
* Read expected buffer size.

* Changed name.
2021-10-24 22:12:43 +01:00
Kane
932780c2bb
Add HAProxy Config to reverse-proxies.en-us.md (#17407)
* Update reverse-proxies.en-us.md

Addition of HAProxy

* Update reverse-proxies.en-us.md
2021-10-24 17:48:26 +02:00
GiteaBot
07c7100c60 [skip ci] Updated translations via Crowdin 2021-10-24 00:25:14 +00:00
wxiaoguang
ff9638839d
Fix issue content history problems, improve UI (#17404)
* Improve: make diff result better, make the HTML element fit the full height in the content history diff dialog
* Bug fix: when edit the main issue, the poster is wrongly set to the issue poster
2021-10-23 22:48:16 +08:00
wxiaoguang
943dc08722
Fix issue content history problems, improve UI (#17404)
* Improve: make diff result better, make the HTML element fit the full height in the content history diff dialog
* Bug fix: when edit the main issue, the poster is wrongly set to the issue poster
2021-10-23 22:47:38 +08:00
wxiaoguang
6c49517cbd
Fix issue markdown bugs (#17411)
* Bug fix: render Markdown http://AppURL/org/repo/issues/4?a=1&b=2#comment-123 test to HTML correctly, close #17394
* Bug fix: fix the positions of checkboxes in rendered HTML, close #17395
2021-10-23 21:38:12 +08:00
GiteaBot
2a9aefdabb [skip ci] Updated translations via Crowdin 2021-10-23 00:28:47 +00:00
Mashiro
82bf564168
Remove deprecated extendDefaultPlugins method of svgo (#17399) 2021-10-22 22:05:53 +02:00
zeripath
d1a056fe52
Frontport Changelog 1.15.5 (#17392) (#17401) 2021-10-22 12:32:08 -04:00
wxiaoguang
406bd3780e
Fix context popup error (#17398)
* Fix context popup error
2021-10-22 22:34:01 +08:00
Nico Schieder
870f5fbc41
Add groups scope/claim to OIDC/OAuth2 Provider (#17367)
* Add groups scope/claim to OICD/OAuth2

Add support for groups claim as part of the OIDC/OAuth2 flow.
Groups is a list of "org" and "org:team" strings to allow clients to
authorize based on the groups a user is part of.

Signed-off-by: Nico Schieder <code@nico-schieder.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-22 17:19:24 +08:00
zeripath
af96286f22
Stop sanitizing full name in API (#17396)
The API convert.toUser function makes the incorrect assumption that full names could
be rendered as is without being escaped. It therefore runs the names through
markup.Sanitize which leads to a double escape of user full names. This
pr stops this.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-10-22 15:17:35 +08:00
GiteaBot
23d36929bc [skip ci] Updated translations via Crowdin 2021-10-22 00:25:10 +00:00
zeripath
09938ccd99
Re-separate the color translation strings (#17390)
Fix #17384

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-21 23:51:03 +02:00
wxiaoguang
a115309f4f
Fix the click behavior for <tr> and <td> with [data-href] (#17388) 2021-10-21 19:19:32 +01:00
wxiaoguang
960c322586
Refactor update checker to use AppState (#17387)
We have the `AppState` module now, it can store app related data easily. We do not need to create separate tables for each feature.

So the update checker can use `AppState` instead of a one-row dedicate table.

And the code of update checker is moved from `models` to `modules`.
2021-10-21 17:10:49 +01:00
Mario Lubenka
67561e79f1
Fix SVG side by side comparison link (#17375)
* Remove swipe-bar z-index

Fixes position of swipe-bar so it does not overlay other UI components when scrolling.

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Unique names for image tabs in pull request

Define unique names for image tabs in pull requests, in order to toggle tabs correctly when multiple are displayed on one page.

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-21 18:43:26 +08:00
Lunny Xiao
f3c7f10c9f
Fix history count failure (#17351)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-21 18:06:19 +08:00
wxiaoguang
83df0caf15
Sync gitea app path for git hooks and authorized keys when starting (#17335)
Gitea writes its own AppPath into git hook scripts. If Gitea's AppPath changes, then the git push will fail.

This PR:

* Introduce an AppState module, it can persist app states into database
* During GlobalInit, Gitea will check if the current AppPath is the same as last one. If they don't match, Gitea will sync git hooks.
* Refactor some code to make them more clear.
* Also, "Detect if gitea binary's name changed" #11341 is related, we call models.RewriteAllPublicKeys to update ssh authorized_keys file
2021-10-21 17:22:43 +08:00
zeripath
053b2f4dce
Handle broken references in mirror sync (#17013)
* Handle broken references in mirror sync

If there are broken references during a mirror attempt to fix using `git remote prune`.

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-10-21 16:45:25 +08:00
wxiaoguang
2add8fe9be
Frontend refactor, PascalCase to camelCase, remove unused code (#17365)
* Frontend refactor, PascalCase to camelCase, remove unused code

* fix
2021-10-21 15:37:43 +08:00
Lunny Xiao
5879ab83b5
Fix heatmap test (#17381) 2021-10-21 14:37:40 +08:00
GiteaBot
9046c022d2 [skip ci] Updated translations via Crowdin 2021-10-21 00:25:11 +00:00
zeripath
c1110b8671
Ensure correct SSH permissions check for private and restricted users (#17370)
Repositories owned by private users and organisations and pulls by restricted users
need to have permissions checked. Previously Serv would simply assumed that if the
user could log in and the repository was not private then it would be visible.

Fix #17364

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-10-20 16:59:05 -04:00
zeripath
c5a408df05
Upgrade Bluemonday to v1.0.16 (#17372)
Upgrade Bluemonday to latest version

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

Co-authored-by: 6543 <6543@obermui.de>
2021-10-20 16:58:39 -04:00
zeripath
35b918f574
Offer rsa-sha2-512 and rsa-sha2-256 algorithms in internal SSH (#17281)
* Offer rsa-sha2-512 and rsa-sha2-256 algorithms in internal SSH

There is a subtle bug in the SSH library x/crypto/ssh which makes the incorrect
assumption that the public key type is the same as the signature algorithm type.

This means that only ssh-rsa signatures are offered by default.

This PR adds a workaround around this problem.

Fix #17175

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

* as per review

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-20 15:55:33 -04:00
Richard Mahn
98f7013756
Prevent NPE in CSV diff rendering when column removed (#17018)
Fixes #16837 if a column is deleted.

We were clobbering the columns that were added by looping through the aline (base) and then when bline (head) was looped through, it clobbered what was in the "cells" array that is show in the diff, and then left a nil cell because nothing was shifted.

This fix properly shifts the cells, and properly puts the b cell either at its location or after, according to what the aline placed in the cells.

This includes test, adding a new test function since adding/removing cells works best with three columns, not two, which results in 4 columns of the resulting cells because it has a deleted column and an added column. If you try this locally, you can try those cases and others, such as adding a column.

There was no need to do anything special for the rows when `aline == 0 || bline == 0` so that was removed. This allows the same code to be used for removed or added lines, with the bcell text always being the RightCell, acell text being the LeftCell.

I still added the patch zeripath gave at https://github.com/go-gitea/gitea/issues/16837#issuecomment-913007382 so that just in case for some reason a cell is nil (which shouldn't happen now) it doesn't throw a 500 error, so the user can at least view the raw diff.

Also fixes in the [view.go](https://github.com/go-gitea/gitea/pull/17018/files#diff-43a7f4747c7ba8bff888c9be11affaafd595fd55d27f3333840eb19df9fad393L521) file how if a CSV file is empty (either created empty or if you edit it and remove all contents) it throws a huge 500 error when you then save it (when you view the file). Since we allow creating, saving and pushing empty files, we shouldn't throw an error on an empty CSV file, but just show its empty contents. This doesn't happen if it is a Markdown file or other type of file that is empty.
EDIT: Now handled in the markup/csv renderer code
2021-10-20 20:10:03 +01:00
Lunny Xiao
f494776931
Use a variable but a function for IsProd because of a slight performance increment (#17368) 2021-10-20 16:37:19 +02:00
Mario Lubenka
0208ea0248
"Copy branch name" button in pull request (#17323)
* Drop data-original from clipboard

data-original attribute was removed. Instead, the original value from
data-content is set after success/fail message was displayed.

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* "Copy branch name" button in pull request

Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>

* Update templates/repo/issue/view_title.tmpl

Co-authored-by: silverwind <me@silverwind.io>

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
2021-10-19 13:32:11 -04:00
silverwind
de61816623
Rename .air.conf to .air.toml (#17360)
As of https://github.com/cosmtrek/air/pull/90, the preferred file
extension is .toml. The file format was always toml itself.
2021-10-20 00:27:29 +08:00
Netduma Luke M
9f3d5c0a23
Re-allow clipboard copy on non-https sites (#17118)
* Re-allow clipboard copy on non-https sites
* fallback clipboard functions
2021-10-19 18:22:16 +08:00
silverwind
eaf493be5d
Update JS dependencies (#17357)
* Update JS dependencies

- Upgrade to eslint 8 and add new plugin rules
- Adapt to various API changes
- Rebuild SVGs

* fix webpack warning on license

* order options alphabetically

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-10-19 15:23:58 +08:00
zeripath
e2a59c57fc
Fix dashboard repolist alignment and repolisting (#17355)
Unfortunately #17301 broke the restriction of the dashboard repolist to
the user's repos because it stopped passing in the uid for the current
user. This PR restores this.

There is also a weird alignment problem - not caused by that PR - where
the menu items in the repolist spread over multiple lines. This PR
simply reduces the padding on these items and switches the justification
of the flex elements to space-evenly.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-10-19 12:38:33 +08:00
GiteaBot
1f41fcc342 [skip ci] Updated translations via Crowdin 2021-10-19 00:25:06 +00:00
wxiaoguang
4822eed99d
Disable form autofill (#17291)
]* fix aria-hidden and tabindex

* use {{template "base/disable_form_autofill"}} instead of {{DisableFormAutofill}}

Co-authored-by: zeripath <art27@cantab.net>
2021-10-19 01:08:41 +03:00
John Olheiser
c59afa752d
Allow mocking timeutil (#17354)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-10-18 21:12:26 +01:00
Mashiro
f0376b7e02
docs: add permission notes to SSH Container Passthrough (#17347)
* Update with-docker.en-us.md

* Update with-docker.en-us.md

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-18 12:26:47 -04:00
techknowlogick
3397fee9fa
api: integration test for nodeinfo (#17346) 2021-10-18 01:36:56 -04:00
GiteaBot
62a6717701 [skip ci] Updated translations via Crowdin 2021-10-18 00:25:12 +00:00
techknowlogick
db895040dd
Use go1.16+ way of installing binaries (#17342) 2021-10-17 18:57:15 -04:00
Lunny Xiao
4a57c9ea17
Fix some lints (#17337)
Fix some linting problems.
2021-10-17 20:47:12 +01:00
Lunny Xiao
5326f4c9c5
Move session to models/login (#17338)
Move model/session.go to models/login
2021-10-17 19:51:56 +01:00
qwerty287
26dfe88ff2
Hide command line merge instructions when user can't push (#17339)
Hides the command line instructions if the authenticated user can't push to the base branch.
Closes #17121
2021-10-17 17:58:36 +01:00
kolaente
554988c7b2
fix: repository summary on mobile (#17322)
This PR fixes the repository summary on mobile. Most of it is vertically centering things and some spacing.

#### Before:
![Screen Shot 2021-10-15 at 19 12 25](https://user-images.githubusercontent.com/13721712/137528901-021867b5-73c3-4f48-8408-18bc573f5ee7.png)

#### After:
![Screen Shot 2021-10-15 at 19 28 06](https://user-images.githubusercontent.com/13721712/137528970-058a66fd-d5d9-44ea-ba5f-998bf8cbf4fe.png)
2021-10-17 15:05:32 +01:00
zeripath
7117c7774a
Make the Mirror Queue a queue (#17326)
Convert the old mirror syncing queue to the more modern queue format.

Fix a bug in the from the repo-archive queue PR - the assumption was made that uniqueness could be enforced with by checking equality in a map in channel unique queues - however this only works for primitive types - which was the initial intention but is an imperfect. This is fixed by marshalling the data and placing the martialled data in the unique map instead.

The documentation is also updated to add information about the deprecated configuration values.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-17 12:43:25 +01:00
Mario Lubenka
b9a2f263b8
Ensure popup text is aligned left (#17327)
Signed-off-by: Mario Lubenka <mario.lubenka@googlemail.com>
2021-10-17 11:14:32 +01:00
GiteaBot
8af5450cf7 [skip ci] Updated translations via Crowdin 2021-10-17 00:29:40 +00:00
wxiaoguang
7333104e89
Fix the PR review form bug during frontend refactor (#17332) 2021-10-16 22:30:31 +02:00
wxiaoguang
1a7473ff45
Split index.js to separate files (#17315)
* split `index.js` to separate files

* tune clipboard

* fix promise

* fix document

* remove intermediate empty file

* fix async event listener

* use `export function` instead of `export {}`, add more comments

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-17 01:28:04 +08:00
6543
3728f1daa0
Add RSS/Atom feed support for user actions (#16002)
Return rss/atom feed for user based on rss url suffix or Content-Type header.
2021-10-16 16:21:16 +02:00
techknowlogick
8edda8b446
Add simple update checker to Gitea (#17212)
* Add simple update checker to Gitea

* update struct and remove comments

* fix lint

* Update custom/conf/app.example.ini

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update custom/conf/app.example.ini

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: Steven <61625851+justusbunsi@users.noreply.github.com>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

* Update modules/cron/tasks_extended.go

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* Update custom/conf/app.example.ini

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>

* take PR feedback into account and display banner on admin dashboard for alerts

* Add more detailed message

* placate lint

* update per feedback

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Steven <61625851+justusbunsi@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2021-10-16 02:14:34 -04:00
wxiaoguang
e18ea9e349
Update documents for Gitea behind reverse proxy. Fix some small bugs (some URLs are generated without sub-path) (#17320)
* Apache `ProxyPassReverse` only works for Location, Content-Location and URI headers on HTTP redirect responses, it causes more problems than it resolves. Now all URLs generated by Gitee have the correct prefix AppSubURL. We do not need to set `ProxyPassReverse`.

* fix url param

* use AppSubURL instead of AppURL in api/v1

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-10-15 23:34:07 -04:00
kolaente
55885297f4
fix: issue close/comment buttons on mobile (#17317)
* fix: issue close/comment buttons on mobile

* fix: lint

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-10-15 22:55:06 -04:00
kolaente
6dd015a53e
fix: code review comments on mobile (#17321)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-10-16 10:22:24 +08:00
GiteaBot
74b6805225 [skip ci] Updated translations via Crowdin 2021-10-16 00:25:26 +00:00
zeripath
58cd55d353
Check for context exceeded in WalkGitLog (#17319)
There is a slight race in checking of a context deadline exceed in #16467
which leads to a 500 on the repository page.

The solution is to check the error coming back from `*LogNameStatusRepoParser.Next()`
and if it is the `ContextDeadlineExceeded` break from the loop.

Fix #17314

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-15 19:41:34 +01:00
zeripath
a889d0cc8c
Add buttons to allow loading of incomplete diffs (#16829)
This PR adds two buttons to the stats and the end of the diffs list to load the (some of) the remaining incomplete diff sections.

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


## Screenshots

### Show more button at the end of the diff
![Screenshot from 2021-09-04 11-12-37](https://user-images.githubusercontent.com/1824502/132091009-b1f6113e-2c04-4be5-8a04-b8ecea56887b.png)

### Show more button at the end of the diff stats box
![Screenshot from 2021-09-04 11-14-54](https://user-images.githubusercontent.com/1824502/132091063-86da5a6d-6628-4b82-bea9-3655cd9f40f6.png)
2021-10-15 17:05:33 +01:00
Lunny Xiao
bdfd751af8
Multiple tokens support for migrating from github (#17134)
* multiple tokens support for migrating from github

* improve code and token description

* Fix bug

* Add comment for get client
2021-10-15 13:47:15 +08:00
wxiaoguang
56362043d3
Frontend refactor: move Vue related code from index.js to components dir, and remove unused codes. (#17301)
* frontend refactor

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Update templates/base/head.tmpl

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/developers/guidelines-frontend.md

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>

* fix typo

* fix typo

* refactor PageData to pageData

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* Simply for the visual difference.

Co-authored-by: delvh <dev.lh@web.de>

* Revert "Apply suggestions from code review"

This reverts commit 4d78ad9b0e96ca180e0823de17659a2e0814c099.

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-15 10:35:26 +08:00
GiteaBot
96ff3e310f [skip ci] Updated translations via Crowdin 2021-10-15 00:25:10 +00:00
Maximilian Weiler
030f696cdd
Show direct match on top for user search (#17303)
This PR makes sure that direct matches in the user search always show on top of the result list.

The following places were checked to follow the desired behavior now:
- Search when adding a user to a team
- Search when adding a user as a collaborator to a repository

Signed-off-by: Maximilian Weiler <16721506+maweil@users.noreply.github.com>
2021-10-15 01:48:47 +02:00
David Jimenez
fa8b8c055d
Don't panic if we fail to parse U2FRegistration data (#17304)
* Don't panic if we fail to parse a U2FRegistration data

Downgrade logging statement from Fatal to Error so that errors parsing
U2FRegistration data does not panic; instead, the invalid key will be
skipped and we will attempt to parse the next one, if available.

Signed-off-by: David Jimenez <dvejmz@sgfault.com>
2021-10-14 18:37:35 +02:00
Lunny Xiao
d47798ccc7
Upgrade chi to v5 (#17298) 2021-10-13 22:50:23 -04:00
GiteaBot
bd14c40461 [skip ci] Updated translations via Crowdin 2021-10-14 00:25:07 +00:00
zeripath
5a8dd96b33
Ensure that git daemon export ok is created for mirrors (#17243)
* Ensure that git daemon export ok is created for mirrors

There is an issue with #16508 where it appears that create repo requires that the
repo does not exist. This causes #17241 where an error is reported because of this.

This PR fixes this and also runs update-server-info for mirrors and generated repos.

Fix #17241

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-13 20:47:02 +01:00
zeripath
01b9d35f1a
Disable core.protectNTFS (#17300)
core.protectNTFS protects NTFS from files which may be difficult to remove or interact
with using the win32 api, however, it also appears to prevent such files from
being entered into the git indexes - fundamentally causing breakages with PRs that
affect these files. However, deliberately setting this to false may cause security
issues due to the remain sparse checkout of files in the merge pipeline.

The only sensible option therefore is to provide an optional setting which admins
could set which would forcibly switch this off if they are affected by this issue.

Fix #17092

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-13 14:20:11 -04:00
zeripath
429258cff3
Use pointer for wrappedConn methods (#17295)
Fix #17294

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-12 21:55:18 +01:00
wxiaoguang
7bcbdd0707
Add user status filter to admin user management page (#16770)
It makes Admin's life easier to filter users by various status.

* introduce window.config.PageData to pass template data to javascript module and small refactor

move legacy window.ActivityTopAuthors to window.config.PageData.ActivityTopAuthors
make HTML structure more IDE-friendly in footer.tmpl and head.tmpl
remove incorrect <style class="list-search-style"></style> in head.tmpl
use log.Error instead of log.Critical in admin user search

* use LEFT JOIN instead of SubQuery when admin filters users by 2fa. revert non-en locale.

* use OptionalBool instead of status map

* refactor SearchUserOptions.toConds to SearchUserOptions.toSearchQueryBase

* add unit test for user search

* only allow admin to use filters to search users
2021-10-12 20:11:35 +02:00
Romain
d0a681fbc3
[API] Add endpount to get user org permissions (#17232)
* Add endpoint

* Add swagger response + generate swagger

* Stop execution if user / org is not found

* Add tests


Co-authored-by: 6543 <6543@obermui.de>
2021-10-12 12:47:19 +02:00
GiteaBot
7b8723158e [skip ci] Updated translations via Crowdin 2021-10-12 00:25:09 +00:00
Viktor Kuzmin
f2a5d1b42b
AutoRegistration is supposed to be working with disabled registration (#17219)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-10-11 12:23:59 -04:00
wxiaoguang
d8e06a90f0
Open markdown image links in new window (#17287) 2021-10-11 20:12:06 +08:00
GiteaBot
758c8c8446 [skip ci] Updated translations via Crowdin 2021-10-11 00:25:06 +00:00
wxiaoguang
c5c88f2f18
Save and view issue/comment content history (#16909)
* issue content history

* Use timeutil.TimeStampNow() for content history time instead of issue/comment.UpdatedUnix (which are not updated in time)

* i18n for frontend

* refactor

* clean up

* fix refactor

* re-format

* temp refactor

* follow db refactor

* rename IssueContentHistory to ContentHistory, remove empty model tags

* fix html

* use avatar refactor to generate avatar url

* add unit test, keep at most 20 history revisions.

* re-format

* syntax nit

* Add issue content history table

* Update models/migrations/v197.go

Co-authored-by: 6543 <6543@obermui.de>

* fix merge

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-10-10 18:40:03 -04:00
GiteaBot
ff9a8a2231 [skip ci] Updated translations via Crowdin 2021-10-10 00:25:11 +00:00
GiteaBot
6d30a00762 [skip ci] Updated translations via Crowdin 2021-10-09 00:25:09 +00:00
techknowlogick
ee73d8409f
changelog for 1.15.4 (frontport) (#17273) 2021-10-08 22:51:57 +01:00
a1012112796
bb39359668
Add a simple way to rename branch like gh (#15870)
- Update default branch if needed
- Update protected branch if needed
- Update all not merged pull request base branch name
- Rename git branch
- Record this rename work and auto redirect for old branch on ui

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: delvh <dev.lh@web.de>
2021-10-08 19:03:04 +02:00
qwerty287
56d79301b9
Move add deploy key form before the list and add a cancel button (#17228) 2021-10-08 18:15:09 +02:00
zeripath
001dbf100d
Defer Last Commit Info (#16467)
One of the biggest reasons for slow repository browsing is that we wait
until last commit information has been generated for all files in the
repository.

This PR proposes deferring this generation to a new POST endpoint that
does the look up outside of the main page request.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-10-08 15:08:22 +02:00
99rgosse
88fa9f3fb1
Remove heads pointing to missing old refs (#17076)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-08 12:59:35 +03:00
Jimmy Praet
b6147152f8
Fix incorrect repository count on organization tab of dashboard (#17256)
Fixes #17249
2021-10-08 08:49:20 +02:00
qwerty287
cd0928f0e8
Allow adding multiple issues to a project (#17226)
Adds an option like for adding multiple issues to a milestone.
Closes #17216
2021-10-08 00:00:02 +02:00
Jimmy Praet
25a2000787
Fix unwanted team review request deletion (#17257)
Add missing issue_id = ? to where clause
Fixes #17251
2021-10-07 22:39:59 +02:00
zeripath
46cac263ca
Handle duplicate keys on GPG key ring (#17242)
It is possible that a keyring can contain duplicate keys on a keyring due to jpegs or
other layers. This currently leads to a confusing error for the user - where we report
a duplicate key insertion.

This PR simply coalesces keys into one key if there are duplicates.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-07 23:10:14 +03:00
Jimmy Praet
29acb3213b
Fix broken Activities link in team dashboard (#17255)
Remove '/' suffix from organization dashboard link

Fixes #17250
2021-10-07 20:27:38 +02:00
techknowlogick
f0bd1e9896
Add protection to disable Gitea when run as root (#17168)
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-07 10:52:08 +02:00
pricly-yellow
4afdb1eb78
API pull's head/base have correct permission (#17214)
close #17181

* for all pull requests API return permissions of caller
* for all webhook return empty permissions

Signed-off-by: Danila Kryukov <pricly_yellow@dismail.de>
Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-07 02:03:37 +02:00
finga
67bc04fe21
Fix problem when database ID is not incremented as expected (#17229)
Although #17124 fixed the same issue for the feed, some other parts
with the same issue were found.

Co-authored-by: finga <finga@onders.org>
2021-10-06 15:36:24 -05:00
wxiaoguang
21a784e94a
fix navbar ui (#17235) 2021-10-06 17:22:44 +02:00
6543
70d8d64cb8
CI: migrate from 'plugins/s3:1' to 'woodpeckerci/plugin-s3:latest' (#17234)
- this fixes the CI release upload issues, as the docker image for this is freshly built (unlike the mostly unmaintained "official" drone plugins), thus containing current CA certs needed for letsencrypt since 2021-09-31.
- woodpecker is a drone-ci fork maintained partially by @6543. it's API compatible with current drone plugins afaik
2021-10-06 13:58:11 +02:00
wxiaoguang
f0ba87fda8
Avatar refactor, move avatar code from models to models.avatars, remove duplicated code (#17123)
Why this refactor

The goal is to move most files from `models` package to `models.xxx` package. Many models depend on avatar model, so just move this first.

And the existing logic is not clear, there are too many function like `AvatarLink`, `RelAvatarLink`, `SizedRelAvatarLink`, `SizedAvatarLink`, `MakeFinalAvatarURL`, `HashedAvatarLink`, etc. This refactor make everything clear:

* user.AvatarLink()
* user.AvatarLinkWithSize(size)
* avatars.GenerateEmailAvatarFastLink(email, size)
* avatars.GenerateEmailAvatarFinalLink(email, size)

And many duplicated code are deleted in route handler, the handler and the model share the same avatar logic now.
2021-10-06 01:25:46 +02:00
n
48c2578bd8
Remove Dashboard/Home button from the navbar (#16844)
This removes the Dashboard/Home buttons and adds its text to the title of the logo.

Co-authored-by: Alexey 〒erentyev <axifnx@gmail.com>
2021-10-05 22:42:02 +02:00
Romain
167914cf8b
Redirect on project after issue created (#17211)
close #17011

If user create an issue with button in project view, after issue is created the user is redirect to project view.
2021-10-05 21:21:52 +02:00
Romain
987152ba40
Add metrics to get issues by repository (#17225) 2021-10-05 20:39:37 +02:00
John Olheiser
760d61b411
Add specific event type to header (#17222)
* Add specific event type to header

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Change single to type
2021-10-05 12:12:17 -05:00
pricly-yellow
20eaca6d05
Fix stange behavior of DownloadPullDiffOrPatch in incorect index (#17223)
Fix GetPullRequestByIndex by validate index > 1

Signed-off-by: Danila Kryukov <pricly_yellow@dismail.de>

Co-authored-by: a1012112796 <1012112796@qq.com>
2021-10-05 16:41:48 +02:00
GiteaBot
f4ea6cc4b4 [skip ci] Updated translations via Crowdin 2021-10-05 00:25:07 +00:00
GiteaBot
dd22c65002 [skip ci] Updated translations via Crowdin 2021-10-04 00:25:03 +00:00
Romain
fc5ee1edf9
Add metrics to get issues by label (#17201)
* Add metrics to get issues by label

* Add comment on IssueByLabelCount

* Code review - Unify "AS" in SQL (#17201)

* Code review - Remove useless join (#17201)

* Code review - Disable issue_by_label by default in settings (#17201)

* use e

* restore empty line

* update docs

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-10-03 18:46:44 -04:00
Petr Vaněk
89ddbe9699
Fix typo in app.example.ini (#17213) 2021-10-03 18:46:20 -04:00
Norwin
1f45b3a629
API: don't allow merged PRs to be reopened (#17192)
* api: dont open merged PRs

* don't change base branch when already merged

* don't allow any state change

* also validate opening merged PRs in EditIssue

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-10-02 23:11:17 -04:00
Norwin
8f75a559ee
Reference in new issue modal: dont pre-populate issue title (#17208)
* dont prepopulate issue title

* cleanup
2021-10-02 12:05:55 -04:00
qwerty287
47193dbcd9
Add option to copy line permalink (#17145)
* Add option to copy line permalink

* Fix lint

* Apply review suggestions

* Update code and fix lint

* Use features/clipboard.js framework
2021-10-02 10:46:43 +03:00
Romain
c64e2a319f
Add projects and project boards in exposed metrics (#17202)
* Add projects and project boards in exposed metrics

* Refactor db.GetEngine

Co-authored-by: delvh <dev.lh@web.de>
2021-10-02 03:32:15 +02:00
GiteaBot
5b2b2cf923 [skip ci] Updated translations via Crowdin 2021-10-02 00:25:02 +00:00
KN4CK3R
3b06675811
Always set a unique Message-ID header. (#17206) 2021-10-01 11:24:43 -04:00
GiteaBot
347d48fdfe [skip ci] Updated translations via Crowdin 2021-10-01 00:25:01 +00:00
zeripath
206ea10b45
Prevent NPE on invalid diff (#17197)
* Prevent NPE on invalid diff

If ParseCompareInfo returns a nil compare info the defer function needs to ensure
that it does not attempt to close the HeadGitRepo.

Fix #17193

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

* add TEST

Co-authored-by: 6543 <6543@obermui.de>
2021-09-30 21:31:02 +02:00
Norwin
3bbdce2601
API: add html urls to notification subjects (#17178)
* API: add html urls to notification subjects

* add "Repository"

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-30 07:17:39 +03:00
GiteaBot
ac10c4ecc2 [skip ci] Updated translations via Crowdin 2021-09-30 00:25:39 +00:00
zeripath
ddd3586c06
Fix missing repo link in issue/pull assigned emails (#17183)
There was a mistake in the template file: `templates/mail/issue/assigned.tmpl`
where the repourl was generated from a non-existent release instead of the issue.

This PR changes this to use the issue but also ensure that the issue repo is loaded.

It also slightly improves the English locale string.

Fix #17160

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2021-09-30 01:20:18 +02:00
Romain
ecfac78f6e
Kanban colored boards (#16647)
Add a column Color in ProjectBoard and color picker in new / edit project board form.
2021-09-29 22:53:12 +02:00
Lunny Xiao
ba1fdbcfdb
upgrade xorm to v1.2.5 (#17177) 2021-09-29 23:08:44 +03:00
silverwind
d30410675b
Fix wording in issue template (#17176)
There was a typo `systemm` here. I opted to just remove the superfluos word altogether.
2021-09-29 13:03:44 +02:00
GiteaBot
51bfe62bd9 [skip ci] Updated translations via Crowdin 2021-09-29 00:25:04 +00:00
techknowlogick
e9a9c20d52
Create pub/priv keypair for federation (#17071)
* add logic for creating pub/priv keypair for federation

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* make fmt

* Update modules/activitypub/keypair.go

Co-authored-by: delvh <dev.lh@web.de>

* add tests

* fix revert

* more tests

* Apply suggestions from code review

Co-authored-by: delvh <dev.lh@web.de>

* make fmt

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
2021-09-28 15:19:22 -04:00
Lunny Xiao
37b29319aa
Fix bug of get context user (#17169)
Co-authored-by: 6543 <6543@obermui.de>
2021-09-28 21:13:04 +08:00
delvh
a82c799fc8
Add delvh to MAINTAINERS (#17170) 2021-09-28 14:28:12 +02:00
GiteaBot
4389b2cacf [skip ci] Updated translations via Crowdin 2021-09-28 00:05:15 +00:00
techknowlogick
babab0bf5e
Add nodeinfo endpoint for federation purposes (#16953)
Nodeinfo is a way to expose certain metadata about a server for use of discovery regarding functionality of its federation capabilities.

Two endpoints are required:
1. `/.well-known/nodeinfo` which informs client where it can find the location of the location of its metadata (including which version of the schema is used)
2. the endpoint which exposes the metadata in json format according to schema.

Notes:
* `openRegistrations` is a required field, but I propose to set to false as default in case someone writes a crawler to discover "open" gitea instances
* to limit data leakage I also propose to not include the `usage` field (note it is required so it should be included, but left as empty).

More info:
https://github.com/jhass/nodeinfo
https://github.com/jhass/nodeinfo/tree/main/schemas/2.1
http://nodeinfo.diaspora.software/protocol.html
2021-09-28 01:38:06 +02:00
Norwin
f48dce3176
Don't return binary file changes in raw PR diffs by default (#17158)
* return diffs without binary file content change

* ?binary=true option to restore old behaviour

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2021-09-27 17:09:49 -04:00
zeripath
e8574f2f7d
Nicely handle missing user in collaborations (#17049)
* Nicely handle missing user in collaborations

It is possible to have a collaboration in a repository which refers to a no-longer
existing user. This causes the repository transfer to fail with an unusual error.

This PR makes `repo.getCollaborators()` nicely handle the missing user by ghosting
the collaboration but also adds consistency check. It also adds an
Access consistency check.

Fix #17044

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

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2021-09-27 19:07:19 +01:00
zeripath
b5856c4437
Create doctor command to fix repo_units broken by dumps from 1.14.3-1.14.6 (#17136)
There was a serious issue with the `gitea dump` command in 1.14.3-1.14.6 which led to corruption of the `config` field of the `repo_unit` table. 

This PR adds a doctor command to attempt to fix the broken repo_units. Users affected by #16961 should run:

```
gitea doctor --fix --run fix-broken-repo-units
```

Fix #16961

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-27 16:55:12 +01:00
Gwyneth Morgan
4e0cca3f7d
Use light/dark theme based on system preference (#17051)
Add a new default theme `auto`, which will automatically switch between
`gitea` (light) and `arc-green` (dark) themes depending on the user's
operating system settings.

Closes: #8183
2021-09-27 15:47:44 +01:00
Forest Johnson
868e937a53
docs: explain where are settings for release files (#17161)
Just a tiny change to save someone some time while reading the docs. I got lost in the angular code and npm packages trying to reverse engineer it  and figure out what setting controlled this file limit: 

![image](https://user-images.githubusercontent.com/7119703/134829716-8f587878-21a3-413b-ba1e-c2bbe9391ad2.png)

Eventually I tracked it down from

b74a0f9060/options/locale/locale_en-US.ini (L2776)

to

b74a0f9060/templates/repo/upload.tmpl (L11)

to 

b74a0f9060/web_src/js/index.js (L1043) 

to 

b74a0f9060/web_src/js/features/dropzone.js (L3)

to

https://www.npmjs.com/package/dropzone

and then I realized I can't read 😅,  back  to 

b74a0f9060/templates/repo/upload.tmpl (L8)

and quickly solved it from there!! 

b74a0f9060/modules/upload/upload.go (L81)


Yes  I know this long path was 90% me failing to read code properly and going on a red herring journey...  but point is we should not have to do this in the first place to know how to  configure this file upload form 🥺 👉 👈
2021-09-27 14:00:54 +01:00
zeripath
920608e592
Support direct comparison (git diff a..b) as well merge comparison (a...b) (#16635)
This PR changes the compare page to make the "..." in the between branches a clickable
link. This changes the comparison type from "..." to "..". Similarly it makes the
initial compare icon clickable to switch the head and base branches.

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-27 13:19:34 +01:00
zeripath
123f0aea00
Allow LDAP Sources to provide Avatars (#16851)
* Allow LDAP Sources to provide Avatars

Add setting to LDAP source to allow it to provide an Avatar.

Currently this is required to point to the image bytes.

Fix #4144

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

* Rename as Avatar Attribute (drop JPEG)

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

* Always synchronize avatar if there is change

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

* Actually get the avatar from the ldap

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

* clean-up

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

* use len()>0 rather than != ""

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

* slight shortcut in IsUploadAvatarChanged

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-26 22:39:36 -04:00
zeripath
7e98cd58dd
Add SkipLocal2FA option to pam and smtp sources (#17078)
* Add SkipLocal2FA option to other pam and smtp sources

Extend #16954 to allow setting skip local 2fa on pam and SMTP authentication sources

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

* make SkipLocal2FA omitempty

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

Co-authored-by: 6543 <6543@obermui.de>
2021-09-26 21:02:01 -04:00
GiteaBot
74542ad35b [skip ci] Updated translations via Crowdin 2021-09-26 00:05:01 +00:00
Alexey 〒erentyev
7e9bd206fd
Fix bundle creation (#17079)
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gwyneth Morgan <87623694+gwymor@users.noreply.github.com>
Co-authored-by: Gwyneth Morgan <gwymor@tilde.club>
2021-09-26 00:29:25 +03:00
Lunny Xiao
58d81835e2
Fix wrong i18n keys (#17150)
Co-authored-by: 6543 <6543@obermui.de>
2021-09-25 16:27:01 +02:00
Lunny Xiao
91e21d4fca
Move twofactor to models/login (#17143) 2021-09-25 15:00:12 +02:00
sebastian-sauer
6fb7fb6cfc
Force color-adjust for markdown checkboxes (#17146)
this forces browsers to render background correctly

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-25 14:45:55 +08:00
GiteaBot
cbd5dc4dd6 [skip ci] Updated translations via Crowdin 2021-09-25 00:04:51 +00:00
zeripath
623d2dd411
Prevent panic in Org mode HighlightCodeBlock (#17140)
When rendering source in org mode there is a mistake in the highlight code that
causes a panic.

This PR fixes this.

Fix #17139

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-24 14:29:32 +01:00
Lunny Xiao
5842a55b31
Move login related structs and functions to models/login (#17093)
* Move login related structs and functions to models/login

* Fix test

* Fix lint

* Fix lint

* Fix lint of windows

* Fix lint

* Fix test

* Fix test

* Only load necessary fixtures when preparing unit tests envs

* Fix lint

* Fix test

* Fix test

* Fix error log

* Fix error log

* Fix error log

* remove unnecessary change

* fix error log

* merge main branch
2021-09-24 19:32:56 +08:00
crapStone
4a2655098f
Unify issue and pr subtitles (#17133) 2021-09-23 18:57:52 +02:00
zeripath
9302eba971
DBContext is just a Context (#17100)
* DBContext is just a Context

This PR removes some of the specialness from the DBContext and makes it context
This allows us to simplify the GetEngine code to wrap around any context in future
and means that we can change our loadRepo(e Engine) functions to simply take contexts.

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

* fix unit tests

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

* another place that needs to set the initial context

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

* avoid race

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

* change attachment error

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-23 23:45:36 +08:00
delvh
b22be7f594
Fix typo skipping a migration (#17130) 2021-09-23 20:42:42 +08:00
Lunny Xiao
d9c69596ff
Fix commit status index problem (#17061)
* Fix commit status index problem

* remove unused functions

* Add fixture and test for migration

* Fix lint

* Fix fixture

* Fix lint

* Fix test

* Fix bug

* Fix bug
2021-09-23 18:50:06 +08:00
Lunny Xiao
d9e237e3f2
Fix problem when database id is not increment as expected (#17124) 2021-09-22 23:09:29 +03:00
Eng Zer Jun
f2e7d5477f
refactor: move from io/ioutil to io and os package (#17109)
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-22 13:38:34 +08:00
techknowlogick
aa631d8cd1
update docs to 1.15.3 2021-09-21 21:38:04 -04:00
6543
fc1e9e6302
Changelog 1.15.3 (#17091) (#17113)
## [1.15.3](https://github.com/go-gitea/gitea/releases/tag/v1.15.3) - 2021-09-19

* ENHANCEMENTS
  * Add fluid to ui container class to remove margin (#16396) (#16976)
  * Add caller to cat-file batch calls (#17082) (#17089)
* BUGFIXES
  * Render full plain readme. (#17083) (#17090)
  * Upgrade xorm to v1.2.4 (#17059)
  * Fix bug of migrate comments which only fetch one page (#17055) (#17058)
  * Do not show issue context popup on external issues (#17050) (#17054)
  * Decrement Fork Num when converting from Fork (#17035) (#17046)
  * Correctly rollback in ForkRepository (#17034) (#17045)
  * Fix missing close in WalkGitLog (#17008) (#17009)
  * Add prefix to SVG id/class attributes (#16997) (#17000)
  * Fix bug of migrated repository not index (#16991) (#16996)
  * Skip AllowedUserVisibilityModes validation on update user if it is an organisation (#16988) (#16990)
  * Fix storage Iterate bug and Add storage doctor to delete garbage attachments (#16971) (#16977)
  * Fix issue with issue default mail template (#16956) (#16975)
  * Ensure that rebase conflicts are handled in updates (#16952) (#16960)
  * Prevent panic on diff generation (#16950) (#16951)

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-22 09:32:45 +08:00
qwerty287
0fa153f421
Merge endpoints for pull diff/patch (#17104)
this merges the two API endpoints for the PR diff/patch in to one
2021-09-22 01:04:53 +02:00
zeripath
10108b184e
Add Horizontal scrollbar to inner menu on Chrome (#17086)
There is a longstanding bug whereby the admin pages, in particular, have not had
a horizontal scrollbar on chrome when the page is narrow.

This PR simply adds overflow-x and adds a default height to the scrollbar to
match that of the vertical bar.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-21 09:35:28 +01:00
wxiaoguang
b231d0deab
Ignore Sync errors on pipes when doing CheckAttributeReader.CheckPath, fix the hang of git cat-file (#17096)
* Ignore Sync errors on pipes when doing `CheckAttributeReader.CheckPath`

* apply env patch

* Drop the Sync and fix a number of issues with the Close function

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

* add logs for DBIndexer and CheckPath

* Fix some more closing bugs

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

* Add test case for language_stats

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

* Update modules/indexer/stats/db.go

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2021-09-20 20:46:51 +01:00
qwerty287
5ac857f4d4
Add API to get commit diff/patch (#17095)
* Add API to get commit diff/patch
* Add Tests

Co-authored-by: 6543 <6543@obermui.de>
2021-09-20 18:14:29 +02:00
GiteaBot
d4bb8e0ae7 [skip ci] Updated translations via Crowdin 2021-09-20 00:04:38 +00:00
Lunny Xiao
a4bfef265d
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db

* Fix lint

* Fix lint

* Fix test

* Fix lint

* Fix lint

* revert unnecessary change

* Fix test

* Fix wrong replace string

* Use *Context

* Correct committer spelling and fix wrong replaced words

Co-authored-by: zeripath <art27@cantab.net>
2021-09-19 19:49:59 +08:00
GiteaBot
462306e263 [skip ci] Updated licenses and gitignores 2021-09-19 00:05:00 +00:00
wxiaoguang
6532aa2ed3
Open the DingTalk link in browser (#17084)
https://developers.dingtalk.com/document/app/message-link-description

To open the link in browser, we should use this URL: `"dingtalk://dingtalkclient/page/link?pc_slide=false&url=" + url.QueryEscape(singleURL)`

Otherwise the page is displayed inside DingTalk client, it makes users very difficult to visit non-public URLs in DingTalk webhook messages.
2021-09-18 20:35:23 +01:00
Bagas Sanjaya
ea207f694d
Add left padding for chunk header of split diff view (#13397)
This commit adds 10px padding-left on chunk header element
(which is `<span>`).

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
2021-09-18 18:59:21 +01:00
silverwind
d04e581f09
Switch migration icon to svg (#15954)
Followup on https://github.com/go-gitea/gitea/pull/15952, use SVG for migration icon.

<img width="541" alt="Screen Shot 2021-05-23 at 00 26 12" src="https://user-images.githubusercontent.com/115237/119242417-c1a37600-bb5d-11eb-9f97-a80aa89741ee.png">
<img width="540" alt="Screen Shot 2021-05-23 at 00 25 39" src="https://user-images.githubusercontent.com/115237/119242419-c2d4a300-bb5d-11eb-9792-1e6e4092c9f9.png">
2021-09-18 17:22:51 +01:00
Jelle Hulter
b74a0f9060
Fixed issue where creating a reference of an issue would create a tag with the full name instead of the username if this is the default in the .ini file (#17074)
Adds an extra attribute to every issue comment containing the actual username, such that it can be used to tag the original author when clicking on "Reference in new issue" (#17073)

Fix #17073
2021-09-18 16:44:45 +01:00
KN4CK3R
8fb3a50a37
Render full plain readme. (#17083) 2021-09-17 21:46:57 -05:00
Norwin
0b368aa73d
OpenAPI: correct documentation of issue listing parameters (#17060)
* correct documentation of issue listing parameters

* make generate-swagger

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-17 21:01:50 -04:00
zeripath
25533657f6
Add caller to cat-file batch calls (#17082)
Some people still appear to report unclosed cat-files. This PR simply adds the caller
to the process descriptor for the CatFileBatch and CatFileBatchCheck calls.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-17 20:54:15 -04:00
GiteaBot
693bea9780 [skip ci] Updated translations via Crowdin 2021-09-18 00:05:15 +00:00
Norwin
0ffad31b92
Notifications API: respond with updated notifications (#17064)
* notifications api: return updated notifications in response

* make generate-swagger

* openapi fix

Co-authored-by: zeripath <art27@cantab.net>
2021-09-17 19:40:50 -04:00
zeripath
ba2e600d17
Add minimum versions of databases to the docs (#17080)
We do not currently state the minimum versions of databases we support.

This PR sets them to:
* MySQL >=5.7
* Postgres >=10
* MSSQL >=2008R2 SP3

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-17 23:25:50 +01:00
zeripath
27b351aba5
Make LDAP be able to skip local 2FA (#16954)
This PR extends #16594 to allow LDAP to be able to be set to skip local 2FA too. The technique used here would be extensible to PAM and SMTP sources.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-17 12:43:47 +01:00
GiteaBot
f96d0d3d5b [skip ci] Updated translations via Crowdin 2021-09-17 00:04:54 +00:00
Lunny Xiao
e21a35698c
Upgrade xorm to v1.2.4 (#17059) (#17068)
Co-authored-by: zeripath <art27@cantab.net>
2021-09-16 13:53:28 -04:00
zeripath
8de44d1995
Clean-up HookPreReceive and restore functionality for pushing non-standard refs (#16705)
* Clean-up HookPreReceive and restore functionality for pushing non-standard refs

There was an inadvertent breaking change in #15629 meaning that notes refs and other
git extension refs will be automatically rejected.

Further following #14295 and #15629 the pre-recieve hook code is untenably long and
too complex.

This PR refactors the hook code and removes the incorrect forced rejection of
non-standard refs.

Fix #16688

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-16 15:34:54 +02:00
Gabriel
a959ed99c2
Issue template form (#16349)
* Create issue template using new format

This issue template has been based off of the current issue creation workflow defined in the ISSUE_TEMPLATE.md file
This commit allows for that issue template (which is a legacy method of creating an issue) to be deleted

* Delete old issue template file

This commit deletes the old issue template file, as it is both legacy and replaced by ISSUE_TEMPLATE/issue.yaml

* Adjust file upload and remove code of conduct checkbox

* Block blank issue creation

* Update feedback

Removed most requirements
Updated prompt to include instruction to state whether using try.gitea.io
Added default value to Gitea version

* Create Feature Request issue form

* Update and rename issue.yaml to bug-report.yaml

* Enable blank issue creation

Co-authored-by: a1012112796 <1012112796@qq.com>

* Update config.yaml

* Remove default & placeholder from Gitea version

* Create issue template in .gitea directory

* Add relevant bug report message to feature request

* Adjust name to remove banner

There is a banner that tells you to create a config.yml when you already have a config.yaml
Renaming the file stops this from occurring.

* Add UI bug report form

* Remove unnecessary question

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-09-15 20:33:13 +03:00
Lunny Xiao
45ebcb0d1c
Fix bug of migrate comments which only fetch one page (#17055)
* Fix bug of migrate comments which only fetch one page

* add next page to trace

Co-authored-by: zeripath <art27@cantab.net>
2021-09-15 19:30:19 +08:00
zeripath
db6b7db06d
Improve LDAP synchronization efficiency (#16994)
The current LDAP sync routine has order n^2 efficiency. This change reduces this
to order n.log n.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-15 10:28:37 +01:00
zeripath
976db2a8b7
Do not show issue context popup on external issues (#17050)
The issues pop-up context cannot work for external issues - therefore do not show
these.

Fix #17047

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-15 09:45:27 +01:00
qwerty287
fc97e0626e
Update template (#17043)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-09-15 00:58:44 -04:00
GiteaBot
5a42e72c04 [skip ci] Updated translations via Crowdin 2021-09-15 00:05:33 +00:00
Lunny Xiao
e2f0ab3343
Add doctor dbconsistency check for release and attachment (#16978) 2021-09-14 20:41:40 +01:00
KN4CK3R
87505a9464
Add AbsoluteListOptions (#17028)
This PR adds a `ListOptions` type which is not paged but uses absolute values. It is implemented as discussed in Discord.
Extracted from #16510 to clean that PR.
2021-09-14 18:48:27 +01:00
zeripath
0a542dd59f
Decrement Fork Num when converting from Fork (#17035)
When converting repositories from forks to normal the root NumFork needs to be
decremented too.

Fix #17026

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-14 18:07:08 +01:00
zeripath
26ef180f46
Correctly rollback in ForkRepository (#17034)
The rollback functionality in
services/repository/repository.go:ForkRepository is incorrect and could
lead to a deadlock as it uses DeleteRepository to delete the rolled-back
repository - a function which creates its own transaction.

This PR adjusts the rollback function to only use RemoveAll as any
database changes will be automatically rolled-back. It also handles
panics and adjusts the Close within WithTx to ensure that if there is a
panic the session will always be closed.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-14 18:16:40 +02:00
zeripath
04b233e940
Always emit the configuration path (#17036)
Often when handling problems it is not clear which configuration file Gitea is
using. This PR simply ensures that the configuration file is emitted.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-13 21:24:57 -04:00
zeripath
8af7a21085
Update go-chi/session (fixes "race" in tests) (#17031)
Update to latest go-chi/session where the NewManager causes a new
Provider instantiation instead of reconfiguring an old one.
(https://gitea.com/go-chi/session/pulls/1)

The NewManager call is now concurrency safe and would allow live
reconfiguration in future but for now this PR simply fixes an
intermittent "data-race" detected in our tests.  (See
https://drone.gitea.io/go-gitea/gitea/43900/2/14)

Related #17027
Related #1441

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-13 09:40:55 +01:00
GiteaBot
132c8c43e1 [skip ci] Updated translations via Crowdin 2021-09-13 00:05:10 +00:00
Alexey 〒erentyev
7c84c94232
fixed create repo page layout (#17012)
Signed-off-by: Alexey Terentyev <axifnx@gmail.com>
2021-09-12 20:24:57 +02:00
zeripath
a334a95a3c
Use common sessioner for API and Web (#17027)
* Use common sessioner for API and Web

Instead of creating separate sessioner and doubly initialising the provider just
use the same sessioner for the API and Web routes.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-12 19:35:38 +02:00
Jimmy Praet
aac7f68af1
Fix reset password email template (#17025)
Removed unused variable passed to mail.link_not_working_do_paste

Co-authored-by: 6543 <6543@obermui.de>
2021-09-12 21:02:07 +08:00
Tchoupinax
77b95fd766
Fix overflow label in mobile view (#17020) 2021-09-12 13:40:20 +02:00
GiteaBot
20a2e26e99 [skip ci] Updated translations via Crowdin 2021-09-12 00:05:05 +00:00
Jimmy Praet
3d6cb25e31
Support unprotected file patterns (#16395)
Fixes #16381

Note that changes to unprotected files via the web editor still cannot be pushed directly to the protected branch. I could easily add such support for edits and deletes if needed. But for adding, uploading or renaming unprotected files, it is not trivial.

* Extract & Move GetAffectedFiles to modules/git
2021-09-11 16:21:17 +02:00
GiteaBot
eb03e819d3 [skip ci] Updated translations via Crowdin 2021-09-11 00:05:02 +00:00
zeripath
f394019e9d
Report the associated filter if there is an error in LDAP (#17014)
If there is an error when performing the admin or restricted filter search
ensure that the filter and the userDN are reported.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-11 00:46:27 +02:00
6543
77f604a928
Add skip and limit to git.GetTags (#16897)
* Make GetTags() api similar to GetBranches()
* Use it for Tag/Release page
2021-09-10 19:30:37 +02:00
zeripath
9ca0e7905c
Add setting to OAuth handlers to skip local 2FA authentication (#16594)
This PR adds a setting to OAuth and OpenID login sources to allow the source to
skip local 2FA authentication.

Fix #13939

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-10 18:37:57 +02:00
6543
51578d6418
Calculate label URL on API (#16186)
close #8028
2021-09-10 18:03:16 +02:00
Romain
9a938dc298
Add "new issue" button on project (#17001)
* Add "new issue" button on project
2021-09-10 13:33:06 +02:00
zeripath
0faf175694
Fix missing close in WalkGitLog (#17008)
When the external context is cancelled it is possible for the
GitLogReader to not itself be Closed.

This PR does three things:

1. Instead of adding a plain defer it wraps the `g.Close` in a func as
`g` may change.
2. It adds the missing explicit g.Close - although the defer fix makes
this unnecessary.
3. It passes down the external context as the base context for the
GitLogReader meaning that the cancellation of the external context will
pass down automatically.

Fix #17007

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-10 17:46:12 +08:00
zeripath
248b96d8a3
Use git attributes to determine generated and vendored status for language stats and diffs (#16773)
Replaces #16262
Replaces #16250
Replaces #14833

This PR first implements a `git check-attr` pipe reader - using `git check-attr --stdin -z --cached` - taking account of the change in the output format in git 1.8.5 and creates a helper function to read a tree into a temporary index file for that pipe reader.

It then wires this in to the language stats helper and into the git diff generation.

Files which are marked generated will be folded by default.

Fixes #14786
Fixes #12653
2021-09-09 21:13:36 +01:00
wxiaoguang
b83b4fbef9
doc: Upgrade from an old Gitea (#16918)
* doc: Upgrade from an old Gitea

* update backup steps

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>

* update backup tips

* update table header

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: silverwind <me@silverwind.io>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: silverwind <me@silverwind.io>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* Update docs/content/doc/upgrade/from-gitea.en-us.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* Update from-gitea.en-us.md

* Update from-gitea.en-us.md

* Update from-gitea.en-us.md

* Update from-gitea.en-us.md

* Update from-gitea.en-us.md

* Update from-gitea.en-us.md

* Update from-gitea.en-us.md

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-09 14:13:21 -04:00
KN4CK3R
cd78c30fd3
Use filename as id/class prefix. (#16997)
Currently the svg minifier (`make svg`) rewrites all `id` and `class` attributes in svg files. Every file gets the ids `a, b, ...`. If multiple svgs with ids are used on a page these ids are conflicting and the results are broken images.

| minified ids | unique ids |
| - | - |
| ![grafik](https://user-images.githubusercontent.com/1666336/132579375-59d3996f-c4e5-43b8-8c8d-82280c90d9e3.png) | ![grafik](https://user-images.githubusercontent.com/1666336/132579413-05bf9285-4e3b-4d0d-8f95-90b212405b05.png) |

This PR adds a prefix (the filename) to every id/class.

Follow up problem: Because we embed svg images there are duplicated ids if one svg image is used multiple times on a page. As those ids refer to the same content it may be no real problem because browser handle that fine.
2021-09-09 08:06:54 +01:00
6543
e14b52ea36
Enable Malayalam, Greek, Persian, Hungarian & Indonesian by default (#16998) 2021-09-09 14:16:42 +08:00
GiteaBot
df2c7901e6 [skip ci] Updated translations via Crowdin 2021-09-09 00:04:58 +00:00
a1012112796
358555f72c
Return correct error response for agit force-push (#16989)
fix a samll nit for agit `force-push` error response

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-09-08 22:20:55 +02:00
Lunny Xiao
efdbba4453
Fix bug of migrated repository not index (#16991)
Fix #16986, #16152
2021-09-08 18:43:19 +01:00
Hakermann420
1b922374db
Changes for German language (#16985)
* translated the rest of index.de-de.md to german

* fixed typo in german locale activate_account email

* fixed typo in german doc/content/page/index.md

* Update docs/content/page/index.de-de.md

Co-authored-by: delvh <dev.lh@web.de>

* commited sugesstions

Co-authored-by: delvh <dev.lh@web.de>

* commited sugesstions

Co-authored-by: delvh <dev.lh@web.de>

* commited sugesstions

Co-authored-by: delvh <dev.lh@web.de>

* revert locale change

Co-authored-by: delvh <dev.lh@web.de>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-09-08 12:37:06 -04:00
6543
8e18b412c3
Skip AllowedUserVisibilityModes validation on update user if it is an organisation (#16988)
if AllowedUserVisibilityModes allow only public & limited, and orgs can be private, a user can create a repo to that organisation whitch will result in an update of the user. On this call the user is validaten and will be rejected since private is not allowed, but its not an user its an valid org ...

Co-authored-by: Alexey 〒erentyev <axifnx@gmail.com>
2021-09-08 17:47:49 +02:00
Lunny Xiao
ddc709ff7f
Add repo_id for attachment (#16958)
When create a new issue or comment and paste/upload an attachment/image, it will not assign an issue id before submit. So if user give up the creating, the attachments will lost key feature and become dirty content. We don't know if we need to delete the attachment even if the repository deleted.

This PR add a repo_id in attachment table so that even if a new upload attachment with no issue_id or release_id but should have repo_id. When deleting a repository, they could also be deleted.

Co-authored-by: 6543 <6543@obermui.de>
2021-09-08 17:19:30 +02:00
6543
f55cd033ed
Make TestOneDevDownloadRepo work again & more resistant (#16987)
* Update TestOneDevDownloadRepo since OneDev api changed

* Use test functions for migrations
2021-09-08 16:17:22 +02:00
silverwind
bc81d12e68
Disable Fomantic's CSS tooltips (#16974)
CSS-only tooltips suffer various issues with positioning and there was
only one single instance of them in the templates. Replace that instance
with a regular popup and exclude these `data-tooltip` styles from the
Fomantic build.
2021-09-08 07:23:46 +01:00
6543
63d7cbcef1
Make mirror feature more configurable (#16957)
Rename`[repository]` `DISABLE_MIRRORS` to `[mirror]` `DISABLE_NEW_PULL`  and add `ENABLED` and `DISABLE_NEW_PUSH` with the below meanings:

- `ENABLED`: **true**: Enables the mirror functionality. Set to **false** to disable all mirrors.
- `DISABLE_NEW_PULL`: **false**: Disable the creation of **new** mirrors. Pre-existing mirrors remain valid.
- `DISABLE_NEW_PUSH`: **false**: Disable the creation of **new** push mirrors. Pre-existing mirrors remain valid.


Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: delvh <dev.lh@web.de>
2021-09-07 17:49:36 +02:00
GiteaBot
ded438fb1a [skip ci] Updated translations via Crowdin 2021-09-07 00:04:55 +00:00
silverwind
9fa6bdb64e
Add Cache-Control to avatar redirects (#16973)
* Add Cache-Control to avatar redirects

This does seem to do the trick to make the Avatar redirects cachable
in Chrome.

In Firefox, it does not seem to work, thought and I found no way to
suppress the requests to the original URLs, I even tried setting an
Etag to no avail.

Related discussion in https://github.com/go-gitea/gitea/issues/16964.

Co-authored-by: zeripath <art27@cantab.net>
2021-09-06 23:05:44 +02:00
6543
cf6d398485
Resolve TODO: Enable pagination on GiteaDownloader.GetComments() & update another TODO (#16963)
* Update TODO in migrations

* Resolve TODO: enable pagination on GiteaDownloader.GetComments()
2021-09-06 18:00:50 +02:00
Lunny Xiao
a807031a30
Fix storage Iterate bug and Add storage doctor to delete garbage attachments (#16971)
* Fix storage Iterate bug and Add storage doctor to delete garbage attachments

* Close object when used
2021-09-06 16:46:20 +02:00
a1012112796
82da380af7
Add missing icon set for ActionRenameRepo (#16972)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-09-06 16:11:17 +02:00
zeripath
0767fe0d80
Prevent panic on diff generation (#16950)
The lastLeftIdx should be reset at the same time as creating a new section otherwise
it is possible for a second addition to end up attempting to read a nil entry.

Fix #16943

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-05 12:16:49 +02:00
zeripath
eb0330a3fe
Ensure that rebase conflicts are handled in updates (#16952)
PR #16125 did not update the error handlers to handle conflict errors relating
to rebases. This PR adds them.

Fix #16922

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-05 10:30:40 +01:00
Prasad Katti
4c7a70b348
Fix issue with issue default mail template (#16956)
The mail template rendering was failing with the error -
`...vices/mailer/mail.go:301:composeIssueCommentMessages() [E] ExecuteTemplate [issue/default/body]: template: issue/default:65:10: executing "issue/default" at <.i18n.Tr>: can't evaluate field i18n in type *models.Comment`

The issue was the template variable i18n is available in the outer scope.

Fix #16877
2021-09-05 09:06:20 +01:00
GiteaBot
5a73153493 [skip ci] Updated translations via Crowdin 2021-09-04 00:04:54 +00:00
techknowlogick
22c73278bc
update docs to 1.15.2 2021-09-03 13:49:06 -04:00
zeripath
7d1d32a436
Changelog 1.15.2 (#16940) (#16944)
## [1.15.2](https://github.com/go-gitea/gitea/releases/tag/v1.15.2) - 2021-09-03

* BUGFIXES
  * Add unique constraint back into issue_index (#16938)
  * Close storage objects before cleaning (#16934) (#16942)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-04 01:06:40 +08:00
aceArt-GmbH
f3b36e2a39
Doc: Mail-Tempales: Fix AppUrl function name (#16939)
Thanks to https://github.com/go-gitea/gitea/pull/16788 I can see why our docker container kept restarting when adding the custom mail template example.
[The example template](https://docs.gitea.io/en-us/mail-templates/#example) has an error

```
2021/09/03 10:55:25 cmd/web.go:91:func1() [F] PANIC: template: mail/issue/default:35: function "AppURL" not defined
        /usr/local/go/src/html/template/template.go:374 (0x1563bb8)
        /go/src/code.gitea.io/gitea/vendor/github.com/unrolled/render/render.go:322 (0x1563782)
        /go/src/code.gitea.io/gitea/vendor/github.com/unrolled/render/render.go:202 (0x1562f8b)
        /go/src/code.gitea.io/gitea/vendor/github.com/unrolled/render/render.go:146 (0x15629d2)
        /go/src/code.gitea.io/gitea/modules/templates/base.go:88 (0x16b0769)
        /go/src/code.gitea.io/gitea/routers/web/base.go:125 (0x225f284)
        /go/src/code.gitea.io/gitea/routers/web/web.go:95 (0x2261284)
        /go/src/code.gitea.io/gitea/routers/init.go:147 (0x22817ba)
        /go/src/code.gitea.io/gitea/cmd/web.go:158 (0x239741a)
        /go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:524 (0x1740884)
        /go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/command.go:173 (0x17415f8)
        /go/src/code.gitea.io/gitea/vendor/github.com/urfave/cli/app.go:277 (0x173e8c7)
        /go/src/code.gitea.io/gitea/main.go:115 (0x23d3e69)
        /usr/local/go/src/runtime/proc.go:225 (0x443995)
        /usr/local/go/src/runtime/asm_amd64.s:1371 (0x47b360)
```
2021-09-03 12:49:42 +01:00
zeripath
076bb8a2a2
Close storage objects before cleaning (#16934)
Storage.Iterate provides the path and an open object. On windows using
local storage means that the objects will be locked thus preventing clean
from deleting them.

This PR simply closes the objects early.

Fix #16932

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-03 11:48:49 +01:00
zeripath
6c125e9797
Use immediate queues in integration tests and ensure that immediate (#16927)
queue type is also used for unique queues.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-03 11:20:57 +01:00
GiteaBot
219dec030d [skip ci] Updated translations via Crowdin 2021-09-03 00:04:56 +00:00
zeripath
b6c752e914
Changelog for 1.14.7 (#16924) (#16928)
* BUGFIXES
  * Add missing gitRepo close at GetDiffRangeWithWhitespaceBehavior (Partial #16894) (#16896)
  * Fix wiki raw commit diff/patch view (#16891) (#16893)
  * Ensure wiki repos are all closed (#16886) (#16889)
  * Upgrade xorm to v1.2.2 (#16663) & Add test to ensure that dumping of login sources remains correct (#16847) (#16849)
  * Recreate Tables should Recreate indexes on MySQL (#16718) (#16740)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-03 05:56:35 +08:00
zeripath
33af0c3aa2
Changelog 1.15.1 (#16925) (#16929)
## [1.15.1](https://github.com/go-gitea/gitea/releases/tag/v1.15.1) - 2021-09-02

* BUGFIXES
  * Allow BASIC authentication access to /:owner/:repo/releases/download/* (#16916) (#16923)
  * Prevent leave changes dialogs due to autofill fields (#16912) (#16920)
  * Ignore review comment when ref commit is missed (#16905) (#16919)
  * Fix wrong attachment removal (#16915) (#16917)
  * Gitlab Migrator: dont ignore reactions of last request (#16903) (#16913)
  * Correctly return the number of Repositories for Organizations (#16807) (#16911)
  * Test if LFS object is accessible (#16865) (#16904)
  * Fix git.Blob.DataAsync(): close pipe since we return a NopCloser (#16899) (#16900)
  * Fix dump and restore respository (#16698) (#16898)
  * Repare and Improve GetDiffRangeWithWhitespaceBehavior (#16894) (#16895)
  * Fix wiki raw commit diff/patch view (#16891) (#16892)
  * Ensure wiki repos are all closed (#16886) (#16888)
  * List limited and private orgs if authenticated on API (#16866) (#16879)
  * Simplify split diff view generation and remove JS dependency (#16775) (#16863)
  * Ensure that the default visibility is set on the user create page (#16845) (#16862)
  * In Render tolerate not being passed a context (#16842) (#16858)
  * Upgrade xorm to v1.2.2 (#16663) & Add test to ensure that dumping of login sources remains correct (#16847) (#16848)
  * Report the correct number of pushes on the feeds (#16811) (#16822)
  * Add primary_key to issue_index (#16813) (#16820)
  * Prevent NPE on empty commit (#16812) (#16819)
  * Fix branch pagination error (#16805) (#16816)
  * Add missing return to handleSettingRemoteAddrError (#16794) (#16795)
  * Remove spurious / from issues.opened_by (#16793)
  * Ensure that template compilation panics are sent to the logs (#16788) (#16792)
  * Update caddyserver/certmagic (#16789) (#16790)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-02 15:39:55 -04:00
zeripath
a75b2f2842
Allow BASIC authentication access to /:owner/:repo/releases/download/* (#16916)
Duplicate #15987 to allow access to releases download through BASIC authentication.

Fix #16914

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-02 16:48:48 +01:00
zeripath
268b2d0c91
Prevent leave changes dialogs due to autofill fields (#16912)
Add ignore-dirty to /user/settings/account
Add autocomplete="off" to push_mirror_address form on /:owner/:repo/settings

Fix #16861

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-02 13:14:37 +01:00
GiteaBot
9b4280ea4b [skip ci] Updated translations via Crowdin 2021-09-02 00:04:56 +00:00
wxiaoguang
07fde28ddb
Fix wrong attachment removal (#16915) 2021-09-01 23:53:29 +02:00
zeripath
6e0e414f55
Ensure that the testlogger has its final test removal safely (#16907)
It is possible to get a data race right at the end of the TestMain
in integrations during the final removal of the test from the testlogger. This PR
uses a Reset function to remove any final tests but adds some extra
logging which will forcibly fail if there is an unclosed logger.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-09-01 14:05:04 +01:00
Lunny Xiao
de2e96e37b
Ignore review comment when ref commit is missed (#16905) 2021-09-01 12:33:07 +01:00
6543
7062614dee
Gitlab Migrator: dont ignore reactions of last request (#16903)
Fix bug related to early breaking when migrating reactions.
2021-09-01 11:20:19 +01:00
zeripath
57b0887ab2
Correctly return the number of Repositories for Organizations (#16807)
Calculate and return the number of Repositories on the dashboard
Organization list.

This PR restores some of the logic that was removed in #14032 to
calculate the number of repos on the dashboard orgs list.

Fix #16648
Replaces #16799

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-09-01 01:31:42 -04:00
zeripath
83640a595b
Workaround coverage bug part 2 (#16906)
* Workaround coverage bug part 2

Just grep away bad lines from coverage files.

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

* try again

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-31 22:43:29 -04:00
a1012112796
cbf05c3f79
Add option to update pull request by rebase (#16125)
* add option to update pull request by `rebase`

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-08-31 16:03:45 +02:00
KN4CK3R
2bb32006fd
Test if LFS object is accessible (#16865)
* Test if object is accessible.

* Added more logging.
2021-08-31 14:35:08 +01:00
6543
d21702475b
Fix git.Blob.DataAsync(): close pipe since we return a NopCloser (#16899)
* make sure headGitRepo is closed on err too

* refactor

* Fix git.Blob.DataAsync(): exec cancel since we already read all bytes (close pipe since we return a NopCloser)
2021-08-31 08:43:31 +01:00
6543
bb4cc876b1
Repare and Improve GetDiffRangeWithWhitespaceBehavior (#16894)
* repare and improve GetDiffRangeWithWhitespaceBehavior

* Context with Timeout
2021-08-31 06:16:23 +02:00
zeripath
f2b4b0f491
Remove ParseQueueConnStr as it is unused (#16878)
Remove ParseQueueConnStr as `modules/nosql` has taken over all of its functions.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-31 05:33:16 +02:00
6543
6d97befddf
Fix wiki raw commit diff/patch view (#16891) 2021-08-31 04:22:54 +02:00
Lunny Xiao
8d7704b5a2
Fix dump and restore respository (#16698)
* Fix dump and restore

* return different error message for get commit

* Fix missing delete release attachment when deleting repository

* Fix ci and add some comments

Co-authored-by: zeripath <art27@cantab.net>
2021-08-30 21:18:15 -04:00
zeripath
c0f5da3e1a
Prevent coverage break (#16887)
* Prevent coverage break

There are repeated failures of our CI due to an intermittent issue with coverage.out
finishing with a spurious `0` on a single line.

This problem is very annoying and very hard to understand where it is coming from,
therefore as the problem appears random and without clear cause we should just strip
this line from our coverage.

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-08-31 01:41:08 +02:00
Richard Ulmer
87eb82cf52
Fix report card link (#16885) 2021-08-31 01:06:30 +02:00
zeripath
9119d24573
Ensure wiki repos are all closed (#16886)
There are multiple places where wiki git repositories are not properly closed.

This PR ensures they are closed.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-30 22:50:35 +02:00
6543
73394f435c
[API] List limited and private orgs if authentificated (#16866)
* fix bug #16785 and similar

* code format

* CI.restart()
2021-08-30 14:00:59 -04:00
zeripath
06b9d553bc
Timeout on flush in testing (#16864)
* Timeout on flush in testing

At the end of each test the queues are flushed. At present there is no limit on the
length of time a flush can take which can lead to long flushes.

However, if the CI task is cancelled we lose the log information as to where the long
flush was taking place.

This PR simply adds a default time limit of 2 minutes - at which point an error will
be produced. This should allow us to more easily find the culprit.

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

* return better error

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

Co-authored-by: 6543 <6543@obermui.de>
2021-08-30 00:27:51 -04:00
GiteaBot
b0ff429882 [skip ci] Updated translations via Crowdin 2021-08-30 00:04:50 +00:00
silverwind
360d8e7c23
Remove unused Fomantic sidebar module (#16853)
* Remove unused Fomantic sidebar module

The [Sidebar](https://fomantic-ui.com/modules/sidebar.html) module seems
currently unused (at least I can't find any reference to it in templates
or js), so remove it from the Fomantic build.

* remove useless minified fomantic build files

* mark fomantic build files as being generated
2021-08-29 21:57:07 +02:00
Patrick Schratz
968225e59c
update theme doc (#16860) 2021-08-29 14:26:43 -04:00
Lunny Xiao
d985d4bc2f
Paginate releases page & set default page size to 10 (#16857)
* Add release default page and set it to 10

* use limit

Co-authored-by: 6543 <6543@obermui.de>
2021-08-29 18:25:16 +02:00
zeripath
f5b0e2c9d2
Simplify split diff view generation and remove JS dependency (#16775)
Gitea has relied on some slow JS code to match up added and deleted lines on the
diff pages. This can cause a considerable slow down on large diff pages.

This PR makes a small change meaning that the matching up can occur much more simply.

Partial fix #1351

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-29 15:28:04 +01:00
wxiaoguang
d24eb6e6ce
Add GoLand configuration in hacking on gitea (#16843)
Co-authored-by: zeripath <art27@cantab.net>
2021-08-28 23:25:08 -04:00
6543
7815f244d6
CI: rm unit-test-race step since its now coverd by unit-test too (#16856)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-29 09:42:56 +08:00
GiteaBot
5e71b9c200 [skip ci] Updated translations via Crowdin 2021-08-29 00:04:59 +00:00
zeripath
c9c0475f4d
In Render tolerate not being passed a context (#16842)
* In Render tolerate not being passed a context

It is possible for RenderString to be passed to an external renderer if markdown
is set to be rendered by an external renderer. No context is currently sent to these
meaning that this will error out.

Fix #16835

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

* Add Context to Repo calls for RenderString

All calls from routers can easily add the context - so add it.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-28 21:15:56 +01:00
zeripath
90c0180447
Ensure that the default visibility is set on the user create page (#16845)
Set the default visibility on the user create page.

Fix #16840

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-28 15:19:52 +01:00
Kyle Evans
cad70599a6
Refactor the fork service slightly to take ForkRepoOptions (#16744)
* Refactor the fork service slightly to take ForkRepoOptions

This reduces the number of places we need to change if we want to add other
options during fork time.

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

* Fix integrations and tests after ForkRepository refactor

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

* Update OldRepo -> BaseRepo

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>

* gofmt pass

Signed-off-by: Kyle Evans <kevans@FreeBSD.org>
2021-08-28 16:37:14 +08:00
zeripath
1904941382
Add test to ensure that dumping of login sources remains correct (#16847)
#16831 has occurred because of a missed regression. This PR adds a simple test to
try to prevent this occuring again.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-28 04:25:27 +01:00
KN4CK3R
88abb0dc8a
Decoupled code from DefaultSigningKey (#16743)
Decoupled code from `DefaultSigningKey`. Makes testing a little bit easier and is cleaner.
2021-08-27 20:28:00 +01:00
zeripath
cd8db3a83d
Prevent "Race" detected in TestAdmin*User (#16830)
These tests are missing the defer prefix.

Related #1441

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-27 15:00:37 +02:00
zeripath
e37342db0c
Add modals to Organization and Team remove/leave (#16471)
* Add modals to Organization and Team remove/leave

Add confirmation modals to Organization and Team remove and leave.

Fix #16215

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

* avoid for-in

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

* Revert "avoid for-in"

This reverts commit 2af9a6f9d46ed31b6fc6e3a29e695577dcf09f75.

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-26 22:57:40 -04:00
GiteaBot
3289aceec2 [skip ci] Updated translations via Crowdin 2021-08-27 00:04:45 +00:00
Mura Li
b60e814055
Enable race detector for CI (#1441)
* Enable race detector by default

Set RACE_ENABLED=0 to disable it when release

* Disable race detector for release builds

* use `true`

* fix

* debug issue

* fix

* verbose

* clean

* Fix wrong merge

* Fix coverage merge

Co-authored-by: Mura Li <typeless@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-26 16:50:04 +08:00
GiteaBot
c446901a5d [skip ci] Updated translations via Crowdin 2021-08-26 00:04:46 +00:00
zeripath
ba6baff696
Report the correct number of pushes on the feeds (#16811)
* Report the correct number of pushes on the feeds

Since the number of commits in the Action table has been limited to 5
the number of commits reported on the feeds page is now incorrectly also
limited to 5. The correct number is available as the Len and this PR
changes this to report this.

Fix #16804

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

* Update templates/user/dashboard/feeds.tmpl

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-25 19:04:58 -04:00
Aliaksandr Mianzhynski
28ac4a7a87
Add EdDSA JWT signing algorithm (#16786)
* Add EdDSA signing algorithm

* Fix typo

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-25 16:50:38 -04:00
Clar Fon
29b971b6d5
Actually compute proper foreground color for labels (#16729) 2021-08-25 12:55:47 -05:00
delvh
20efc6b56c
Unify migration descriptions (#16781)
* Unify migration descriptions

* Clarify that pure Git migration differs from other migrations

Co-authored-by: Norwin <noerw@users.noreply.github.com>

* Use Pull Requests for Gitea migration

Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-08-25 21:47:05 +08:00
Lunny Xiao
b88dbe1208
Use a common quote to instead of check database type (#16817)
`` ` `` will be converted to different database quote by xorm. So check database type is unnecessary.
2021-08-25 13:23:34 +01:00
zeripath
697213bdb3
Add primary_key to issue_index (#16813)
Make the group_id a primary key in issue_index. This already has an unique index
and therefore is a good candidate for becoming a primary key.

This PR also changes all other uses of this table to add the group_id as the
primary key.

Fix #16802

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-25 09:42:51 +01:00
zeripath
e891d68dd7
Prevent NPE on empty commit (#16812) 2021-08-24 19:33:23 -04:00
Lunny Xiao
4e761fa385
Fix branch pagination error (#16805)
Fix #16801

Even if default branch is removed from the current page, but the total branches number should be still kept. So that the pagination calculation will be correct.
2021-08-24 23:15:07 +01:00
Lunny Xiao
efaf109435
Add information for migrate failure (#16803)
Improve the reporting of errors when there is a migration failure
2021-08-24 18:46:55 +01:00
John Olheiser
648464b504
Add bundle download for repository (#14538)
* Add bundle download

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix build tags

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Download specific commit

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-08-24 11:47:09 -05:00
GiteaBot
d22cb600ed [skip ci] Updated translations via Crowdin 2021-08-24 00:04:47 +00:00
zeripath
921afb57fb
Add missing return to handleSettingRemoteAddrError (#16794)
There is a missing return in handleSettingRemoteAddrError which means
that the error page for repo settings is duplicately rendered.

Fix #16771

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-23 18:09:25 -04:00
zeripath
1cd4a3b963
Update caddyserver/certmagic (#16789)
Fixes issue with windows users & letsencrypt

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-23 18:07:40 -04:00
zeripath
f31e7a67cf
Just use a slice when rendering file (#16774)
Highlight currently uses a map which is memory inefficient. Switch to use a slice instead.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-23 22:23:39 +01:00
zeripath
73defbbd1c
Ensure that template compilation panics are sent to the logs (#16788)
Although panics within the rendering pipeline are caught and dealt with,
panics that occur before that starts are unprotected and will kill Gitea
without being sent to the logs.

This PR adds a basic recovery handler to catch panics that occur after
the logger is initialised and ensure that they're sent to the logger.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-23 20:40:59 +01:00
GiteaBot
94f529af02 [skip ci] Updated translations via Crowdin 2021-08-23 00:04:31 +00:00
techknowlogick
db1e3d02a5
frontport: 1.15.0 changelog (#16772)
* frontport: 1.15.0 changelog

* Update config.yaml
2021-08-22 20:29:51 +01:00
wxiaoguang
b55c699c62
Alter issue/comment table TEXT fields to LONGTEXT (#16765)
* Alter issue/comment table TEXT fields to LONGTEXT

* Use If not Switch

Co-authored-by: zeripath <art27@cantab.net>
2021-08-22 23:33:05 +08:00
zeripath
7f85610942
Fix openidConnect source regression from #16544 (#16759)
Unfortunately there is bug in #16544 meaning that openid connects aren't
being matched properly as the capitalisation in that PR is incorrect.

This PR changes the capitalisation back to what is expected.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-22 10:17:05 +01:00
GiteaBot
208ae9e996 [skip ci] Updated licenses and gitignores 2021-08-22 00:06:14 +00:00
KN4CK3R
cee5f7c5e2
Add migrate from OneDev (#16356)
* Use context to simplify logic.

* Added migration from OneDev.
This PR adds [OneDev](https://code.onedev.io/) as migration source.

Supported:
- [x] Milestones
- [x] Issues
- [x] Pull Requests
- [x] Comments
- [x] Reviews
- [x] Labels
2021-08-22 00:47:45 +02:00
wxiaoguang
2d1935acc7
Upgrade go.mod go version to 1.16 (#16764) 2021-08-21 20:04:17 +01:00
Abner
7844bf1430
Download lfs in git and web workflow from minio/s3 directly (#16731) 2021-08-21 20:22:06 +02:00
wxiaoguang
06f82641cb
when the update request doesn't intend to update attachments (eg: change checkbox state), ignore attachment updates (#16762) 2021-08-21 14:04:47 +01:00
KN4CK3R
0bd58d61e5
Added introspection endpoint. (#16752)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-20 22:16:45 -04:00
Steven
e9747de952
Fix dependency link rendering in PR sidebar (#16754)
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2021-08-21 01:02:47 +01:00
Steven
3ecc4a1b9e
Fix dependency translations (#16753)
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-08-21 00:13:45 +01:00
KN4CK3R
dc2613600c
Keep attachments on tasklist update (#16750)
* Send attachments too.

* Use tasklist flag.

* use action="ignoreAttachments" instead of "tasklist"

* Use boolean parameter.

Co-authored-by: zeripath <art27@cantab.net>
2021-08-20 15:26:19 -04:00
Elouan Martinet
3b2ed4762e
Do not use thin scrollbars on Firefox (#16738)
In #7269, thin scrollbars were added in Arc Green theme. It got moved
in base theme in #13361.

This PR removes the use of thin scrollbars which causes an
accessibility issue. The scrollbars become too thin to be dragged.

Signed-off-by: Elouan Martinet <exa@elou.world>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-19 17:31:47 -04:00
zeripath
03937891e2
Return nil proxy function if proxy not enabled (#16742)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-19 16:41:20 -04:00
KN4CK3R
4debb74eda
Fix wrong user in OpenID response (#16736)
* Fixed usage of wrong user.

* Added tests.
2021-08-19 12:11:30 -04:00
zeripath
c9bca8c5e0
Recreate Tables should Recreate indexes on MySQL (#16718)
The MySQL indexes are not being renamed at the same time as RENAME table despite the
CASCADE. Therefore it is probably better to just recreate the indexes instead.

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

Co-authored-by: 6543 <6543@obermui.de>
2021-08-19 07:11:36 +03:00
n
4aa3cacc4f
Add edit button to wiki sidebar and footer (#16719)
* Add edit button to wiki sidebar and footer

* Make edit button transparent

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-08-18 14:14:08 -04:00
KN4CK3R
9f0c8f90af
Fix migration svg color (#16715)
* Fixed svg color.

* Use --color-text.

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-08-19 00:07:52 +08:00
Lunny Xiao
f9acad82ca
Add proxy settings and support for migration and webhook (#16704)
* Add proxy settings and support for migration and webhook

* Fix default value

* Add newline for example ini

* Add lfs proxy support

* Fix lint

* Follow @zeripath's review

* Fix git clone

* Fix test

* missgin http requests for proxy

* use empty

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-08-18 21:10:39 +08:00
KN4CK3R
422c30d315
Refactored and fixed migration tests. (#16714)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-17 20:47:18 -04:00
GiteaBot
65c6acccf6 [skip ci] Updated translations via Crowdin 2021-08-18 00:04:48 +00:00
zeripath
e0853d4a21
Add API Token Cache (#16547)
One of the issues holding back performance of the API is the problem of hashing.
Whilst banning BASIC authentication with passwords will help, the API Token scheme
still requires a PBKDF2 hash - which means that heavy API use (using Tokens) can
still cause enormous numbers of hash computations.

A slight solution to this whilst we consider moving to using JWT based tokens and/or
a session orientated solution is to simply cache the successful tokens. This has some
security issues but this should be balanced by the security issues of load from
hashing.

Related #14668

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-17 14:30:42 -04:00
techknowlogick
274aeb3a9e
build with go1.17 (#16707)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-08-17 08:31:28 -04:00
techknowlogick
37d0d94843
Use github token URL when fetching oauth token (#16709)
Fixes regression from #16544
2021-08-17 09:07:52 +01:00
silverwind
ea07726dc1
Update JS dependencies (#16708)
* Update JS dependencies

- Update all JS dependencies
- Adapt to recent webpack changes
- Add new lint rules and fix issues
- Regenerate SVGs and update svgo api usage

Fixes: https://github.com/go-gitea/gitea/pull/16492

* adapt jest config and sort keys

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-17 01:32:48 -04:00
GiteaBot
cf4328359b [skip ci] Updated translations via Crowdin 2021-08-17 00:07:42 +00:00
GiteaBot
fe3299614a [skip ci] Updated translations via Crowdin 2021-08-16 00:07:41 +00:00
Lunny Xiao
f7a302ca6f
Upgrade levelqueue 0.4.1 (#16696) 2021-08-15 22:52:26 +02:00
GiteaBot
f5158b4304 [skip ci] Updated translations via Crowdin 2021-08-15 00:07:47 +00:00
delvh
d17f555fe3
Improve resource string (#16691)
* Improve resource string

Co-authored-by: zeripath <art27@cantab.net>
2021-08-14 16:10:39 +02:00
Lunny Xiao
74d75eb69c
Fix spelling of HookProcReceiveResult (#16690) 2021-08-14 13:17:10 +02:00
GiteaBot
bbf9f41354 [skip ci] Updated translations via Crowdin 2021-08-14 00:07:48 +00:00
zeripath
23a87a003e
Ensure empty lines are copiable and final new line too (#16678)
* Ensure empty lines are copiable and final new line too

When files are highlighted the newline character needs to be added in a whitespace
compliant mode. Also ensure the final empty newline is rendered.

Fix #16434

* Add test and ensure spans closed

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-14 01:16:56 +02:00
Jimmy Praet
a4962a9440
Add filter by owner and team to issue/pulls search endpoint (#16662)
* Filter by owner and team in API issue/pulls search

* Add integration test
2021-08-13 22:47:25 +02:00
6543
3a6edd3685
Update issue_index to finish migration (#16685)
* update issue_index to finish migration

* One Func to RecalculateIssueIndexForRepo
2021-08-13 21:06:18 +08:00
GiteaBot
6bf5afe5de [skip ci] Updated translations via Crowdin 2021-08-13 00:07:45 +00:00
Lunny Xiao
7224cfc578
Upgrade xorm to v1.2.2 (#16663)
* Upgrade xorm to v1.2.2

* Change the Engine interface to match xorm v1.2.2
2021-08-13 01:11:42 +02:00
zeripath
5fbccad906
Fix NPE in fuzzer (#16680)
The fuzzer found an issue with the issue pattern processor where there is a spurious
path.Clean which does not need to be there. This PR also sets the default AppURL for
the fuzzer too.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-13 00:22:05 +02:00
6543
2289580bb7
[API] generalize list header (#16551)
* Add info about list endpoints to CONTRIBUTING.md

* Let all list endpoints return X-Total-Count header 

* Add TODOs for GetCombinedCommitStatusByRef

* Fix models/issue_stopwatch.go

* Rrefactor models.ListDeployKeys

* Introduce helper func and use them for SetLinkHeader related func
2021-08-12 14:43:08 +02:00
a1012112796
ca13e1d56c
Add link to vscode to repo header (#16664)
add link to vscode to repo header

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-08-12 14:21:34 +02:00
zeripath
162c32af7e
Send registration email on user autoregistration (#16523)
When users login and are autoregistered send email notification.

Fix #16178

* Protect public functions within the mailer by testing if the mailer is configured

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

Co-authored-by: 6543 <6543@obermui.de>
2021-08-12 10:26:33 +03:00
zeripath
e29e163737
Improve SMTP authentication and Fix user creation bugs (#16612)
* Improve SMTP authentication, Fix user creation bugs and add LDAP cert/key options

This PR has two parts:

Improvements for SMTP authentication:

* Default to use SMTPS if port is 465, and allow setting of force SMTPS.
* Always use STARTTLS if available
* Provide CRAM-MD5 mechanism
* Add options for HELO hostname disabling
* Add options for providing certificates and keys
* Handle application specific password response as a failed user login
instead of as a 500.

Close #16104

Fix creation of new users:

* A bug was introduced when allowing users to change usernames which
prevents the creation of external users.
* The LoginSource refactor also broke this page.

Close #16104

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-11 21:42:58 +01:00
6543
f1a810e090
Related refactors to ctx.FormX functions (#16567)
* use FormTrim if posible

* speedup goGet

* only convert if nessesary
2021-08-11 18:08:52 +03:00
nitul1991
2d25b7d44b
Add an api endpoint to fetch git notes (#15373) (#16649)
close #15373
2021-08-11 03:01:40 +02:00
6543
c4d70a0325
Rename ctx.Form() to ctx.FormString() and move code into own file (#16571)
Followup from #16562 prepare for #16567

* Rename ctx.Form() to ctx.FormString()
* Reimplement FormX func to need less code and cpu cycles
* Move code into own file
2021-08-11 02:31:13 +02:00
GiteaBot
2eeae4edb6 [skip ci] Updated translations via Crowdin 2021-08-11 00:07:40 +00:00
6543
89245ee309
Upgrade github.com/google/go-github v32.1.0 -> v37.0.0 (#16661)
* Upgrade github.com/google/go-github vv32.1.0 -> v37.0.0

* refactor: use GetX() func to reduce code
2021-08-10 11:49:43 +02:00
KN4CK3R
d9ef43a712
Replace list.List with slices (#16311)
* Replaced list with slice.

* Fixed usage of pointer to temporary variable.

* Replaced LIFO list with slice.

* Lint

* Removed type check.

* Removed duplicated code.

* Lint

* Fixed merge.

Co-authored-by: 6543 <6543@obermui.de>
2021-08-09 14:08:51 -04:00
nitul1991
23d438f565
Change the implementation of the go-git version of GetNote to mirror the non go-git version when passed a non-existent commit (#16658)
Fixes #16657
2021-08-09 16:24:34 +01:00
GiteaBot
1dc41c47b9 [skip ci] Updated translations via Crowdin 2021-08-09 00:07:47 +00:00
6543
eaa791bedd
Add Version info to migrations.go (#16653)
Gitea migrations of 1.15.0 ends at v189
2021-08-08 13:34:42 -04:00
zeripath
9c116f2bb5
Restore compatibility with SQLServer 2008 R2 in migrations (#16627)
* Restore compatibility with SQLServer 2008 R2 in migrations

`ALTER TABLE DROP ... IF EXISTS ...` is only supported in SQL Server >16.

The `IF EXISTS` here is a belt-and-braces and does not need to be present. Therefore
can be dropped.

We need to figure out some way of restricting our SQL syntax against the minimum
version of SQL Server we will support.

My suspicion is that `ALTER DATABASE database_name SET COMPATIBILITY_LEVEL = 100` may
do that but there may be other side-effects so I am not whether to do that.

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

* try just dropping the index only

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

* use lowercase for system tables

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-08 13:34:24 +03:00
GiteaBot
07bc380c9f [skip ci] Updated translations via Crowdin 2021-08-08 00:07:46 +00:00
zeripath
59e6db0b65
Changelog for 1.15.0-rc3 (#16621) (#16645)
Frontport #16621

 ## [1.15.0-rc3](https://github.com/go-gitea/gitea/releases/tag/v1.15.0-rc3) - 2021-08-06

* BREAKING
  * Upgrade to the latest version of golang-jwt and increase minimum go to 1.15 (#16590) (#16606)
* SECURITY
  * Upgrade to the latest version of golang-jwt and increase minimum go to 1.15 (#16590) (#16606)
  * Correctly create of git-daemon-export-ok files (#16508) (#16514)
  * Don't show private user's repo in explore view (#16550) (#16554)
  * Update node tar dependency to 6.1.6 (#16622) (#16623)
* API
  * Swagger AccessToken fixes (#16574) (#16597)
  * Set AllowedHeaders on API CORS handler (#16524) (#16618)
* BUGFIXES
  * Restore Accessibility for Dropdown (#16576) (#16617)
  * Pass down SignedUserName down to AccessLogger context (#16605) (#16616)
  * Fix table alignment in markdown (#16596) (#16602)
  * Fix 500 on first wiki page (#16586) (#16598)
  * Lock goth/gothic and Re-attempt OAuth2 registration on login if registration failed at startup (#16564) (#16570)
  * Upgrade levelqueue to v0.4.0 (#16560) (#16561)
  * Handle too long PR titles correctly (#16517) (#16549)
  * Fix data race in bleve indexer (#16474) (#16509)
  * Restore CORS on git smart http protocol (#16496) (#16506)
  * Fix race in log (#16490) (#16505)
  * Fix prepareWikiFileName to respect existing unescaped files (#16487) (#16498)
  * Make cancel from CatFileBatch and CatFileBatchCheck wait for the command to end (#16479) (#16480)
  * Update notification table with only latest data (#16445) (#16469)
  * Revert to use alpine 3.13 (#16451) (#16452)
  * Fix crash following ldap authentication update (#16447) (#16448)
  * Fix direct creation of external users on admin page (partial #16612) (#16613)
  * Prevent 500 on draft releases without tag (#16634) (#16636)

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-08-07 20:27:49 +03:00
Romain
14762abf0b
Separate open and closed issue in metrics (#16637)
* Get the issue counts in one query

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-08-07 12:43:50 +03:00
techknowlogick
620c5690ea
Add note about build-time flags for PAM support (#16641)
Fix #16639
2021-08-07 01:22:30 -04:00
GiteaBot
2bbf1313b4 [skip ci] Updated translations via Crowdin 2021-08-07 00:07:42 +00:00
zeripath
afd88a2418
Allow setting X-FRAME-OPTIONS (#16643)
* Allow setting X-FRAME-OPTIONS

This PR provides a mechanism to set the X-FRAME-OPTIONS header.

Fix #7951

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

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2021-08-06 16:47:10 -04:00
zeripath
067d82b5a6
Prevent 500 on draft releases without tag (#16634)
It is possible to create draft releases prior to creating a tag. This will cause a
500 on the releases page due to compare page failing.

This PR only shows the compare button if there is a SHA1 present.

Fix #16610

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-05 21:13:16 -04:00
zeripath
ab9bb54144
Add microsoft oauth2 providers (#16544)
* Clean up oauth2 providers

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

* Add AzureAD, AzureADv2, MicrosoftOnline OAuth2 providers

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

* Apply suggestions from code review

* remove unused Scopes

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-05 21:11:08 -04:00
GiteaBot
7e7006e00d [skip ci] Updated translations via Crowdin 2021-08-06 00:08:10 +00:00
zeripath
9430bb7f40
Frontport changelog for v1.14.6 (#16632)
* Frontport changelog for v1.14.6

Changelog frontported to below v1.15.0-rc1.

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

* Update config.yaml

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-05 20:05:20 -04:00
zeripath
6e6f23b315
Restore Accessibility for Dropdown (#16576)
* Restore #10096/#8638 and re-fix #15172

This PR restores the vendored and patched dropdow from #8638. It
however, abandons the calls to `click()` using instead the default
dropdown click calls instead. This prevents the issue of the dropdown
grabbing focus permanently however, this may have negative effects on
the effect of focus on the dropdowns.

Of note, the behaviour of the template selector dropdown on the repo
creation page is slightly odd - I don't believe that this odd behaviour
is caused by this PR but rather by the feed source for this. I suspect
that the dropdown should be adding a delete button to its selection.

Fix #15172
References: #7057

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

* leverage fomantic-build instead

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

* as per jookia

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-06 01:16:24 +03:00
Richard Mahn
fd39e6dc6a
Fixes #16557 - duplicate csv import (#16631)
Remove the unnecessary duplicate package import for `encoding/csv` in `modules/csv/csv.go`

Fix #16557
2021-08-05 17:56:11 +01:00
zeripath
3a1332c326
Update node tar dependency to 6.1.6 (#16622)
Forcibly update dev dependency on tar to 6.1.6

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-08-05 00:14:27 -04:00
zeripath
806aa870cb
Switch back to node 16 (#16624)
Now that node 16.6.1 is out we can (if desired) switch back to node 16.

This PR proposes changing drone to run node:16

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-08-05 01:46:19 +02:00
zeripath
19e2c6a302
Set AllowedHeaders on API CORS handler (#16524)
Set AllowedHeaders on API CORS handler and add missing Access-Control-Expose-Headers
to pull API.

Fix #16100

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-04 21:56:49 +02:00
zeripath
7c4172ef71
Pass down SignedUserName down to AccessLogger context (#16605)
* Pass down SignedUserName down to AccessLogger context

Unfortunately when the AccessLogger was moved back before the contexters the
SignedUserName reporting was lost. This is due to Request.WithContext leading to a
shallow copy of the Request and the modules/context/Context being within that request.

This PR adds a new context variable of a string pointer which is set and handled
in the contexters.

Fix #16600

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

* handle nil ptr issue

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-08-04 13:26:30 -04:00
GiteaBot
f03abe8fb1 [skip ci] Updated translations via Crowdin 2021-08-04 00:07:39 +00:00
zeripath
35735bbef9
Upgrade to golang-jwt 3.2.2 (#16590)
* Upgrade to golang-jwt 3.2.2

Upgrade to the latest version of golang-jwt

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

* Forcibly replace the 3.2.1 version of golang-jwt/jwt and increase minimum Go version

Using go.mod we can forcibly replace the 3.2.1 version used by goth to 3.2.2.

Further given golang-jwt/jwts stated policy of only supporting supported go versions
we should just raise our minimal version of go to 1.16 for 1.16 as by time of release
1.15 will be out of support.

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

* update minimal go required

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

* update config.yaml

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

Co-authored-by: 6543 <6543@obermui.de>
2021-08-03 14:32:01 -04:00
Clar Fon
80b7889fee
Clarify where server.LFS_CONTENT_PATH was moved to (#16601)
Signed-off-by: ltdk <usr@ltdk.xyz>
2021-08-03 09:03:04 +01:00
Albert ARIBAUD
a51cb3d4cb
Make PR merge options more intuitive (#5863) (#16582)
Reword options making clear whether the PRed branch is rebased or not, and which type of commit will be created if any.
2021-08-02 20:23:57 +01:00
zeripath
1fc7d6d6ad
Fix table alignment in markdown (#16596)
Set the TableOptions in markdown to allow alignment of the tables to work correctly

Fix #15959

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-02 17:11:18 +01:00
6543
24366eddec
[CI] Use node v14 instead of node v16 untill it will pass again (#16595)
* for CI release: use node 14 (lts) to build until 16 do fail

* all in for node v14.x
2021-08-02 03:47:29 +02:00
GiteaBot
3375e7658e [skip ci] Updated translations via Crowdin 2021-08-02 00:07:40 +00:00
zeripath
48c7c880b8
Swagger AccessToken fixes (#16574)
There is a subtle problem with the Swagger definition for AccessTokens which causes
autogeneration of APIs for these endpoints to fail.

This PR corrects these errors.

Ref: https://github.com/zeripath/java-gitea-api/issues/4
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-08-01 16:44:15 -04:00
zeripath
e51c73ae5c
Fix 500 on first wiki page (#16586)
* Fix 500 on first wiki page

There is a mistake in #16319 and #16487 which means that the first time
a wiki page is created a 500 is reported because the `master` branch is
not in existence in that wiki yet.

This PR simply checks for this error and returns not found.

Fix #16584

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-01 19:04:32 +02:00
Lars Hvam
d686d7b052
Fix swagger doc by rename repoAddTopíc to repoAddTopic (#16580)
* Swagger API: rename repoAddTopíc to repoAddTopic

This changes the operationId to only contain 7 bit ascii, note "í" instead of "i"
2021-08-01 18:28:05 +02:00
zeripath
e3b6526922
Use node:16.5 for frontend instead of node:16 (#16591)
* Disable frontend testing

Jest does not appear to work on the latest node 16.6.0 and fails with an inscrutable
message.

I have been unable to work out what the problem is. This PR simply disables the
test-frontend part in the makefile.

Another alternative would be to drop node to node 14 - which is the LTS for node.

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

* actually just tell on 16.5 instead

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

* Use node 16.5 instead of 16

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-08-01 17:33:02 +03:00
GiteaBot
b73e421646 [skip ci] Updated translations via Crowdin 2021-08-01 00:07:51 +00:00
GiteaBot
e8306505f2 [skip ci] Updated translations via Crowdin 2021-07-31 00:07:42 +00:00
zeripath
72738f0cb5
Lock goth/gothic and Re-attempt OAuth2 registration on login if registration failed at startup (#16564)
This PR has two parts:

* Add locking to goth and gothic calls with a RWMutex

The goth and gothic calls are currently unlocked and thus are a cause of multiple potential races

* Reattempt OAuth2 registration on login if registration failed

If OAuth2 registration fails at startup we currently disable the login_source however an alternative approach could be to reattempt registration on login attempt.
    
Fix #16096

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-29 18:53:18 +01:00
AJ ONeal
b9a0e33238
Pre-fill suggested New File 'name' and 'content' with Query Params (#16556)
* feature: add (GitHub-style) querystrings for pre-filling new file content

* docs: add query parameters for new files
2021-07-29 05:39:46 +02:00
Marty
4e68d6f41d
Show correct text when comparing commits on empty pull request (#16569)
* fix

* use own text

* Update templates/repo/commits_table.tmpl

Co-authored-by: marty <m.karkossa@ultraware.nl>
Co-authored-by: zeripath <art27@cantab.net>
2021-07-29 03:32:48 +01:00
Lunny Xiao
33e0b38287
Rename context.Query to context.Form (#16562) 2021-07-29 03:42:15 +02:00
a1012112796
3705168837
Add agit flow support in gitea (#14295)
* feature: add agit flow support

ref: https://git-repo.info/en/2020/03/agit-flow-and-git-repo/

example:

```Bash
git checkout -b test
echo "test" >> README.md
git commit -m "test"
git push origin HEAD:refs/for/master -o topic=test
```

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix lint

* simplify code add fix some nits

* update merge help message

* Apply suggestions from code review. Thanks @jiangxin

* add forced-update message

* fix lint

* splite writePktLine

* add refs/for/<target-branch>/<topic-branch> support also

* Add test code add fix api

* fix lint

* fix test

* skip test if git version < 2.29

* try test with git 2.30.1

* fix permission check bug

* fix some nit

* logic implify and test code update

* fix bug

* apply suggestions from code review

* prepare for merge

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

* fix permission check bug

- test code update
- apply suggestions from code review @zeripath

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix bug when target branch isn't exist

* prevent some special push and fix some nits

* fix lint

* try splite

* Apply suggestions from code review

- fix permission check
- handle user rename

* fix version negotiation

* remane

* fix template

* handle empty repo

* ui: fix  branch link under the title

* fix nits

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-28 17:42:56 +08:00
Lunny Xiao
5b2e2d29ca
Upgrade levelqueue to v0.4.0 (#16560)
Fix #16546
2021-07-27 16:55:48 +01:00
GiteaBot
4b6370c46d [skip ci] Updated translations via Crowdin 2021-07-27 00:07:52 +00:00
a1012112796
9102738797
not show private user's repo in explore view (#16550)
after #16069, visibility is also usefull for user,
so this limit is not usefull.

fix #16545
2021-07-27 00:02:35 +02:00
6543
7c7771e42b
Fix session bugs (#16552)
* fix deadlog bug

* Fix models/issue_stopwatch.go

* Update models/issue_stopwatch.go

Co-authored-by: zeripath <art27@cantab.net>
2021-07-26 23:46:06 +03:00
GiteaBot
e76f8cac9a [skip ci] Updated translations via Crowdin 2021-07-26 00:07:41 +00:00
zeripath
6a33b290a0
Fix add authentication page (#16543)
* Fix add authentication page

There is a regression in #16199 whereby the add authentication page
fails to react to the change in selected type.

This is due to the String() method on the LoginSourceType which is ameliorated
with an Int() function being added.

Following on from this there are a few other related bugs.

Fix #16541

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-25 08:09:52 +01:00
zeripath
fd15fd4c67
Handle too long PR titles correctly (#16517)
The CompareAndPullRequestPost handler for POST to /compare
incorrectly handles returning errors to the user. For a start
it does not set the necessary markers to switch SimpleMDE
but it also does not immediately return to the form.

This PR fixes this by setting the appropriate values, fixing
the templates and preventing the suggestion of a too long
title.

Fix #16507

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-25 03:59:27 +01:00
GiteaBot
4f23624b16 [skip ci] Updated licenses and gitignores 2021-07-25 00:07:38 +00:00
6543
d717c692fa
bump github.com/markbates/goth from v1.67.1 to v1.68.0 (#16538) 2021-07-24 18:17:02 +01:00
Lunny Xiao
9f31f3aa8a
Add an abstract json layout to make it's easier to change json library (#16528)
* Add an abstract json layout to make it's easier to change json library

* Fix import

* Fix import sequence

* Fix blank lines

* Fix blank lines
2021-07-24 18:03:58 +02:00
techknowlogick
e0f9635c06
Add Linode as an installation option in docs (#16529)
Add Linode as an installation option in docs

Co-authored-by: zeripath <art27@cantab.net>
2021-07-24 15:08:23 +01:00
techknowlogick
5a84908d42
Add snap to docs (#16530) 2021-07-24 14:06:38 +01:00
techknowlogick
29a22ade82
switch to maintained lib (#16532)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-07-24 13:00:41 +02:00
zeripath
5d2e11eedb
Refactor: Move login out of models (#16199)
`models` does far too much. In particular it handles all `UserSignin`.

It shouldn't be responsible for calling LDAP, SMTP or PAM for signing in.

Therefore we should move this code out of `models`.

This code has to depend on `models` - therefore it belongs in `services`.

There is a package in `services` called `auth` and clearly this functionality belongs in there.

Plan:

- [x] Change `auth.Auth` to `auth.Method` - as they represent methods of authentication.
- [x] Move `models.UserSignIn` into `auth`
- [x] Move `models.ExternalUserLogin`
- [x] Move most of the `LoginVia*` methods to `auth` or subpackages
- [x] Move Resynchronize functionality to `auth`
  - Involved some restructuring of `models/ssh_key.go` to reduce the size of this massive file and simplify its files.
- [x] Move the rest of the LDAP functionality in to the ldap subpackage
- [x] Re-factor the login sources to express an interfaces `auth.Source`?
  - I've done this through some smaller interfaces Authenticator and Synchronizable - which would allow us to extend things in future
- [x] Now LDAP is out of models - need to think about modules/auth/ldap and I think all of that functionality might just be moveable
- [x] Similarly a lot Oauth2 functionality need not be in models too and should be moved to services/auth/source/oauth2
  - [x] modules/auth/oauth2/oauth2.go uses xorm... This is naughty - probably need to move this into models.
  - [x] models/oauth2.go - mostly should be in modules/auth/oauth2 or services/auth/source/oauth2 
- [x] More simplifications of login_source.go may need to be done
- Allow wiring in of notify registration -  *this can now easily be done - but I think we should do it in another PR*  - see #16178 
- More refactors...?
  - OpenID should probably become an auth Method but I think that can be left for another PR
  - Methods should also probably be cleaned up  - again another PR I think.
  - SSPI still needs more refactors.* Rename auth.Auth auth.Method
* Restructure ssh_key.go

- move functions from models/user.go that relate to ssh_key to ssh_key
- split ssh_key.go to try create clearer function domains for allow for
future refactors here.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-24 11:16:34 +01:00
zeripath
f135a818f5
Make Mermaid.js limit configurable (#16519)
* Make Mermaid.js limit configurable

Add `MERMAID_MAX_SOURCE_CHARACTERS` to `[markup]` settings
to make the maximum size of a mermaid render configurable.

Fix #16513

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

* fixup! Make Mermaid.js limit configurable

* Update custom/conf/app.example.ini

Co-authored-by: silverwind <me@silverwind.io>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-24 00:21:51 -04:00
GiteaBot
342f338bda [skip ci] Updated translations via Crowdin 2021-07-24 00:07:49 +00:00
Lunny Xiao
9421bfedb3
Fix issue pasted image missing if no release permission (#16520)
* Fix issue pasted image missing if no release permission

* Update routers/web/web.go

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-07-23 14:08:04 -04:00
qwerty287
ab77768fce
Fix typo (#16522) 2021-07-23 15:05:37 +02:00
lengyuqu
078e2b2c39
Add support for corporate WeChat webhooks (#15910)
* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* Update templates/admin/hook_new.tmpl

Co-authored-by: a1012112796 <1012112796@qq.com>

* Update services/webhook/wechatwork.go

Co-authored-by: a1012112796 <1012112796@qq.com>

* 修善wechatwork

* 修善wechatwork

* fix

* Update locale_cs-CZ.ini

fix

* fix build

* fix

* fix build

* make webhooks.zh-cn.md

* delet unnecessary blank line

* delet unnecessary blank line

* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* Update templates/admin/hook_new.tmpl

Co-authored-by: a1012112796 <1012112796@qq.com>

* Update services/webhook/wechatwork.go

Co-authored-by: a1012112796 <1012112796@qq.com>

* 修善wechatwork

* 修善wechatwork

* fix

* fix build

* fix

* fix build

* make webhooks.zh-cn.md

* delet unnecessary blank line

* delet unnecessary blank line

* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* fix

* fix

* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* fix wechat

* fix wechat

* fix wechat

* fix wechat

* Fix invalid params and typo of email templates (#16394)

Signed-off-by: Meano <meanocat@gmail.com>

* Add LRU mem cache implementation (#16226)

The current default memory cache implementation is unbounded in size and number of
objects cached. This is hardly ideal.

This PR proposes creating a TwoQueue LRU cache as the underlying cache for Gitea.
The cache is limited by the number of objects stored in the cache (rather than size)
for simplicity. The default number of objects is 50000 - which is perhaps too small
as most of our objects cached are going to be much less than 1kB.

It may be worth considering using a different LRU implementation that actively limits
sizes or avoids GC - however, this is just a beginning implementation.

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

* [skip ci] Updated translations via Crowdin

* Replace `plugins/docker` with `techknowlogick/drone-docker`in ci (#16407)

* plugins/docker -> techknowlogick/drone-docker

* It is multi-arch

* docs: rewrite email setup (#16404)

* Add intro for both the docs page and mailer methods
  * Fix numbering level in SMTP section
  * Recommends implicit TLS

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>

* Validate Issue Index before querying DB (#16406)

* Fix external renderer (#16401)

* fix external renderer

* use GBackground context as fallback

* no fallback, return error

Co-authored-by: Lauris BH <lauris@nix.lv>

* Add checkbox to delete pull branch after successful merge (#16049)

* Add checkbox to delete pull branch after successful merge

* Omit DeleteBranchAfterMerge field in json

* Log a warning instead of error when PR head branch deleted

* Add DefaultDeleteBranchAfterMerge to PullRequestConfig

* Add support for delete_branch_after_merge via API

* Fix for API: the branch should be deleted from the HEAD repo

If head and base repo are the same, reuse the already opened ctx.Repo.GitRepo

* Don't delegate to CleanupBranch, only reuse branch deletion code

CleanupBranch contains too much logic that has already been performed by the Merge

* Reuse gitrepo in MergePullRequest

Co-authored-by: Andrew Thornton <art27@cantab.net>

* [skip ci] Updated translations via Crowdin

* Detect encoding changes while parsing diff (#16330)

* Detect encoding changes while parsing diff

* Let branch/tag name be a valid ref to get CI status (#16400)

* fix #16384#

* refactor: move shared helper func to utils package

* extend Tests

* use ctx.Repo.GitRepo if not nil

* fix

* fix

* 企业微信webhook

* 企业微信webhook

* 企业微信webhook

* fix build

* fix build

* Apply suggestions from code review

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: myheavily <myheavily>
Co-authored-by: zhaoxin <gitea@fake.local>
Co-authored-by: Meano <Meano@foxmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: GiteaBot <teabot@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Bagas Sanjaya <bagasdotme@gmail.com>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Jimmy Praet <jimmy.praet@telenet.be>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-23 12:41:27 +08:00
GiteaBot
afb040e021 [skip ci] Updated translations via Crowdin 2021-07-23 00:07:51 +00:00
zeripath
81091c4f34
Changelog for 1.15.0-rc2 (#16511) (#16515)
* Changelog for 1.15.0-rc2

Results of `~/go/bin/changelog -m 1.15.0 --after 16422 generate`

We need to release RC2 as there are mulitple problems with alpine 3.14 related to
the seccomp issues on Docker <20.
2021-07-22 20:20:21 +02:00
zeripath
1ce4fb256f
Restore creation of git-daemon-export-ok files (#16508)
Somewhere along the line the creation of git-daemon-export-ok
files disappeared but the updating of these files when
repo visibility changes remained. The problem is that the
current state will create files even when the org or user
is private.

This PR restores creation correctly.

Fix #15521

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-22 12:53:54 +01:00
GiteaBot
9f02d1c3c0 [skip ci] Updated translations via Crowdin 2021-07-22 00:07:51 +00:00
Patrick Schratz
ef395286bf
update user/repos api description (#16503)
Currently states 

> List the repos that the authenticated user owns or has access to

but the endpoint does not list all repos a user has access to, only the ones a user owns

(Also verified and discussed in Discord)

Fixes #16502
2021-07-21 17:49:10 +01:00
zeripath
28f6f7bb03
Restore CORS on git smart http protocol (#16496)
Unfortunately the chi changes have resulted in the CORS headers for the
git smart http protocol going missing.

This is mostly because the OPTIONS method is not being handled by
httpBase anymore.

This PR adds a GetOptions, PostOptions and Options methods to web
handler to allow OPTIONS method requests to still reach the httpBase
function.

Fix #16350
Close #16491

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-21 11:32:35 +08:00
zeripath
49bd9a1111
Fix race in log (#16490)
A race has been detected in #1441 relating to getting log levels.

This PR protects the GetLevel and GetStacktraceLevel calls with a RW mutex.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-20 20:09:29 +01:00
zeripath
97381aad5d
Make cancel from CatFileBatch and CatFileBatchCheck wait for the command to end (#16479)
Fix #16427 (again!)

* handle sharing violation error code

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-07-20 20:23:01 +03:00
6543
b26c3b482f
Add TestPrepareWikiFileName (#16487)
* Add TestPrepareWikiFileName

* use LsTree as LsFiles is index only

* ajust other tests

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-07-20 15:16:20 +02:00
zeripath
2635778425
Add basic edit ldap auth test & actually fix #16252 (#16465)
One of the reasons why #16447 was needed and why #16268 was needed in
the first place was because it appears that editing ldap configuration
doesn't get tested.

This PR therefore adds a basic test that will run the edit pipeline.

In doing so it's now clear that #16447 and #16268 aren't actually
solving #16252. It turns out that what actually happens is that is that
the bytes are actually double encoded.

This PR now changes the json unmarshal wrapper to handle this double
encode.

Fix #16252

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

Co-authored-by: 6543 <6543@obermui.de>
2021-07-20 14:30:22 +03:00
Stanley Hu
08ef45b359
Add fluid to ui container class to remove margin (#16396) 2021-07-20 08:22:23 +02:00
Gary Wang
e01b782f33
fix: support delete non-urlencoded wiki page (#16482)
* fix: support delete non-urlencoded wiki page

* fix: check error
2021-07-19 18:14:00 +02:00
GiteaBot
2256499db5 [skip ci] Updated translations via Crowdin 2021-07-19 00:07:50 +00:00
Lunny Xiao
43262226db
Fix data race in bleve indexer (#16474)
* Fix data race in bleve indexer
2021-07-18 21:59:10 +02:00
Antoine Goutenoir
bb7a7c4292
docs: fix various typos and translate to french (#16477)
Co-authored-by: 6543 <6543@obermui.de>
2021-07-18 12:21:32 -04:00
Lars Lehtonen
2344007fa3
modules/markup/markdown: fix dropped test error (#16438) 2021-07-18 14:09:34 +02:00
GiteaBot
29d4917660 [skip ci] Updated translations via Crowdin 2021-07-18 00:07:50 +00:00
Jonathan Herlin
fd3f149abd
Improve 2FA autofill (#16473)
This improves the autofill suggestion on mobile devices and some password managers
2021-07-18 02:06:22 +02:00
a1012112796
ec357833bc
show tag name on dashboard items list (#16466)
fix #16458

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-07-17 23:21:04 +02:00
6543
4b512abf5b
CI: Add unit-test-race (#16470) 2021-07-17 22:46:20 +02:00
zeripath
e83abfc289
Prevent race in TestPersistableChannelQueue (#16468)
* Prevent race in TestPersistableChannelQueue

A slight race has become apparent in the TestPersistableChannelQueue.

This PR simply adds locking to prevent the race.

* make print value of "$(GOTESTFLAGS)" on test-backend and unit-test-coverage


Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-07-17 19:09:56 +02:00
zeripath
93f31e1897
Update notification table with only latest data (#16445)
When marking notifications read the results may be returned out of order
or be delayed.  This PR sends a sequence number to gitea so that the
browser can ensure that only the results of the latest notification
change are shown.

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

Co-authored-by: 6543 <6543@obermui.de>
2021-07-17 17:18:10 +01:00
zeripath
b08e14bbcf
Retry rename on lock induced failures (re-fix) (#16461)
Unfortunately #16435 asserts the wrong error and should use
os.LinkError not os.PathError.

Fix #16439

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-16 19:16:04 +02:00
zeripath
6d8648ce06
Frontport v1.14.5 (#16454)
* Frontport v1.14.5

Frontport #16450

Frontport the changelog from v1.14.5

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

* Update config.yaml

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-16 11:23:45 -04:00
dosera
95f40047ef
Extend the fail2ban instructions with a hint on how to make X-Real-IP… (#16446)
Following the merging of #14959 - Gitea is a lot more strict regarding the interpretation of `X-Real-IP` and `X-Forwarded-For` headers.

This PR updates the fail2ban documentation to include hints to set: `REVERSE_PROXY_TRUSTED_PROXIES` and `REVERSE_PROXY_LIMIT` appropriately.

See discussion in #16443

Co-authored-by: zeripath <art27@cantab.net>
2021-07-16 10:04:52 +01:00
techknowlogick
7b31aae414
revert to use alpine 3.13 (#16451)
Co-authored-by: zeripath <art27@cantab.net>
2021-07-16 09:54:39 +08:00
zeripath
fdb0e82148
Fix crash following ldap authentication update (#16447)
Unfortunately #16268 contained a terrible error, whereby there was a double
indirection taken when unmarshalling the source data. This fatally breaks
authentication configuration reading.

Fix #16342

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-15 20:17:51 -04:00
GiteaBot
e417cca777 [skip ci] Updated translations via Crowdin 2021-07-16 00:07:52 +00:00
Josef Fröhle
8d962daed6
cleanup code issueFullPattern in modules/markup (#16419)
fix #16415
2021-07-15 22:33:56 +02:00
zeripath
d7ee5dc775
Update documentation to reflect #15219 (#16442)
The move to render custom/public as within /assets in #15219 missed updating
several documentation pages.

This PR updates this documentation.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-15 20:49:12 +01:00
Richard Nienaber
908136c557
add configuration option to restrict users by default (#16256)
* add configuration option to restrict users by default

* default IsRestricted permission only set on sign up

setting this in the model messes with other workflows (e.g. syncing LDAP users) where the IsRestricted permission needs to be explicitly set and not overridden by a config value

* fix formatting

* Apply suggestions from code review

* ensure newly created user is set to restricted

* ensure imports are in the correct order

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-15 15:19:48 -04:00
Ion Jaureguialzo Sarasola
251d7f524a
Check user instead of organization when creating a repo from a template via API (#16346)
* Check user instead of organization

* Enforce that only admins can copy a repo to another user
2021-07-15 20:19:39 +02:00
techknowlogick
ff69dfff7a
microbadger is no more, rm from readme (#16440)
* microbadger is no more, rm from readme

* Update README_ZH.md
2021-07-15 13:08:20 -04:00
Jimmy Praet
8df3d6575a
Change @every 24h default schedules to @midnight (#16431) 2021-07-15 11:55:48 -04:00
6543
195c9999a1
Changelog for v1.15.0-rc1 (#16422)
* changelog -m 1.15.0 generate

* enhance changelog

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: techknowlogick <matti@mdranta.net>

* move SECURITY before FEATURES

* move ENHANCEMENTS above BUGFIXES

* as per techknowlogick

* more

* node16

* Apply suggestions from code review

Co-authored-by: Kyle D. <kdumontnu@gmail.com>

* next

* Apply suggestions from code review

* Update CHANGELOG.md

Co-authored-by: Norwin <noerw@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Kyle D. <kdumontnu@gmail.com>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-15 11:47:57 -04:00
zeripath
33a8eec33e
Retry rename on lock induced failures (#16435)
* Retry rename on lock induced failures

Due to external locking on Windows it is possible for an
os.Rename to fail if the files or directories are being
used elsewhere.

This PR simply suggests retrying the rename again similar
to how we handle the os.Remove problems.

Fix #16427

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

* resolve CI fail

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-15 11:46:07 -04:00
GiteaBot
aed086f8b0 [skip ci] Updated translations via Crowdin 2021-07-15 15:07:57 +00:00
GiteaBot
8484ee2c28 [skip ci] Updated translations via Crowdin 2021-07-15 10:07:52 +00:00
GiteaBot
5cc5dfe036 [skip ci] Updated translations via Crowdin 2021-07-15 09:08:09 +00:00
techknowlogick
376fc350ee
add note about minimum required version of git installed (#16433) 2021-07-14 23:28:49 -04:00
GiteaBot
11c79b56da [skip ci] Updated translations via Crowdin 2021-07-14 20:07:55 +00:00
Lunny Xiao
efeb8e890b
Change the release cycle to match actual situations (#16430)
* Change the release cycle to match actual situations

* Update CONTRIBUTING.md

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-07-14 14:03:00 -04:00
techknowlogick
e180456983
Change docker tag logic (#16421)
* Change docker logic

* Apply suggestions from code review

Co-authored-by: Kyle D. <kdumontnu@gmail.com>

* docs

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Kyle D. <kdumontnu@gmail.com>
2021-07-14 18:08:43 +01:00
GiteaBot
14b6257160 [skip ci] Updated translations via Crowdin 2021-07-14 15:07:54 +00:00
zeripath
3dcb3e9073
Second attempt at preventing zombies (#16326)
* Second attempt at preventing zombies

* Ensure that the pipes are closed in ssh.go
* Ensure that a cancellable context is passed up in cmd/* http requests
* Make cmd.fail return properly so defers are obeyed
* Ensure that something is sent to stdout in case of blocks here

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

* placate lint

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

* placate lint 2

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

* placate lint 3

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

* fixup

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

* Apply suggestions from code review

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-07-14 10:43:13 -04:00
GiteaBot
ee43d70a0c [skip ci] Updated translations via Crowdin 2021-07-14 14:07:52 +00:00
GiteaBot
0ead8cea6c [skip ci] Updated translations via Crowdin 2021-07-14 13:08:17 +00:00
6543
8798e3a098
Use TrN helper for email templates (#16425)
* Add TrN helper

* use TrN

* a nit
2021-07-14 15:06:09 +02:00
delvh
8464fa15d0
Make gpg resource string more readable (#16423) 2021-07-14 12:50:39 +02:00
GiteaBot
febee86d0d [skip ci] Updated translations via Crowdin 2021-07-14 00:07:53 +00:00
Meano
423a0fccb6
Fix activation of primary email addresses (#16385)
* fix: primary email cannot be activated

* Primary email should be activated together with user account when
'RegisterEmailConfirm' is enabled.

* To fix the existing error state. When 'RegisterEmailConfirm' is enabled, the
admin should have permission to modify the activations status of user email.
And the user should be allowed to send activation to primary email.

* Only judge whether email is primary from email_address table.

* Improve logging and refactor isEmailActive

Co-authored-by: zeripath <art27@cantab.net>
2021-07-13 22:59:27 +02:00
6543
56b7f53329
Return updated repository when changing repository using API (#16420) 2021-07-13 20:31:59 +01:00
Lauris BH
d26551bd0c
Load issue/PR context popup data only when needed (#15955)
* Load issue/PR context popup data only when needed

* Add SVG icon Vue component

* Remove unneeded check
2021-07-13 20:09:19 +02:00
Stanley Hu
3dba75fb97
Support HTTP/2 in Let's Encrypt (#16371)
Modify the tlsConfig.NextProtos for Let's Encrypt and built-in HTTPS server in order to support HTTP/2.

Co-authored-by: 6543 <6543@obermui.de>
2021-07-13 18:17:46 +01:00
6543
57ee06fb94
fix calculation for finalPage in repo-search component (#16382)
Co-authored-by: Jan Naahs <jan.naahs@naahstea.de>
2021-07-13 16:05:27 +02:00
zeripath
b82293270c
Add option to provide signature for a token to verify key ownership (#14054)
* Add option to provide signed token to verify key ownership

Currently we will only allow a key to be matched to a user if it matches
an activated email address. This PR provides a different mechanism - if
the user provides a signature for automatically generated token (based
on the timestamp, user creation time, user ID, username and primary
email.

* Ensure verified keys can act for all active emails for the user

* Add code to mark keys as verified

* Slight UI adjustments

* Slight UI adjustments 2

* Simplify signature verification slightly

* fix postgres test

* add api routes

* handle swapped primary-keys

* Verify the no-reply address for verified keys

* Only add email addresses that are activated to keys

* Fix committer shortcut properly

* Restructure gpg_keys.go

* Use common Verification Token code

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-13 15:28:07 +02:00
Lunny Xiao
67f135ca5d
Fix archive error when rename repo or user (#16399)
Use repo id instead of full name to generate archive path
2021-07-13 14:16:31 +02:00
6543
b81106be3f
Let branch/tag name be a valid ref to get CI status (#16400)
* fix #16384#

* refactor: move shared helper func to utils package

* extend Tests

* use ctx.Repo.GitRepo if not nil
2021-07-13 08:14:14 +01:00
Jimmy Praet
4ce32c9e93
Detect encoding changes while parsing diff (#16330)
* Detect encoding changes while parsing diff
2021-07-13 03:13:52 +02:00
GiteaBot
2614309a58 [skip ci] Updated translations via Crowdin 2021-07-13 00:07:51 +00:00
Jimmy Praet
78118a3b02
Add checkbox to delete pull branch after successful merge (#16049)
* Add checkbox to delete pull branch after successful merge

* Omit DeleteBranchAfterMerge field in json

* Log a warning instead of error when PR head branch deleted

* Add DefaultDeleteBranchAfterMerge to PullRequestConfig

* Add support for delete_branch_after_merge via API

* Fix for API: the branch should be deleted from the HEAD repo

If head and base repo are the same, reuse the already opened ctx.Repo.GitRepo

* Don't delegate to CleanupBranch, only reuse branch deletion code

CleanupBranch contains too much logic that has already been performed by the Merge

* Reuse gitrepo in MergePullRequest

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-07-13 01:26:25 +02:00
6543
46a4c6835d
Fix external renderer (#16401)
* fix external renderer

* use GBackground context as fallback

* no fallback, return error

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-07-12 17:13:59 -04:00
Norwin
fb04cc7dbd
Validate Issue Index before querying DB (#16406) 2021-07-12 16:22:27 -04:00
Bagas Sanjaya
18c18bb196
docs: rewrite email setup (#16404)
* Add intro for both the docs page and mailer methods
  * Fix numbering level in SMTP section
  * Recommends implicit TLS

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2021-07-12 22:05:40 +02:00
6543
5b1d0a7701
Replace plugins/docker with techknowlogick/drone-dockerin ci (#16407)
* plugins/docker -> techknowlogick/drone-docker

* It is multi-arch
2021-07-12 15:20:44 -04:00
GiteaBot
522b720954 [skip ci] Updated translations via Crowdin 2021-07-12 00:24:54 +00:00
zeripath
2f725cbc9e
Add LRU mem cache implementation (#16226)
The current default memory cache implementation is unbounded in size and number of
objects cached. This is hardly ideal.

This PR proposes creating a TwoQueue LRU cache as the underlying cache for Gitea.
The cache is limited by the number of objects stored in the cache (rather than size)
for simplicity. The default number of objects is 50000 - which is perhaps too small
as most of our objects cached are going to be much less than 1kB.

It may be worth considering using a different LRU implementation that actively limits
sizes or avoids GC - however, this is just a beginning implementation.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-10 23:54:15 +02:00
Meano
07284792d4
Fix invalid params and typo of email templates (#16394)
Signed-off-by: Meano <meanocat@gmail.com>
2021-07-10 19:40:14 +02:00
GiteaBot
7a402067ce [skip ci] Updated translations via Crowdin 2021-07-10 00:24:52 +00:00
Avahe Kellenberger
8cbb38f546
Added documentation about 413 errors with an nginx solution (#15313)
* Added documentation about 413 errors with an nginx solution.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-10 02:16:07 +02:00
Jonathan Hult
615444dcbd
Fix #16387 - rootless Docker user (#16388)
Move comment to top of USER instruction
2021-07-09 10:08:22 -04:00
6543
91162bbaea
Update bluemonday to v1.0.15 (#16379)
* update github.com/microcosm-cc/bluemonday

* add exec flag to contrib/update_dependencies.sh

* Fix TESTS
2021-07-09 03:30:31 +02:00
GiteaBot
6c6938e2ed [skip ci] Updated translations via Crowdin 2021-07-09 00:25:09 +00:00
Tobias Florek
5e819ee1de
specify user in rootless container numerically (#16361)
* specify user in rootless container numerically

With kubernetes' PodSecurityPolicy set to runAsNonRoot it will not allow starting the container.  The error message is
```
Error: container has runAsNonRoot and image has non-numeric user (git), cannot verify user is non-root
```
The `USER` directive has to be numerical for that to work.

* mention the name of the uid/gid

Co-authored-by: 6543 <6543@obermui.de>
2021-07-08 15:30:09 -04:00
zeripath
d06f9ce274
Redirect on bad CSRF instead of presenting bad page (#14937)
The current CSRF handler is a bit harsh with bad CSRF tokens on webpages
I think we can be a little kinder and redirect to base page with a flash error

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-08 15:57:24 +02:00
luzpaz
fc1607b368
Fix source typos (#16374)
* Fix source typos

Follow up to e0296b6a6  
Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby`

* rm "ignore destory on `make misspell-check`"

Co-authored-by: 6543 <6543@obermui.de>
2021-07-08 14:55:09 +02:00
luzpaz
e0296b6a6d
Fix various documentation, user-facing, and source comment typos (#16367)
* Fix various doc, user-facing, and source comment typos

Found via `codespell -q 3 -S ./options/locale,./vendor -L ba,pullrequest,pullrequests,readby`
2021-07-08 13:38:13 +02:00
GiteaBot
bc6f060b8c [skip ci] Updated translations via Crowdin 2021-07-08 00:24:51 +00:00
Gary Wang
b06342f29c
fix: not able to update local created non-urlencoded wiki pages (#16139)
* fix: not able to update local created non-urlencoded wiki pages

* tidy code

* as per suggestion

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

* Don't replace space to dash for unescaped wiki filename

Co-authored-by: zeripath <art27@cantab.net>

* Remove incorrect comment

* Remove NameToUnescapedFilename()

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-07 19:23:09 -04:00
techknowlogick
061a8e7bb9
Alpine 3.14 released (#16170)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-07-07 15:43:00 -04:00
techknowlogick
7613f31c6b
Update vendor 20210707 (#16366)
* update gitea.com/go-chi/binding

* update github.com/blevesearch/bleve/v2

* update github.com/caddyserver/certmagic

* update github.com/go-git/go-git/v5

* update github.com/lafriks/xormstore

* update github.com/yuin/goldmark

* Revert "update gitea.com/go-chi/binding"

This reverts commit dea2f292b116114f9316fab95c5fd124174da404.
2021-07-07 15:41:05 -04:00
冯天书
9543e068e9
Fix typo in customizing-gitea.en-us.md (#16362)
Fixed a type in a URL in PlantUML code example in `customizing-gitea.en-us.md`.
2021-07-07 17:25:42 +02:00
GiteaBot
4fa791c47b [skip ci] Updated translations via Crowdin 2021-07-07 00:14:50 +00:00
6543
1b29747f0f
Changelog for v1.14.4 (#16348) (#16351)
* Changelog for v1.14.4 (#16348)

* docs: bump version

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-06 23:41:07 +08:00
GiteaBot
27c1578235 [skip ci] Updated translations via Crowdin 2021-07-06 00:14:50 +00:00
a1012112796
5bb97a12d7
Creating a repo from a template repo via API (#15958)
* Creating a repo from a template repo via API

fix #15934
ref:
https://docs.github.com/en/rest/reference/repos#create-a-repository-using-a-template

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-07-05 17:29:08 +02:00
Lunny Xiao
64122fe105
Fix docs assets link (#16337) 2021-07-04 15:56:40 +02:00
Lunny Xiao
760af187ba
Upgrade xorm to v1.1.1 (#16339) 2021-07-04 15:10:46 +02:00
zeripath
32fd11395b
Fix relative links in postprocessed images (#16334)
If a pre-post-processed file contains relative img tags these need to be updated
and joined correctly with the prefix. Finally, the node attributes need to be updated.

Fix #16308

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-07-04 10:26:04 +01:00
6543
fae07cbc8f
Update Vendor (#16325)
* Add Dependencie Update Script

* update gitea.com/lunny/levelqueue

* update github.com/PuerkitoBio/goquery

* update github.com/alecthomas/chroma

* update github.com/blevesearch/bleve/v2

* update github.com/caddyserver/certmagic

* update github.com/go-enry/go-enry/v2

* update github.com/go-redis/redis/v8

* update github.com/hashicorp/golang-lru

* update github.com/klauspost/compress

* update github.com/markbates/goth

* update github.com/mholt/archiver/v3

* update github.com/microcosm-cc/bluemonday

* update github.com/minio/minio-go/v7

* update github.com/olivere/elastic/v7

* update github.com/xanzy/go-gitlab

* update github.com/yuin/goldmark
2021-07-04 04:06:10 +02:00
GiteaBot
65ae46bc20 [skip ci] Updated licenses and gitignores 2021-07-04 00:14:37 +00:00
Val Lorentz
2e40ff38d1
docs: Fix broken anchors in links to awesome-gitea (#16331) 2021-07-03 21:42:33 +01:00
Stephen Holdaway
f166f9b2e1
Fix U2F error reasons always hidden (#16327)
This strict equality check in `u2fError` was causing the error
description to hide immediately after showing. `Object.keys`
always returns strings, but `errorType` argument is usually a
number type.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2021-07-03 09:19:38 +01:00
GiteaBot
a9ba29b1cd [skip ci] Updated translations via Crowdin 2021-07-03 00:14:49 +00:00
zeripath
62c278e4ab
Fix modified files list in webhooks when there is a space (#16288)
* Fix modified files list in webhooks when there is a space

There is an unfortunate bug with GetCommitFileStatus where files with
spaces are misparsed and split at the space.

There is a second bug because modern gits detect renames meaning that
this function no longer works correctly.

There is a third bug in that merge commits don't have their modified
files detected correctly.

Fix #15865


Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-07-02 21:23:37 +02:00
6543
836884429a
Add forge emojies (#16296)
* codeberg :codeberg:
* gitlab :gitlab:
* git :git:
* github :github:
* gogs :gogs:
2021-07-02 16:04:57 +02:00
sebastian-sauer
92328a3394
Add API to get commits of PR (#16300)
* Add API to get commits of PR

fixes #10918

Co-authored-by: Andrew Bezold <andrew.bezold@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-07-02 14:19:57 +02:00
Jimmy Praet
a3476e5ad5
Wrap around for previous/next buttons (#16319)
Fixes #16317

Wrap around from last to first comment when clicking "Next" on last comment.
Wrap around from first to last comment when clicking "Previous" on first comment.
2021-07-02 00:02:48 +02:00
6543
290f458d46
Reserve user/repo pattern for rss feature (#16323) 2021-07-01 23:13:20 +08:00
Norwin
fc1d9629c6
Clarify GPG binary check (#14832)
fixes #14817

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-07-01 16:14:09 +02:00
6543
dfa18a8b1c
Introduce NotifySubjectType (#16320)
* Introduce NotifySubjectType

* update swagger docs
2021-07-01 12:51:24 +02:00
Jimmy Praet
ce286f9d9c
Support custom mime type mapping for text files (#16304)
* Support custom mime type mapping for text files

* Apply suggested change to routers/common/repo.go

Co-authored-by: KN4CK3R <admin@oldschoolhack.me>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
2021-06-30 17:31:54 -04:00
zeripath
9979983283
Update Go-Git to take advantage of LargeObjectThreshold (#16316)
Following the merging of https://github.com/go-git/go-git/pull/330 we
can now add a setting to avoid go-git reading and caching large objects.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-30 22:58:45 +02:00
techknowlogick
4f26e0ac0e
up current stable version in docs (#16318) 2021-06-30 16:27:09 -04:00
zeripath
302e8b6d02
Prevent zombie processes (#16314)
Unfortunately go doesn't always ensure that execd processes are completely
waited for. On linux this means that zombie processes can occur.

This PR ensures that these are waited for by using signal notifier in serv and
passing a context elsewhere.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-30 22:07:23 +02:00
zeripath
365c4e9316
Add button to delete undeleted repositories from failed migrations (#16197)
This PR adds a button to delete failed repositories if there has been a
failure during migration and for whatever reason the repository doesn't
get deleted automatically.

Fix #16154

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-30 21:14:53 +02:00
zeripath
71c7d0a993
Fix default push instructions on empty repos (#16302)
* Fix default push instructions on empty repos

Use script block like in `repo/clone_buttons.tmpl` to set default instructions
for pushing to empty repos.

Fix #16295

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-30 20:40:51 +02:00
KN4CK3R
7d70a6eff8
Fix webhook commits wrong hash on HEAD reset (#16283)
Use `..` instead of `...` with `rev-list`. In combination with #16282 the receiver can get the correct commit. The behaviour is now like Github.

fixes #11802
2021-06-30 19:49:06 +02:00
Adyanth H
66bf74d1b9
Escape reference to user table in models.SearchEmails (#16313)
Fix #16312

Signed-off-by: Adyanth H <adyanthh@gmail.com>
2021-06-30 18:37:20 +02:00
Lunny Xiao
0966349354
Make the github migration less rate limit waiting to get comment per page from repository but not per issue (#16070)
* Make the github migration less rate limit waiting to get comment per page from repository but not per issue

* Fix lint

* adjust Downloader interface

* Fix missed reviews

* Fix test

* Remove unused struct
2021-06-30 15:23:49 +08:00
sebastian-sauer
e8c6cead0f
Fix list_options GetStartEnd (#16303)
end is start + pageSize and not start + page
2021-06-29 22:42:23 +01:00
6543
dea7a5c5b9
just add some unit tests (#16291)
* code.gitea.io/gitea/routers/utils coverage: 100.0%

* code.gitea.io/gitea/routers/install 0% -> 5.0%

* ConvertUtf8ToUtf8mb4: make sure DBType is mysql
2021-06-29 22:00:02 +01:00
zeripath
add74fb368
Fix panic in recursive cache (#16298)
There is a bug with last commit cache recursive cache where the last
commit information that refers to the current tree itself will cause a
panic due to its path ("") not being included in the expected tree entry
paths.

This PR fixes this by skipping the missing entry.

Fix #16290

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-29 16:12:43 -04:00
6543
653704c102
Add Vultr and DO Marketplace links (#16297)
* fix emoji img path

* move cloudron

* Add Vultr and DO
2021-06-29 15:42:47 -04:00
6543
65548359cc
Add custom emoji support (#16004) 2021-06-29 16:28:38 +02:00
KN4CK3R
aac663e0da
Implemented head_commit for webhooks (#16282)
* Removed Len field.

* Added head_commit webhook field.

* Added comment for returns.
2021-06-29 15:34:03 +02:00
GiteaBot
579fcad8cd [skip ci] Updated translations via Crowdin 2021-06-29 00:29:44 +00:00
zeripath
2f3d3ac20b
Update fail2ban documentation (#16286)
Following the merge of #16278 we need to update the fail2ban
documentation to take account of the availability of the new
sshConnectionFailed failed authentication attempt log message.

Also add a deprecation notice regarding the previous publicKeyHandler
messages, as these may be a source of false positives.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-28 19:26:40 -04:00
Jimmy Praet
f424862cbb
Fix previous/next button size (#16284) 2021-06-28 21:36:09 +02:00
zeripath
f825f20d49
Upgrade Gliderlabs SSH to 0.3.3 and add FailedConnectionCallback (#16278)
* Upgrade Gliderlabs SSH to 0.3.3 and add FailedConnectionCallback

Following the merging of https://github.com/gliderlabs/ssh/pull/143 we
can now report connections to the ssh server that have failed before
public key exchange has completed using the standard fail2ban message.

This PR updates Gliderlabs SSH and adds a callback that will provide this
logging.

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

* move the callback to its own function to make the logging appear little nicer

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-28 13:05:27 -04:00
Mike L
5c80ecc2f7
Counterwork seemingly unclickable repo button labels (#15064)
As title, the change counter-works the effect from #14926 that links seem unclickable (especially in the default gitea theme), while maintaining some sort of visual harmony.

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-06-28 09:21:43 +01:00
GiteaBot
6ca667d3f2 [skip ci] Updated translations via Crowdin 2021-06-28 00:29:35 +00:00
Norwin
9c6aeb47f7
Link to previous blames in file blame page (#16259)
Adds a link to each blame hunk, to view the blame of an earlier version of the file, similar to GitHub. Also refactors the blame render from fmtstring based to template based.

* Fix blame bottom line and add blame prior button

* Jump to previous parent commit from the commit.

* Fix previous commit link

* Fix previous blame link

* Fix the given file not exist in the previous commit.

* Fix blameRow struct not export

* fix theming issues, rename template var

* remove unused LastCommit fetch

* fix location of blame-hunk divider

* rewrite previous commit checks

* remove duplicate commit lookup

its already resolved and stored in ctx.Repo.Commit!

* split out blamePart processing into function

Co-authored-by: rogerluo410 <rogerluo410@gmail.com>
2021-06-28 01:13:20 +02:00
6543
59c58553ba
Fix API to return author for author on commits(#16276) 2021-06-27 23:15:42 +01:00
zeripath
9a0cd3af3b
Handle misencoding of login_source cfg in mssql (#16268)
* Handle misencoding of login_source cfg in mssql

Unfortunately due a bug in xorm (see https://gitea.com/xorm/xorm/pulls/1957) updating
loginsources on MSSQL causes them to become corrupted. (#16252)

Whilst waiting for the referenced PR to be merged and to handle the corrupted
loginsources correctly we need to add a wrapper to the `FromDB()` methods to look
for and ignore the misplaced BOMs that have been added.

Fix #16252

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

* Update models/login_source.go
2021-06-27 16:21:16 -04:00
Jimmy Praet
fe66b612b5
Add previous/next buttons to review comments (#16273)
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
2021-06-27 20:57:01 +01:00
KN4CK3R
9b1b4b5433
Refactor Webhook + Add X-Hub-Signature (#16176)
This PR removes multiple unneeded fields from the `HookTask` struct and adds the two headers `X-Hub-Signature` and `X-Hub-Signature-256`.

## ⚠️ BREAKING ⚠️ 

* The `Secret` field is no longer passed as part of the payload.
* "Breaking" change (or fix?): The webhook history shows the real called url and not the url registered in the webhook (`deliver.go`@129).

Close #16115
Fixes #7788
Fixes #11755

Co-authored-by: zeripath <art27@cantab.net>
2021-06-27 20:21:09 +01:00
6543
0b27b93728
Make allowed Visiblity modes configurable for Users (#16271)
Now that #16069 is merged, some sites may wish to enforce that users are all public, limited or private, and/or disallow users from becoming private.

This PR adds functionality and settings to constrain a user's ability to change their visibility.

Co-authored-by: zeripath <art27@cantab.net>
2021-06-27 19:47:35 +01:00
Jimmy Praet
2a98ec1c3c
Add jpraet to MAINTAINERS (#16274) 2021-06-27 18:35:31 +01:00
Norwin
615001d746
review comments: break-word for long file names (#16272)
* review comments: break-word for long file names

fixes #16248

Co-authored-by: zeripath <art27@cantab.net>
2021-06-27 17:21:19 +02:00
Jimmy Praet
eee03ae90a
Add scroll-margin-top to account for sticky header (#16269)
Fixes #16263

Co-authored-by: zeripath <art27@cantab.net>
2021-06-27 15:36:49 +01:00
Steven
f533b5d5cf
Make app.ini more restrictive on new installations (#16266)
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-06-27 11:07:36 +01:00
zeripath
35f37a3625
Add --quiet and --verbose to gitea web to control initial logging (#16260)
One of the repeatedly reported issues has been that gitea produces too much console
logging during set up even if the console logger is turned off.

Fundamentally this is due to some otherwise very helpful logging that has to occur
before logging is set up. This has come to a head with the merging of #16243 where
otherwise potentially helpful Trace logging in the git module now appears on the
console.

This PR proposes three things:

1. Change the initial default logger to Info not Trace.
2. Change the logging for the AppPath things to Info in recompense.
3. Add two new command line options to gitea web: --quiet and --verbose

`gitea web -q` or `gitea web --quiet` will only log Fatal level initially.
`gitea web -verbose` will log at Trace.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-26 20:56:58 -04:00
GiteaBot
540215588a [skip ci] Updated licenses and gitignores 2021-06-27 00:29:32 +00:00
Sergey Dryabzhinsky
22a0636544
Add Visible modes function from Organisation to Users too (#16069)
You can limit or hide organisations. This pull make it also posible for users

- new strings to translte
- add checkbox to user profile form
- add checkbox to admin user.edit form
- filter explore page user search
- filter api admin and public user searches
- allow admins view "hidden" users
- add app option DEFAULT_USER_VISIBILITY
- rewrite many files to use Visibility field
- check for teams intersection
- fix context output
- right fake 404 if not visible

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-06-26 20:53:14 +01:00
zeripath
19ac575d57
Limit stdout tracelog to actual stdout (#16258)
Related #16243

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-26 13:47:56 +01:00
Lunny Xiao
e3c626834b
Let package git depend on setting but not opposite (#15241)
* Let package git depend on setting but not opposite

* private some package variables
2021-06-26 13:28:55 +02:00
KN4CK3R
e673e42f7e
Fixed issues not updated by commits (#16254)
`UpdateIssuesCommit` may get called with fewer commits because of `FeedMaxCommitNum` and therefore may miss some commands.
2021-06-26 10:13:51 +01:00
John Olheiser
622f1e764c
Add better errors for disabled account recovery (#15117)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-06-25 23:16:36 -05:00
zeripath
62a4879e84
Improve efficiency in FindRenderizableReferenceNumeric and getReferences (#16251)
* Fuzzer finds an NPE due to incorrect URLPrefix

The Fuzzer is running on a non-repo urlprefix which is incorrect for RenderRaw


* Make FindRenderizableReferenceNumeric and getReferences more efficient

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-26 01:11:33 +02:00
ayb
9b33d18899
Added support for gopher URLs. (#14749)
* Added support for gopher URLs.

* Add setting and make this user settable instead

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-06-25 18:38:27 -04:00
zeripath
1a1ce9b721
Fuzzer finds an NPE due to incorrect URLPrefix (#16249)
The Fuzzer is running on a non-repo urlprefix which is incorrect for RenderRaw

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

Co-authored-by: 6543 <6543@obermui.de>
2021-06-25 14:14:49 -04:00
Jimmy Praet
06f483d0c4
Append to existing trailers in generated squash commit message (#15980)
* Remove superfluous newline before Co-authored-by trailers

* Append to existing PR description trailer section

If the existing PR description message already contains a trailer section (e.g. Signed-off-by: ),
append to it instead of creating a new trailer section.

* Reuse compiled regexp

* Simplify regex and deal with trailing \n in PR description

* Add tests for CommitMessageTrailersPattern

- add support for Key:Value (no space after colon)
- add support for whitespace "folding"

* Update services/pull/pull_test.go

Co-authored-by: Norwin <noerw@users.noreply.github.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-25 13:01:43 -04:00
Steven
31acd3c0c2
Prevent webhook action buttons from shifting (#16087)
On long webhook urls the action buttons (edit, delete) have been shifted
by the url text.

Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-25 13:00:09 -04:00
siddweiker
f573e93ed4
Fix heatmap activity (#15252)
* Group heatmap actions by 15 minute intervals

Signed-off-by: Sidd Weiker <siddweiker@gmail.com>

* Add multi-contribution test for user heatmap

Signed-off-by: Sidd Weiker <siddweiker@gmail.com>

* Add timezone aware summation for activity heatmap

Signed-off-by: Sidd Weiker <siddweiker@gmail.com>

* Fix api user heatmap test

Signed-off-by: Sidd Weiker <siddweiker@gmail.com>

* Update variable declaration style

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-25 12:59:25 -04:00
6543
3ef23d5411
Use gitea logging module for git module (#16243)
remove log() func from gogs times and switch to proper logging

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-06-25 17:54:08 +01:00
KN4CK3R
44b8b07631
Add tag protection (#15629)
* Added tag protection in hook.

* Prevent UI tag creation if protected.

* Added settings page.

* Added tests.

* Added suggestions.

* Moved tests.

* Use individual errors.

* Removed unneeded methods.

* Switched delete selector.

* Changed method names.

* No reason to be unique.

* Allow editing of protected tags.

* Removed unique key from migration.

* Added docs page.

* Changed date.

* Respond with 404 to not found tags.

* Replaced glob with regex pattern.

* Added support for glob and regex pattern.

* Updated documentation.

* Changed white* to allow*.

* Fixed edit button link.

* Added cancel button.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-25 16:28:55 +02:00
Martin Strob
7a0ed9a046
fix IIS reverse proxy doc (#16246) 2021-06-25 14:38:41 +02:00
GiteaBot
837e8b30a7 [skip ci] Updated translations via Crowdin 2021-06-25 00:11:36 +00:00
sebastian-sauer
6c3433151f
API: Allow COMMENT reviews to not specify a body (#16229)
* Allow COMMENT reviews to not specify a body

when using web ui there is no need to specify a body.
so we don't need to specify a body if adding a COMMENT-review
via our api.

* Ensure comments or Body is provided

and add some integration tests for reviewtype COMMENT.

Signed-off-by: Sebastian Sauer <sauer.sebastian@gmail.com>
2021-06-25 00:05:51 +02:00
Mura Li
fd6b1be1b6
Replace ARCCache with TwoQueueCache to avoid patent issue (#16240)
Co-authored-by: Mura Li <typeless@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-24 14:37:07 -04:00
KN4CK3R
4cc63e9919
Fix diff expansion is missing final line in a file (#16222)
* Fixed down offset.

* Fixed wrong line count result.
2021-06-24 17:47:46 +02:00
GiteaBot
71c5a8f7f8 [skip ci] Updated translations via Crowdin 2021-06-24 00:11:37 +00:00
zeripath
d13a0e621b
Do not show No match found for tribute (#16231)
Tribute.js will show an untranslated no match found if no emoji or mentions.

Further the mentions should really require a preceding space.

This PR fixes both of these.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-23 19:02:23 -04:00
zeripath
5f2ef17fdb
Don't WARN log UserNotExist errors on ExternalUserLogin failure (#16238)
Instead log these at debug - with warn logging for other errors.

Fix #16235

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-23 17:41:39 -04:00
Lunny Xiao
b223d36195
Rework repository archive (#14723)
* Use storage to store archive files

* Fix backend lint

* Add archiver table on database

* Finish archive download

* Fix test

* Add database migrations

* Add status for archiver

* Fix lint

* Add queue

* Add doctor to check and delete old archives

* Improve archive queue

* Fix tests

* improve archive storage

* Delete repo archives

* Add missing fixture

* fix fixture

* Fix fixture

* Fix test

* Fix archiver cleaning

* Fix bug

* Add docs for repository archive storage

* remove repo-archive configuration

* Fix test

* Fix test

* Fix lint

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-23 17:12:38 -04:00
KN4CK3R
c9c7afda1a
Add sanitizer rules per renderer (#16110)
* Added sanitizer rules per renderer.

* Updated documentation.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-23 17:09:51 -04:00
6543
eb324a9402
[API] Add repoGetTag (#16166)
* GetTag -> GetAnnotatedTag

* API: Add repoGetTag

* fix swagger docs

* support "/" as tag name char

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-23 17:08:47 -04:00
Viktor Yakovchuk
08f4b3f312
Fix 500 Error with branch and tag sharing the same name #15592 (#16040)
* Fix 500 Error with branch and tag sharing the same name #15592

Fixed 500 error while create Pull request when there are more
than one sources (branch, tag) with the same name

Fix #15592

Signed-off-by: Viktor Yakovchuk <viktor@yakovchuk.net>

* fix logging

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-06-23 17:08:26 -04:00
Lunny Xiao
f2babf3346
Add code block highlight to orgmode back (#14222)
Fix missed orgmode code block hightlight

Co-authored-by: zeripath <art27@cantab.net>
2021-06-23 22:45:47 +02:00
6543
58501a2682
[API] GET / SET User Settings (#16169)
* API: GET/SET User Settings

* linter

* Apply suggestions from code review

* Update modules/structs/user.go

* lint

* fix swagger

* move User2UserSettings to convert

* as per @zeripath "preferences" -> "settings"

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-23 15:58:44 -04:00
techknowlogick
8640717f5f
Add docs for windows env vars (#16236)
* Add docs for windows env vars

Fix #16213

* Fix docs/content/doc/developers/hacking-on-gitea.en-us.md

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2021-06-23 15:57:56 -04:00
KN4CK3R
383ffcfa34
Small refactoring of modules/private (#15947)
* Use correct variable name.

* doer is never nil here.

* Use status code constants.

* Replaced generic map with concrete struct.

* Fixed windows lint.

* Removed unused method.

* Changed error codes.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-23 15:38:19 -04:00
6543
5930d09096
Fix Nits (#16234)
* template fix

* nits

* add doer to "created issue/pull"
2021-06-23 19:43:33 +02:00
KN4CK3R
31f6b95dfa
Use data path instead of config path (#16227) 2021-06-23 16:56:25 +02:00
6543
be81dc8b20
Localize Email Templates (#16200)
close #14822
2021-06-23 14:33:21 +02:00
techknowlogick
d4ae87ea32
Run compliance on amd64 infra (#16232)
* Run compliance on amd64 infra

* Update .drone.yml
2021-06-23 01:36:27 -04:00
Jimmy Praet
17030ced75
Improve notifications for WIP draft PR's (#14663)
* #14559 Reduce amount of email notifications for WIP draft PR's

don't notify repo watchers of WIP draft PR's

* #13190 Notification when WIP Pull Request is ready for review

* Send email notification to repo watchers when WIP PR is created

* Send ui notification to repo watchers when WIP PR is created

* send specific email notification when PR is marked ready for review

instead of reusing the CreatePullRequest action

* Fix lint error

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-23 00:14:22 -04:00
sebastian-sauer
66f8da538a
Use pulls url if issue is a pull request (#16230)
if a pull request is displayed use the /pulls path
if a pull requests diff is displayed use the /pulls/{id}/files url
if an issue is displayed use the issues url

Fixes #16102

Signed-off-by: Sebastian Sauer <sauer.sebastian@gmail.com>
2021-06-22 21:13:31 +01:00
zeripath
d55b5eb0d3
Use html.Parse rather than html.ParseFragment (#16223)
* Use html.Parse rather than html.ParseFragment
  There have been a few issues with html.ParseFragment - just use html.Parse instead.

* Skip document node

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-22 00:12:22 +02:00
KN4CK3R
36c158bc93
Update milestone counters on new issue. (#16183)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-06-21 14:34:58 -04:00
zeripath
6a083a7234
Update documentation for Implicit TLS (#16220)
As per RFC 8314, it is now recommended to prefer TLS over STARTTLS.

Fix #16160

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-21 14:34:37 -04:00
zeripath
681e81babd
reqOrgMembership calls need to be preceded by reqToken (#16198)
ReqOrgMembership calls need to be preceded by reqToken

Fix #16192

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-06-21 14:01:44 +01:00
KN4CK3R
4fcae3d06d
Add tests for all webhooks (#16214)
* Added tests for MS Teams.

* Added tests for Dingtalk.

* Added tests for Telegram.

* Added tests for Feishu.

* Added tests for Discord.

* Added tests for closed issue and pullrequest comment.

* Added tests for Matrix.

* Trim all spaces.

* Added tests for Slack.

* Added JSONPayload tests.

* Added general tests.

* Replaced duplicated code.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-20 22:12:19 -04:00
GiteaBot
8601440e81 [skip ci] Updated translations via Crowdin 2021-06-21 00:11:34 +00:00
zeripath
196593e2e9
More efficiently parse shas for shaPostProcessor (#16101)
* More efficiently parse shas for shaPostProcessor

The shaPostProcessor currently repeatedly calls git rev-parse --verify on both backends
which is fine if there is only one thing that matches a sha - however if there are
multiple things then this becomes wildly inefficient.

This PR provides functions for both backends which are much faster to use.

Fix #16092

* Add ShaExistCache to RenderContext

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-06-21 00:39:12 +02:00
zeripath
23358bc55d
Use git log name-status in get last commit (#16059)
* Improve get last commit using git log --name-status

git log --name-status -c provides information about the diff between a
commit and its parents. Using this and adjusting the algorithm to use
the first change to a path allows for a much faster generation of commit
info.

There is a subtle change in the results generated but this will cause
the results to more closely match those from elsewhere.

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-21 01:00:46 +03:00
GiteaBot
8fa3bbc424 [skip ci] Updated translations via Crowdin 2021-06-20 00:11:36 +00:00
GiteaBot
6667f52694 [skip ci] Updated translations via Crowdin 2021-06-19 00:11:34 +00:00
parnic
35742d4af7
Reintroduce squash merge default comment as a config setting (#16134)
* Reinstate most of commit 09304db9a5

* Move the behaviour behind a config setting

* Also fix the initial #12365
2021-06-19 00:08:22 +02:00
6543
889dea8fc1
Remove User.GetOrganizations() (#14032)
as title
2021-06-18 19:00:53 +02:00
6543
59f25587e8
Changelog v1.14.3 (#16131) (#16196)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2021-06-18 11:54:08 -04:00
6543
d5be9ddc97
fix TestAPIRepoTransfer (#16189) 2021-06-18 16:46:22 +02:00
GiteaBot
d8792ebcef [skip ci] Updated translations via Crowdin 2021-06-18 00:12:01 +00:00
6543
75205b5669
Fix some API bugs (#16184)
* Repository object only count releases as releases (fix #16144)

* EditOrg respect RepoAdminChangeTeamAccess option (fix #16013)
2021-06-18 01:24:55 +02:00
KN4CK3R
29695cd6d5
Add asymmetric JWT signing (#16010)
* Added asymmetric token signing.

* Load signing key from settings.

* Added optional kid parameter.

* Updated documentation.

* Add "kid" to token header.
2021-06-17 23:56:46 +02:00
6543
f7cd394680
[API] Add repoCreateTag (#16165)
* Add API CreateTag

* Add Test

* API: expose Tag Message
2021-06-17 18:04:10 +02:00
Mura Li
19dedc3fa5
Speed up git diff highlight generation (#16180)
Co-authored-by: Mura Li <typeless@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-06-17 10:55:16 -04:00
6543
b3fbd37e99
[API] expose repo.GetReviewers() & repo.GetAssignees() (#16168)
* API: expose repo.GetReviewers() & repo.GetAssignees()

* Add tests

* fix unrelated swagger query type
2021-06-17 16:02:34 +02:00
zeripath
0db1048c3a
Run processors on whole of text (#16155)
There is an inefficiency in the design of our processors which means that Emoji
and other processors run in order n^2 time.

This PR forces the processors to process the entirety of text node before passing
back up. The fundamental inefficiency remains but it should be significantly
ameliorated.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-17 11:35:05 +01:00
6543
6ad5d0a306
[API] ListReleases add filter for draft and pre-releases (#16175)
* invent ctx.QueryOptionalBool

* [API] ListReleases add draft and pre-release filter

* Add X-Total-Count header

* Add a release to fixtures

* Add TEST for API ListReleases
2021-06-17 10:58:10 +02:00
6543
c9d053f0ca
[API] User expose counters (#16167) 2021-06-17 09:17:35 +02:00
6543
9469e14dc6
[API] Issue Search Add filter for MilestoneNames (#16173) 2021-06-17 08:40:59 +02:00
GiteaBot
fdf9ab11cd [skip ci] Updated translations via Crowdin 2021-06-17 00:11:43 +00:00
zeripath
1ec9e906dc
Ensure settings for Service and Mailer are read on the install page (#15943)
* Ensure settings for Service and Mailer are read on the install page

NewContext does not set the mailer or service settings so add
a new function that will run this.

Fix #15894

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

* placate lint

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-16 19:32:57 -04:00
6543
0e081ff0ce
[API] ListIssues add more filters (#16174)
* [API] ListIssues add more filters:
optional filter repo issues by:
 - since
 - before
 - created_by
 - assigned_by
 - mentioned_by

* Add Tests

* Update routers/api/v1/repo/issue.go

Co-authored-by: Lanre Adelowo <adelowomailbox@gmail.com>

* Apply suggestions from code review

Co-authored-by: Lanre Adelowo <adelowomailbox@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-16 18:33:37 -04:00
zeripath
ffbf35b7e9
Clean-up the settings hierarchy for issue_indexer queue (#16001)
There are a couple of settings in `[indexer]` relating to the `issue_indexer` queue
which override settings in unpredictable ways. This PR adjusts this hierarchy and makes
explicit that these settings are deprecated.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-16 18:19:20 -04:00
zeripath
5f4522cd1f
Fix missing discard in repo_language_stats (#16030)
Set the missing discard(1) in repo_language_stats.

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

Co-authored-by: 6543 <6543@obermui.de>
2021-06-16 18:16:47 -04:00
zeripath
6d69df2804
Add Status Updates whilst Gitea migrations are occurring (#15076)
* Add migrating message

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

* simplify messenger

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

* make messenger an interface

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

* rename

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

* prepare for merge

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

* as per tech

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

Co-authored-by: 6543 <6543@obermui.de>
2021-06-16 18:02:24 -04:00
Jonathan Tran
047c39e91b
Fix spelling (#16179)
Co-authored-by: Jonathan Tran <jon@allspice.io>
2021-06-16 23:56:43 +02:00
6543
9273601064
Add subject-type filter to list notification API endpoints (#16177)
Close #15886
2021-06-16 18:04:37 +01:00
zeripath
f4d3bf7867
issue-keyword class is being incorrectly stripped off spans (#16163)
Bluemonday sanitizer regexp rules are not additive, so the addition of the icons,
emojis and chroma syntax policy has led to this being stripped.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-16 03:02:03 +02:00
GiteaBot
3bf7a83d7f [skip ci] Updated translations via Crowdin 2021-06-16 00:11:33 +00:00
zeripath
b8e4ce754e
Only check access tokens if they are likely to be tokens (#16164)
* Only check access tokens if they are likely to be tokens

Gitea will currently check every if every password is an access token even though
most passwords are not and cannot be access tokens.

By creation access tokens are 40 byte hexadecimal strings therefore only these should
be checked.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-16 00:29:25 +02:00
Steven
3d991319df
Update MAINTAINERS (#16162) 2021-06-15 15:16:18 -04:00
koalp
864f0c0447
Use milestone deadline when sorting issues (#14551)
When sorting issues by deadline, the deadline of the milestone the issue
is attached to wasn't taken into account.

It have been changed and the nearest deadline is taken into account for
sorting.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-14 21:15:56 -04:00
zeripath
95352e6bd5
Make command in authorized keys a template (#16003)
Fix #15595
Replaces #15978

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-14 21:15:12 -04:00
KN4CK3R
ebf253b841
Add attachments for PR reviews (#16075)
* First step for multiple dropzones per page.

* Allow attachments on review comments.

* Lint.

* Fixed accidental initialize of the review textarea.

* Initialize SimpleMDE textarea.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-14 21:12:33 -04:00
GiteaBot
0adcea9ba6 [skip ci] Updated translations via Crowdin 2021-06-15 00:11:35 +00:00
KN4CK3R
68503bfae6
Fixed setting of wrong position (#16148) 2021-06-14 22:42:58 +02:00
zeripath
15fbf23d13
v180 migration should be standalone (#16151)
Unfortunately the v180 migration picked up a few non-standalone dependencies. This PR
forcibly copies the important parts back into the migration.

Fix #16150

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-14 15:07:49 -04:00
Nils Dralle
f374789fe2
Fix private repo permission problem (#16142)
* Change user access permission

* Add string 'transfer_notices_3'

* Add 3rd transfer note to transfer dialog

* Add test

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-14 14:30:35 -04:00
KN4CK3R
440039c0cc
Add push to remote mirror repository (#15157)
* Added push mirror model.

* Integrated push mirror into queue.

* Moved methods into own file.

* Added basic implementation.

* Mirror wiki too.

* Removed duplicated method.

* Get url for different remotes.

* Added migration.

* Unified remote url access.

* Add/Remove push mirror remotes.

* Prevent hangs with missing credentials.

* Moved code between files.

* Changed sanitizer interface.

* Added push mirror backend methods.

* Only update the mirror remote.

* Limit refs on push.

* Added UI part.

* Added missing table.

* Delete mirror if repository gets removed.

* Changed signature. Handle object errors.

* Added upload method.

* Added "upload" unit tests.

* Added transfer adapter unit tests.

* Send correct headers.

* Added pushing of LFS objects.

* Added more logging.

* Simpler body handling.

* Process files in batches to reduce HTTP calls.

* Added created timestamp.

* Fixed invalid column name.

* Changed name to prevent xorm auto setting.

* Remove table header im empty.

* Strip exit code from error message.

* Added docs page about mirroring.

* Fixed date.

* Fixed merge errors.

* Moved test to integrations.

* Added push mirror test.

* Added test.
2021-06-14 19:20:43 +02:00
Lunny Xiao
5d113bdd19
Improve performance of dashboard list orgs (#16099)
* Improve performance of dashboard list orgs

* Fix wrong error description

* unexport queryUserOrgIDs method

* SimpleOrg -> MinimalOrg

* .

Co-authored-by: 6543 <6543@obermui.de>
2021-06-14 20:18:09 +08:00
KN4CK3R
1295e750b4
Add OpenID claims "profile" and "email". (#16141)
* Added OpenID claims "profile" and "email".

* Splitted error.

* Added scopes_supported and claims_supported.

* Added more metadata.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-14 13:33:16 +03:00
KN4CK3R
2b39357443
Fixed sanitize errors. (#15240)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-13 23:06:52 -04:00
Lunny Xiao
0393a57511
Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index (#15599)
* Add a new table issue_index to store the max issue index so that issue could be deleted with no duplicated index

* Fix pull index

* Add tests for concurrent creating issues

* Fix lint

* Fix tests

* Fix postgres test

* Add test for migration v180

* Rename wrong test file name

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-14 10:22:55 +08:00
a1012112796
a005265718
small refactor for retry downloader (#16137)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-06-13 16:59:19 +02:00
GiteaBot
5c2f9b3f83 [skip ci] Updated licenses and gitignores 2021-06-13 00:11:23 +00:00
Andrei Yankovich
b5f5eab913
Removable media support (#16136)
Add support removable media for snap version of gitia.
for get more info about removable media interface see the snapcraft [documentation](https://snapcraft.io/docs/removable-media-interface)
2021-06-11 14:51:05 -04:00
zeripath
daa5a23548
Set self-adjusting deadline for connection writing (#16068)
* Set self-adjusting deadline for connection writing

In #16055 it appears that the simple 5s deadline doesn't work for large
file writes. Now we can't - or at least shouldn't just set no deadline
as go will happily let these connections block indefinitely. However,
what seems reasonable is to set some minimum rate we expect for writing.

This PR suggests the following algorithm:

* Every write has a minimum timeout of 5s (adjustable at compile time.)
* If there has been a previous write - then consider its previous
deadline, add half of the minimum timeout + 2s per kb about to written.
* If that new deadline is after the minimum timeout use that.

Fix #16055

* Linearly increase timeout

* Make PerWriteTimeout, PerWritePerKbTimeouts configurable

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

Co-authored-by: 6543 <6543@obermui.de>
2021-06-11 00:25:25 +03:00
6543
86e2789960
Vendor Update (#16121)
* update github.com/PuerkitoBio/goquery

* update github.com/alecthomas/chroma

* update github.com/blevesearch/bleve/v2

* update github.com/caddyserver/certmagic

* update github.com/go-enry/go-enry/v2

* update github.com/go-git/go-billy/v5

* update github.com/go-git/go-git/v5

* update github.com/go-redis/redis/v8

* update github.com/go-testfixtures/testfixtures/v3

* update github.com/jaytaylor/html2text

* update github.com/json-iterator/go

* update github.com/klauspost/compress

* update github.com/markbates/goth

* update github.com/mattn/go-isatty

* update github.com/mholt/archiver/v3

* update github.com/microcosm-cc/bluemonday

* update github.com/minio/minio-go/v7

* update github.com/prometheus/client_golang

* update github.com/unrolled/render

* update github.com/xanzy/go-gitlab

* update github.com/yuin/goldmark

* update github.com/yuin/goldmark-highlighting

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-10 16:44:25 +02:00
Lunny Xiao
f088dc4ea1
Remove utf8 option from installation page (#16126) 2021-06-10 16:52:37 +08:00
GiteaBot
3dafb074c6 [skip ci] Updated translations via Crowdin 2021-06-10 00:11:49 +00:00
Lunny Xiao
179c727b4f
Fix bug on getIssueIDsByRepoID (#16119)
* Fix bug on getIssueIDsByRepoID

* Add test
2021-06-10 02:08:19 +02:00
Lunny Xiao
5fef041079
Remove unnecessary goroutine (#16080)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-06-09 15:52:55 -04:00
Lunny Xiao
fb3ffeb18d
Add sso.Group, context.Auth, context.APIAuth to allow auth special routes (#16086)
* Add sso.Group, context.Auth, context.APIAuth to allow auth special routes

* Remove unnecessary check

* Rename sso -> auth

* remove unused method of Auth interface
2021-06-09 19:53:16 +02:00
Lunny Xiao
da057996d5
Fix http path bug (#16117)
* Fix http path bug

* Add missed request

* add tests

Co-authored-by: 6543 <6543@obermui.de>
2021-06-09 14:53:12 +02:00
Lunny Xiao
1bfb0a24d8
Refactor routers directory (#15800)
* refactor routers directory

* move func used for web and api to common

* make corsHandler a function to prohibit side efects

* rm unused func

Co-authored-by: 6543 <6543@obermui.de>
2021-06-09 01:33:54 +02:00
zeripath
e03a91a48e
Remove spurious AppSubUrl in serviceworker request. (#16047)
There is another spurious AppSubUrl placement in the serviceworker registration.
This PR removes it.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-08 18:46:13 +01:00
Lunny Xiao
44f8c812ec
Fix doctor --run check-db-consistency --fix with label fix (#16094)
* Add doctor for wrong label and issue_label data

* Fix labels and issue labels check

* Remove unnecessary functions
2021-06-08 12:36:23 +08:00
Lunny Xiao
b9d611e917
Always store primary email address into email_address table and also the state (#15956)
* Always store primary email address into email_address table and also the state

* Add lower_email to not convert email to lower as what's added

* Fix fixture

* Fix tests

* Use BeforeInsert to save lower email

* Fix v180 migration

* fix tests

* Fix test

* Remove wrong submited codes

* Fix test

* Fix test

* Fix test

* Add test for v181 migration

* remove change user's email to lower

* Revert change on user's email column

* Fix lower email

* Fix test

* Fix test
2021-06-08 11:52:51 +08:00
KN4CK3R
21cde5c439
Fix data URI scramble (#16098)
* Removed unused method.

* No prefix for data uris.

* Added test to prevent regressions.
2021-06-07 18:55:26 +02:00
Lunny Xiao
0909695204
Merge all deleteBranch as one function and also fix bug when delete branch don't close related PRs (#16067)
* Fix bug when delete branch don't close related PRs

* Merge all deletebranch as one method

* Add missed branch.go

* fix comment

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-07 22:52:59 +08:00
KN4CK3R
3607f79d78
Fixed assert statements. (#16089) 2021-06-07 07:27:09 +02:00
zeripath
51775f65bc
Make commit info cancelable (#16032)
* Make modules/context.Context a context.Context

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

* Simplify context calls

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

* Set the base context for requests to the HammerContext

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

* pass context into get-last-commit

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

* Make commit_info cancellable

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

* use context as context

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

Co-authored-by: 6543 <6543@obermui.de>
2021-06-06 19:44:58 -04:00
Lunny Xiao
b6762e2306
Fix regression of renderer (#16091)
* Fix regression of renderer

* Fix render setting load twice bug
2021-06-06 18:50:07 -04:00
GiteaBot
b3ef6a61e5 [skip ci] Updated translations via Crowdin 2021-06-06 00:11:36 +00:00
KN4CK3R
ee5e1c4a88
Rewrite of the LFS server (#15523)
* Restructured code. Moved static checks out of loop.

* Restructured batch api. Add support for individual errors.

* Let router decide if LFS is enabled.

* Renamed methods.

* Return correct status from verify handler.

* Unified media type check in router.

* Changed error code according to spec.

* Moved checks into router.

* Removed invalid v1 api methods.

* Unified methods.

* Display better error messages.

* Added size parameter. Create meta object on upload.

* Use object error on invalid size.

* Skip upload if object exists.

* Moved methods.

* Suppress fields in response.

* Changed error on accept.

* Added tests.

* Use ErrorResponse object.

* Test against message property.

* Add support for the old invalid lfs client.

* Fixed the check because MinIO wraps the error.

* Use individual repositories.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-06 02:59:27 +03:00
Steven
683cfe39ef
Change default TMPDIR path in rootless containers (#16077)
Signed-off-by: Steven Kriegler <61625851+justusbunsi@users.noreply.github.com>
2021-06-06 00:04:56 +02:00
zeripath
fe18a85f54
Fix panic (#16072)
There is an incorrect casting in the wrapped queue.

Fix #16071

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-05 15:23:22 +01:00
NekoBit
b77c62d950
Fix typo and add TODO notice (#16064)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-05 14:33:34 +01:00
KN4CK3R
8e262104c2
Add Image Diff for SVG files (#14867)
* Added type sniffer.

* Switched content detection from base to typesniffer.

* Added GuessContentType to Blob.

* Moved image info logic to client.
Added support for SVG images in diff.

* Restore old blocked svg behaviour.

* Added missing image formats.

* Execute image diff only when container is visible.

* add margin to spinner

* improve BIN tag on image diffs

* Default to render view.

* Show image diff on incomplete diff.

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-06-05 15:32:19 +03:00
Lunny Xiao
7979c3654e
Copy git data from disk when restore repository (#16066) 2021-06-04 16:14:20 +03:00
GiteaBot
a38f62ad0f [skip ci] Updated translations via Crowdin 2021-06-04 00:11:34 +00:00
KN4CK3R
8e5a37c310
Fixed unknown translation key. (#16057) 2021-06-03 23:50:31 +01:00
GiteaBot
6a7bf974be [skip ci] Updated translations via Crowdin 2021-06-03 00:11:34 +00:00
6543
c1ff59c1cd
use "true" for RACE_ENABLED (#15261) 2021-06-02 17:34:11 +02:00
zeripath
9fdda90085
Fix case change in ownernames (#16045)
If you change the case of a username the change needs to be propagated to their
repositories.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-06-02 13:03:59 +01:00
zeripath
8947422781
Fix bug due to missing MaxStartups and MaxSessions (#16046)
Unforunately #16009 makes these settings mandatory. This PR uses the same technique
as used for the certificates to make these settings non-mandatory.

Fix #16044

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

Co-authored-by: 6543 <6543@obermui.de>
2021-06-01 15:55:17 -04:00
a1012112796
7081046b5f
Fix language switch for install page (#16043)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-06-01 21:12:50 +02:00
a1012112796
072df3ff87
update `.raw-content` when edit issue/comment content (#16021)
* update ``.raw-content`` when edit issue/comment content

fix #16000

Signed-off-by: a1012112796 <1012112796@qq.com>

* handle empty content

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-31 22:22:49 -04:00
Dario Louzado
5de01e21a1
Make sshd_config more flexible regarding connections (#16009)
* Make sshd_config more flexible regarding
MaxStartups and MaxSessions.

See https://man.openbsd.org/sshd_config
for more information.

* make property prefix equals
other existing Gitea SSH properties.

Co-authored-by: dlouzado <dlouzado@senado.leg.br>
2021-05-31 21:33:50 -04:00
GiteaBot
c63d1d814c [skip ci] Updated translations via Crowdin 2021-06-01 00:11:31 +00:00
zeripath
cbf30830d2
Add missing SameSite settings for the i_like_gitea cookie (#16037)
The i_like_gitea cookie appears to be missing the SameSite settings. I think they
were present at some point but may have been removed in a merge.

This PR ensures that they are set.

Fix #15972

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-31 14:22:36 -04:00
zeripath
7a484c0788
Hide mirror passwords on repo settings page (#16022)
This PR simply hides mirror passwords from being displayed on the repo settings page.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-31 11:46:20 +01:00
Norwin
cb940c4312
Encrypt migration credentials at rest (#15895)
* encrypt migration credentials in task persistence

Not sure this is the best approach, we could encrypt the entire
`PayloadContent` instead. Also instead of clearing individual fields in
payload content, we could just delete the task once it has
(successfully) finished..?

* remove credentials of past migrations

* only run DB migration for completed tasks

* fix binding

* add omitempty

* never serialize unencrypted credentials

* fix import order

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-31 04:25:47 -04:00
zeripath
256b1a3561
Fix bug in reverse proxy (#16026)
Unfortunately go panics you try to cast a nil interface{} as another primitive
therefore you need to check interfaces are not nil before casting.

Fix #16025

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-31 02:54:16 -04:00
zeripath
3183a465d7
Make modules/context.Context a context.Context (#16031)
* Make modules/context.Context a context.Context

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

* Simplify context calls

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

* Set the base context for requests to the HammerContext

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-31 02:18:11 -04:00
GiteaBot
518ed504ef [skip ci] Updated translations via Crowdin 2021-05-31 00:11:22 +00:00
silverwind
37205039fc
Replace clipboard.js with async clipboard api (#15899)
Use async clipboard api [1] over this dependency, saving around 10kB
bundle size before minify while delivering the same functionality.

The issue comment button works but does not have a popup indication. We
could add some toast-style notifications in the future to fix that but I
think it's out of scope of this PR.

[1] https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText
2021-05-30 20:15:57 +01:00
zeripath
36dce0e457
Close the dataRC reader sooner (#16023)
Fix #15932

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-30 17:38:44 +01:00
Lunny Xiao
effad26c0e
Improve assets handler middleware (#15961)
* Use route to serve assets but not middleware

* Fix build error with bindata tag

* convert path to absolute

* fix build

* reduce function stack

* Add tests for assets

* Remove test for assets because they are not generated

* Use a http function to serve assets

* Still use middleware to serve assets then less middleware stack for assets

* Move serveContent to original position

* remove unnecessary blank line change

* Fix bug for /assets* requests

* clean code

Co-authored-by: zeripath <art27@cantab.net>
2021-05-30 18:25:11 +08:00
Jimmy Praet
d79c8bc302
Don't manipulate input params in email notification (#16011) 2021-05-30 10:38:38 +01:00
GiteaBot
d8c99c64d5 [skip ci] Updated licenses and gitignores 2021-05-30 00:11:22 +00:00
Lunny Xiao
a9daebca22
Fix get tag when migration (#16014)
Co-authored-by: zeripath <art27@cantab.net>
2021-05-29 16:04:58 -04:00
KN4CK3R
efe77eec85
Unified custom config creation (#16012)
* Unified custom config creation.

* Fixed log message.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-29 19:44:14 +01:00
Kyle D
2a998048ef
Remove New PR button in PRs (#15998) 2021-05-29 22:00:02 +08:00
BoYanZh
fb6c6895fa
fix get OS on some of the windows computers (#16007) 2021-05-29 08:37:21 +01:00
GiteaBot
461915daa6 [skip ci] Updated translations via Crowdin 2021-05-29 00:11:33 +00:00
Kyle D
a5d8f58341
Update queue workers for v1.15 (#15999)
* Update queue workers for v1.15

* update app.example.ini

* update re queue path

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-05-28 13:33:52 -04:00
GiteaBot
e39e79d3ff [skip ci] Updated translations via Crowdin 2021-05-28 00:11:34 +00:00
Jimmy Praet
c9480c5f60
Add links to toggle WIP status (#14677)
* Add links to toggle PR WIP status

* Allow PR author to toggle WIP status

* refactors and restyling, remove links from translations

Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: silverwind <me@silverwind.io>
2021-05-27 22:02:04 +02:00
zeripath
6d6a65cf5c
Allow Token/Basic auth on raw paths (#15987)
It appears that people have been using token authentication to navigate to raw paths
and recent changes have broken this. Whilst ideally these paths would not be being used
like this - it was not the intention to be a breaking change.

This PR restores access to these paths.

Fix #13772

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-27 19:46:11 +01:00
a1012112796
b27a9d43a5
add permission check for `GenerateRepository` (#15946)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-27 12:08:46 -04:00
Kyle D
c61b460038
Fix extra curly brace breaking release compare (#15988) 2021-05-26 21:07:39 -04:00
zeripath
6d39053711
Fix setting of SameSite on cookies (#15989)
Fix #15972

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-26 21:01:07 -04:00
techknowlogick
568fe8c595
follow redirect when fetching theme archive (#15986) 2021-05-26 18:03:39 -04:00
a1012112796
d1dbbf43b0
not show link to migration on repo reate page when it was disabled (#15957)
* not show link to migration on repo reate page when it was disabled

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix lint

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-26 12:13:00 -04:00
zeripath
c1a80b7d6a
Use filepath.ToSlash and Join in indexer defaults and queues (#15971)
As revealed by #15964 there is inconsistent use of filepath Join and path Join
for these directories. The best thing to do is to use filepath.Join but then ToSlash
them for consistency.

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

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2021-05-25 22:50:35 -04:00
GiteaBot
b59afa272f [skip ci] Updated translations via Crowdin 2021-05-26 00:04:32 +00:00
fnetX (aka fralix)
d5f20104da
Remove branch URL before IssueRefURL (#15968)
Revert change for account / org dashboard where IssueRefURLs do not
contain the full repo URL (case RepoLink is not true)

Co-authored-by: Norwin <noerw@users.noreply.github.com>

Remove trailing whitespace from PR review
2021-05-25 16:02:37 -04:00
Viktor Yakovchuk
5285a3e70e
Add possibility to make branch in branch page (#15960)
* Add possibility to make branch in branch page (#15911)

Add possibility to make branch in branch page
in the area next to Download and Delete buttons.
It is a more intuitive place in the interface
compared to what is already there.

Signed-off-by: Viktor Yakovchuk <viktor@yakovchuk.net>

* Update templates/repo/branch/list.tmpl

Co-authored-by: zeripath <art27@cantab.net>
2021-05-24 15:57:46 +01:00
zeripath
3aaf64885f
Change default queue settings to be low go-routines (#15964)
This PR suggests a change to the default configuration for queues:

* Use a common DATADIR for the queues
* Set starting workers to 0 and make boost a single worker

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-24 02:23:55 +03:00
KN4CK3R
6021fbfe7a
Make tasklist checkboxes clickable (#15791)
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-23 17:14:03 +03:00
silverwind
b4d10598c9
Remove fomantic accordion module (#15951)
Replace it with native <detail> element. Did some slight restyling on
the release downloads, new behaviour should be exactly the same
otherwise.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-23 08:45:39 +08:00
silverwind
308b562b3c
Remove remaining fontawesome usage in templates (#15952)
Can not remove the dependency yet because easymde depends on it.
2021-05-22 23:29:46 +02:00
Ikko Ashimine
5c7e2f47b7
Update pull_request_template.md (#15948)
Branch name
- master -> main
2021-05-22 10:46:33 -04:00
KN4CK3R
77fa7146c6
Add email headers (#15939)
* Added additional email headers.

* Added tests.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-22 14:47:16 +08:00
silverwind
be745be0a4
Double the avatar size factor (#15941)
* Double the avatar size factor

This results on finer Avatar rendering on Hi-DPI display.

* fix test

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-21 21:18:43 -04:00
GiteaBot
44d76ff7cb [skip ci] Updated translations via Crowdin 2021-05-22 00:04:28 +00:00
Patrick Schratz
d957a1569a
Bump postgres and mysql versions (#15710)
* bump postgres and mysql DB versions

* posgres test against v10

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-21 18:11:48 -04:00
a1012112796
fec8324026
add a new internal hook to save ssh log (#15787)
* add a new internal hook to save ssh log

as title, when a ssh error ocure like #15785.
only when switch ``RUN_MODE`` to dev can we
found which error is ocure. But this way is
not a good idea for production envirment.

this changes try save ssh error mesage to the
log file like other log by a new internal hook.
I think it's usefull for find error message
in production envirment. Thanks.

Signed-off-by: a1012112796 <1012112796@qq.com>

* rename and fix nit

* Update modules/private/hook.go

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-21 17:37:16 -04:00
Norwin
35b0c8aa7d
fix default avatar url (#15938) 2021-05-21 13:03:27 -04:00
Steven
d6d2444f2a
Add curl to rootless docker image (#15908)
Signed-off-by: JustusBunsi <61625851+justusbunsi@users.noreply.github.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-21 00:03:41 -04:00
sebastian-sauer
90eeb6363c
Fix layout of milestone view (#15927)
fix #15047

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-20 17:53:55 -04:00
silverwind
9b7d692e9e
Use node 16 on release tasks too (#15936)
Forgot these in https://github.com/go-gitea/gitea/pull/15804.
2021-05-20 16:37:20 -04:00
zeripath
17be645498
Encrypt LDAP bind password in db with SECRET_KEY (#15547)
* Encrypt LDAP bind password in db with SECRET_KEY

The LDAP source bind password are currently stored in plaintext in the db
This PR simply encrypts them with the setting.SECRET_KEY.

Fix #15460

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

* remove ui warning regarding unencrypted password

Co-authored-by: silverwind <me@silverwind.io>
2021-05-20 09:29:57 +01:00
GiteaBot
124b256c53 [skip ci] Updated translations via Crowdin 2021-05-20 00:25:08 +00:00
silverwind
c636ef8f1d
Disable legal comments in esbuild (#15929)
We already serve licenses.txt so we don't need these inline comments
preserved during esbuild minification. Saves around 4kB before gzip.
2021-05-19 22:46:30 +01:00
Norwin
e542b416a7
api: fix overly strict edit pr permissions (#15900)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-05-19 10:48:48 -04:00
silverwind
370cfde35e
Fix and restyle menu on code line (#15913)
* Fix and restyle menu on code line

* fix multiline and more tweaks

* move to separate files

* remove has-context-menu class

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-18 23:16:02 -04:00
zeripath
0e56e9c9d9
Restore token authentication for git http when 2FA active (#15915)
There was a small regression in #15303 whereby token auth
with 2FA active would be disallowed.

This PR fixes this.

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

Co-authored-by: 6543 <6543@obermui.de>
2021-05-18 22:30:33 -04:00
GiteaBot
825547b20e [skip ci] Updated translations via Crowdin 2021-05-19 00:25:09 +00:00
Ikko Ashimine
3e068fcdcb
Fix typo in hacking-on-gitea.en-us.md (#15918)
* continously -> continuously
* continous -> continuous
2021-05-18 19:35:59 +02:00
GiteaBot
1da0d156bc [skip ci] Updated translations via Crowdin 2021-05-18 00:25:04 +00:00
silverwind
4c3e56da13
Use Wants= over Requires= in systemd file (#15897)
`Requires=` has the behaviour of stopping `gitea.service` when the
database is stopped but not bringing it up again after the database is
started again. Use `Wants=` to define a weak requirement instead,
meaning `gitea.service` will be kept running when the database is
stopped, which is not an issue because gitea will just reconnect later
on.

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

Co-authored-by: zeripath <art27@cantab.net>
2021-05-17 16:09:15 +03:00
Norwin
a137ee7a68
git migration: don't prompt interactively for clone credentials (#15902)
* don't prompt interactively for clone credentials

* apply GIT_TERMINAL_PROMPT=0 to all git cmds

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-17 18:59:31 +08:00
GiteaBot
131b59ef89 [skip ci] Updated translations via Crowdin 2021-05-17 00:25:05 +00:00
Norwin
ba76bd78b6
remove unimplemented searchbar from project view (#15901) 2021-05-17 02:10:30 +02:00
silverwind
a32bfd867d
Issue sidebar and misc css fixes (#15524)
- Replace remaining font icons with SVG in issue sidebar
- Rework issue due date display
- Realign avatar in timeline
- Fix font size in repo search and code explore
- Consolidate active button styles
- Fix loading form on arc-green
- Align time tracker buttons vertically

Fixes: https://github.com/go-gitea/gitea/issues/15896
2021-05-16 22:18:18 +02:00
Lunny Xiao
892e6561ff
Use a special name for update default branch on repository setting (#15893) 2021-05-16 14:24:47 -04:00
Ian Wienand
c3aaf5eafd
Rework Token API comments (#15162)
Move the token API discussion into a common section discussing the
generation and listing of the tokens.  Add a note on the display of
the sha1 during creation and listing.

Co-authored-by: Norwin <noerw@users.noreply.github.com>
2021-05-16 15:51:53 +02:00
Lunny Xiao
0bf8d34630
improve empty notice (#15890) 2021-05-16 19:58:26 +08:00
zeripath
3a04d6f43f
Systemd needs After as well as Require (#15881)
If the gitea service is stopped because of the db going down
it needs an `After=db.service` to ensure it is restarted in
addition to the `Requires=db.service` to ensure that the db
is started before gitea is started.

Fix #15866

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-16 16:41:37 +08:00
GiteaBot
41136db47e [skip ci] Updated licenses and gitignores 2021-05-16 00:25:04 +00:00
zeripath
58646cab22
Move sans-serif fallback font higher than emoji fonts (#15855)
The Tor browser does not use the system-ui font and no other fonts in the stack match
its default fonts. In fact it is possible that it will in future only
match generic fonts. This means that all rendering will first try the
emoji fonts before falling back to the sans-serif font for glyphs.

In this case has the emoji fall back fonts for Tor contains empty glyphs
for numbers - in order to protect privacy - and leads to numbers being
rendered as empty glyphs. This is clearly not ideal and whilst we could
use the Arimo font - as I state above I suspect that Tor will eventually
ban detecting this and we should instead move the sans-serif font higher
in the stack so that it matches before the emoji fonts.

Partial fix of #15844

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-16 02:12:55 +02:00
6543
e0c93fed05
GitHub: migrate draft releases too (#15884)
* GitHub: migrate draft releases too

* refactor
2021-05-15 18:37:17 -04:00
zeripath
8e32eeb5de
Hold the event source when there are no listeners (#15725)
* Hold the event source when there are no listeners

The event source does not need to run when there are no listeners. Therefore
pause it when there are none.

* add some more logging

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-15 23:46:13 +02:00
zeripath
f582ec4e53
Create a session on ReverseProxy and ensure that ReverseProxy users cannot change username (#15304)
* Create a session on ReverseProxy and ensure that ReverseProxy users cannot change username

ReverseProxy users should generate a session on reverse proxy username change.

Also prevent ReverseProxy users from changing their username.

Fix #2407

* add testcase

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-15 20:33:13 +02:00
zeripath
17c5c654a5
Prevent double-login for Git HTTP and LFS and simplify login (#15303)
* Prevent double-login for Git HTTP and LFS and simplify login

There are a number of inconsistencies with our current methods for
logging in for git and lfs. The first is that there is a double login
process. This is particularly evident in 1.13 where there are no less
than 4 hash checks for basic authentication due to the previous
IsPasswordSet behaviour.

This duplicated code had individual inconsistencies that were not
helpful and caused confusion.

This PR does the following:

* Remove the specific login code from the git and lfs handlers except
for the lfs special bearer token
* Simplify the meaning of DisableBasicAuthentication to allow Token and
Oauth2 sign-in.
* The removal of the specific code from git and lfs means that these
both now have the same login semantics and can - if not
DisableBasicAuthentication - login from external services. Further it
allows Oauth2 token authentication as per our standard mechanisms.
* The change in the recovery handler prevents the service from
re-attempting to login - primarily because this could easily cause a
further panic and it is wasteful.

* add test

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-05-15 17:32:09 +02:00
zeripath
ba526ceffe
Multiple Queue improvements: LevelDB Wait on empty, shutdown empty shadow level queue, reduce goroutines etc (#15693)
* move shutdownfns, terminatefns and hammerfns out of separate goroutines

Coalesce the shutdownfns etc into a list of functions that get run at shutdown
rather then have them run at goroutines blocked on selects.

This may help reduce the background select/poll load in certain
configurations.

* The LevelDB queues can actually wait on empty instead of polling

Slight refactor to cause leveldb queues to wait on empty instead of polling.

* Shutdown the shadow level queue once it is empty

* Remove bytefifo additional goroutine for readToChan as it can just be run in run

* Remove additional removeWorkers goroutine for workers

* Simplify the AtShutdown and AtTerminate functions and add Channel Flusher

* Add shutdown flusher to CUQ

* move persistable channel shutdown stuff to Shutdown Fn

* Ensure that UPCQ has the correct config

* handle shutdown during the flushing

* reduce risk of race between zeroBoost and addWorkers

* prevent double shutdown

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-15 16:22:26 +02:00
Naohisa Murakami
9f19c2b8cc
Fix error message when saving generated LOCAL_ROOT_URL config (#15880) 2021-05-15 11:23:21 +01:00
Norwin
b6b8b194ca
Fix blame row height alignment (#15863)
* fix blame row alignment on firefox

* fix blame row alignment in chrome

* fix blame row alignment in safari

as per @silverwind

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-14 21:15:53 -04:00
GiteaBot
f3febeb594 [skip ci] Updated translations via Crowdin 2021-05-15 00:25:06 +00:00
zeripath
d0ea10b21f
Close the gitrepo when deleting the repository (#15876)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-14 21:19:38 +01:00
Lunny Xiao
f6be429781
Upgrade xorm to v1.1.0 (#15869) 2021-05-14 20:17:06 +01:00
Blake Miner
e2f39c2b64
Fix bound address/port for caddy's certmagic library (see #15848) (#15859) 2021-05-14 15:39:10 +01:00
KN4CK3R
df72cf6211
Fix LFS commit finder not working (#15856)
* Create a copy of the sha bytes.


Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-05-14 14:12:11 +01:00
zeripath
1a5659943e
Add timeout to writing to responses (#15831)
In #15826 it has become apparent that there are a few occasions when a response can
hang during writing, and because there is no timeout go will happily just block
interminably. This PR adds a fixed 5 second timeout to all writes to a connection.

Fix #15826

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-14 13:26:03 +01:00
zeripath
2d87a84709
Stop calling WriteHeader in Write (#15862)
Fixes http: superfluous response.WriteHeader call from code.gitea.io/gitea/modules/context.(*Response).WriteHeader (response.go:67)

* Looking again we don't need this writeHeader as all of our downstream
implementations will always do it for us

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-14 11:05:50 +03:00
silverwind
05fb1f61d5
Add jest rootDir and test-frontend dependency (#15860)
- Define jest rootDir to limit where it looks for test files
- Add missing dependency on test-frontend target so it can be ran from a
  clean checkout
2021-05-14 07:28:51 +01:00
Jimmy
44286e29f0
reverse proxy for IIS (#15555)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-14 00:36:53 -04:00
zeripath
418c5feded
Add information on how to rotate logging from outside container (#15852)
Fix #15842

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-14 00:36:23 -04:00
zeripath
bbbe625343
Only write config in environment-to-ini if there are changes (#15861)
* Only write config in environment-to-ini if there are changes

Only write the new config in environment-to-ini if there are changes or the
destination is not the same as the customconf.

Fix #15719
Fix #15857

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-05-14 01:01:05 +02:00
zeripath
d234d37aa8
Restore PAM user autocreation functionality (#15825)
* Restore PAM user autocreation functionality

PAM autoregistration of users currently fails due to email invalidity.
This PR adds a new setting to PAM to allow an email domain to be set
or just sets the email to the noreply address and if that fails falls
back to uuid@localhost

Fix #15702

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

* As per KN4CKER

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-13 23:11:47 +01:00
silverwind
9545c345a8
Update JS dependencies, use Node 16 (#15804)
- Update all JS dependencies to latest version
- Use Node 16 on CI
- Add new lint rules
- Add some gitignore entries for debug files

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-13 11:12:36 -04:00
zeripath
0ada74edbc
Only offer hostcertificates if they exist (#15849)
A common bug report is the otherwise harmless sshd logging:

```
Could not load host certificate "/data/ssh/ssh_host_ed25519_cert": No such file or directory
```

This PR simply checks if these files exist before creation of sshd_config and if
they do not exist, doesn't add a reference to them.

Fix #14110 amongst others.

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

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-13 15:11:28 +03:00
mlpo
52f8dcda43
Allow custom highlight mapping beyond file extensions (#15808)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-13 12:31:23 +03:00
yan
27b29ffb22
fix truncate utf8 string (#15828)
* fix truncate utf8 string.

* revoke truncated user info.
2021-05-13 08:50:57 +01:00
GiteaBot
6d2a333fdc [skip ci] Updated translations via Crowdin 2021-05-13 00:25:06 +00:00
Blake Miner
6a8e5f69cf
Fix bound address/port for caddy's certmagic library (#15758)
* Fix bound address/port for caddy's certmagic library

* Fix bug

Co-authored-by: zeripath <art27@cantab.net>
2021-05-12 20:58:55 +01:00
techknowlogick
ffbd0fef06
change s3 bucket name (#15847) 2021-05-12 15:08:33 -04:00
silverwind
8ab815ae93
Unregister non-matching serviceworkers (#15834)
* Unregister non-matching serviceworkers

With the addition of the /assets url, users who visited a previous
version of the site now may have two active service workers, one with
the old scope `/` and one with scope `/assets`. This check for
serviceworkers that do not match the current script path and unregisters
them.

Also included is a small refactor to publicpath.js which was simplified
because AssetUrlPrefix is always present now. Also it makes use of the
new joinPaths helper too.

Fixes: https://github.com/go-gitea/gitea/pull/15823
2021-05-12 20:36:53 +02:00
Lunny Xiao
b61092bcb0
Upgrade unrolled/render to v1.1.1 (#15845) 2021-05-12 18:47:05 +01:00
Oymate
ec2addc0ed
Update README.md | Add translation section (#15830)
* Update README.md

* chinese translation

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update README.md

* Update README.md

* Update README.md

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-12 11:02:55 -04:00
silverwind
dd81c29052
Reaction improvements (#15836)
- Add some spacing to inline reactions
- Adjust colors and add variables
2021-05-12 07:16:22 +01:00
zeripath
2a565478d1
Tagger can be empty, as can Commit and Author - tolerate this (#15835)
Unfortunately some old repositories can have tags with empty Tagger, Commit
or Author. Go-Git variants will always have empty values for these whereas
the native git variant leaves them at nil. The simplest solution is just to
always have these set to empty Signatures.

v156 migration also makes the incorrect assumption that these cannot be empty.
Therefore add some handling to this and add logging and adjust broken
logging elsewhere in this migration.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-12 01:11:42 -04:00
KN4CK3R
3d7d750a99
Fix individual tests (addition to #15802) (#15818)
* Decouple TestAction_GetRepoLink and TestSizedAvatarLink.

* Load database for TestCheckGPGUserEmail.

* Load database for TestMakeIDsFromAPIAssigneesToAdd.

* Load database for TestGetUserIDsByNames and TestGetMaileableUsersByIDs.

* Load database for TestUser_ToUser.

* Load database for TestRepository_EditWikiPage.

* Include AppSubURL in test.

* Prevent panic with empty slice.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-12 00:13:42 -04:00
GiteaBot
96b1315e6e [skip ci] Updated translations via Crowdin 2021-05-12 00:12:06 +00:00
zeripath
aa65a607e4
Queue manager FlushAll can loop rapidly - add delay (#15733)
* Queue manager FlushAll can loop rapidly - add delay

Add delay within FlushAll to prevent rapid loop when workers are busy

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

* as per lunny

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

Co-authored-by: 6543 <6543@obermui.de>
2021-05-12 00:22:08 +01:00
Mike L
793e03244b
label size, PR ref, new PR button alignment (#15363)
Co-authored-by: zeripath <art27@cantab.net>
2021-05-11 23:11:12 +01:00
Lunny Xiao
143071ee41
don't record error when loading ref comment but ref comment id is zero (#15820) 2021-05-11 21:43:35 +01:00
zeripath
fc6501e4e0
Set autocomplete off on branches selector (#15809)
Fix #15782

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-11 12:32:06 -04:00
techknowlogick
2dc3e4edc8
point appleboy/drone-git-push to use updated primary branch 2021-05-10 20:27:56 -04:00
KN4CK3R
f8335444de
Add Active and ProhibitLogin to API (#15689)
* Added active and prohibit_login.

* Do not omit fields for normal users.
2021-05-11 02:22:29 +02:00
Adam Szatyin
d86d123322
Add mimetype mapping settings (#15133)
* Fix APK's Content-Type header

* Fix case sensitive comparison

* Add custom mime type mapping for downloadable files

* Add documentation for MIME type mapping

* Rename download.mimetype.mapping configuration to repository.mimetype_mapping

Co-authored-by: zeripath <art27@cantab.net>
2021-05-10 16:38:08 -04:00
John Olheiser
2f65c6b2f0
Add err to log (#15813)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-05-10 20:48:23 +01:00
Lunny Xiao
d37a89ed05
don't record error when request a non-exist user (#15819)
* don't record error when request a non-exist user

* Update routers/repo/http.go

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-10 13:43:55 -04:00
a1012112796
75d8297045
add note about `cron.SCHEDULE` format in document (#15812)
* add note about ``cron.SCHEDULE`` format in document

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update custom/conf/app.example.ini

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-10 12:54:45 -04:00
Lunny Xiao
3656a2a672
Fix goth user infer bug (#15821) 2021-05-10 16:31:32 +01:00
Lunny Xiao
e5723d6556
Move restore repo to internal router and invoke from command to avoid open the same db file or queues files (#15790)
* Move restore repo to internal router and invoke from command to avoid open the same db file or queues files

* Follow @zeripath's review

* set no timeout for resotre repo private request

* make restore repo cancelable
2021-05-10 15:57:45 +08:00
silverwind
1e6fa57acb
Use single shared random string generation function (#15741)
* Use single shared random string generation function

- Replace 3 functions that do the same with 1 shared one
- Use crypto/rand over math/rand for a stronger RNG
- Output only alphanumerical for URL compatibilty

Fixes: #15536

* use const string method

* Update modules/avatar/avatar.go

Co-authored-by: a1012112796 <1012112796@qq.com>

Co-authored-by: a1012112796 <1012112796@qq.com>
2021-05-10 07:45:17 +01:00
zeripath
270aab429e
On open repository open common cat file batch and batch-check (#15667)
Use common git cat-file --batch and git cat-file --batch-check to
significantly reduce calls to git.
    
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-10 03:27:03 +02:00
zeripath
038e1db4df
Return go-get info on subdirs (#15642)
This PR is an alternative to #15628 and makes the go get handler a
handler.

Fix #15625

Close #15628

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-09 22:50:06 +01:00
zeripath
4a84022d25
Comment out app.example.ini (#15807)
This PR is an alternative to #15559.

Instead of deleting the app.example.ini - just comment out most of the
thing. This makes it clear what needs to be set and what is completely
optional - and keeps the documentation.

The app.example.ini is moved around to move the most important settings
higher in the document.

Close #15559

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-09 23:10:05 +02:00
silverwind
17a7797cdd
Fix incorrect asset URL (#15805)
Fixes another regression from https://github.com/go-gitea/gitea/pull/15219.
2021-05-09 21:03:09 +01:00
Steven
2e0f315617
Respect default merge message syntax when parsing item references (#15772)
* Respect merge message structure for parsing item references

Signed-off-by: JustusBunsi <61625851+justusbunsi@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-05-09 19:25:23 +01:00
zeripath
a2df265476
Add trace logging to SSO methods (#15803)
It is currenly impossible to detect which "SSO" method is responsible for login. This
PR adds some basic trace logging to these methods.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-09 18:04:53 +02:00
6543
4ea0b46d9b
Tests should use test files (#15801) 2021-05-09 17:20:33 +02:00
6543
a229e34387
Allow only internal registration (#15795)
* Add ALLOW_ONLY_INTERNAL_REGISTRATION into settings

* OpenID respect setting too
2021-05-09 16:13:35 +02:00
KN4CK3R
e818e9150f
Fixed individual markdown tests. (#15802) 2021-05-09 15:29:49 +02:00
6543
a98c09d2ae
Changelog v1.14.2 (#15794) (#15799)
* Changelog v1.14.2 (#15794)

* changelog tool generate

* format & add

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-05-09 13:49:26 +02:00
silverwind
c3802dcc0f
Use binary version of revive linter (#15739)
Use the common `go get` method to install and run the revive linter,
removing the useless build/lint.go and related vendor libraries.
2021-05-09 13:08:02 +02:00
zeripath
a69fb523a7
Ensure that ctx.Written is checked after issues(...) calls (#15797)
Fix issue noted in #15783

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-09 10:33:49 +08:00
Steven
864e656d81
Display conflict-free merge messages for pull requests (#15773)
Repositories using external issue tracker tend to use numeric issues in
commits. To prevent conflicts during issue reference parsing or inside
commit hooks, this change respects these configuration and uses the !
character to refer to pull requests in merge commit messages.

For repositories using squash merges, this was already handled.

Signed-off-by: JustusBunsi <61625851+justusbunsi@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-05-08 20:19:42 +01:00
zeripath
e22ee468cf
Exponential Backoff for ByteFIFO (#15724)
This PR is another in the vein of queue improvements. It suggests an
exponential backoff for bytefifo queues to reduce the load from queue
polling. This will mostly be useful for redis queues.

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-08 17:29:47 +01:00
silverwind
2a9b8d173a
Code comments improvements (#15722)
- Right-align the Reply and Resolve buttons
- Center Resolved text and add some padding
- Add padding to inline comments
- Indent the comment content to align with author name
- Re-parent form to allow better button layout space.

Co-authored-by: zeripath <art27@cantab.net>
2021-05-08 18:28:25 +03:00
silverwind
24ad131221
Rename StaticUrlPrefix to AssetUrlPrefix (#15779)
Use a new name for this template/frontend variable to make it distinct
from the server variable StaticURLPrefix.
2021-05-08 16:27:25 +02:00
6543
e278614753
[API] make change repo settings work on empty repos (#15778)
* API: Fix #15602

* Add TEST
2021-05-08 14:11:36 +02:00
6543
272bbb200d
Make let target "clean-all" remove node_modules folder too (#15780)
* Make let target "clean-all" remove node_modules folder too
2021-05-08 11:57:48 +02:00
Jonathan Tran
9557b8603a
Add selecting tags on the compare page (#15723)
* Add selecting tags on the compare page

* Remove unused condition and change indentation

* Fix tag tab in dropdown to be black

* Add compare tag integration test

Co-authored-by: Jonathan Tran <jon@allspice.io>
2021-05-07 23:10:05 +02:00
silverwind
4900881924
Use esbuild to minify CSS (#15756)
It's about a 30% speedup in webpack build time with neglible differences
in the output size. We do lose the ability for CSS source maps, but I
rarely have a use for them anyways.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-05-07 15:12:37 -04:00
zeripath
a4c13229b7
Use pulls in commit graph unless pulls are disabled (#15774)
Fix #15370

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-07 20:10:30 +02:00
silverwind
d4f28fd4ad
Fix URL of gitea emoji (#15770)
Fixes regression from #15219
2021-05-07 17:34:33 +02:00
6543
16034bb613
OAuth2 login: Set account link to "login" as default behavior (#15768) 2021-05-07 16:15:16 +02:00
zeripath
8f0539c235
Set GIT_DIR correctly if it is not set (#15751)
* Set GIT_DIR correctly if it is not set

* Expand out templates

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-07 15:19:09 +02:00
a1012112796
c25813182c
not show ref-in-new-issue pop when issue was disabled (#15761)
fix #15718

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-05-07 13:59:01 +02:00
zeripath
bdc1697729
Drop back to use IsAnInteractiveSession for SVC (#15749)
* Drop back to use IsAnInteractiveSession for SVC

There is an apparent permission change problem when using
IsWindowsService to determine if the SVC manager should be
used.

This PR simply drops back to using IsAnInteractiveSession as
this does not change behaviour.

Fix #15454

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

* Yes staticcheck I know this is deprecated

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

* Just leave me alone lint

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

Co-authored-by: 6543 <6543@obermui.de>
2021-05-07 11:27:31 +02:00
6543
640066840e
Use a generic markup class to display externally rendered files and diffs (#15735)
* creates and implements generic markup less class

* How to give custom CSS to externally rendered html

* Clarifies sources of CSS styling of markup

* further clarification of sources of markup styling

* rename _markdown to _markup

* remove defunct import

* fix orphaned reference

* Update docs/content/doc/advanced/external-renderers.en-us.md

* more renames markdown -> markup

* do not suggest less customization

* add back tokens

* fix class whitespace, remove useless if-clause

* remove unused csv-data rules

* use named exports and rename functions

* sort imports

Co-authored-by: HarvsG <11440490+HarvsG@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: silverwind <me@silverwind.io>
2021-05-07 10:43:41 +02:00
silverwind
9b5185d3cc
Improve logo customization docs (#15754)
* Improve logo customization docs

* Update docs/content/doc/advanced/customizing-gitea.en-us.md

* Update docs/content/doc/advanced/customizing-gitea.en-us.md

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-07 02:32:29 -04:00
zeripath
114c85e6ef
Fix bug where repositories appear unadopted (#15757)
Fix bug where repositories with capital letters in their names appear unadopted.

Fix #15755

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-05-07 09:21:34 +08:00
zeripath
edb838997c
Fix setting version table in dump (#15753)
* Fix setting version table in dump

As noted on Discord there is a problem with gitea dump where the version table
is not being dumped correctly.

This is due to a missing pointer in the TableInfo.

This PR fixes this.

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

* Update models_test.go
2021-05-07 00:17:43 +01:00
N. L. H
45970ae82e
Feature/oauth userinfo (#15721)
* Implemented userinfo #8534

* Make lint happy

* Add userinfo endpoint to openid-configuration

* Give an error when uid equals 0

* Implemented BearerTokenErrorCode handling

* instead of ctx.error use ctx.json so that clients
parse error and error_description correctly

* Removed unneeded if statement

* Use switch instead of subsequent if statements
Have a default for unknown errorcodes.

Co-authored-by: Nils Hillmann <hillmann@nlh-software.de>
Co-authored-by: nlhsoftware <nlhsoftware@noreply.localhost>
2021-05-06 01:30:15 -04:00
6543
6a3ad0b24e
reverse #15734 partial and comment (#15740)
* reverse & comment

* Update templates/repo/graph/commits.tmpl

Co-authored-by: 6543 <6543@obermui.de>

Co-authored-by: zeripath <art27@cantab.net>
2021-05-06 00:05:54 -04:00
a1012112796
3088866531
fix some ui bug about draft release (#15137)
* fix some ui bug about draft release

- should not show draft release in tag list because
  it will't create real tag
- still show draft release without tag and commit message
  for draft release instead of 404 error
- remove tag load for attachement links because it's useless

Signed-off-by: a1012112796 <1012112796@qq.com>

* add test code

* fix test

That's because has added a new release in relaese test database.

* fix dropdown link for draft release
2021-05-06 05:12:50 +02:00
zeripath
eedc0c8324
Defer closing the gitrepo until the end of the wrapped context functions (#15653)
There was a mistake in #15372 where deferral of gitrepo close occurs before it should.

This PR fixes this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-06 01:30:25 +02:00
zeripath
e071b53686
Fix close button change on delete in simplemde area (#15737)
* Fix close button change on delete in simplemde area

Fix issue with close button changing when deleting in the simplemde textarea.

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

* apply suggestion

Co-authored-by: 6543 <6543@obermui.de>
2021-05-05 23:46:04 +01:00
silverwind
da41714c50
Add caret styling CSS (#15651)
* Add caret styling CSS

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

* add rule in arc-green as well

* grammar

* Update web_src/less/themes/theme-arc-green.less

Co-authored-by: Wim <wim@42.be>

* remove extra rule

* add comment

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Wim <wim@42.be>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-05 14:14:04 -04:00
silverwind
a961335dc7
Issue list alignment tweaks (#15483)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-05-05 12:57:59 -04:00
KN4CK3R
5e98d670d3
Commit Graph: Pull-Requests should not link to issues (#15734)
Use `/pulls` and simplify code.
2021-05-05 17:57:39 +02:00
zeripath
eed88dc34d
Fix broken avatars since #15301 (#15731)
There was a missing * from the avatars routes in #15301.

Fix #15727

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-05 14:06:39 +01:00
John Olheiser
2bd5408e5f
MySQL 5 FAQ (#15729)
* MySQL 5

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Wording
2021-05-05 05:39:09 +01:00
zeripath
47fd156936
Use route rather than use thus reducing the number of stack frames (#15301)
Since the move to Chi the number of stack frames has proliferated somewhat catastrophically and we're up to 96 frames with multiple tests of the url outside of a trie which is inefficient.

This PR reduces the number of stack frames by 6 through careful use of Route, moves Captcha into its own router so that it only fires on Captcha routes, similarly for avatars and repo-avatars.

The robots.txt, / and apple-touch-icon.png are moved out of requiring Contexter.

It moves access logger higher in the stack frame because there is no reason why it can't be higher.

Extract from #15186
Contains #15292
2021-05-04 22:48:31 +01:00
techknowlogick
ab77a24f18
update branch in CI and docs (#15631) 2021-05-04 12:16:23 -04:00
silverwind
21465a2ce3
Fix webkit calendar icon color on arc-green (#15713)
Co-authored-by: zeripath <art27@cantab.net>
2021-05-04 16:56:43 +03:00
Loutro
34b21625c2
Display specific message if diff is not displayed because of too long line (#15611)
* 7184-  message if line too long

* Update options/locale/locale_en-US.ini

Co-authored-by: silverwind <me@silverwind.io>

* add flag on missing cases

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

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-05-04 13:58:49 +01:00
6543
1cd301796c
Only log Error on getLastCommitStatus error to let pull list still be visible (#15716) 2021-05-04 14:03:02 +02:00
GiteaBot
ed39377900 [skip ci] Updated translations via Crowdin 2021-05-04 00:12:31 +00:00
Jonathan Tran
5e047b9bd7
Add compare tag dropdown to releases page (#15695)
* Add compare tag dropdown to releases page

* Change defaults to be more intuitive and remove unneeded option

* Fix to select branch on releases page

Co-authored-by: Jonathan Tran <jon@allspice.io>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
2021-05-03 13:27:48 -04:00
zeripath
1b017fe7ca
Fix setting redis db path (#15698)
There is a bug setting the redis db in the common nosql manager whereby the db path
always fails.

This PR fixes this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-03 13:24:24 -04:00
zeripath
d11b9fbcce
Prevent race in TestChannelQueue_Batch (#15703)
There is a potential race in TestChannelQueue_Batch due to boost workers starting up

This PR simply removes the boosts from this test.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-03 17:16:59 +01:00
mlpo
5c5cfd6b18
Improve Light Chroma style (#15699)
* Improve Light Chroma style

* Light Chroma style: avoid close colors

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-05-02 22:43:08 -04:00
GiteaBot
87f8a3d39b [skip ci] Updated translations via Crowdin 2021-05-03 00:12:17 +00:00
KN4CK3R
8c8471e754
Addition to (Add Location, Website and Description to API #15675) (#15690)
* Use same name as other structs.

* Sync with normal forms.

* Edit description with API.

* Workaround for nil value.
2021-05-02 21:03:15 +02:00
zeripath
0590176a23
Only use boost workers for leveldb shadow queues (#15696)
* The leveldb shadow queue of a persistable channel queue should always start with 0
workers and just use boost to add additional workers if necessary.

* create a zero boost so that if there are no workers in a pool - boost to start the workers

* actually set timeout appropriately on boosted workers

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-02 08:22:30 +01:00
zeripath
6ebd833780
Fix DB session cleanup (#15697)
The DB session clean up needs to check expiry not created_unix.

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

Co-authored-by: 6543 <6543@obermui.de>
2021-05-01 22:51:03 -04:00
zeripath
a926ff919d
Performance improvement for last commit cache and show-ref (#15455)
* Improve performance when there are multiple commits in the last commit cache

* read refs directly if we can

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-05-02 03:16:08 +02:00
Kyle D
fda2e4549f
Move tooltip down to allow selection of Remove File on error (#15672) 2021-05-01 17:33:21 -04:00
silverwind
a64cdfd4fd
Markdown CSS tweaks (#15572)
Update Markdown CSS to more closely match GH rendering. Changes include
better nested list margins and tweaked font sizes.

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-05-01 17:32:43 -04:00
a1012112796
ae6d7860be
add cron job to delete old actions from database (#15688)
that's a way to save database storage space.

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-05-01 14:17:02 +02:00
KN4CK3R
ca0460beb7
Unify integration test configs. (#15650) 2021-05-01 10:54:55 +01:00
KN4CK3R
67e10397af
Add Location, Website and Biography to API (#15675) 2021-05-01 10:05:55 +01:00
GiteaBot
5811e162ae [skip ci] Updated translations via Crowdin 2021-05-01 00:12:19 +00:00
KN4CK3R
7670c1c99e
Fixed several activation bugs (#15473)
* Removed unneeded form tag.

* Fixed typo.

* Fixed NPE.

* Use better error page.

* Splitted GET and POST.
2021-04-30 22:21:33 +02:00
KN4CK3R
ee3fb92419
Delete references if repository gets deleted (#15681)
* Remove DeletedBranch and LFSLocks.

* Sort beans.

Co-authored-by: zeripath <art27@cantab.net>
2021-04-30 21:10:39 +02:00
Lunny Xiao
f5eb33c354
Fix orphaned objects deletion bug (#15657)
* Fix orphaned objects deletion bug

* extend test

Co-authored-by: 6543 <6543@obermui.de>
2021-04-30 20:08:46 +02:00
KN4CK3R
c80d7f33b6
Unified link creation. (#15619) 2021-04-30 19:25:13 +02:00
KN4CK3R
1456978246
Added missing prefix on install route. (#15677)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-30 11:59:16 -04:00
yearski
49b28956e2
Docs: fix location for custom/options/license (#15671) 2021-04-30 16:36:28 +02:00
6543
a6bfe59b4b
Docs: renderers rst: rst2html.py -> pandoc (#15659) 2021-04-30 14:50:55 +08:00
KN4CK3R
2e85165349
Delete protected branch if repository gets removed (#15658)
* Added missing error parameters.

* Delete protected branch if repository gets removed.

* Added doctor fix.
2021-04-30 00:48:52 +02:00
Martin Michaelis
d576126286
Remove random password in Dockerfiles (#15362)
* Remove random password of git user in dockerfile

* Disable git user account in rootless dockerfile
2021-04-29 19:48:52 +02:00
Garrit Franke
f67e36097a
fix(settings): misaligned buttons (#15656)
Co-authored-by: 6543 <6543@obermui.de>
2021-04-29 13:05:07 -04:00
Lunny Xiao
d7dbe4feeb
Fix readme render bug (#15649) 2021-04-28 22:22:54 +02:00
zeripath
2c57352a30
Remove spurious set name from eventsource.sharedworker.js (#15643)
Fix #15617

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-28 10:40:04 -04:00
a1012112796
1e877613bf
add /assets as root dir of public files (#15219)
* add `/assets` as root dir of public files

Signed-off-by: a1012112796 <1012112796@qq.com>

* move serviceworker.js

* make fmt

* fix some link

* fix test

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-04-28 12:35:06 +00:00
silverwind
cc7d118b12
Remove x-ua-compatible header (#15640)
The header is deprecated since IE 11 so it only serves to support IE 10
and below which are browsers which are long unsupported now.
2021-04-28 03:15:16 +03:00
a1012112796
f31443d6a8
not update updated uinx for git gc (#15637)
fix #15634

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-04-28 00:33:16 +08:00
GiteaBot
e711050450 [skip ci] Updated translations via Crowdin 2021-04-27 00:12:19 +00:00
zeripath
b07938be5b
Fix commit graph author link (#15627)
The author link on the commit graph is incorrect and isn't providing a link to the author.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-26 19:02:15 +01:00
Lunny Xiao
3d5bb3e6a3
fix webhook timeout bug (#15613)
* Also fix the potential problem in httplib
2021-04-25 21:48:12 +03:00
Dong Nguyen
6ea6e2b4eb
Update config-cheat-sheet.en-us.md (#15606)
Add more guide about `PROVIDER_CONFIG` when `PROVIDER` is `db` (https://github.com/go-gitea/gitea/issues/14016)
2021-04-24 16:58:40 +02:00
silverwind
ec69f34726
Update JS dependencies (#15591)
* Update JS dependencies

- Update all JS dependencies
- Regenerate SVGs
- Remove unused postcss dependency
- Remove removed webpack option

* re-add postcss

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-24 13:07:22 +03:00
techknowlogick
ea40eb749b
Resolve panic on failed interface conversion in migration v156 (#15604)
go panics otherwise with `panic: interface conversion: error is git.ErrNotExist, not *git.ErrNotExist`, thanks to Codeberg/Andi for reporting this.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-24 11:14:39 +08:00
Lunny Xiao
1b3dbdba4e
Attachment support repository route (#15580) 2021-04-23 11:18:21 -04:00
6543
bee8ce342f
Fix go-fuzz (#15596)
* Fix go-fuzz

followup of https://github.com/go-gitea/gitea/pull/15175

* simplify

* enhance
2021-04-23 16:22:52 +08:00
GiteaBot
e91932bc15 [skip ci] Updated translations via Crowdin 2021-04-23 00:12:28 +00:00
6543
792b4dba2c
[Vendor] Update directly used dependencys (#15593)
* update github.com/blevesearch/bleve v2.0.2 -> v2.0.3

* github.com/denisenkom/go-mssqldb v0.9.0 -> v0.10.0

* github.com/editorconfig/editorconfig-core-go v2.4.1 -> v2.4.2

* github.com/go-chi/cors v1.1.1 -> v1.2.0

* github.com/go-git/go-billy v5.0.0 -> v5.1.0

* github.com/go-git/go-git v5.2.0 -> v5.3.0

* github.com/go-ldap/ldap v3.2.4 -> v3.3.0

* github.com/go-redis/redis v8.6.0 -> v8.8.2

* github.com/go-sql-driver/mysql v1.5.0 -> v1.6.0

* github.com/go-swagger/go-swagger v0.26.1 -> v0.27.0

* github.com/lib/pq v1.9.0 -> v1.10.1

* github.com/mattn/go-sqlite3 v1.14.6 -> v1.14.7

* github.com/go-testfixtures/testfixtures v3.5.0 -> v3.6.0

* github.com/issue9/identicon v1.0.1 -> v1.2.0

* github.com/klauspost/compress v1.11.8 -> v1.12.1

* github.com/mgechev/revive v1.0.3 -> v1.0.6

* github.com/microcosm-cc/bluemonday v1.0.7 -> v1.0.8

* github.com/niklasfasching/go-org v1.4.0 -> v1.5.0

* github.com/olivere/elastic v7.0.22 -> v7.0.24

* github.com/pelletier/go-toml v1.8.1 -> v1.9.0

* github.com/prometheus/client_golang v1.9.0 -> v1.10.0

* github.com/xanzy/go-gitlab v0.44.0 -> v0.48.0

* github.com/yuin/goldmark v1.3.3 -> v1.3.5

* github.com/6543/go-version v1.2.4 -> v1.3.1

* do github.com/lib/pq v1.10.0 -> v1.10.1 again ...
2021-04-22 20:08:53 -04:00
silverwind
834fc74873
Raw file view tweaks (#15520)
- Limit SVG images to 600px width
- Adjust size of view toggle buttons to match other buttons
- Make Edit/Delete buttons easier to click

Had to create a separate CSS file because the less parser can not parse
CSS4 case-insensitive attribute selectors which are widely supported by
browsers.

Fixes: https://github.com/go-gitea/gitea/issues/15515
2021-04-22 23:43:44 +02:00
6543
8ea1d32bea
[Vendor] update certmagic (#15590)
* update github.com/caddyserver/certmagic v0.12.0 -> v0.13.0

* migrate
2021-04-22 22:42:33 +02:00
Lunny Xiao
e7fc078891
Fix missing storage init (#15589) 2021-04-22 18:48:47 +02:00
zeripath
d6a33cef23
If the default branch is not present do not report error on stats indexing (follow-up of #15546) (#15583)
#15546 doesn't completely fix this problem because the error returned is an ObjectNotExist
error not a BranchNotExist error.

Add test for ErrObjectNotExist too

Fix #15257

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-22 17:35:29 +02:00
Björn Heinrichs
72e0ad8000
Fix docker enviroment variable from TYPE to DB_TYPE (#15585)
As documented in https://docs.gitea.io/en-us/config-cheat-sheet/ the database type is defined using db_type not type.
2021-04-22 16:34:12 +02:00
Nathan Smith
445e47b692
Bump unrolled/render to v1.1.0 (#15581)
v1.1.0 has improved buffer pooling
2021-04-22 10:54:27 +01:00
zeripath
f719ffc783
If the default branch is not present do not report error on stats indexing (#15546)
* If the default branch is not present do not report error on stats indexing

Fix #15257

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

* as per lunny

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-22 09:19:21 +08:00
zeripath
df416f2414
Add placeholder text to deploy key textarea (#15575)
* Add placeholder text to deploy key textarea

Related #15574

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

* Update templates/repo/settings/deploy_keys.tmpl

* Update templates/repo/settings/deploy_keys.tmpl
2021-04-21 16:19:32 -04:00
zeripath
1cd8d0ca0e
Fix NPE on view commit with notes (#15561)
Fix #15558

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-21 19:00:27 +01:00
Lunny Xiao
2255afffad
Fix lfs management find (#15537)
Fix #15236

* Do not do 40byte conversion within ParseTreeLine
* Missed a to40ByteSHA

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-04-21 18:31:59 +02:00
Kyle D
9b8ffa1c7a
Output node min version variable (#15562) 2021-04-21 14:15:18 +08:00
GiteaBot
d85a4e8cec [skip ci] Updated translations via Crowdin 2021-04-21 00:12:23 +00:00
silverwind
5e85cdad29
Project board improvements (#15429)
* Project board improvements

- Fix link colors
- Extract CSS to own file
- Various minor tweaks to make it look better

Fixes: https://github.com/go-gitea/gitea/issues/15424
Fixes: https://github.com/go-gitea/gitea/issues/15506
Fixes: https://github.com/go-gitea/gitea/pull/15511

* fix squashed cards on small view area

* more css fixes, add second row from issue list

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-20 00:13:03 -04:00
Nathan Zook
2242f381e6
Added OpenAPI document link to usage (#15535)
* Added OpenAPI document link to usage

The OpenAPI document at /api/swagger.v1.json needs an obvious reference.  Sadly, I am English monolingual, so someone else is going to have to do the other languages.  In the mean time, this PR should help anyone looking for the file.

* Update docs/content/doc/developers/api-usage.en-us.md

Co-authored-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-19 23:29:08 -04:00
GiteaBot
3a49c00f0d [skip ci] Updated translations via Crowdin 2021-04-20 00:12:27 +00:00
Lunny Xiao
9d99f6ab19
Refactor renders (#15175)
* Refactor renders

* Some performance optimization

* Fix comment

* Transform reader

* Fix csv test

* Fix test

* Fix tests

* Improve optimaziation

* Fix test

* Fix test

* Detect file encoding with reader

* Improve optimaziation

* reduce memory usage

* improve code

* fix build

* Fix test

* Fix for go1.15

* Fix render

* Fix comment

* Fix lint

* Fix test

* Don't use NormalEOF when unnecessary

* revert change on util.go

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* rename function

* Take NormalEOF back

Co-authored-by: zeripath <art27@cantab.net>
2021-04-19 18:25:08 -04:00
Raphael Kruse
c9cc6698d2
Fix a broken link in customizing-gitea.en-us.md (#15543) 2021-04-19 11:47:49 -04:00
Lunny Xiao
ce8255fb7b
Change the chinese discuss link to discourse (#15533) 2021-04-18 19:12:16 +08:00
GiteaBot
7417628f8d [skip ci] Updated translations via Crowdin 2021-04-18 00:12:19 +00:00
Lunny Xiao
a3c4c57b7c
Fix bug on commit graph (#15517) 2021-04-17 10:27:25 +01:00
GiteaBot
eee30d5586 [skip ci] Updated translations via Crowdin 2021-04-17 00:12:20 +00:00
zeripath
b1e138511b
Prevent migration 156 failure if tag commit missing (#15519)
It is possible that tag commits could be deleted or missing from repos. This causes
migration 156 to fail and breaks upgrade.

This PR simply logs the failure.

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

Co-authored-by: 6543 <6543@obermui.de>
2021-04-16 19:28:40 -04:00
zeripath
324cff68c9
Send size to /avatars if requested (#15459)
If an avatar is requested in a particular size ensure that /avatars also gets the size request

Fix #15453

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-17 00:22:25 +02:00
Lunny Xiao
c29620c05f
Add tests for clone from wiki (#15513)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-16 17:39:21 -04:00
6543
a67861b4dc
Fix Benchmark tests, remove a broken one & add two new (#15250)
* Benchmark Integration TESTS

* CI: add benching-arm64 pipeline

* BenchmarkRepo: name test case tests

* Fix BenchmarkRepoBranchCommit beside Create new Branch

* CI: benching use amd64

* rm total broken "BenchmarkRepo"

* dont run benchmark in CI
2021-04-16 20:30:16 +02:00
techknowlogick
c29e85228f
frontport: 1.14.1 changelog (#15503)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-16 00:06:02 -04:00
techknowlogick
024ef3940f
add well-known config for OIDC (#15355)
* add well-known config for OIDC

* spacing per feedback

* Update oidc_wellknown.tmpl

* add id_token

* Update oidc_wellknown.tmpl

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-15 22:32:00 -04:00
zeripath
6a7090b41d
Fix missing icons and colorpicker when mounted on suburl (#15501)
* Fix missing icons and colorpicker when mounted on suburl

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

* as per silverwind

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-04-16 01:15:51 +03:00
Kindyroo
953f39822b
Fix: npx webpack make: *** [Makefile:699: public/js/index.js] Error -… (#15465)
* Fix: npx webpack make: *** [Makefile:699: public/js/index.js] Error -1073741819

* Update webpack.config.js

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
2021-04-15 16:07:31 -04:00
Lunny Xiao
92c09a90f7
Fix bug clone wiki (#15499)
Fix #15494

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-04-15 19:57:19 +01:00
Lunny Xiao
8202dd1311
Performance improvement for list pull requests (#15447) 2021-04-15 19:34:43 +02:00
Kyle D
f44543a1bb
Disable Stars config option (#14653)
* Add config option to disable stars

* Replace "stars" with watched in user profile

* Add documentation
2021-04-15 18:53:57 +02:00
firesoft-de
af2adb4e35
Specify relation between multiple signing options (#15496) 2021-04-15 18:06:32 +02:00
6543
2a42d80d14
migration: github: if rate limit is not enabled, ignore it (#15490) 2021-04-15 15:34:22 +02:00
zeripath
217b5c150f
Query the DB for the hash before inserting in to email_hash (#15457)
Some postgres users have logging which logs even failed transactions. So
just query the db before trying to insert.

Fix #15451

Signed-off-by: Andrew Thornton art27@cantab.net
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-15 13:22:04 +01:00
silverwind
f7830041f4
Make build scripts compatible with node 12 (#15479)
* Make build scripts compatible with node 12

"fs/promises" is not in node 12, use a more compatible way to import it.
Also, lock major down versions of the image build dependencies to
prevent future surprises.

* add node_modules dependency
2021-04-15 12:02:34 +01:00
zeripath
9d07facdeb
Ensure review dismissal only dismisses the correct review (#15477)
Fix #15472

Signed-off-by: Andrew Thornton art27@cantab.net
2021-04-15 11:03:11 +01:00
zeripath
61bae620c1
Build go-git variants for windows (#15482)
It appears that there are significant performance problems with the pure git backend
on windows.

Therefore until we can sort this out - provide go-git backend builds.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-15 12:02:44 +03:00
Lunny Xiao
dc5a1d617d
Fix potential copy lfs records failure when fork a repository (#15441) 2021-04-14 22:15:28 +01:00
KN4CK3R
cf8f66e5dc
Use subdir for URL (#15446)
Fixes #15444
2021-04-14 20:43:17 +01:00
Naohisa Murakami
1426601cf7
Use index of the supported tags to choose user lang (#15452)
Fix #14793.

The previous implementation used the first return value of matcher.Match, which is the chosen language tag but may contain extensions such as de-DE-u-rg-chzzzz.

As mentioned in the documentation of language package, matcher.Match also returns the index of the supported tags, so I think it is better to use it rather than manipulate the returned language tag.
2021-04-14 19:52:01 +01:00
John Olheiser
078df7a392
quick fix (#15464)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-04-14 18:54:54 +01:00
KN4CK3R
662bbed32e
Fixed several typos. (#15470) 2021-04-14 17:44:01 +01:00
a1012112796
08ba895c2b
fix wrong file link in code search page (#15466)
in previous the grenrated link is
``testg/testrepo/src/commit/....``
which is not right.

the right version is ``/testg/testrepo/.......``
(start wiht ``/``)
or ``http://127.0.0.1:3000/xxxxx`` (full link)

to make it hase same result with explore page
I choose the secound style.

fix #15438

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: 6543 <6543@obermui.de>
2021-04-14 17:59:42 +02:00
zeripath
1ee776970a
Fix ambiguous argument error on tags (#15432)
There is a weird gotcha with GetTagCommitID that because it uses git rev-list
can cause an ambiguous argument error.

This PR simply makes tags use the same code as branches.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-14 16:22:37 +02:00
Lunny Xiao
424bd86c60
Display more repository type on admin repository management (#15440) 2021-04-14 15:33:22 +02:00
zeripath
8e2a8efd84
Prevent superfluous response.WriteHeader (#15456)
This PR simply checks the status before writing the header.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-14 14:57:18 +02:00
Martin Michaelis
55eb1745bd
OAuth2 auto-register (#5123)
* Refactored handleOAuth2SignIn in routers/user/auth.go

The function handleOAuth2SignIn was called twice but some code path could only
be reached by one of the invocations. Moved the unnecessary code path out of
handleOAuth2SignIn.


* Refactored user creation

There was common code to create a user and display the correct error message.
And after the creation the only user should be an admin and if enabled a
confirmation email should be sent. This common code is now abstracted into
two functions and a helper function to call both.

* Added auto-register for OAuth2 users

If enabled new OAuth2 users will be registered with their OAuth2 details.
The UserID, Name and Email fields from the gothUser are used.
Therefore the OpenID Connect provider needs additional scopes to return
the coresponding claims.

* Added error for missing fields in OAuth2 response

* Linking and auto linking on oauth2 registration

* Set default username source to nickname

* Add automatic oauth2 scopes for github and google

* Add hint to change the openid connect scopes if fields are missing

* Extend info about auto linking security risk

Co-authored-by: Viktor Kuzmin <kvaster@gmail.com>
Signed-off-by: Martin Michaelis <code@mgjm.de>
2021-04-14 14:02:12 +02:00
6543
ca2e1d8090
docs: migration start new section (#15462) 2021-04-14 08:46:17 +02:00
GiteaBot
35381a0e4f [skip ci] Updated translations via Crowdin 2021-04-14 00:12:38 +00:00
zeripath
cd79fbf94a
v172 migration adds created_unix field instead of expiry (#15458)
The Session table must have an Expiry field not a created_unix field - somehow
this migration adds the incorrect named field leading to #15445 reports.

Fix #15445

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-13 20:04:17 -04:00
Lunny Xiao
66f0fd0959
Add NeedPostProcess for Parser interface to improve performance of csv render (#15153) 2021-04-13 15:06:31 +08:00
KN4CK3R
bf3e584de2
Fix repository search (#15428)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-12 22:09:46 -04:00
zeripath
27f9bda769
Prevent NPE on avatar direct rendering if federated avatars disabled (#15434)
#13649 assumed that direct avatar urls would always be libravatar urls - this leads
to NPEs if federated avatar service is disabled.

Fix #15421

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-12 20:57:12 -04:00
silverwind
51313fbb63
Clone panel fixes (#15435)
- Use <button> over <div> for a button
- Fix absent border-right on wiki
- Fix absent border-radius on wiki

Co-authored-by: 6543 <6543@obermui.de>
2021-04-12 20:10:57 -04:00
silverwind
b18042bb8c
Fix wiki clone urls (#15430)
Fix wiki clone urls

Regressed by: 9a4050f1e8
Fixes: https://github.com/go-gitea/gitea/issues/15420
2021-04-12 23:52:48 +02:00
techknowlogick
26e16e4ee4
docs: rm deprecated docs regarding environment variable usage in docker image (#15405)
* docs: rm deprecated docs regarding environment variable usage in docker image

* Update docs/content/doc/installation/with-docker.en-us.md

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
2021-04-12 15:42:02 -04:00
KN4CK3R
a35a5b225c
Add ETag header (#15370)
* Add ETag header.

* Comply with RFC 7232.

* Moved logic into httpcache.go

* Changed name.

* Lint

* Implemented If-None-Match list.

* Fixed missing header on *

* Removed weak etag support.

* Removed * support.

* Added unit test.

* Lint

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-12 10:49:26 -04:00
Johan Van de Wauw
6d2866f20c
dump: Add option to skip LFS/attachment files (#15407)
* Add option to skip dumping LFS/attachment files

* Fix fmt issues

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-12 17:33:32 +08:00
Tomás Warynyca
db4acd864f
fix dingtalk icon url (#15417) 2021-04-12 15:17:57 +08:00
GiteaBot
d42509a534 [skip ci] Updated translations via Crowdin 2021-04-12 00:12:18 +00:00
6543
83d771c1c7
use repo1_bare to test against (#15402) 2021-04-11 11:45:29 -04:00
zeripath
8171478d1d
Standardise icon on projects PR page (#15387)
Fix #15272

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-11 11:00:14 -04:00
a1012112796
63411309fb
add some reponse status on api docs (#15399)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-04-11 09:53:23 +01:00
6543
18efe9a023
Changelog v1.14.0 (#15360) (#15400)
* Changelog v1.14.0 (#15360)

* clean & merge & update v1.14.0 changelog

* backport v1.13.x changelogs

* update latest gitea version
2021-04-11 13:23:55 +08:00
silverwind
d848098f60
Enforce tab indentation in templates (#15289)
* Enforce tab indendation in templates

This adds editorconfig-checker [1] to lint the template files so they
conform the editorconfig files. I fixed all current identation issues
using the fix mode of eclint [2] and some manual corrections.

We can extend this linting to other files later, for now I'd like this
PR to focus on HTML template files only.

[1] https://github.com/editorconfig-checker/editorconfig-checker
[2] https://github.com/jedmao/eclint

* fix indendation

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-10 23:46:37 -04:00
GiteaBot
0c77e0791c [skip ci] Updated translations via Crowdin 2021-04-11 00:12:21 +00:00
Lunny Xiao
1fc1d60517
Fix delete nonexist oauth application 500 and prevent deadlock (#15384)
* Fix delete nonexist oauth application 500

* Fix test

* Close the session

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

* Update integrations/api_oauth2_apps_test.go

* Fix more missed sess.Close

* Remove unnecessary blank line

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-04-10 16:49:10 -04:00
zeripath
c680eb2cc7
Links in markdown should be absolute to the repository not the server (#15088)
* Links in markdown should be absolute to the repository not the server

Fix #15075

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

* match github

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

* add testcase

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

Co-authored-by: 6543 <6543@obermui.de>
2021-04-11 00:26:28 +08:00
zeripath
84f5a0bc62
Always set the merge base used to merge the commit (#15352)
The issue is that the TestPatch will reset the PR MergeBase - and it is possible for TestPatch to update the MergeBase whilst a merge is ongoing. The ensuing merge will then complete but it doesn't re-set the MergeBase it used to merge the PR.

Fixes the intermittent error in git test.

Signed-off-by: Andrew Thornton art27@cantab.net
2021-04-10 09:27:29 +01:00
a1012112796
e375cbfd46
rsponse 404 when delete not exist email (#15383)
fix #15357

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-04-10 07:12:38 +01:00
zeripath
9a0858cecf
SHA in merged commit comment should be rendered ui sha (#15376)
* SHA in merged commit comment should be rendered ui sha

On a PR page the sha of the merge commit should be rendered in monospace
as a SHA. Also fixes an issue with the manually merged string.

Fix #15049

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

* issues.force_push_codes needs this too.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-09 22:24:59 -04:00
zeripath
136a20926c
Turn RepoRef and RepoAssignment back into func(*Context) (#15372)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-09 20:26:08 -04:00
GiteaBot
d0eeba9ff9 [skip ci] Updated translations via Crowdin 2021-04-10 00:13:11 +00:00
silverwind
216976247c
Remove usage of JS globals (#15378)
Refactor the exported globals in index.js to JS-initialized event
handlers.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-09 19:42:38 -04:00
zeripath
b9ed3cbc26
Upgrade to bluemonday 1.0.7 (#15379)
* Upgrade to bluemonday 1.0.7

Fix #15349

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

* resolve unit test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-09 19:13:06 -04:00
KN4CK3R
07aa3845f8
Update MAINTAINERS (#15382) 2021-04-09 19:11:31 -04:00
Mike L
013657ec76
Use semantic dropdown for code search query type (#15276)
Add comments to CSS rules

Co-authored-by: zeripath <art27@cantab.net>
2021-04-09 16:53:16 -04:00
silverwind
afa781bf20
Dropzone styling improvements (#15291)
* Dropzone styling improvements

- Move all dropzone styles to separate file
- Fix white background in arc-green
- Fix rendering of non-square images and previews

* increase thumbnail quality, set contain in js, replace blur effect with opacity
2021-04-10 00:51:27 +08:00
koalp
3dc099773d
Fix mirror_lfs source string in en-US locale (#15369)
The mirror_lfs source string was set to "Large File System" instead of "Large File Storage"

This has been fixed
2021-04-09 11:00:32 -04:00
zeripath
9d2c251214
Move FCGI req.URL.Path fix-up to the FCGI listener (#15292)
Simplify the web.go FCGI path by moving the req.URL.Path fix-up to listener

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

Co-authored-by: 6543 <6543@obermui.de>
2021-04-09 21:17:57 +08:00
silverwind
99f835b9ca
Disable Vue's console advertisments (#15354) 2021-04-09 11:12:55 +01:00
6543
477c4530e4
Fix admin user list (#15358) 2021-04-09 10:16:10 +02:00
6543
9c4601bdf8
Code Formats, Nits & Unused Func/Var deletions (#15286)
* _ to unused func options

* rm useless brakets

* rm trifial non used models functions

* rm dead code

* rm dead global vars

* fix routers/api/v1/repo/issue.go

* dont overload import module
2021-04-09 09:40:34 +02:00
silverwind
0991f9aa42
Stop packaging node_modules in release tarballs (#15273)
- Don't package node_modules in tarballs, they are not cross-platform
  anymore and npm cache should not be messed with directly. Instead,
  require an internet connection to rebuild the UI, which is not necessary
  in the general use case because prebuilt UI files are shipped in the
  public directory.
- Simplify the fomantic build and make the target phony. We don't need
  anything more for something that is rarely ran.
- Use regular tar again to build tarballs and add variable for excludes
- Disable annoying npm update notifications

Fixes: https://github.com/go-gitea/gitea/pull/14578
Fixes: https://github.com/go-gitea/gitea/pull/15256
Fixes: https://github.com/go-gitea/gitea/pull/15262

Co-authored-by: 6543 <6543@obermui.de>
2021-04-09 01:08:14 -04:00
zeripath
7088bcf61b
Fix Dropzone following #15315 (#15353)
* Fix Dropzone following #15315

#15315 appears to have caused a change in the way Dropzone is imported - and it
now produces a module rather than the constructor.

This PR rather hackily just adds another Dropzone call to the result.

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

* use destructured export

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-04-09 10:32:30 +08:00
6543
147826a577
[API] pull notification subject status: add "merged" (#15344)
Current subject status can be "", "open" and "closed". This add "merged" to it.
2021-04-09 03:36:23 +02:00
silverwind
9a2553920f
Fix button border issue (#15350)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-09 08:52:32 +08:00
KN4CK3R
c03e488e14
Add LFS Migration and Mirror (#14726)
* Implemented LFS client.

* Implemented scanning for pointer files.

* Implemented downloading of lfs files.

* Moved model-dependent code into services.

* Removed models dependency. Added TryReadPointerFromBuffer.

* Migrated code from service to module.

* Centralised storage creation.

* Removed dependency from models.

* Moved ContentStore into modules.

* Share structs between server and client.

* Moved method to services.

* Implemented lfs download on clone.

* Implemented LFS sync on clone and mirror update.

* Added form fields.

* Updated templates.

* Fixed condition.

* Use alternate endpoint.

* Added missing methods.

* Fixed typo and make linter happy.

* Detached pointer parser from gogit dependency.

* Fixed TestGetLFSRange test.

* Added context to support cancellation.

* Use ReadFull to probably read more data.

* Removed duplicated code from models.

* Moved scan implementation into pointer_scanner_nogogit.

* Changed method name.

* Added comments.

* Added more/specific log/error messages.

* Embedded lfs.Pointer into models.LFSMetaObject.

* Moved code from models to module.

* Moved code from models to module.

* Moved code from models to module.

* Reduced pointer usage.

* Embedded type.

* Use promoted fields.

* Fixed unexpected eof.

* Added unit tests.

* Implemented migration of local file paths.

* Show an error on invalid LFS endpoints.

* Hide settings if not used.

* Added LFS info to mirror struct.

* Fixed comment.

* Check LFS endpoint.

* Manage LFS settings from mirror page.

* Fixed selector.

* Adjusted selector.

* Added more tests.

* Added local filesystem migration test.

* Fixed typo.

* Reset settings.

* Added special windows path handling.

* Added unit test for HTTPClient.

* Added unit test for BasicTransferAdapter.

* Moved into util package.

* Test if LFS endpoint is allowed.

* Added support for git://

* Just use a static placeholder as the displayed url may be invalid.

* Reverted to original code.

* Added "Advanced Settings".

* Updated wording.

* Added discovery info link.

* Implemented suggestion.

* Fixed missing format parameter.

* Added Pointer.IsValid().

* Always remove model on error.

* Added suggestions.

* Use channel instead of array.

* Update routers/repo/migrate.go

* fmt

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

Co-authored-by: zeripath <art27@cantab.net>
2021-04-08 18:25:57 -04:00
zeripath
f544414a23
Show diff on rename with diff changes (#15338)
More recent versions of git have increased support for detection of renames meaning
that a rename with diff changes is now supported.

Although ParsePatch supports this - our templates do not and the simplest solution
is simply to show the diff.

Fix #15335

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

Co-authored-by: 6543 <6543@obermui.de>
2021-04-08 15:35:36 -04:00
silverwind
b62bd8e7c0
Disable cssnano's colormin plugin (#15347)
It produces odd rgba values which also seem to cause issues in monaco's
color parser where the scoll shadow went red for some reason.

Regression by: https://github.com/go-gitea/gitea/pull/15333
2021-04-08 19:28:41 +01:00
zeripath
e8693eb328
Prepend AppSubUrl to links for default avatar (#15341)
Fix #15334

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-08 15:25:06 +02:00
Roger Luo
fa06e98553
Add dashboard milestone search and repo milestone search by name (#14866)
Feature for issue #13845:
 - Add milestones search by name on dashboard milestones page.
 - Add milestones search by name on repo issue/milestones page.
2021-04-08 13:53:59 +02:00
silverwind
0d1a5e0ffc
Add frontend testing, require node 12 (#15315)
- Add basic frontend unit testing infrastructure using jest in ESM mode
- Rename 'make test' to 'make test-backend'
- Introduce 'make test-frontend' and 'make test' that runs both
- Bump Node.js requirement to v12. v10 will be EOL in less than a month.
- Convert all build-related JS files to ESM.

I opted to run frontend tests run as part of the compliance pipeline because
they complete fast and are not platform-specific like the golang tests.
2021-04-08 12:41:57 +02:00
silverwind
4eea819b24
Monaco improvements (#15333)
- Create theme at runtime which follows the CSS variables of the site
- Disable a few opinionated Monaco defaults like minimap and word highlights
- Move styles to separate file

Co-authored-by: zeripath <art27@cantab.net>
2021-04-08 17:53:00 +08:00
zeripath
05b7e32829
Fix handling of logout event (#15323)
It appears that there is a slight bug in the handling of the data of logout event -
the javascript should be testing the data field of the data field for the logout
instruction.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-08 02:48:13 +03:00
6543
298d56fe8b
[Frontport] Changelog (v1.13.6, v1.13.7, v1.14.0-rc2) (#15328)
* Changelog v1.13.7 (#15319)

* Update Changelog (#15322)

* update

* next

* RC2

* Update Docs Version
2021-04-07 13:41:02 -04:00
John Olheiser
426ebbfc3b
Fix CanCreateRepo check (#15311)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2021-04-07 09:26:41 +02:00
GiteaBot
75dfc46d7c [skip ci] Updated translations via Crowdin 2021-04-07 00:12:18 +00:00
zeripath
fa3895ce81
Move modules/forms to services/forms (#15305)
Forms are dependent on models and therefore should be in services.

This PR also removes the old auth. aliasing

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-06 20:44:05 +01:00
zeripath
8be2cc4fc7
Reduce memory usage in testgit (#15306)
* reduce memory use in rawtest

* just use hashsum for diffs

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-06 18:44:02 +02:00
zeripath
b101fa83a6
Fix bug in Wrap (#15302)
Whilst doing other work I have noticed that there is an issue with Wrap when passing an
http.Handler - the next should be the next handler in line not empty.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-06 17:40:56 +02:00
KN4CK3R
5f18404045
Close file on invalid range (Addition to #15166) (#15268)
* Close file on invalid range.

* Close on seek error

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

* Moved 'Seek' into server.

* io.ReadSeekCloser is only available in Go 1.16

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-06 21:22:34 +08:00
silverwind
1ba8b95eb4
Update JS dependencies (#15290)
- Update all JS dependencies to latest version, no functional changes.
- Remove unused direct dependencies core-js and terser-webpack-plugin.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-04-06 03:03:07 +02:00
GiteaBot
7bf1e7a18b [skip ci] Updated translations via Crowdin 2021-04-06 00:12:35 +00:00
zeripath
04196b7658
Update to bluemonday-1.0.6 (#15294)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-05 17:38:31 -04:00
Kyle D
e10d028b03
Check if stopwatch element empty (#15278) 2021-04-05 18:45:01 +02:00
6543
16dea6cebd
[refactor] replace int with httpStatusCodes (#15282)
* replace "200" (int) with "http.StatusOK" (const)

* ctx.Error & ctx.HTML

* ctx.JSON Part1

* ctx.JSON Part2

* ctx.JSON Part3
2021-04-05 11:30:52 -04:00
Ikko Ashimine
e9fba18a26
Fix typo in app.example.ini (#15287)
seperated -> separated

Co-authored-by: zeripath <art27@cantab.net>
2021-04-05 17:49:14 +08:00
Lunny Xiao
fe3dcedd02
Fix xorm log stack level (#15285) 2021-04-05 08:41:22 +01:00
zeripath
48ef04ee56
Drop the event source if we are unauthorized (#15275)
A previous commit that sent unauthorized if the user is unauthorized
simply leads to the repeated reopening of the eventsource. #

This PR changes the event returned to tell the client to close the
eventsource and thus prevents the repeated reopening.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-04 22:37:50 +01:00
GiteaBot
f2715b8e29 [skip ci] Updated translations via Crowdin 2021-04-04 00:12:19 +00:00
zeripath
0bb8bd8190
Add size to Save function (#15264)
Fix #15253

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-03 18:19:59 +02:00
KN4CK3R
3cc7d27b6f
Close file on invalid range (#15166)
* Close file on invalid range.

* Close on seek error

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-03 14:44:12 +02:00
silverwind
d0c9b3e208
Branch page and misc css improvements (#15208)
- Improve branches page, increase icon size, use octicons, use css vars
- Style placeholder color via css var
- Slightly increase contrast of input fields and active/hover states
- Add styling for select boxes in arc-green
2021-04-03 10:37:32 +02:00
techknowlogick
70d84f9b73
update golang libraries (#15258) 2021-04-03 11:02:27 +08:00
GiteaBot
42e62facf7 [skip ci] Updated translations via Crowdin 2021-04-03 00:12:19 +00:00
6543
80d6c6d7de
[refactor] mailer service (#15072)
* Unexport SendUserMail

* Instead of "[]*models.User" or "[]string" lists infent "[]*MailRecipient" for mailer

* adopt

* code format

* TODOs for "i18n"

* clean

* no fallback for lang -> just use english

* lint

* exec testComposeIssueCommentMessage per lang and use only emails

* rm MailRecipient

* Dont reload from users from db if you alredy have in ram

* nits

* minimize diff

Signed-off-by: 6543 <6543@obermui.de>

* localize subjects

* linter ...

* Tr extend

* start tmpl edit ...

* Apply suggestions from code review

* use translation.Locale

* improve mailIssueCommentBatch

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

* add i18n to datas

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

* a comment

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-04-02 11:25:13 +01:00
zeripath
cc2d540092
Fix release expansion issue (#15251)
* Fix release expansion issue

Fix #14578

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

* fix cache statement too

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

* and update the npmrcs

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

* as per @silverwind

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
2021-04-02 14:49:53 +08:00
GiteaBot
54eae008d9 [skip ci] Updated translations via Crowdin 2021-04-02 00:16:50 +00:00
Lunny Xiao
42efa14f51
Introduce esbuild on webpack (#14578)
* Vendor node mods as cache; fix esbuild/fomantic offline build

* Fix --exclude; use bsdtar for consistent globbing

* Fall back to GNU tar; forward-compatible for APT 2.0

* Avoid having extd. attrs with bsdtar

* Dependency and misc. optimizations

* Remove extra code after esbuild-loader update

Co-authored-by: Mike L <cl.jeremy@qq.com>
2021-04-02 02:11:04 +02:00
KN4CK3R
bc1f2117f1
Fix graph pagination (#15225)
* Fixed invalid HTML tag.

* Fixed pagination.

* Update templates/repo/graph/commits.tmpl

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-01 16:01:23 -04:00
zeripath
a351b22dc0
Prevent NPE in CommentMustAsDiff if no hunk header (#15199)
I do not understand how this can happen or why.

There is an apparent possibility for a comment.Patch to be missing a hunk header
- this should not happen and do not understand how. But it appears to happen on
1.13 at least in some case.

This PR will simply add a new section if the cursection is empty
thus preventing the NPE.

Fix #15198

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-04-01 14:29:14 -04:00
zeripath
ff460ca74d
Speed up enry.IsVendor (#15213)
`enry.IsVendor` is kinda slow as it simply iterates across all regexps.
This PR ajdusts the regexps to combine them to make this process a
little quicker.

Related #15143

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-04-01 19:41:09 +02:00
a1012112796
43fb4921e3
response simple text message for not html request when 404 (#15229)
* response simple text message for not html request when response 404

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-04-01 17:11:42 +02:00
mayswind
9b316a327e
Fix timezone bug when clicking heatmap (#15141) 2021-04-01 12:52:17 +02:00
a1012112796
007fb00c0e
response 404 for diff/patch of a commit that not exist (#15221)
* response 404 for diff/patch of a commit that not exist

fix #15217

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update routers/repo/commit.go

Co-authored-by: silverwind <me@silverwind.io>

* use ctx.NotFound()

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
2021-04-01 08:17:14 +03:00
GiteaBot
f07b137e04 [skip ci] Updated translations via Crowdin 2021-04-01 00:16:36 +00:00
silverwind
aee5ef0051
Diff box fixes (#15214)
- Fix misaligned "Show Outdated" buttons via flexbox
- Add hover effect to "Show Outdated" buttons
- Remove overreaching margin from selector .diff-file-box and handle
  cases individually.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-31 18:19:53 -04:00
Kyle D
8d9f191195
Update docs for bad ini syntax in noreply (#15226) 2021-03-31 17:13:46 -04:00
zeripath
113c1557ff
Fix regression from #14623 - use debug SVC handler only on interactive sessions (#15210)
Unfortunately #14623 changed from the deprecated IsInteractiveSession to
IsWindowsService without recognising that they are the complement of
each other.

This means that Windows SVC control is not working correctly. This PR
adds some Tracing statements but also fixes the bug.

Fix #15159

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-31 22:48:48 +03:00
David Crocker
79ac7468dc
Fix documentation for the fallback mail subject (#15223)
The documentation for the [fallback mail subject](d989247bb0/services/mailer/mail_issue.go (L14-L16)) was missing `{{}}` around `.Issue.Index`.
2021-03-31 11:36:21 -04:00
GiteaBot
9d57373144 [skip ci] Updated translations via Crowdin 2021-03-31 00:12:40 +00:00
silverwind
1b762fc5d8
Remove vendored copy of fomantic-dropdown (#15193)
jQuery 3.6.0 seems to have broke the dropdown focus handling (focus
would get stuck on the dropdown) in this module which we have vendored
on top of fomantic for accessibility improvements.

Either downgrading jQuery to 3.5.1 or removing the vendor copy seems to
resolve the issue and I opted for removing the copy because I think such
changes should be done upstream and the removal also lightens the JS by
155kB before minify/gzip.

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-30 19:27:06 +02:00
a1012112796
f5b6dc9759
add 'fonts' into 'KnownPublicEntries' (#15188)
fix #15184

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-30 15:47:34 +03:00
silverwind
d099f0858f
Remove file-loader dependency (#15196)
- Upgrade webpack to 5.28 to enable publicPath option
- Use asset modules in place of deprecated file-loader

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-30 19:17:24 +08:00
silverwind
cce006b857
Fix webhook delivery and issue checklist for arc-green (#15195)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-30 09:02:41 +03:00
GiteaBot
0e7a2fb9e2 [skip ci] Updated translations via Crowdin 2021-03-30 00:12:39 +00:00
KN4CK3R
0c6137617f
Add Tabular Diff for CSV files (#14661)
Implements request #14320 The rendering of CSV files does match the diff style.

* Moved CSV logic into base package.

* Added method to create a tabular diff.

* Added CSV compare context.

* Added CSV diff template.

* Use new table style in CSV markup.

* Added file size limit for CSV rendering.

* Display CSV parser errors in diff.

* Lazy read single file.

* Lazy read rows for full diff.

* Added unit tests for various CSV changes.
2021-03-29 22:44:28 +02:00
silverwind
d3b8127ad3
Fix margin between avatars on org pages (#15194)
Fixes: https://github.com/go-gitea/gitea/issues/15191
2021-03-29 20:57:27 +01:00
zeripath
c1ca4a8313
Improve /api/v1/repos/issues/search by just getting repo ids (#15179)
/api/v1/repos/issues/search is a highly inefficient search which is unfortunately
the basis for our dependency searching algorithm. In particular it currently loads
all of the repositories and their owners and their primary coding language all of
which is immediately thrown away.

This PR makes one simple change - just get the IDs.

Related #14560
Related #12827

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-29 18:12:21 +01:00
a1012112796
2b9e0b4d1b
should run RetrieveRepoMetas() for empty pr (#15187)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-03-29 07:58:48 +01:00
GiteaBot
3416e2a825 [skip ci] Updated translations via Crowdin 2021-03-29 00:12:37 +00:00
a1012112796
3273fb9af1
use level config in main section when subsection not set level (#15176)
in previouse if a log subsetcion not set level
it will use ``info`` as default value.

this pr will make default value (``[log] -> LEVEL``) useable.

example config:
```INI
[log]
MODE = console
LEVEL = Trace

[log.console]
LEVEL =
STDERR = false
```

previous result:
```JSON
// console:
{
  "level": "info",
  ...................
}
```

after change:

```JSON
// console:
{
  "level": "track",
  ...................
}
```

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-28 20:08:19 +01:00
zeripath
82d1a7fb17
Update repository size on cron gc task (#15177)
git gc cron could change the size of the repository therefore we should update the
size of the repo stored in our database.

Also significantly improve the efficiency of counting lfs associated with the
repository
2021-03-28 05:56:28 +02:00
techknowlogick
5ad65c8f5d
update docs to reference 1.13.6 (#15182) 2021-03-28 11:09:01 +08:00
sotho
e7609929c1
Expose resolver via API (#15167)
* Expose resolver via API
2021-03-28 00:37:51 +01:00
6543
290cf75f93
[refactor] Unify the export of user data via API (#15144)
* [refactor] unify how user data is exported via API

* test time via unix timestamp
2021-03-27 17:45:26 +01:00
parnic
f4d27498bd
Add DefaultMergeStyle option to repository (#14789)
Fixes #12293
2021-03-27 15:55:40 +01:00
Jimmy Praet
6b836ac5f7
fix org navbar (#15173) 2021-03-26 22:15:13 +01:00
6543
dc56fb7c84
fix regression of 15139 (#15164) 2021-03-26 03:46:41 +01:00
zeripath
b68eb54f95
Clusterfuzz found another way (#15160)
Clusterfuzz found another way so I found another way to stop it

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-26 01:21:00 +02:00
GiteaBot
0048d7c7cf [skip ci] Updated translations via Crowdin 2021-03-25 00:12:38 +00:00
sotho
f2844b7583
Fix wrong user returned in API (#15139)
The API call: GET /repos/{owner}/{repo}/pulls/{index}/reviews/{id}/comments
returns always the reviewer, but should return the poster.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-03-24 21:26:15 +01:00
zeripath
39ef6f83d5
Create Proper Migration Tests (#15116)
* Create Proper Migration tests

Unfortunately our testing regime has so far meant that migrations do not
get proper testing.

This PR begins the process of creating migration tests for this.

* Add test for v176

* fix mssql drop db

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-24 19:27:22 +01:00
zeripath
750ac52db2
Fix Migration 176 yet again (#15131)
* Fix Migration 176 yet again

Whilst creating a test for v176 in the migrations_test PR
it has become clear that this was still wrong.

This is now fixed. Genuinely.

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

* and fix repo transfer

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-23 23:10:19 +00:00
Lunny Xiao
f4e677edb1
Fix bug on avatar middleware (#15124) 2021-03-23 18:20:24 +01:00
zeripath
687e2dfa55
Fix consistency check (#15120)
In my last fix I missed adding the label_ prefix to the
consistency check count.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-23 11:23:33 +01:00
GiteaBot
4c4a86bf8c [skip ci] Updated translations via Crowdin 2021-03-23 00:12:49 +00:00
silverwind
405969c541
Remove raw-loader dependency (#15112)
Webpack now includes this functionality, allowing us to drop this
now-deprecated dependency.

Ref: https://webpack.js.org/guides/asset-modules/
Ref: https://webpack.js.org/loaders/raw-loader/
2021-03-22 23:10:09 +01:00
zeripath
dfb3e50dce
Fix the v176 migration (#15110)
There is a serious issue with the v176 migration where there is a mistaken missing
label_id selection.

*introduced by #14912*

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-22 19:26:38 +01:00
6543
5f038cd7fe
[Vendor] update gitea-sdk v0.14.0 (#15103)
* upgraded code.gitea.io/sdk/gitea v0.13.2 => v0.14.0

* rm workaround
2021-03-22 18:03:18 +01:00
Lunny Xiao
8567cba0d9
Implement delete release attachments and update release attachments' name (#14130)
* Implement delete release attachment

* Add attachments on release edit page

* Fix bug

* Finish del release attachments

* Fix frontend lint

* Fix tests

* Support edit release attachments

* Added tests

* Remove the unnecessary parameter isCreate from UpdateReleaseOrCreatReleaseFromTag

* Rename UpdateReleaseOrCreatReleaseFromTag to UpdateRelease

* Fix middle align
2021-03-23 00:09:51 +08:00
silverwind
1a03fa7a4f
Update JS dependencies (#15033)
* Update JS dependencies

- Update all JS dependencies
- For octicons, rename trashcan to trash
- For svgo, migrate to v2 api, output seems to have slightly changed but icons look the same
- For stylelint, update config, fix custom property duplicates
- For monaco, drop legacy Edge support
- For eslint, enable new rules, fix new issues
- For less-loader, remove deprecated import syntax

* update svgo usage in generate-images and rebuild logo.svg with it
2021-03-22 05:04:19 +01:00
zeripath
a587a28434
Fix another clusterfuzz identified issue (#15096)
* Fix another clusterfuzz identified issue

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-22 02:45:01 +01:00
GiteaBot
e6377d5eb4 [skip ci] Updated translations via Crowdin 2021-03-22 00:12:36 +00:00
KN4CK3R
32833a9cfb
Fixed previous fix. (#15098) 2021-03-21 19:51:54 +00:00
silverwind
4fd6e82198
Fix lock modal content rendering outside modal (#15095)
* Fix lock modal content rendering outside modal

The .content was not a child to .modal so was rendering outside. This is
a recent regression but I'm not certain when it was introduced.

* remove extraneous closing div
2021-03-21 19:58:28 +01:00
6543
98c8513db2
Changelog v1.13.5 (#15084) (#15093)
* Changelog v1.13.5 (#15084)

* fix unrel. nit
2021-03-21 13:58:19 -04:00
zeripath
46782d53bc
Place wrapper around comment as diff to catch panics (#15085)
There are a few recurrent issues with comment as diff reporting panics that are resistant to fixing due to the fact that the panic occurs in the template render and is swallowed by the template renderer.

This PR just adds some logging to force the panic to properly logged and re-propagates back up to the template renderer so we can actually detect what the issue is.

Signed-off-by: Andrew Thornton art27@cantab.net
2021-03-21 16:59:58 +00:00
6543
24f7bd5899
Use i18n.Reset to reload locales (#15073) 2021-03-21 16:11:36 +01:00
a1012112796
17731e05ff
fix double 'push tag' action feed (#15078)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-03-21 11:11:22 +01:00
Lauris BH
2f0eb9fd5d
Handle unauthorized user events gracefully (#15071) 2021-03-20 21:39:43 +01:00
6543
78e8f62706
[Refactor] remove possible resource leak (#15067)
* move "copy uploaded lfs files 2 repo" to own function for "defer file.Close()"

* rm type overload

* Update modules/repofiles/upload.go

Co-authored-by: zeripath <art27@cantab.net>
2021-03-21 00:30:29 +08:00
zeripath
9ed9ed9ae0
Update to goldmark 1.3.3 (#15059)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-20 12:23:55 +01:00
silverwind
d05539eb3e
Fix markdown rendering in milestone content (#15056)
- Add missing markdown class for rendered markdown.
- Increase font size of milestone name in list.

Fixes: https://github.com/go-gitea/gitea/issues/15046
2021-03-20 10:36:52 +01:00
GiteaBot
bb5eb849f2 [skip ci] Updated translations via Crowdin 2021-03-20 00:12:40 +00:00
Lasse Brandt Thomsen
0fe32826ed
Allow read/write to user root and only read to group git on documentation (#15041)
Co-authored-by: Lasse Brandt Thomsen <lasse@bitmand.dk>
2021-03-20 00:45:04 +01:00
Lunny Xiao
cf549500e0
Fix bug when upload on web (#15042)
* Fix bug when upload on web

* move into own function

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-03-19 23:49:29 +01:00
6543
fcf2c97d39
Changelog for 1.14.0-RC1 (#14935)
* Changelog for 1.14.0-RC1

* api

* Apply suggestions from code review

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* update

* Apply suggestions from code review

Co-authored-by: techknowlogick <matti@mdranta.net>

* Update CHANGELOG.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* update

* Update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* Apply suggestions from code review

* Move things to SECURITY that are SECURITY

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

* Update CHANGELOG.md

Co-authored-by: Lauris BH <lauris@nix.lv>

* Update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: Norwin <noerw@users.noreply.github.com>

* Update CHANGELOG.md

Co-authored-by: Kyle D. <kdumontnu@gmail.com>

* sort

* Update CHANGELOG.md

Co-authored-by: Kyle D. <kdumontnu@gmail.com>

* :gitea: 🚀

* Update date

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: Kyle D. <kdumontnu@gmail.com>
2021-03-19 22:42:57 +02:00
6543
a3a65137ba
Delete Labels & IssueLabels on Repo Delete too (#15039)
* Doctor: find IssueLabels without existing label

* on Repo Delete: delete labels & issue_labels too

* performance nits

* Add Migration: Delete orphaned IssueLabels

* Migration v174: use Sync2

* USE sess !!!

* better func name

* code format & comment

* RAW SQL

* Update models/migrations/v176.go

* next try?
2021-03-19 21:01:24 +02:00
zeripath
dace0ce1b1
Prevent addition of labels from outside the repository or organisation in issues (#14912)
* Never add labels not from this repository or organisation and remove org labels on transfer

Prevent the addition of labels from outside of the repository or
organisation and remove organisation labels on transfer.

Related #14908

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

* switch to use sql

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

* remove AS

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

* subquery alias

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

* Give me some AS?

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

* double AS

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

* try try again

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

* once more around the merry go round

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

* fix api problem

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

* Add outside label consistency check into doctor

This PR adds another consistency check into doctor in order to detect
labels that have been added from outside of repositories and organisations

Fix #14908

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

* fix migration

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

* prep for merge

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-19 21:25:14 +08:00
Mike L
54d7b0f8e7
Fix UI elements getting underline like links (#15038) 2021-03-19 03:21:28 +01:00
GiteaBot
99707791ed [skip ci] Updated translations via Crowdin 2021-03-19 00:13:12 +00:00
Mike L
0e5c6c4498
Fix CJK fonts again and misc. font issues (#14575)
* Push system-ui further down the stack, fix #12966

* Fix Firefox showing U+300x in emoji font and more

* Revert emoji font and fix long-standing Safari bug

* Exclude Safari emoji fix above 1.25x zoom

* Minor correctness/typo fix, affects only legacy platforms

* Emoji consistency for monospace (e.g. EasyMDE)

* Override paradigm; macOS/iOS-specific metric fix

* Move whitespace fix to font-face

* Handle metric calculation errors with Firefox

* One last workaround for aliased fonts in Linux
2021-03-19 00:43:43 +01:00
zeripath
c0c052bdbb
another clusterfuzz spotted issue (#15032)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-18 22:37:11 +01:00
Mike L
0e95a41ccd
Fix hover color for last row of repo file list (#15018) 2021-03-18 18:05:26 +00:00
KN4CK3R
e8ad6c1ff3
Do not convert file path to lowercase (#15023)
* Do not convert file path to lowercase.

* lint

* Check against lowercase hostname.
2021-03-18 13:58:47 +00:00
Norwin
032f4c3969
fix href on label in sidebar (#15022) 2021-03-18 14:47:17 +02:00
zeripath
070c57867d
Fix postgres ID sequences broken by recreate-table (#15015)
* Fix postgres ID sequences broken by recreate-table

Unfortunately there is a subtle problem with recreatetable on postgres which
leads to the sequences not being renamed and not being left at 0.

Fix #14725

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

* let us try information_schema instead

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

* try again

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2021-03-18 02:06:40 -04:00
zeripath
71aca93dec
Remove extraneous logging (#15020)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-18 04:25:52 +01:00
Roger Luo
119d2cb6e4
Create new issue from code (#14863)
* Feat: add reference in new issue with permalink menu for code view.

* Fix: recover index.js file.

* Add comments and redo ci.

* Fix code convention

* Fix code.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2021-03-17 22:02:38 -04:00
GiteaBot
03e99f847c [skip ci] Updated translations via Crowdin 2021-03-18 00:12:43 +00:00
Norwin
598dd21cd4
org dashboard: move teamselector left (#14954)
Co-authored-by: zeripath <art27@cantab.net>
2021-03-17 18:45:16 -04:00
a1012112796
27b8eff96b
support gitmailmap in GetCodeActivityStats() (#15009)
ref:
- https://git-scm.com/docs/gitmailmap
- https://git-scm.com/docs/git-log#Documentation/git-log.txt-emaNem

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: zeripath <art27@cantab.net>
2021-03-17 17:00:26 -04:00
Norwin
5d57f4bcb8
sort release attachments by name (#15008)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-17 11:25:49 +02:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
51ea8dd444
chore: bump minio to RELEASE.2021-03-12T00-00-47Z (#15006)
* chore: bump minio to RELEASE.2021-03-12T00-00-47Z

-    image: minio/minio:RELEASE.2021-01-16T02-19-44Z
+    image: minio/minio:RELEASE.2021-03-12T00-00-47Z

Signed-off-by: wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf <a_mirre@utb.cz>
2021-03-17 08:40:52 +00:00
Kyle D
df891dc59f
Validate email in oauth registration form (#15014) 2021-03-17 04:54:02 +01:00
KN4CK3R
7019076f7f
Fixed wrong migrate url error description. (#15010) 2021-03-17 03:34:09 +01:00
GiteaBot
5bb544e3ae [skip ci] Updated translations via Crowdin 2021-03-17 00:12:36 +00:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
d2dc182dcd
fix: {show,link to} proper PR on kanban board ref (#15004)
the issue was that PR references in kanban boards were being generated
using `.ID` instead of `.Index`, which led to constructing incorrect
links to possibly non-existent {PR,issue}s and following that to showing
nonsensical values in the boards.

kudos also go to @zeripath for pointing at the file to fix.

Signed-off-by: wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf <a_mirre@utb.cz>
Co-authored-by: zeripath <art27@cantab.net>
2021-03-16 15:42:25 +00:00
Patrick Schratz
ab70b2f4e4
add pat-s to MAINTAINERS list (#15007) 2021-03-16 14:37:04 +00:00
zeripath
bf53cf0e04
Ensure that new pull request button works on forked forks owned by owner of the root (#14932)
Prevent 404 on new pull request button on forked fork owned by the owner
of the root repository. Also ensure that the names make sense.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-16 02:36:34 +01:00
Norwin
f4629fc472
Move repo.CloseIssuesViaCommitInAnyBranch to issue settings (#14965) 2021-03-16 02:00:52 +01:00
GiteaBot
ad42adac93 [skip ci] Updated translations via Crowdin 2021-03-16 00:12:50 +00:00
zeripath
ed31ddc29a
Fix several render issues (#14986)
* Fix an issue with panics related to attributes
* Wrap goldmark render in a recovery function
* Reduce memory use in render emoji
* Use a pipe for rendering goldmark - still needs more work and a limiter

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-16 00:20:05 +01:00
Lauris BH
044cd4d016
Add reverse proxy configuration support for remote IP address (#14959)
* Add reverse proxy configuration support for remote IP address validation

* Trust all IP addresses in containerized environments by default

* Use single option to specify networks and proxy IP addresses. By default trust all loopback IPs

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-16 00:27:28 +02:00
zeripath
6e423d5573
Ensure validation occurs on clone addresses too (#14994)
* Ensure validation occurs on clone addresses too

Fix #14984

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

* fix lint

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

* fix test

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

* Fix api tests

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-15 17:52:11 -04:00
tuxmaster5000
f268b4896b
Update comparison docs for gitlab (#14999) 2021-03-15 11:19:00 -04:00
Lauris BH
1ae9b2a89b
Update go-enry to v2.6.1 (#14997)
Co-authored-by: Gitea <gitea@gitea.io>
2021-03-15 04:20:02 +01:00
Mike L
5f8478ab0a
Fix repo page language stat span color (#14993)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-14 22:27:58 +02:00
Bo-Yi Wu
167b0f46ef
chore(models): rewrite code format. (#14754)
* chore: rewrite format.

* chore: update format

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* chore: update format

Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>

* chore: Adjacent parameters with the same type should be grouped together

* chore: update format.
2021-03-14 19:52:12 +01:00
zeripath
164e35ead3
Make sure sibling images get a link too (#14979)
* Make sure sibling images get a link too

Due a problem with the ast.Walker in the our transformer in goldmark
an image with a sibling image will not be transformed to gain a parent
link. This PR fixes this.

Fix #12925

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-14 16:36:51 +00:00
zeripath
6463483ec5
Do not show full lfs file on error in git_test.go:rawTest() (#14980)
If there is a problem uploading to LFS it is possible for the raw
endpoint to return a very large file when a pointer file is expected
This will then cause the drone logs to fill up unnecessarily with
the contents of the very large file.

If the file returned from raw is of the incorrect size we should
therefore not test it see if it contains the pointer file
and just declare that it is incorrect.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-14 15:53:59 +00:00
Mike L
9566c9f0c7
Re-enable listing of forks when logged out (#14992)
* Re-enable listing of forks when logged out

* Further improvements on repo button logic
2021-03-14 14:48:28 +00:00
GiteaBot
f5aaa74b90 [skip ci] Updated licenses and gitignores 2021-03-14 00:12:26 +00:00
Norwin
658d1bfac8
API: fix set milestone on PR creation (#14981)
* API: fix set milestone on PR creation

pr creation via API failed with 404, because we searched
for milestoneID 0, due to uninitialized var usage D:

* add tests

* fix expected status codes

* fix tests

Co-authored-by: 6543 <6543@obermui.de>
2021-03-13 19:06:52 +01:00
Mike L
e256a62257
Fix spacing of issue/pulls list review status icons (#14985) 2021-03-13 15:37:09 +02:00
GiteaBot
cc6470425c [skip ci] Updated translations via Crowdin 2021-03-13 00:12:41 +00:00
Norwin
19bcd29c7e
fix release mail html template (#14975)
was missing an </a>
2021-03-12 21:47:52 +00:00
Norwin
3c7582061f
check if original author is set (#14971)
Co-authored-by: zeripath <art27@cantab.net>
2021-03-12 21:01:33 +00:00
zeripath
ff1bccf3dd
Fix Anchor jumping with escaped query components (#14969)
Fix #14968

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-12 18:59:13 +00:00
zeripath
42b9b46ad2
Never add labels not from this repository or organisation and remove org labels on transfer (#14928)
* Never add labels not from this repository or organisation and remove org labels on transfer

Prevent the addition of labels from outside of the repository or
organisation and remove organisation labels on transfer.

Related #14908

* switch to use sql

* subquery alias

* once more around the merry go round

* fix api problem
2021-03-12 18:45:49 +01:00
zeripath
ccfb205ad1
Fix excluding more than two labels on issues list (#14962)
* Fix excluding more than two labels on issues list

Fix #14840

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

* refactor DRY

* fix multiple-label filter on milestone issuelist

* Apply suggestions from code review

Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>

* Update web_src/js/index.js

Co-authored-by: Norwin Roosen <git@nroo.de>
Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>
2021-03-13 00:07:23 +08:00
Norwin
855a4f476e
don't show project cog in issue sidebar if no permission (#14953) 2021-03-12 16:14:02 +01:00
zeripath
91ee3be588
Prevent incorrect HTML escaping in swagger.json (#14957)
* Prevent incorrect HTML escaping in swagger.json

Fix #14706

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

* oops add it to the helper

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

* try again

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-11 23:43:04 -05:00
Norwin
df76d9f7ad
Show correct issues for team dashboard (#14952)
* fix no items under /org/$org/{issues,pulls}?type=mentioned

it was filtering by org id, but org-mentions are not persisted like that
to the DB, we need to filter by UID.
This means, selecting different teams will only have an effect on the
selected repos, otherwise results will be the same, which may be
suboptimal.

fixes #14941

* don't spam a warning for a perfectly fine request
2021-03-12 04:06:33 +01:00
a1012112796
a44b2d01d2
CI: pre install git last verson and git lfs in test (#14681)
link:
https://hub.docker.com/r/gitea/test_env
Source:
https://gitea.com/gitea/test_env/src/branch/master/Dockerfile

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-03-12 03:04:43 +01:00
GiteaBot
21be2aee1a [skip ci] Updated translations via Crowdin 2021-03-12 00:12:35 +00:00
Kyle D
e475ccfe09
Add kdumontnu to MAINTAINERS (#14964) 2021-03-11 23:25:07 +01:00
zeripath
5705f72fd6
Prevent panic when editing forked repos by API (#14960)
When editing forked repos using the API the BaseRepository needs to loaded
in order to check its visibility otherwise there will be NPE panic.

Fix #14956

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-11 19:09:52 +01:00
zeripath
c8e5c79cfd
Add ui.explore settings to control view of explore pages (2) (#14094)
This is an alternative PR to #13687.

Add `[ui.explore]` settings to allow restricting the
explore pages to logged in users only and to disable the users explore page.

The two proposed settings are:

- `REQUIRE_SIGNIN_VIEW`: Only allows access to the explore pages if the
user is signed in. Also restricts
  - `/api/v1/user/search`
  - `/api/v1/users/{username}`
  - `/api/v1/users/{username}/repos`
  - but does not restrict `/api/v1/users/{username}/heatmap`
- `DISABLE_USERS_PAGE`: Disables the /explore/users page

Fix #2908

Close #13687 

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-03-11 13:40:54 +00:00
KN4CK3R
bc423a1e84
Use correct default value (#14949)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-11 00:09:30 -05:00
techknowlogick
b175791665
build darwin on arm64 platforms (#14951)
fix #14945
2021-03-10 23:59:57 -05:00
GiteaBot
a13c801b21 [skip ci] Updated translations via Crowdin 2021-03-11 00:12:39 +00:00
GiteaBot
b7208c727d [skip ci] Updated translations via Crowdin 2021-03-10 00:12:39 +00:00
Ikko Ashimine
5b94a07ab5
Fix typo in .golangci.yml (#14933)
occured -> occurred
2021-03-09 03:38:18 -05:00
GiteaBot
8ee4d977a1 [skip ci] Updated translations via Crowdin 2021-03-09 00:12:38 +00:00
6543
177da717a7
[API] get pull, return head branch sha, even if deleted (#14931)
* API: return head branch sha, even if deleted

* relax if ref not resolvable
2021-03-08 21:48:31 +01:00
6543
14d8cb7819
Move Workaround for #12675 into it's own function (#14922)
* Move Workatround for #12675 into it's own function

* use more reliable solution (as tea do)
2021-03-08 20:00:19 +01:00
Norwin
f4ce10c6a3
Minor UI fixes (#14926)
* disable fork button when not signed in

* fix commit body styling on PR page

* fixup! fix commit body styling on PR page
2021-03-08 18:55:37 +01:00
fnetX (aka fralix)
f061277c86
Add "captcha" to list of reserved usernames (#14929)
Signed-off-by: Otto Richter <git@fralix.ovh>
2021-03-08 17:49:29 +01:00
zeripath
61711143b9
Fix alignment of People and Teams right arrow on org homepage (#14924)
Fix #14854

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-08 15:52:58 +01:00
zeripath
eb576269d4
Re-enable import local paths after reversion from #13610 (#14925)
PR #13610 unfortunately disabled importing repositories from local paths.
This PR restores this functionality.

Fix #14700

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-08 13:10:17 +00:00
zeripath
c03f530212
Make internal SSH server host key path configurable (#14918)
* Make SSH server host key path configurable

* make it possible to have multiple keys

* Make gitea.rsa the default key

* Add some more logging

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-08 03:43:59 +01:00
zeripath
78b7529cd4
Fix overdue marking of closed issues and milestones (#14923)
Closed milestones and issues should only be marked overdue if they were
closed after their deadline.

Fix: #14536

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-08 02:55:57 +01:00
GiteaBot
09fe0abb32 [skip ci] Updated translations via Crowdin 2021-03-08 00:12:25 +00:00
6543
ae62bb7b6c
Changelog v1.13.4 (#14917) (#14920) 2021-03-08 00:07:02 +01:00
Norwin
5eafd117a6
docs: swagger show models by default (#14880) 2021-03-07 22:19:14 +01:00
KN4CK3R
40aca73347
Fix migration context data (#14910)
* Unified context data.

* Changed method name.
2021-03-07 20:21:09 +01:00
zeripath
9b261f52f0
Add SameSite setting for cookies (#14900)
Add SameSite setting for cookies and rationalise the cookie setting code. Switches SameSite to Lax by default. 

There is a possible future extension of differentiating which cookies could be set at Strict by default but that is for a future PR.

Fix #5583

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-07 08:12:43 +00:00
zeripath
beed5476e2
Prevent panic when empty MilestoneID in repo/issue/list (#14911)
This PR adds a simple check to only test the MilestoneID if it is not empty.

Fix #14906

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-07 10:25:54 +08:00
GiteaBot
4ba8572361 [skip ci] Updated licenses and gitignores 2021-03-07 00:12:31 +00:00
zeripath
a68db9076a
Fix race in LFS ContentStore.Put(...) (#14895)
Continuing on from #14888

The previous implementation has race whereby an incomplete upload or
hash mismatch upload can end up in the ContentStore. This PR moves the
validation into the reader so that if there is a hash error or size
mismatch the reader will return with an error instead of an io.EOF
causing the storage to abort the storage.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-06 20:21:56 +00:00
Lunny Xiao
5ccf8b6430
Fix issue search with db indexer because of mysql 5.7 sqlmode (#14907)
* Fix sqlmode bug

* distinct is necessary
2021-03-06 23:11:12 +08:00
Lunny Xiao
f4efa10f77
Hide resync all ssh principals when using internal ssh server (#14904)
Co-authored-by: 6543 <6543@obermui.de>
2021-03-06 15:32:08 +08:00
zeripath
20f13bfdfc
Fix a couple of issues with a feeds (#14897)
@CirnoT spotted a couple of issues with feeds on discord.

This PR fixes both of these.
2021-03-06 05:09:49 +01:00
GiteaBot
fd4b309c6f [skip ci] Updated translations via Crowdin 2021-03-06 00:12:35 +00:00
John Olheiser
f1da46622e
Signed-off-by: jolheiser <john.olheiser@gmail.com> (#14898) 2021-03-05 21:00:15 +00:00
Lunny Xiao
9db590f2ee
Fix bug when combine label comments (#14894)
* Fix bug when combine label comments

* Added some code comments

* More comments
2021-03-05 16:17:32 +01:00
zeripath
144cfe5720
Fix race in local storage (#14888)
LocalStorage should only put completed files in position

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-05 14:19:17 +01:00
Lunny Xiao
7525450232
When transfering repository and database transaction failed, rollback the renames (#14864)
Fix #14821

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-03-05 03:28:52 +01:00
Norwin
0a8a3ab0f5
Show private heatmap on profile to self & admins (#14881)
followup to #14080
2021-03-04 23:59:13 +01:00
6543
11229ca539
IsUserAllowedToUpdate ignore igonre if user is nil (#14885) 2021-03-04 19:27:54 +01:00
6543
8ac1367718
[Docs] Fix how lfs data path is set (#14855)
* fix docs: lfs data path

* DEPRECATED note

* 已废弃

* better english sentence

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-04 18:01:44 +01:00
6543
1d18b76e0e
Add changelog for v1.13.3 (#14877) (#14883)
* Add changelog for v1.13.3 (#14877)

Add changelog for v1.13.3

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <matti@mdranta.net>

* Update Docs

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
2021-03-04 10:00:23 -05:00
a1012112796
a5279b74b6
Make manual merge autodetection optional and add manual merge as merge method (#12543)
* Make auto check manual merge as a chooseable mod and add manual merge way on ui

as title, Before this pr, we use same way with GH to check manually merge.
It good, but in some special cases, misjudgments can occur. and it's hard
to fix this bug. So I add option to allow repo manager block "auto check manual merge"
function, Then it will have same style like gitlab(allow empty pr). and to compensate for
not being able to detect THE PR merge automatically, I added a manual approach.

Signed-off-by: a1012112796 <1012112796@qq.com>

* make swager

* api support

* ping ci

* fix TestPullCreate_EmptyChangesWithCommits

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* Apply review suggestions and add test

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* fix build

* test error message

* make fmt

* Fix indentation issues identified by @silverwind

Co-authored-by: silverwind <me@silverwind.io>

* Fix tests and make manually merged disabled error on API the same

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

* a small nit

* fix wrong commit id error

* fix bug

* simple test

* fix test

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-03-03 22:41:23 -05:00
zeripath
523efa433b
Move Bleve and Elastic code indexers to use a common cat-file --batch (#14781)
* Extract out the common cat-file batch calls

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

* Move bleve and elastic indexers to use a common cat-file --batch when indexing

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

* move catfilebatch to batch_reader and rename to batch_reader.go

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-03 21:57:01 -05:00
zeripath
0044e80491
Add CORS config on to /login/oauth/access_token endpoint (#14850)
Fix #7204

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-03-04 03:25:30 +02:00
zeripath
59d1cc49f1
Fix paging of file commit logs (#14831)
Unfortunately `git log revision ... --skip=x -- path` skips the number of commits
not the number of commits relating to the path.

This PR changes the function to have a reader that reads and skips the
necessary number of commits by hand instead.

Fix #8716

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-03-04 02:48:19 +02:00
zeripath
0bdeb2b302
Add missing repo.projects unit into swagger (#14876)
Fix #14875

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-03 23:44:30 +01:00
GiteaBot
b2986ab8b2 [skip ci] Updated translations via Crowdin 2021-03-03 00:12:35 +00:00
Norwin
a050de8db3
Handle urls with trailing slash (#14852) 2021-03-02 17:23:36 +01:00
zeripath
def964e57f
Make searching issues by keyword case insensitive on DB (#14848)
Most DBs apart from SQLite will use a default Collation that is not case insensitive.
This means that SearchIssuesByKeyword becomes case sensitive for db indexing - in
contrast to the bleve and elastic indexers.

This PR simply uses UPPER(...) to do the LIKE - and although it may be more efficient
to change collations this would be a non-trivial task.

Fix #13663

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-02 14:07:01 +01:00
GiteaBot
f878c8231f [skip ci] Updated translations via Crowdin 2021-03-02 00:12:37 +00:00
zeripath
f0e15250b9
Migrate to use jsoniter instead of encoding/json (#14841)
* Migrate to use jsoniter

* fix tests

* update gitea.com/go-chi/binding

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-03-01 22:08:10 +01:00
zeripath
59fd641d1f
When Deleting Repository only explicitly close PRs whose base is not this repository (#14823)
When Deleting Repository only explicitly close PRs whose base is not this repository

Fix #14775

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-03-01 18:39:44 +01:00
Paweł Bogusławski
85e6e07346
Organization removal confirmation using name not password (#14738)
* Organization removal confirmation using name not password

Gitea is asking for user password to confirm organization
removal so this operation cannot be done in systems with
SSO authentication (where no user passwords are used).

This mod changes the way gitea confirms organization
removal - user must enter organization name (not user
password) to confirm operation (similar to repository
removal confirmation).

Author-Change-Id: IB#1107219

* Translation removed

Translation removed from PR - will be restored using Crowdin
after pull got merged.

Fixes: 95ddcdd8bd8097a952894556d42641d5ec269288
Related: https://github.com/go-gitea/gitea/pull/14738
Author-Change-Id: IB#1107219
2021-03-01 16:33:05 +02:00
a1012112796
6cf97df9fd
remove duplicate define of CheckAttribute() (#14837)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-03-01 14:14:17 +02:00
techknowlogick
faf775c552
drone workspace path 2021-02-28 23:57:58 -05:00
techknowlogick
1e95b389c0
drone workspace base 2021-02-28 23:25:09 -05:00
techknowlogick
d801a158c5
use gomod support w/ xgo (#14836) 2021-03-01 11:43:55 +08:00
6543
a4148c0f12
Repository transfer has to be confirmed, if user can not create repo for new owner (#14792)
* make repo as "pending transfer" if on transfer start doer has no right to create repo in new destination

* if new pending transfer ocured, create UI & Mail notifications
2021-03-01 01:47:30 +01:00
GiteaBot
e0900310c4 [skip ci] Updated translations via Crowdin 2021-03-01 00:12:52 +00:00
techknowlogick
47f6a4ec3f
go1.16 (#14783) 2021-02-28 18:08:33 -05:00
zeripath
030646eea4
Set HCaptchaSiteKey on Link Account pages (#14834)
When using HCaptcha on link account pages the site key needs to be passed
in. This PR ensures that HCaptchaSiteKey is set in the data.

Fix #14766

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-28 17:04:15 -05:00
a1012112796
83cf1a894e
Create tag on ui (#13467)
Support create single tag directly

support create tag with message from create release ui

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-02-28 19:57:45 +00:00
Jimmy Praet
3e652860bb
All organization members should be assignable as reviewer (#14262)
For public repos, all organization members should be assignable as reviewer

Co-authored-by: zeripath <art27@cantab.net>
2021-02-28 18:24:00 +00:00
a1012112796
5de76965a1
add preview support for wiki editor when disable simpleMDE (#14757)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-02-28 16:48:29 +00:00
6543
dc081959db
Fix issue/pul sidebar (#14826) 2021-02-28 15:05:55 +01:00
zeripath
cf29cb30d3
Prevent use of double sub-path and incorrect asset path in manifest (#14827)
MakeAbsoluteAssetURL should just url join the static url prefix on to appurl
if it is not an absolute path - this is because StaticURLPrefix is an absolute
prefix not a relative prefix to the app sub url.

Fix #14422

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-28 12:29:22 +00:00
a1012112796
2e8ce1eaed
Remove pt-pt from doc config file (#14830)
Because it not has any content now. It's not necessary to
show this link on the footer.

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-02-28 11:46:21 +01:00
6543
b4b4d765f3
Fix missleading sentence (#14829) 2021-02-28 07:54:12 +00:00
GiteaBot
4e7e3bd4bf [skip ci] Updated licenses and gitignores 2021-02-28 00:43:14 +00:00
zeripath
3d8b5ad5f3
Fix a couple of CommentAsPatch issues. (#14804)
* CutDiffAroundLine makes the incorrect assumption that `---` and `+++` always represent part of the header of a diff.

This PR adds a flag to its parsing to prevent this problem and adds a streaming parsing technique to CutDiffAroundLine using an io.pipe instead of just sending data to an unbounded buffer.

Fix #14711

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

* Handle unquoted comment patch files

When making comment patches unfortunately the patch does not always quote the filename
This makes the diff --git header ambiguous again.

This PR finally adds handling for ambiguity in to parse patch

Fix #14812

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

* Add in testing for no error

There is no way currently for CutDiffAroundLine in this test to cause an
error however, it should still be tested.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-27 19:46:14 +01:00
KN4CK3R
904a26c57c
Add Image Diff options in Pull Request Diff view (#14450)
Implemented GitHub style image diff
2021-02-27 18:25:00 +01:00
GiteaBot
42118c6bc8 [skip ci] Updated translations via Crowdin 2021-02-27 00:19:24 +00:00
zeripath
50208e903a
Disable broken OAuth2 providers at startup (#14802)
Instead of causing a log.Fatal, we should handle broken OAuth2
providers by disabling them.

Fix #8930

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-25 22:20:58 -05:00
GiteaBot
97e5a1d7b3 [skip ci] Updated translations via Crowdin 2021-02-26 00:19:27 +00:00
Mike L
4172b1955f
Fix dashboard UI bugs and more (#14767)
This PR fixes a few UI bugs I spontaneously encountered:

- Fixes emojis in repo titles getting head-cut and tail-cut in dashboard feed due to introduction of 1.25 em emojis at 1 em line-height, by simply using the original 1 3/7 em value of `semantic.css`
- Fixes regression (too long repo names should be capped to 70%) in #13828 due to flex children not respecting properties like `overflow: hidden;`, and removes a block of dead style code
- Follow-up to #14761, removes extraneous code for top navbar and correct right margin for Font Awesome
- Fixes color emphasis inversion in arc-green theme for top right buttons (edit, delete) on commit view boxes
2021-02-25 13:35:43 +01:00
6543
8f4d55452a
use gogs.ico to create a better svg for migration page (#14795) 2021-02-25 14:13:44 +08:00
GiteaBot
7aa48fe6f3 [skip ci] Updated translations via Crowdin 2021-02-25 00:19:26 +00:00
6543
5cc1a49b19
Generate man pages (#13901)
* extend gitignore

* first working draft

* use docs subcomand

* rm config-sheet-sheet-2-man
2021-02-24 16:36:48 -06:00
Kyle D
61f347e349
Add environment-to-ini to docker image (#14762)
* Add environment-to-app.ini routine

* Call environment-to-ini in docker setup scripts

* Automatically convert section vars to lower case to match documentation

* Remove git patch instructions

* Add env variable documentation to Install Docker
2021-02-23 20:21:44 +01:00
techknowlogick
428d0edcb0
Exclude running docker build on cron tasks (#14778) 2021-02-23 04:55:35 +01:00
GiteaBot
6c012b7e49 [skip ci] Updated translations via Crowdin 2021-02-23 00:19:34 +00:00
6543
1d63e17de8
CI: translation update as cron task (#14774) 2021-02-23 07:16:02 +08:00
a1012112796
5d2b7ba639
Add EasyMDE support for release content editor (#14744)
* Add easyMDE(simpleMDE) support for release content editor

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-02-22 21:17:51 +01:00
a1012112796
7bf61a89d3
fix a small nit (#14769) 2021-02-22 19:54:01 +01:00
GiteaBot
ff2a0e8dcd [skip ci] Updated translations via Crowdin 2021-02-22 13:46:10 +00:00
techknowlogick
1f570f2208
build for only available darwin target (#14771) 2021-02-22 08:44:54 -05:00
Lunny Xiao
00fffdf5df
Make release-linux archtectures via envs (#14184) 2021-02-22 09:01:57 +02:00
Lunny Xiao
e79dae29cc
Fix repo-restore bug with poster not replaced (#14759)
* Fix restore bug

* Fix restore bug

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-02-22 11:57:41 +08:00
a1012112796
cd8b2f3273
Fix double alert in oauth2 application edit view (#14764)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-02-22 03:51:45 +01:00
a1012112796
1ecdc55aff
fix link account ui (#14763)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-21 20:14:27 -05:00
Kyle D
a50ca28355
Only for direct descendants of items (#14761) 2021-02-21 16:22:15 -05:00
GiteaBot
73a093d60f [skip ci] Updated translations via Crowdin 2021-02-21 16:52:24 +00:00
Lunny Xiao
bd9361384a
Fix go get (#14758)
* Fix go get

* Fix default branch

Co-authored-by: 6543 <6543@obermui.de>
2021-02-22 00:51:15 +08:00
GiteaBot
b56c19d819 [skip ci] Updated translations via Crowdin 2021-02-21 10:00:43 +00:00
Bagas Sanjaya
1f13229830
Add helper descriptions on new repo page (#14591)
* Add helper descriptions on new repo page

Add helpers for:
  * repo description
  * .gitignore
  * license
  * README
  * default branch
  * signature trust model

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>

* Oops, rename trust_model_helper

To match similar helper.

trust_model_helper_intro -> trust_model_helper

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2021-02-21 17:59:31 +08:00
GiteaBot
d6068c1cf7 [skip ci] Updated licenses and gitignores 2021-02-21 00:19:09 +00:00
GiteaBot
7118347bae [skip ci] Updated translations via Crowdin 2021-02-20 22:10:05 +00:00
gordon--
343c756357
Heatmap days clickable (#13935)
* Heatmap days clickable

* Error handling

* Unselect filter

* better dayclick handler

* made linter happy

* clickable heatmap for profiles

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-20 17:08:58 -05:00
Lunny Xiao
f3e64f677f
Remove unused commit (#14741)
* Remove unused commit

* a small nit

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: a1012112796 <1012112796@qq.com>
2021-02-20 15:02:39 +01:00
GiteaBot
835f301063 [skip ci] Updated translations via Crowdin 2021-02-20 10:19:10 +00:00
6543
190bd0accd
Export LFS & TimeTracking function status (#14753) 2021-02-20 11:17:51 +01:00
GiteaBot
db07aedd32 [skip ci] Updated translations via Crowdin 2021-02-20 04:28:10 +00:00
zeripath
65c940f66c
Prevent endless loop if templates missing (#14752)
Since the chi upgrade if the templates are missing an endless loop will occur if
status/500.tmpl is missing.

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-20 12:26:57 +08:00
Norwin
91424fff3d
stopwatch notif: check if timetracking is enabled (#14750)
fixes #14435
2021-02-20 00:06:56 +01:00
zeripath
aa4f9180e4
Clarify the suffices and prefixes of setting.AppSubURL and setting.AppURL (#12999)
Also removes some unnecessary uses of fmt.Sprintf and adds documentation
strings

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-19 22:36:43 +01:00
a1012112796
39aa11f9c0
fix preview status switch button on wiki editr (#14742)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-02-19 19:58:11 +01:00
Ikko Ashimine
ca9c1f822e
[docs] Fix typo in command-line.en-us.md (#14746)
seperated -> separated

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-19 11:29:22 -05:00
GiteaBot
404f3484ad [skip ci] Updated translations via Crowdin 2021-02-19 15:46:38 +00:00
6543
25fe60d12f
Update golangci-lint v1.35.2 -> v1.37.0 (#14747) 2021-02-19 16:45:23 +01:00
Norwin
d38ae597e1
Add UI to delete tracked times (#14100)
Co-authored-by: 6543 <6543@obermui.de>
2021-02-19 12:52:11 +02:00
GiteaBot
6a696b93b1 [skip ci] Updated translations via Crowdin 2021-02-19 10:06:49 +00:00
zeripath
092299891f
Move the stopwatches to the eventsource stream (#14588)
Move the stopwatches to the eventsource stream

Use the /user/events eventsource to update the stopwatches
instead of polling /api/v1/user/stopwatches if the eventsource
is enabled.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-19 11:05:35 +01:00
Lunny Xiao
430b3b7806
Fix misleading word on delete repositories' archives (#14737) 2021-02-19 01:24:51 -05:00
GiteaBot
cc551dac97 [skip ci] Updated translations via Crowdin 2021-02-19 00:41:31 +00:00
Lunny Xiao
6362b24a59
Fix when a commit not found returned 500 (#14732)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-02-18 19:40:17 -05:00
Jacob Hrbek
8f05a2876b
models/repo: Fix typo in comment (#14731)
* models/repo: Fix typo in comment

* another typo

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-18 10:39:04 -05:00
GiteaBot
9c41ad03b4 [skip ci] Updated translations via Crowdin 2021-02-18 14:48:40 +00:00
Jacob Hrbek
867f4c557d
routers/routes/web: Fix typo in comment (#14729) 2021-02-18 22:47:23 +08:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
c9a04cfdc8
Issue template addition: Are you using Gitea behind CloudFlare? (#14098)
* chore: are you using Gitea behind CloudFlare

since more often than not CF appears to serve stale cache and cause
troubles, I'd argue it might be helpful to ask about it in this here
issue template

* implement suggestion: change question to comment

* as per @techknowlogick's suggestion

* chore: edit comment

* implement @mrsdizzie's suggestion
* as the comment grows, rather span multiple lines
* Gitea --> gitea to match case used in the rest of the template

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-18 12:28:07 +01:00
6543
8d5c795cc4
[API] Add Restricted Field to User (#14630)
* Expose Restricted field for User

* Add Option to Change Restricted on User via adminEditUser API

* Add test who change restricted & test if it changed it ...

* make generate-swagger

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-18 16:25:35 +08:00
techknowlogick
ce0346448f
remove outdated notice in makefile (#14720)
Co-authored-by: 6543 <6543@obermui.de>
2021-02-17 21:48:12 -05:00
Jimmy Praet
4c82485424
#14699 Make branch names in PR description clickable (#14716) 2021-02-18 03:45:49 +01:00
zeripath
7ab6c77b41
Remove NULs byte arrays passed to PostProcess (#14587)
PostProcess is supposed to be parsing and handling HTML
fragments, but on fuzzing it appears that there is a weird
issue with NUL elements that could cause a memory address
error in downstream libraries.

The simplest solution is to strip out the weird NULs - they
should not be there in any case and would be stripped out
anyway.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-18 02:32:14 +01:00
Lunny Xiao
ec06eb112c
Fix github download on migration (#14703)
* Fix github download on migration

* Use Context for Client

Co-authored-by: zeripath <art27@cantab.net>
2021-02-18 01:36:49 +01:00
zeripath
ae7e6cd474
Reduce calls to git cat-file -s (#14682)
* Reduce calls to git cat-file -s

There are multiple places where there are repeated calls to git cat-file
-s due to the blobs not being created with their size.

Through judicious use of git ls-tree -l and slight adjustments to the
indexer code we can avoid a lot of these calls.

* simplify by always expecting the long format

* Also always set the sized field and tell the indexer the update is sized
2021-02-17 22:32:25 +01:00
zeripath
7ba158183a
Use cat-file --batch in GetLanguageStats (#14685)
* Use cat-file --batch in GetLanguageStats

This PR moves to using a single cat-file --batch in GetLanguageStats
significantly reducing the number of processes spawned during language stat
processing.

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

* placate lint

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

* Update modules/git/repo_language_stats_nogogit.go

Co-authored-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-17 14:32:47 -05:00
6543
fe628d8406
Vendor Update (#14696)
* github.com/yuin/goldmark v1.3.1 -> v1.3.2

* github.com/xanzy/go-gitlab v0.42.0 -> v0.44.0

* github.com/prometheus/client_golang v1.8.0 -> v1.9.0

* github.com/minio/minio-go v7.0.7 -> v7.0.9

* github.com/lafriks/xormstore v1.3.2 -> v1.4.0

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-16 22:47:24 -05:00
GiteaBot
dc707aea09 [skip ci] Updated translations via Crowdin 2021-02-16 22:38:34 +00:00
zeripath
ad43b119a8
Add Password Algorithm option to install page (#14701)
Add Password Algorithm option to install page

Fix #14674 

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2021-02-16 23:37:20 +01:00
zeripath
66a148e398
Restore detection of branches are equal on compare page (#14586)
Somehow the test for detecting if branches are equal broke
this PR restores this functionality.

Fix #14502

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-16 16:39:45 +01:00
GiteaBot
ebddee8d2b [skip ci] Updated translations via Crowdin 2021-02-16 03:04:48 +00:00
zeripath
60ef2a7c67
Add fullTextSearch to dropdowns by default (#14694)
This PR adds `fullTextSearch: 'exact'` to most dropdown
invocations meaning that if there is a search box for the
dropdown it will automatically do a fullTextSearch looking
for the provided fragment instead of starting at the beginning

We should consider changing other places that use
`fullTextSearch: true` to `'exact'` because these will be using a
fuzzy-textual search that doesn't necessarily return the
expected results.

Fix #14689

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-16 11:03:32 +08:00
zeripath
0a9a484e1e
Create DB session provider(based on xorm) (#13031)
* Create Xorm session provider

This PR creates a Xorm session provider which creates
the appropriate Session table for macaron/session.

Fix #7137

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

* extraneous l

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

* fix lint

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

* use key instead of ID to be compatible with go-macaron/session

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

* And change the migration too.

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

* Update spacing of imports

Co-authored-by: 6543 <6543@obermui.de>

* Update modules/session/xorm.go

Co-authored-by: techknowlogick <matti@mdranta.net>

* add xorm provider to the virtual provider

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

* prep for master merge

* prep for merge master

* As per @lunny

* move migration out of the way

* Move to call this db session as per @lunny

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-15 00:33:31 -05:00
Damien Goutte-Gattat
fc4a8c2980
Allow blocking some email domains from registering an account (#14667)
Gitea allows to whitelist email domains so that only email addresses from certain domains are allowed to register an account, but does not currently allows to do the opposite: blacklisting email domains so that addresses from certain domains are *forbidden* to register an account.

The idea has been briefly mentioned in the discussion about issue #6350, but never implemented. This PR does that.

The rationale is that, in my experience of running a Gitea instance, *a single email domain* is responsible for *most* of the spam accounts, and for *all* of the spam accounts that manage to get past the email confirmation step. So on top of the other spam mitigation measures already available (email confirmation, CAPTCHA, etc.), having the option to block a particularly annoying domain would be helpful.

close #13628
2021-02-15 00:31:29 +01:00
Kyle D
d475d53c41
Fix svg spacing (#14638)
* Add right margin to icons in menu items

* Reduce padding on user profile submenu to fit in one line by default (english)
2021-02-14 17:49:22 +01:00
GiteaBot
5e5b063c6f [skip ci] Updated translations via Crowdin 2021-02-14 14:52:16 +00:00
zeripath
beb2058186
Fix broken spans in diffs (#14678)
Gitea runs diff on highlighted code fragment for each line in order to provide
code highlight diffs. Unfortunately this diff algorithm is not aware that span tags
and entities are atomic and cannot be split.

The current fixup code makes some attempt to fix these broken tags however, it cannot
handle situations where a tag is split over multiple blocks.

This PR provides a more algorithmic fixup mechanism whereby spans and entities are
completely coalesced into their respective blocks.

This may result in a incompletely reduced diff but - it will definitely prevent the
broken entities and spans that are currently possible.

As a result of this fixup several inconsistencies were discovered in our testcases
and these were also fixed.

Fix #14231

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-14 15:51:00 +01:00
GiteaBot
f3847c9d82 [skip ci] Updated licenses and gitignores 2021-02-14 00:19:09 +00:00
zeripath
c9f1baf620
Prevent template renderer from rendering error (#14646)
When there is a panic during template rendering unrolled/render
will automatically render the error. This leads to the
panic being displayed in the page and not a 500 page

Fix #14467
Fix #14525

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-13 19:41:53 +00:00
zeripath
b3c2e23cbb
Prevent race in PersistableChannelUniqueQueue.Has (#14651)
There is potentially a race with a slow starting internal
queue causing a NPE if Has is checked before the internal
queue has been setup.

This PR adds a lock on the Has() fn.

Fix #14311

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-13 20:02:09 +01:00
Lunny Xiao
5e4fa7c703
Turn default hash password algorightm back to pbkdf2 from argon2 until we found a better one (#14673)
* Turn default hash password algorightm back to pbkdf2 from argon2 until we found a better one

* Add a warning on document
2021-02-13 18:03:29 +01:00
GiteaBot
ed834126a6 [skip ci] Updated translations via Crowdin 2021-02-13 16:08:31 +00:00
6543
0a4c2d75cd
rm gogs relict (#14665) 2021-02-14 00:07:17 +08:00
vnkmpf
487f2ee41c
Whitespace in commits (#14650)
* Add whitespace to commit view

* Add whitespace to /compare/a...b

* Move repeated whitespaceFlags to gitdiff

* Add whitespace for wiki pages
2021-02-13 05:35:43 +01:00
techknowlogick
a3cc842e15
Show Gitea version in swagger (#14654)
Show Gitea version in swagger

Co-authored-by: 6543 <6543@obermui.de>
2021-02-12 21:51:56 +01:00
6543
9e852edc41
Add v171 (addSortingColToProjectBoard) migration for #14634 (#14652)
* add v171 Migration for #14634

* NOT NULL

Co-authored-by: Lauris BH <lauris@nix.lv>
2021-02-12 13:01:26 +02:00
vnkmpf
51fb0463a3
Fix truncated organization names (#14655)
* Fix truncated organization names

Previous ellipsis implementation hid vertical overflow - image + descent line of letters.
Organization visibility in select on dashboard was not always visible.
This commit extracts classes which don't make collisions with other items on page.
2021-02-12 03:29:07 +02:00
Anton Khimich
5a18712dd7
Fix PATCH /repos/{owner}/{repo} panic (#14637)
* Fix a runtime error when modifying a repository through API call

Using the `PATCH /repos/{owner}/{repo}` endpoint and attempting to
modify `default_branch` on an empty repository will cause a
panic. This commit adds a check for a nil pointer before attempting
to dereference it.

* Apply suggestions from code review

* Apply suggestions from code review

* Ensure that the git repository is loaded

If you change the default branch for a repository you must change it in
git too. Therefore you must open the repository before changing the
default branch.

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

* Allow empty repos to have their default branches changed

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

Co-authored-by: Anton Khimich <anton.khimicha@mail.utoronto.ca>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-02-11 20:53:41 +01:00
vnkmpf
441f3f0f20
Make fileheader sticky in diffs (#14616)
* Make fileheader sticky #12552

* Remove sticky filenames when width is 480px or less

On mobile phone sticky filename is hidden due to the combination
of many possible widths and lengths.

* Fix text color for .markdown-info

* Fix visual of sticky diff box on 480px or less

- Hide arrow for select buttons.
- Fix changes, additions and deletions.
With flexbox they look very broken.
This commit hides some words to, so the result is:
"123 changed files  987 additions  456 deletions"
- center text in buttons

Co-authored-by: zeripath <art27@cantab.net>
2021-02-11 19:28:51 +01:00
Paweł Bogusławski
7d7007dca7
Added option to disable webhooks (#13176)
* Added option to disable web hooks

This mod introduces DISABLE_WEB_HOOKS parameter in [security] section
of app.ini (by default set to false). If set to true it disables web
hooks feature. Any existing undelivered web hook tasks will be cancelled.
Any existing web hook definitions will be left untouched in db but
its delivery tasks will be ignored.

Author-Change-Id: IB#1105130

* Webhook spelling fixed

Webhook spelling fixed.

Fixes: 07df6614dc84cdd2e9f39c57577fa1062bd70012
Related: https://github.com/go-gitea/gitea/pull/13176#pullrequestreview-510868421
Author-Change-Id: IB#1105174

* Parameter description fixed

Parameter description fixed.

Fixes: 07df6614dc84cdd2e9f39c57577fa1062bd70012
Related: https://github.com/go-gitea/gitea/pull/13176#pullrequestreview-514086107
Author-Change-Id: IB#1105174
2021-02-11 12:34:34 -05:00
a1012112796
ac701637b4
Add dismiss review feature (#12674)
* Add dismiss review feature

refs:
    https://github.blog/2016-10-12-dismissing-reviews-on-pull-requests/
    https://developer.github.com/v3/pulls/reviews/#dismiss-a-review-for-a-pull-request

* change modal ui and error message

* Add unDismissReview api

Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-02-11 18:32:25 +01:00
Romain
c69c01d2b6
Sort / Move project boards (#14634)
Sort Project board (#14533)
2021-02-11 17:32:27 +01:00
6543
ac97ea573c
[Vendor] Update go-redis to v8.5.0 (#13749)
* Update go-redis to v8.4.0

* github.com/go-redis/redis/v8  v8.4.0 -> v8.5.0

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* TODO

* Use the Queue termination channel as the default context for pushes

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

* missed one

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

Co-authored-by: zeripath <art27@cantab.net>
2021-02-10 21:28:32 +00:00
zeripath
4cffc46f65
Allow org labels to be set with issue templates (#14593)
Fix #13688

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-10 17:18:22 +00:00
zeripath
0a23079485
Do not assume all 40 char strings are SHA1s (#14624)
GetCommit() assumes that all 40 char strings are SHA1s. This leads to an
error if you try to do a PR on a branch which is 40 characters long.

This PR attempts the SHA first - and if it fails will switch to using rev-parse.

Fix #14470

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-10 07:37:25 +00:00
zeripath
f9abf94bd9
HasPreviousCommit causes recursive load of commits unnecessarily (#14598)
This PR improves HasPreviousCommit to prevent the automatic and recursive loading
of previous commits using git merge-base --is-ancestor and git rev-list

Fix #13684

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-10 07:00:57 +00:00
Lunny Xiao
c0c59a4c99
Improve the comment on comment type (#14609) 2021-02-10 04:57:30 +01:00
zeripath
f82b1dd7c3
Prevent adding nil label to .AddedLabels or .RemovedLabels (#14623)
* Prevent adding nil label to .AddedLabels or .RemovedLabels

There are possibly a few old databases out there with malmigrated data that can
cause panics with empty labels being migrated.

This PR adds a few tests to prevent nil labels being added.

Fix #14466

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

* Add doctor command to remove the broken label comments

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

Co-authored-by: 6543 <6543@obermui.de>
2021-02-10 10:50:44 +08:00
zeripath
30f7ddb833
Ensure memcache TTL cannot be over 30 days (#14592)
Memcached TTL cannot be > 30 days and if it is attempted the TTL is interpreted as
a unix timestamp.

This PR ensures that the TTL is switched to a unix timestamp in those cases.

Fix #14571

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-09 22:29:03 +00:00
vnkmpf
3a4801d195
Truncated organisations name #14583 (#14615)
- truncate to max length 40
- add CSS ellipsis
2021-02-09 19:51:01 +00:00
zeripath
b337c606d3
Add support for ref parameter to get raw file API (#14602)
Fix #14597

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-09 01:15:47 +01:00
uli-heller
758627cf8f
Fixed irritating error message related to go version (#14611)
I do have go-1.13.8 installed and get the error message

```
Gitea requires Go 1.13 or greater to build. You can get it at https://golang.org/dl/
```

I do thing that Go 1.14 or greater is actually required
2021-02-08 10:16:53 -05:00
zeripath
378acc9d96
Use OldRef instead of CommitSHA for DeleteBranch comments (#14604)
Fix #14545

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-08 11:09:14 +08:00
zeripath
98827e99f6
Add information on how to build statically (#14594)
Fix #14576

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-08 10:06:21 +08:00
GiteaBot
f180009375 [skip ci] Updated translations via Crowdin 2021-02-08 01:01:27 +00:00
zeripath
3477e616ab
Exclude the current dump file from the dump (#14606)
* Exclude the current dump file from the dump

Always prevent the current file from being added to the dump.

Fix #13618

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

* Add skip custom directory option

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

* placate lint

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

Co-authored-by: 6543 <6543@obermui.de>
2021-02-08 09:00:12 +08:00
zeripath
e65cfabda7
Remove spurious DataAsync Error logging (#14599)
Breaking the pipe is a valid way of killing a piped command and any error from
a broken cat-file batch command should be passed back up to the writer any way
therefore specifically logging it is unnecessary.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-02-07 21:04:58 +00:00
6543
5f248d0df2
[API] Add delete release by tag & fix unreleased inconsistency (#14563)
* DeleteReleaseByTag delete release not git tags

* Add api to delete tag (without release)

* fix & extend tests

* fix swagger doc
2021-02-07 19:32:18 +01:00
Lunny Xiao
240fea8c14
Fix rate limit bug when downloading assets on migrating from github (#14564) 2021-02-07 15:56:11 +00:00
6543
cbe7f5296e
[API] Add affected files of commits to commit struct (#14579)
* Add files affected by a commit to gitea API -- similar to github

* Add files affected by a commit to gitea API

* Fix stupid error

* Fix other stupid typo

* Generate swagger tmpl

* Comply with convert to git commit refacto

* update swagger docs

* extend test

* format code

* Update integrations/api_repo_git_commits_test.go

* Update modules/convert/git_commit.go

Co-authored-by: Laurent Cahour <laurent.cahour@dont-nod.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-02-07 15:43:40 +01:00
GiteaBot
c11db35aec [skip ci] Updated licenses and gitignores 2021-02-07 00:18:59 +00:00
John Olheiser
19fccdc45d
Fix locale init (#14582)
just log if lang is already loaded since we can not reload it

Co-authored-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-02-05 22:41:45 +01:00
Farid AYOUJIL
f72ce26326
Add Content-Length header to HEAD requests (#14542)
* Add Content-Length header to HEAD requests

This change adds the header Content-Length to HEAD HTTP requests.

The previous behaviour was blocking some Windows executables (i.e
bitsadmin.exe) from downloading files hosted in Gitea.

This along with PR #14541, makes the web server compliant with HTTP RFC 2616 which states
"The methods GET and HEAD MUST be supported by all general-purpose servers"
and
"The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response."

This should also respond to issues #8030 and #14532.

* This change adds the header Content-Length to HEAD HTTP requests

Pass the Size of the content as a parameter to ServeData() instead of
calculating it using ioutil.ReadAll(reader) --> this call is dangerous
and can result in a denial of service.

* Add Content-Length header to HEAD requests

Quick fix for imported dependency not used.

* Check if size is positiv int ...

Co-authored-by: zeripath <art27@cantab.net>
2021-02-05 21:10:40 +01:00
Michel Ganguin
4457d0e8d9
Honor REGISTER_MANUAL_CONFIRM when doing openid registration (#14548)
REGISTER_MANUAL_CONFIRM is not honored when doing performing an openid registration. The new account is directly accessible.

With this patch, the manual confirm flag gets honored in the same way as a "normal" registration.
2021-02-05 04:03:20 +01:00
Lunny Xiao
32c4563d8d
Fix lfs file viewer (#14568) 2021-02-05 02:29:42 +01:00
Ikko Ashimine
1ea4339332
Fix typo in generate-emoji.go (#14570)
modifer -> modifier

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-02-04 12:57:42 -05:00
Lunny Xiao
3537d80088
Fix bug about ListOptions and stars/watchers pagnation (#14556)
* Fix bug about ListOptions and stars/watchers pagnation

* fix unit test

Co-authored-by: 6543 <6543@obermui.de>
2021-02-04 11:23:46 -06:00
Anton Khimich
80b1d02b2f
Fix gpg key deletion (#14561)
* Fix GPG key deletion when user is deleted

Per #14531, deleting a user account will delete the user's GPG keys
from the `gpg_key` table but not from `gpg_key_import`, which causes
an error when creating an account with the same email and attempting
to re-add the same key. This commit deletes all entries from
`gpg_key_import` that match any GPG key IDs belonging to the user.

* Format added code in models/user.go

* Create a new function for listing GPG keys and apply it

Create a new function `listGPGKeys` and replace a previous use
of `ListGPGKeys`. Thanks to @6543 for the patch.

Co-authored-by: Anton Khimich <anton.khimicha@mail.utoronto.ca>
Co-authored-by: 6543 <6543@obermui.de>
2021-02-04 17:16:21 +08:00
Cameron Braid
3c965c3e30
[API] GetRelease by tag only return release (#14397)
get release by tag should filter out tag releases to be consistent with list releases and get by id

Co-authored-by: 6543 <6543@obermui.de>
2021-02-04 04:12:25 +01:00
6543
87009ab40a
Reduce data races (#14549)
* Add race conditions into test

* Fix Race in GetManager()

* DataAsync() use error chan

* just log no chan

* finish
2021-02-03 22:36:38 +01:00
6543
0d1444751f
[API] Add pagination to ListBranches (#14524)
* make PaginateUserSlice generic -> PaginateSlice

* Add pagination to ListBranches

* add skip, limit to Repository.GetBranches()

* Move routers/api/v1/utils/utils PaginateSlice -> modules/util/paginate.go

* repo_module.GetBranches paginate

* fix & rename & more logging

* better description

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: a1012112796 <1012112796@qq.com>
2021-02-03 20:06:13 +01:00
Howie Zhao
c295a27d4a
docs: update installation with-docker zh-cn (#14554) 2021-02-03 17:12:35 +01:00
Bagas Sanjaya
bd28f1d642
[Docs] Clone filters (#14555)
In summary: set uploadpack.allowfilter

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>
2021-02-03 10:11:20 -05:00
techknowlogick
9b6ff819d7
update docs to show latest stable version (1.13.2) (#14550) 2021-02-03 08:46:42 +01:00
Farid AYOUJIL
1737a76e1f
Adding Chi's GetHead middleware (#14541)
Before moving to Chi, HEAD requests were automatically answered by GET
handlers (SetAutoHead(true) from macaron was used).

This Change will restore the previous behaviour.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-02 10:53:42 +02:00
6543
3f332a9919
Changelog v1.13.2 (#14535) (#14543) 2021-02-02 02:19:10 +01:00
GiteaBot
dcd20f4364 [skip ci] Updated translations via Crowdin 2021-02-01 21:58:33 +00:00
6543
6d27703f14
[API] List, Check, Add & delete endpoints for repository teams (#13630)
* List, Check, Add & delete endpoints for repository teams

* return units on single team responce too

* Add Tests
2021-02-01 22:57:12 +01:00
GiteaBot
a9188631b9 [skip ci] Updated translations via Crowdin 2021-02-01 04:50:39 +00:00
6543
6fc2d36fb5
rm redirect (#14534) 2021-02-01 12:49:25 +08:00
Atilla Lonny
6064bfa3c3
Upgrade 'css-minimizer-webpack-plugin' to the latest version (#14527)
This patch resolves #14520
2021-01-30 19:07:23 +01:00
zeripath
fcfbab99fc
Set the name Mapper in migrations (#14526)
Migrations currently uses the default Xorm mapper which is
not the same as the mapper Gitea actually uses.

This means that there is a difference between the struct
parsing and mapping to database tables in migrations as
compared to normal Sync2.

This was the cause for the catastrophic problem in v168 -
untagged fields are not mapped in the same way in migrations
as compared to outside of migrations.

This is also likely the cause of some weird subtle failures
in other migrations as any untagged field may not be being
mapped exactly the same way.

This PR suggests that we ensure that the mapper is set at
the start of the migrations code - but also enforces a strict
clean mapper between each migration.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-01-30 16:24:25 +01:00
Stefan
eea4197cd9
Internal ssh server respect Ciphers, MACs and KeyExchanges settings (#14523) 2021-01-30 14:20:32 +01:00
Lunny Xiao
5e20fd6dbf
Move middlewares to web/middleware (#14480)
Co-authored-by: 6543 <6543@obermui.de>
2021-01-30 10:55:53 +02:00
6543
0e0424c8ec
Add Doctor FixWrongUserType (#14522)
* Add Doctor FixWrongUserType

* use NoAutoTime
2021-01-29 19:30:43 +01:00
GiteaBot
05365816ab [skip ci] Updated translations via Crowdin 2021-01-29 15:53:59 +00:00
John Olheiser
e92552abb4
noop (#14521)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-29 23:52:13 +08:00
Lunny Xiao
0cd87d64ff
Update docs and comments to remove macaron (#14491) 2021-01-29 16:35:30 +01:00
GiteaBot
25b6255b92 [skip ci] Updated translations via Crowdin 2021-01-29 13:44:05 +00:00
Lunny Xiao
87b098f3b6
Fix json charset bug (#14514) 2021-01-29 08:42:47 -05:00
a1012112796
f19da14c34
enhancement: add signoff option in commit form (#14516)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-01-29 16:57:45 +08:00
Lunny Xiao
f761c82c94
Fix load time bug (#14508) 2021-01-29 05:33:47 +01:00
delvh
aec8029277
Fix missing locale bug introduced by #14429 (#14513)
Fixes #14512
2021-01-29 04:06:10 +01:00
kevinlin18
0e4a9dbcb9
[docs] Add zh-tw Translations (#14507) 2021-01-29 01:57:58 +01:00
6543
2ebe609d65
Fix migration v141 (#14387)
* Fix mig 141

* Add Migration to fix it

* update null values to false first

* Alter Table if posible

* use dropTableColumns instead of recreateTable

* MySQL use Alter

* Postgres use Alter

* Update models/migrations/v167.go

* Apply suggestions from code review

* use 2x add col & 2x update & 2x drop col

* let sqlite be the only issue

* use recreate since it just WORKS
2021-01-28 23:58:33 +01:00
6543
3599d44399
Extend TestUserOrgs to cover permission cases (#14495)
* TestMyOrgs: add unauthorized test

* Extend TestUserOrgs, to cover permission cases
2021-01-28 22:40:41 +01:00
6543
99b7af6fc8
Add some Unit-Tests (#14500)
* fix url

* modules/auth/pa: coverage: 40#.0%

* modules/base coverage: 67.6% -> 89.9%

* modules/cache coverage: 0% -> 12.0%

* modules/convert coverage: 27.1% -> 29.7%
2021-01-28 19:08:11 +01:00
6543
d1353e1f7c
Vendor Update (#14496)
* update code.gitea.io/sdk/gitea v0.13.1 -> v0.13.2

* update github.com/go-swagger/go-swagger v0.25.0 -> v0.26.0

* update github.com/google/uuid v1.1.2 -> v1.2.0

* update github.com/klauspost/compress v1.11.3 -> v1.11.7

* update github.com/lib/pq 083382b7e6fc -> v1.9.0

* update github.com/markbates/goth v1.65.0 -> v1.66.1

* update github.com/mattn/go-sqlite3 v1.14.4 -> v1.14.6

* update github.com/mgechev/revive 246eac737dc7 -> v1.0.3

* update github.com/minio/minio-go/v7 v7.0.6 -> v7.0.7

* update github.com/niklasfasching/go-org v1.3.2 -> v1.4.0

* update github.com/olivere/elastic/v7 v7.0.21 -> v7.0.22

* update github.com/pquerna/otp v1.2.0 -> v1.3.0

* update github.com/xanzy/go-gitlab v0.39.0 -> v0.42.0

* update github.com/yuin/goldmark v1.2.1 -> v1.3.1
2021-01-28 17:56:38 +01:00
GiteaBot
e45bf12a34 [skip ci] Updated translations via Crowdin 2021-01-28 12:31:28 +00:00
Lunny Xiao
154b23da0a
Fix display since time round (#14226)
* Fix display since time round

* Fix since time

* Fix tests
2021-01-28 13:29:22 +01:00
6543
a7cfb9f2c3
Fix JSON Header response (#14499) 2021-01-27 15:46:22 -06:00
GiteaBot
fe5266a25b [skip ci] Updated translations via Crowdin 2021-01-27 17:47:55 +00:00
Lunny Xiao
a51cc6dea4
Fix access log (#14475)
Fix #14121, #14478.

The `AccessLog` middleware has to be after `Contexter` or `APIContexter` so that we can get `LoginUserName` if possible.
And also there is a **BREAK** change that it removed internal API access log.
2021-01-27 18:46:35 +01:00
Kyle D
4c6e029506
Use gitea.svg for public/img/gitea-gitea.svg instead of logo.svg (#14479) 2021-01-27 17:15:39 +01:00
Lunny Xiao
41c0776568
Fix captcha (#14488)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-27 22:56:54 +08:00
Lunny Xiao
669ff8e9b1
Fix switch language (#14484)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-27 16:20:42 +02:00
PhilAtWysdom
af7f71207c
Fix: url.Values map was not initialized (#14485)
Values map was not initialized, leading to error 500 on submission of initial configuration

Co-authored-by: 6543 <6543@obermui.de>
2021-01-27 15:33:32 +02:00
GiteaBot
2e90a256be [skip ci] Updated translations via Crowdin 2021-01-27 12:48:37 +00:00
Lunny Xiao
cfa57dde66
Fix bug that username missed on issue list assignee filter (#14481)
Co-authored-by: 6543 <6543@obermui.de>
2021-01-27 20:47:00 +08:00
GiteaBot
1080b27a39 [skip ci] Updated translations via Crowdin 2021-01-27 10:02:09 +00:00
Jui-Nan Lin
c10503afec
[Feature] add precise search type for Elastic Search (#12869)
* feat: add type query parameters for specifying precise search

* feat: add select dropdown in search box

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-01-27 12:00:35 +02:00
6543
b2c20b68a0
Print usefull error if SQLite is used in settings but not supported (#14476)
* move log output to points where they are relefant

* check explicit of sqlite3 in settings
2021-01-27 04:57:18 +01:00
GiteaBot
5845c87b31 [skip ci] Updated translations via Crowdin 2021-01-26 22:48:54 +00:00
Lunny Xiao
d3aa4971c7
Fix bug because of duplicated join (#14454)
* Fix bug because of duplicated join

* Move join into setupsession

* Fix bug

* Fix bug

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-26 23:47:42 +01:00
Brad Albright
a598877fdf
Cron job to cleanup hook_task table (#13080)
Close **Prune hook_task Table (#10741)**

Added a cron job to delete webhook deliveries in the hook_task table. It can be turned on/off and the schedule controlled globally via app.ini. The data can be deleted by either the age of the delivery which is the default or by deleting the all but the most recent deliveries _per webhook_.

Note: I had previously submitted pr #11416  but I closed it when I realized that I had deleted per repository instead of per webhook. Also, I decided allowing the settings to be overridden via the ui was overkill. Also this version allows the deletion by age which is probably what most people would want.
2021-01-26 22:02:42 +01:00
Lunny Xiao
0f726caf97
Fix panic 500 page rendering (#14474) 2021-01-26 19:04:20 +01:00
GiteaBot
afbddf1f0e [skip ci] Updated translations via Crowdin 2021-01-26 15:38:19 +00:00
Lunny Xiao
6433ba0ec3
Move macaron to chi (#14293)
Use [chi](https://github.com/go-chi/chi) instead of the forked [macaron](https://gitea.com/macaron/macaron). Since macaron and chi have conflicts with session share, this big PR becomes a have-to thing. According my previous idea, we can replace macaron step by step but I'm wrong. :( Below is a list of big changes on this PR.

- [x] Define `context.ResponseWriter` interface with an implementation `context.Response`.
- [x] Use chi instead of macaron, and also a customize `Route` to wrap chi so that the router usage is similar as before.
- [x] Create different routers for `web`, `api`, `internal` and `install` so that the codes will be more clear and no magic .
- [x] Use https://github.com/unrolled/render instead of macaron's internal render
- [x] Use https://github.com/NYTimes/gziphandler instead of https://gitea.com/macaron/gzip
- [x] Use https://gitea.com/go-chi/session which is a modified version of https://gitea.com/macaron/session and removed `nodb` support since it will not be maintained. **BREAK**
- [x] Use https://gitea.com/go-chi/captcha which is a modified version of https://gitea.com/macaron/captcha
- [x] Use https://gitea.com/go-chi/cache which is a modified version of https://gitea.com/macaron/cache
- [x] Use https://gitea.com/go-chi/binding which is a modified version of https://gitea.com/macaron/binding
- [x] Use https://github.com/go-chi/cors instead of https://gitea.com/macaron/cors
- [x] Dropped https://gitea.com/macaron/i18n and make a new one in `code.gitea.io/gitea/modules/translation`
- [x] Move validation form structs from `code.gitea.io/gitea/modules/auth` to `code.gitea.io/gitea/modules/forms` to avoid dependency cycle.
- [x] Removed macaron log service because it's not need any more. **BREAK**
- [x] All form structs have to be get by `web.GetForm(ctx)` in the route function but not as a function parameter on routes definition.
- [x] Move Git HTTP protocol implementation to use routers directly.
- [x] Fix the problem that chi routes don't support trailing slash but macaron did.
- [x] `/api/v1/swagger` now will be redirect to `/api/swagger` but not render directly so that `APIContext` will not create a html render. 

Notices:
- Chi router don't support request with trailing slash
- Integration test `TestUserHeatmap` maybe mysql version related. It's failed on my macOS(mysql 5.7.29 installed via brew) but succeed on CI.

Co-authored-by: 6543 <6543@obermui.de>
2021-01-26 16:36:53 +01:00
GiteaBot
3adbbb4255 [skip ci] Updated translations via Crowdin 2021-01-26 01:22:19 +00:00
Dofri Jónsson
012bf388ab
Fix incorrect key name so registerManualConfirm setting works as expected. (#14455) 2021-01-26 09:20:59 +08:00
GiteaBot
efe4235412 [skip ci] Updated translations via Crowdin 2021-01-24 23:38:47 +00:00
techknowlogick
d2ea21d0d8
Use caddy's certmagic library for extensible/robust ACME handling (#14177)
* use certmagic for more extensible/robust ACME cert handling

* accept TOS based on config option

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

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-25 01:37:35 +02:00
Andrew Bezold
bc05ddc0eb
Redirect on changed user and org name (#11649)
* Add redirect for user

* Add redirect for orgs

* Add user redirect test

* Appease linter

* Add comment to DeleteUserRedirect function

* Fix locale changes

* Fix GetUserByParams

* Fix orgAssignment

* Remove debug logging

* Add redirect prompt

* Dont Export DeleteUserRedirect & only use it within a session

* Unexport newUserRedirect

* cleanup

* Fix & Dedub API code

* Format Template

* Add Migration & rm dublicat

* Refactor: unexport newRepoRedirect() & rm dedub del exec

* if this fails we'll need to re-rename the user directory

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-24 16:23:05 +01:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
4f608ad31f
chore: bump minio to RELEASE.2021-01-16T02-19-44Z (#14445)
-    image: minio/minio:RELEASE.2020-10-09T22-55-05Z
+    image: minio/minio:RELEASE.2021-01-16T02-19-44Z
2021-01-24 22:46:08 +08:00
GiteaBot
4c3ccb096e [skip ci] Updated translations via Crowdin 2021-01-24 12:23:25 +00:00
a1012112796
93a734b3b5
CI: skip build steps for cron update works (#14443)
Signed-off-by: a1012112796 <1012112796@qq.com>
2021-01-24 13:21:33 +01:00
GiteaBot
e35a2b65bc [skip ci] Updated licenses and gitignores 2021-01-24 00:19:18 +00:00
GiteaBot
4b7d85bfa5 [skip ci] Updated translations via Crowdin 2021-01-23 19:34:53 +00:00
6543
4acb499f30
just overload to not get it by mistake again ... (#14440) 2021-01-23 21:33:43 +02:00
GiteaBot
800c436b0b [skip ci] Updated translations via Crowdin 2021-01-23 14:45:16 +00:00
Klaus Vink Slott
525d75c160
Add link to packages in openSUSE build service (#14439)
* Link to OpenSUSE build service
2021-01-23 15:44:00 +01:00
delvh
9872b8d97a
Improve Description in new/ edit Project template (#14429)
Fixes #14358

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2021-01-23 11:30:28 +01:00
Jimmy Praet
91e59a6690
Don't show "Reference in new issue" when issues unit is globally disabled (#14437)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-23 11:58:22 +08:00
a1012112796
6764e8f7b8
CI: Update license & gitignore by cron (#14419)
do generate-license & generate-gitignore by cron

close #12684

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-01-23 03:53:13 +01:00
Jimmy Praet
271a011ba1
Fix close/reopen with comment (#14436)
it previously only worked for the simple textarea, and not for the rich textarea
2021-01-23 03:08:19 +01:00
kolaente
b672899372
Add german translation guidelines (#14283)
* Add german translation guidelines

* Add German Language to Docs

* add Translation cateory & move guidelines into it

Co-authored-by: kolaente <k@knt.li>
Co-authored-by: 6543 <6543@obermui.de>
2021-01-22 20:12:50 +01:00
GiteaBot
4d4cace5e7 [skip ci] Updated translations via Crowdin 2021-01-22 17:50:31 +00:00
Lunny Xiao
3287ce22ef
Fix lfs preview bug (#14428) 2021-01-22 17:49:13 +00:00
GiteaBot
e35d1bf502 [skip ci] Updated translations via Crowdin 2021-01-22 07:23:00 +00:00
dependabot[bot]
61f9a72f24
Bump gsap from 3.5.1 to 3.6.0 (#14410)
Bumps [gsap](https://github.com/greensock/GSAP) from 3.5.1 to 3.6.0.
- [Release notes](https://github.com/greensock/GSAP/releases)
- [Commits](https://github.com/greensock/GSAP/compare/3.5.1...3.6.0)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-22 02:21:45 -05:00
6543
a0e424da85
Enhance Ghost comment mitigation Settings (#14392)
* refactor models.DeleteComment and delete related reactions too

* use deleteComment for UserDeleteWithCommentsMaxDays in DeleteUser

* nits

* Use time.Duration as other time settings have

* docs

* Resolve Fixme & fix potential deadlock

* Disabled by Default

* Update Config Value Description

* switch args

* Update models/issue_comment.go

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
2021-01-21 21:56:19 -05:00
GiteaBot
0e2e73410e [skip ci] Updated translations via Crowdin 2021-01-22 00:29:25 +00:00
zeripath
20f980dcc2
ensure timeout error is shown on u2f timeout (#14417)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-01-22 01:28:14 +01:00
EV3R4
af7054511e
Add TrN for repository limit (#12492)
* Added TrN for repository limit

* Removed form.reach_limit_of_creation_0

* disable Create Button if user can not create

Co-authored-by: 6543 <6543@obermui.de>
2021-01-22 00:44:37 +01:00
GiteaBot
aa4c33b43d [skip ci] Updated translations via Crowdin 2021-01-21 22:15:39 +00:00
techknowlogick
62643d94a3
Update golangci-lint to 1.35.2 (#14418) 2021-01-21 17:14:23 -05:00
Chester Liu
072d550dda
Allow ssh-keygen on Windows to detect ssh key type (#14413) 2021-01-21 21:10:36 +01:00
GiteaBot
c05c0a1512 [skip ci] Updated translations via Crowdin 2021-01-21 19:35:12 +00:00
6543
81c833d92d
Add support to migrate from gogs (#14342)
Add support to migrate gogs:

  *  issues
  *  comments
  *  labels
  *  milestones
  *  wiki


Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-01-21 20:33:58 +01:00
Norwin
b5570d3e68
Display current stopwatch in navbar (#14122)
* add notification about running stopwatch to header

* serialize seconds, duration in stopwatches api

* ajax update stopwatch

i should get my testenv working locally...

* new variant: hover dialog

* noscript compatibility

* js: live-update stopwatch time

* js live update robustness
2021-01-21 15:51:52 +01:00
KN4CK3R
56a8929605
Comment - Reference in new issue (#14366)
* Implemented "Reference in new issue"

* Fixed menu style on "pulls/x/files" because "button" has a style.

* Added context menu for PR file comments.

* Use only a single modal for every comment.

* Use current repository as default. Added search filter.

* Added suggested changes.

* Fixed assignment.

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2021-01-21 14:51:17 +01:00
Patrick Schratz
1c230f69d9
update ssh passthrough (#14403)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-20 21:25:18 -05:00
GiteaBot
83c920d7fa [skip ci] Updated translations via Crowdin 2021-01-20 21:19:05 +00:00
Kamil Domański
26da20aa93
load U2F js only on pages which need it (#11585)
* load U2F js only on pages which need it

* Update templates/base/head.tmpl
2021-01-20 21:17:46 +00:00
Artemis Tosini
cb08248c33
Add support for ed25519_sk and ecdsa_sk SSH keys (#13462)
* Add support for ed25519_sk and ecdsa_sk SSH keys

These start with sk-ssh-ed25519@openssh.com and sk-ecdsa-sha2-nistp256@openssh.com.
They are supported in recent versions of go x/crypto/ssh and OpenSSH 8.2
or higher.

* skip ssh-keygen

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2021-01-20 20:36:55 +00:00
Roberto Santalla
ef85bf84ee
Project: show referenced PRs in issue cards (#14183)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-20 21:53:48 +02:00
zeripath
172229966c
Prevent panic on fuzzer provided string (#14405)
* Prevent panic on fuzzer provided string

The fuzzer has found that providing a <body> tag with an attribute to
PostProcess causes a panic. This PR removes any rendered html or body
tags from the output.

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

* Placate lint

* placate lint again

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

* minor cleanup

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-01-20 23:10:50 +08:00
techknowlogick
b708968694
upgrade to alpine 3.13 (#14343) 2021-01-20 05:21:01 +01:00
Lunny Xiao
135b0e502d
Fix log http status is always zero (#14400)
* Fix log http status is always zero

* Fix lint

Co-authored-by: 6543 <6543@obermui.de>
2021-01-19 20:47:43 -05:00
Kyle D
41e19b93a2
Align dropdown right (#14406) 2021-01-20 02:08:21 +01:00
Jake Howard
e05670da84
Note that all template directories are relative to the CustomPath configuration, not a custom directory inside it (#14399)
* Note that all template directories are relative to the `CustomPath` configuration, not a `custom` directory inside it.

This is a minor clarification, which makes locating where the templates need to be much easier

* Note that it's possible to read the `GITEA_CUSTOM` value from the admin

* Use "$GITEA_CUSTOM" as placeholder

It's more obvious it's a variable and not a typo
2021-01-19 10:50:55 -05:00
Chester Liu
0c0445c97a
Add pager to the branches page (#14202)
* Add pager to the branches page

* override pageSize if bigger than max

* Make branches commit range configurable

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
2021-01-19 05:07:38 +01:00
KN4CK3R
8d0e331c0a
Removed invalid form tag (#14391)
introduced by #5073
2021-01-19 04:02:47 +01:00
Daniel Vos
185c5ae2c4
Update back-up restore example for 1.13 changes (#14374)
Signed-off-by: Daniël Vos <danielvos@outlook.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-01-18 21:05:11 -05:00
Lunny Xiao
b4dc080c96
It seems vet on windows is unnecessary (#14302)
* It seems vet on windows is unnecessary

* add vet back to drone but remove GOOS and GOARCH when build vet
2021-01-19 02:56:10 +01:00
zeripath
b59ed41e81
Use path not filepath in routers/editor (#14390)
The incorrect use of filepath instead of path means that
it is possible to cause a stackoverflow on Windows

Signed-off-by: Andrew Thornton <art27@cantab.net>
2021-01-19 00:20:10 +01:00
Ash McKenzie
6ff63c8202
Display error if twofaSecret cannot be retrieved (#14372) 2021-01-18 21:38:41 +01:00
6543
2686e6bbbe
Check if label template exist first (#14384)
* add check

* refactor

* rollback repo on error after session closed
2021-01-18 21:00:50 +01:00
Ash McKenzie
127907c5e6
Allow passcode invalid error to appear (#14371)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-18 03:51:32 -05:00
Jimmy Praet
f95dce2f10
exclude authored PRs from Review Requested filter (#14368)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-18 07:13:15 +02:00
GiteaBot
8e39157e92 [skip ci] Updated translations via Crowdin 2021-01-18 01:22:31 +00:00
Lauris BH
f5abe2f563
Upgrade blevesearch dependency to v2.0.1 (#14346)
* Upgrade blevesearch dependency to v2.0.1

* Update rupture to v1.0.0

* Fix test
2021-01-17 20:21:14 -05:00
GiteaBot
3aa53dc6bc [skip ci] Updated translations via Crowdin 2021-01-17 20:49:54 +00:00
6543
21da519c0c
Implement ghost comment mitigation (#14349)
* Implement ghost comment mitigation

Adds a config option USER_DELETE_WITH_COMMENTS_MAX_DAYS to the [service] section. See https://codeberg.org/Codeberg/Discussion/issues/24 for the underlying issue.

* cleanup

* use setting module correctly

* add to docs

Co-authored-by: Moritz Marquardt <git@momar.de>
2021-01-17 21:48:38 +01:00
Lauris BH
ca63a9d3f1
Add edit, delete and reaction support to code review comments on issue page (#14339) 2021-01-17 19:29:10 +02:00
Jimmy Praet
acb1ceb1f4
Add review requested filter on pull request overview (#13701)
* Add review requested filter on pull request overview #13682

fix formatting

* add review_requested filter to /repos/issues/search API endpoint

* only Approve and Reject status should supersede Request status

* add support for team reviews

* refactor: remove duplication of issue filtering conditions
2021-01-17 17:34:19 +01:00
Jimmy Praet
872d308892
escape branch names in compare url (#14364) 2021-01-17 15:57:42 +01:00
GiteaBot
66e426b2f1 [skip ci] Updated translations via Crowdin 2021-01-17 14:17:10 +00:00
Jimmy Praet
4d9349123f
label and milestone webhooks on issue/pull creation (#14363) 2021-01-17 16:15:57 +02:00
GiteaBot
e6155ff9b6 [skip ci] Updated translations via Crowdin 2021-01-16 11:24:18 +00:00
Lunny Xiao
dc66e4740f
Fix middlewares sequences (#14354)
Co-authored-by: 6543 <6543@obermui.de>
2021-01-16 12:23:02 +01:00
GiteaBot
76fefd803f [skip ci] Updated translations via Crowdin 2021-01-16 04:56:29 +00:00
Lauris BH
0a3c3357f3
Sort issue search results by revelance (#14353) 2021-01-16 12:55:17 +08:00
GiteaBot
2db4733c7d [skip ci] Updated translations via Crowdin 2021-01-15 20:30:48 +00:00
6543
3091600cc8
KanBan: be able to set default board (#14147)
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
2021-01-15 22:29:32 +02:00
GiteaBot
c09e11d018 [skip ci] Updated translations via Crowdin 2021-01-15 09:39:56 +00:00
Kyle D
bfd0c47ef6
Kd/fix allow svg doctype (#14344)
* make svg regex case-insensitive & use strict word boundary

* allow doctype svg

* add doctype tests

* allow <!DOCTYPE svg> and <svg/>
2021-01-15 17:38:41 +08:00
Norwin
a21adf92ec
restrict query selector to edit form (#14307)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-15 06:55:51 +02:00
Lauris BH
6eee9f0f4e
Merge default and system webhooks under one menu (#14244) 2021-01-15 01:24:03 +02:00
Lunny Xiao
84b147c7f0
Use IsProd instead of testing if it's equal. (#14336)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-01-14 23:17:03 +02:00
Lunny Xiao
60a3297a33
Use ServerError provided by Context (#14333)
... instead of InternalServerError by macaron
2021-01-14 21:27:22 +01:00
Lunny Xiao
f76c30094f
Fix typo (#14332) 2021-01-14 23:35:10 +08:00
Kyungmin Bae
edbc5c86df
Use Request.URL.RequestURI() for fcgi (#14312) (#14314) 2021-01-13 20:30:46 +00:00
techknowlogick
954aeefb05
Update Link 2021-01-13 10:55:52 -05:00
GiteaBot
648d85d426 [skip ci] Updated translations via Crowdin 2021-01-13 15:54:47 +00:00
Kyle D
920c0bde2d
Kd/add bountysource (#14323)
* Add bountysource to Sponsors link

* Add badge to readme
2021-01-13 10:53:17 -05:00
Elena Neuschild
564030336d
Issues overview should not show issues from archived repos (#13220)
* Add lots of comments to user.Issues()

* Answered some questions from comments

* fix typo in comment

* Refac user.Issues(): add func repoIDs

* Refac user.Issues(): add func userRepoIDs

* Refac user.Issues(): add func issueIDsFromSearch

* Refac user.Issues(): improve error handling

* Refac user.Issues(): add inline documentation and move variable declarations closer to their usages

* Refac user.Issues(): add func repoIDMap

* Refac user.Issues(): cleanup

* Refac: Separate Issues from Pulls during routing

* fix typo in comment

* Adapt Unittests to Refactoring

* Issue13171: Issue and PR Overviews now ignore archived Repositories

* changed some verbatim SQL conditions to builder.Eq

* models/issue.go: use OptionalBool properly

Co-authored-by: 6543 <6543@obermui.de>

* Use IsArchived rather than ExcludeArchivedRepos

* fixed broken test after merge

* added nil check

* Added Unit Test securing Issue 13171 fix

* Improved IsArchived filtering in issue.GetUserIssueStats

* Removed unused func

* Added grouping to avoid returning duplicate repo IDs

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Gitea <gitea@fake.local>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-01-12 23:19:17 -05:00
Jonathan Tran
81467e6f35
Display SVG files as images instead of text (#14101)
* Change to display SVG files as images

* Remove unsafe styles from SVG CSP

* Add integration test to test SVG headers

* Add config setting to disable SVG rendering

* Add test for img tag when loading SVG image

* Remove the Raw view button for svg files since we don't fully support this

* Fix copyright year

* Rename and move config setting

* Add setting to cheat sheet in docs

* Fix so that comment matches cheat sheet

* Add allowing styles in CSP based on pull request feedback

* Re-enable raw button since we show SVG styles now

* Change so that SVG files are editable

* Add UI to toggle between source and rendered image for SVGs

* Change to show blame button for SVG images

* Fix to update ctx data

* Add test for DetectContentType when file is longer than sniffLen

Co-authored-by: Jonathan Tran <jon@allspice.io>
Co-authored-by: Kyle D <kdumontnu@gmail.com>
2021-01-12 22:45:19 -05:00
GiteaBot
9465e60504 [skip ci] Updated translations via Crowdin 2021-01-13 00:51:06 +00:00
Nuno Silva
db9bb1ff69
Update docs to clarify issues raised in #14272 (#14318)
- example config is not supposed to be copied
- 'persistable-channel' uses a leveldb internally
- '*CONN_STR' overrides queue DIR
2021-01-13 08:49:52 +08:00
GiteaBot
9659808172 [skip ci] Updated translations via Crowdin 2021-01-10 18:06:29 +00:00
6543
74a0481586
[Refactor] Passwort Hash/Set (#14282)
* move SaltGeneration into HashPasswort and rename it to what it does

* Migration: Where Password is Valid with Empty String delete it

* prohibit empty password hash

* let SetPassword("") unset pwd stuff
2021-01-10 20:05:18 +02:00
6543
6b3b6f1833
Add option to change username to the admin panel (#14229)
Co-authored-by: Bwko <bouwko@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: zeripath <art27@cantab.net>
2021-01-10 14:14:02 +02:00
a1012112796
d989247bb0
fix mailIssueCommentBatch for pull request (#14252)
fix #14250

Signed-off-by: a1012112796 <1012112796@qq.com>
2021-01-09 17:34:08 +00:00
Cirno the Strongest
736928286b
Remove self from MAINTAINERS (#14286)
My time is limited and given recent developments, I don't think i want to dedicate any more of my time to this project.
2021-01-09 01:53:19 -05:00
Jimmy Praet
bcb7f35221
Do not reload page after adding comments in Pull Request reviews (#13877)
Fixed #8861 
* use ajax on PR review page

* handle review comments

* extract duplicate code

FetchCodeCommentsByLine was initially more or less copied from fetchCodeCommentsByReview. Now they both use a common findCodeComments function instead

* use the Engine that was passed into the method

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-08 23:49:55 +02:00
Lunny Xiao
ce43d38b4f
Fix session bug when introduce chi (#14287)
* Update go-chi session
2021-01-08 14:15:06 +02:00
GiteaBot
461406070c [skip ci] Updated translations via Crowdin 2021-01-07 13:41:39 +00:00
Timo Gurr
c1e30c9a84
Add secure/httpOnly attributes to the lang cookie (#9690) (#14279) 2021-01-07 14:40:24 +01:00
Lunny Xiao
3c96a37162
Some code improvements (#14266) 2021-01-06 19:23:57 +00:00
GiteaBot
8688c2be95 [skip ci] Updated translations via Crowdin 2021-01-06 15:12:41 +00:00
Lunny Xiao
9f73cae635
Fix wrong type on hooktask to convert typ from char(16) to varchar(16) (#14148)
* Fix wrong type on hooktask to convert typ from char(16) to varchar(16)

* Fix bugs

* Improve code

* Use different trim function for MSSQL

* Fix bug

* Removed wrong changed line

* Removed wrong changed line

* Fix nullable

* Fix lint

* Ignore sqlite on migration

* Fix mssql modify column failure

* Move modifyColumn to migrations.go so that other migrate function could use it
2021-01-06 16:11:23 +01:00
Grace
d2ee1221cc
Upgrade XORM links in documentation. (#14265)
* [en] upgrade XORM link.

* [fr] upgrade XORM link.

* [zh-cn] upgrade XORM link.

* [zh-tw] upgrade XORM link.
2021-01-06 02:25:01 -05:00
Jimmy Praet
8224f03a23
Check permission for the appropriate unit type (#14261)
* Check permission for the appropriate unit type

Fixes false positives for "User created Issues in Repository which they no longer have access to" errors

* change log level to Debug

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-06 07:07:58 +02:00
techknowlogick
d1581a4563
Add compliance check for windows to ensure cross platform build (#14260)
* Add compliance check for windows to ensure cross platform build

* no race condition

* woops. meant to change windows, not arm64

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-05 21:16:37 -05:00
GiteaBot
91ceba0427 [skip ci] Updated translations via Crowdin 2021-01-06 01:39:13 +00:00
Lunny Xiao
a1c9e8f266
Fix windows build error (#14263)
* fix build

* take flash error message back and fix more windows lint error

* performance optimization

* own step to check lint for windows

Co-authored-by: 6543 <6543@obermui.de>
2021-01-06 09:38:00 +08:00
GiteaBot
4ef5f17a7e [skip ci] Updated translations via Crowdin 2021-01-05 13:56:10 +00:00
6543
325add71cf
Add option for administrator to reset user 2FA (#14243)
* Frontend

* Backend

* only show 2FA-Reset option if posible
2021-01-05 14:54:48 +01:00
Lunny Xiao
15a475b7db
Fix recovery middleware to render gitea style page. (#13857)
* Some changes to fix recovery

* Move Recovery to middlewares

* Remove trace code

* Fix lint

* add session middleware and remove dependent on macaron for sso

* Fix panic 500 page rendering

* Fix bugs

* Fix fmt

* Fix vendor

* recover unnecessary change

* Fix lint and addd some comments about the copied codes.

* Use util.StatDir instead of com.StatDir

Co-authored-by: 6543 <6543@obermui.de>
2021-01-05 21:05:40 +08:00
Lunny Xiao
126c9331d6
upgrade xorm to v1.0.6 (#14246) 2021-01-05 14:28:51 +08:00
Cirno the Strongest
8db0372a45
Handle NotifyCreateRef as create branch in feeds (#14245)
Co-authored-by: Lauris BH <lauris@nix.lv>
2021-01-04 18:51:00 +02:00
Antoine GIRARD
3d38ecb1fc
Publish docker rootless docs (#14240)
Co-authored-by: 6543 <6543@obermui.de>
2021-01-04 15:23:04 +01:00
Cirno the Strongest
21fbee1503
Various UI fixes (#14239)
* Fix #14238

* Fix #14235

* Fix #14237

* Fix #14234

* Use octicon to show private status of repo in admin dashboard

* Fix #14232

* Fix #14236
2021-01-04 13:18:12 +01:00
Kyle D
4092c044e0
Kd/fix team avatar aspect ratio (#14200)
* Add org member avatar to text data for fixed width

* set min-width to prevent single char lines
2021-01-03 22:20:05 +01:00
Jimmy Praet
9cc5a89b8c
Issue and pull request filters on organization dashboard #14052 (#14072) 2021-01-03 18:29:12 +01:00
Nuno Silva
44ff1d6a1e
Render links for commit hashes followed by comma (#14224)
Regex test cases: https://regex101.com/r/mVbPxM/2/

fixes #14223
2021-01-03 23:11:10 +08:00
Paul Barton
7576e37a65
Add MirrorInterval to the API (#14163)
* Added MirrorInterval to the API

* Remove MirrorInterval from CreateRepository

* Removed Duplicate UpdateMirror Function

* Updated Error Logging

* Update Log Message for is not Mirror

Co-authored-by: 6543 <6543@obermui.de>

* Delete Debug Statement that snuck in

Co-authored-by: zeripath <art27@cantab.net>

* Add Check for If Interval is too small

* Output to API Call

* Add Error Object when time is Less than Min Interval

* Frequency Error Message

Co-authored-by: zeripath <art27@cantab.net>

* Allow Zero Mirror Interval

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2021-01-02 18:47:47 -05:00
Lunny Xiao
3abea9e9eb
Fix avatar bugs (#14217) 2021-01-02 18:01:09 +00:00
Jimmy Praet
e6acce649b
Send notifications for mentions in pulls, issues, (code-)comments (#14218)
Fixes #14187: mention handling extracted from email notification code
Fixes #14013: add notification for mentions in pull request code comments
Fixes #13450: Not receiving any emails with setting "Only Email on Mention"
2021-01-02 18:04:02 +01:00
zeripath
ac88b0ee83
Ensure that schema search path is set with every connection on postgres (#14131)
* Ensure that schema search path is set with every connection on postgres

Unfortunately every connection to postgres requires that the search path is
set appropriately.

This PR shadows the postgres driver to ensure that as soon as a connection
is open, the search_path is set appropriately.

Fix #14088

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

* no golangci-lint that is not a helpful suggestion

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

* Use Execer if available

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-01-02 10:07:43 +08:00
Lunny Xiao
d44f192d3e
When visit /favicon.ico but the static file is not exist return 404 but not continue to handle the route (#14211)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-01-01 17:05:45 -05:00
Lunny Xiao
8c086bae6e
Fix wrong publisher id (#14212)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2021-01-01 16:03:31 -05:00
Kyle D
0f99edf123
Prevent clipping input text in Chrome (#14179) 2021-01-01 14:05:40 -05:00
silverwind
1bf7d71a0a
Consolidate Logos and update README header (#14136)
* Consolidate Logos and update README header

- Remove unused `logo-lg.png`, `logo-sm.png` and `logo-192.png`.
- Consolidate `favicon.svg` and `logo.svg` to just `logo.svg`.
- Remove Safari Mask icon, it seems to work fine with just `favicon.png` (no SVG support).
- Remove Fluid Icon. It only served Firefox and SVG works just fine there.
- Update customization instructions.
- Update README.md to use SVG icon, increase logo size and center it and badges.

* Update README_ZH.md

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>

* Update README_ZH.md

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2021-01-01 14:04:35 -05:00
Lunny Xiao
21adeaad70
Fix dashboard issues labels filter bug (#14210)
Co-authored-by: zeripath <art27@cantab.net>
2021-01-01 12:49:42 -05:00
Johnny Oskarsson
a07e67d9cc
Minimal OpenID Connect implementation (#14139)
This is "minimal" in the sense that only the Authorization Code Flow
from OpenID Connect Core is implemented.  No discovery, no configuration
endpoint, and no user scope management.

OpenID Connect is an extension to the (already implemented) OAuth 2.0
protocol, and essentially an `id_token` JWT is added to the access token
endpoint response when using the Authorization Code Flow.  I also added
support for the "nonce" field since it is required to be used in the
id_token if the client decides to include it in its initial request.

In order to enable this extension an OAuth 2.0 scope containing
"openid" is needed. Other OAuth 2.0 requests should not be impacted by
this change.

This minimal implementation is enough to enable single sign-on (SSO)
for other sites, e.g. by using something like `mod_auth_openidc` to
only allow access to a CI server if a user has logged into Gitea.

Fixes: #1310

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2021-01-02 00:33:27 +08:00
techknowlogick
4f2f08bd80
deprecate building for mips (#14174)
Co-authored-by: zeripath <art27@cantab.net>
2021-01-01 23:22:32 +08:00
techknowlogick
c9b9b462d2
Update owners for 2021 (#14206)
Fix #13801
2021-01-01 01:41:03 +02:00
a1012112796
b003116fca
fix branch selector on new issue page (#14194)
fix #14185

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-31 13:32:11 -05:00
zeripath
ef825bd242
Check for notExist on profile repository page (#14197)
Fix #14189
2020-12-31 15:45:54 +08:00
Chester Liu
632800eda7
Check for 'main' as potential default branch name (#14193) 2020-12-30 15:46:26 +00:00
Kyle D
c074e46292
Hide migration failed by default (#14188) 2020-12-30 11:04:30 +08:00
GiteaBot
af2fe9a733 [skip ci] Updated translations via Crowdin 2020-12-29 23:49:34 +00:00
silverwind
8e5aea88c7
Improve label and text wrapping (#14113)
* Improve label wrapping

- Adjust issue list styles so labels can wrap on the same line as the
  text. This relies on `display: inline` with the HTML whitespace being
  used as the separator.
- Add global word-break: break-word. This should generally avoid text
  overflows in various places.

* add whitespace to history labels

* use overflow-wrap

* restore word-break rules

* use correct pre

* use better selector for middle align

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-29 18:48:28 -05:00
GiteaBot
cfc3916b3f [skip ci] Updated translations via Crowdin 2020-12-29 00:39:54 +00:00
techknowlogick
9164ff7791
frontport 1.13.1 changelog (#14175)
* frontport 1.13.1 changelog

* Update config.yaml

Co-authored-by: zeripath <art27@cantab.net>
2020-12-28 19:38:44 -05:00
silverwind
9a4050f1e8
Consolidate clone button templates (#14023)
The four clone button templates are pretty much identical except the one
in a non-empty repo had a few features which the others lacked.

Consolidate them in a single shared template which also makes the JS
that remembers protocol work on them all.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-28 13:30:06 -05:00
0xflotus
366ce66cad
fix: small typo error (#14170)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-28 12:08:01 -05:00
Lunny Xiao
11555d850b
Fix bug of link query order on markdown render (#14156)
* Fix bug of link query order on markdown render

* Fix bluemonday bug and fix one wrong test

Co-authored-by: 6543 <6543@obermui.de>
2020-12-29 00:28:27 +08:00
Daniil Pankratov
3175d08626
CLI support for OAuth sources custom icons (#14166)
Co-authored-by: Daniil Pankratov <daniil.pankratov@t-systems.com>
2020-12-28 09:39:12 +01:00
GiteaBot
d75f011345 [skip ci] Updated translations via Crowdin 2020-12-28 02:37:00 +00:00
Timo Ley
2b2a4a53bf
Custom icons for OAuth sources (#14161)
* Add Icon URL to Backend

* Template for Icon URL

* Localization & Edit Icon URL

* Improve Custom Icon URL

* Removed not working else

Co-authored-by: 6543 <6543@obermui.de>
2020-12-28 03:35:55 +01:00
GiteaBot
f6ca44c706 [skip ci] Updated translations via Crowdin 2020-12-27 19:59:15 +00:00
Jimmy Praet
40274b4a93
Team dashboards (#14159) 2020-12-27 21:58:03 +02:00
Bagas Sanjaya
25f8970b2c
[Docs] Database preparation: Clarify why database client is installed on Gitea server (#12833)
* Database preparation: Clarify why database client is installed on Gitea server

The database client program (`mysql` or `psql`) is used to test database
connection, but Gitea use Go's database driver to do the same.

Also, rename "server part" and "client part" to "server application" and
"client program" to disambiguate.

* Update docs/content/doc/installation/database-preparation.en-us.md

Co-authored-by: 6543 <6543@obermui.de>
2020-12-27 23:55:45 +08:00
silverwind
50a2dd52ba
Update JS dependencies and webpack (#14118)
* Update JS dependencies

- Update all JS dependencies
- Adapt webpack config for version 5
- Update to Less 4.0, adapting usage of removed mixin syntax
- Enable new ESLint rules and fix discovered issues

* update license-webpack-plugin to fix missing licenses

* update license-webpack-plugin once more to get webpack into the license output

* switch to license-checker-webpack-plugin again for performance

* update deps again

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-12-27 15:24:27 +01:00
silverwind
fe403725f4
Improve basic button and label styles (#14119)
* Improve disabled styles for repo buttons

- Simplify disabled styling of label by matching for the disabled
  attribute.
- Raise fomantic disabled opacity from .45 to .55 to for more contrast.
- Use CSS vars for basic button styles.

* restore clickability on label

* color tweaks and remove arc-green style

* slightly reduce button size

* consolidate vars

* also cover active class

* slightly more distinct active class

* remove useless rule
2020-12-27 18:53:53 +08:00
Lunny Xiao
dd08853b10
Dump github/gitlab/gitea repository data to a local directory and restore to gitea (#12244)
* Dump github/gitlab repository data to a local directory

* Fix lint

* Adjust directory structure

* Allow migration special units

* Allow migration ignore release assets

* Fix lint

* Add restore repository

* stage the changes

* Merge

* Fix lint

* Update the interface

* Add some restore methods

* Finish restore

* Add comments

* Fix restore

* Add a token flag

* Fix bug

* Fix test

* Fix test

* Fix bug

* Fix bug

* Fix lint

* Fix restore

* refactor downloader

* fmt

* Fix bug isEnd detection on getIssues

* Refactor maxPerPage

* Remove unused codes

* Remove unused codes

* Fix bug

* Fix restore

* Fix dump

* Uploader should not depend downloader

* use release attachment name but not id

* Fix restore bug

* Fix lint

* Fix restore bug

* Add a method of DownloadFunc for base.Release to make uploader not depend on downloader

* fix Release yml marshal

* Fix trace information

* Fix bug when dump & restore

* Save relative path on yml file

* Fix bug

* Use relative path

* Update docs

* Use git service string but not int

* Recognize clone addr to service type
2020-12-27 11:34:19 +08:00
6543
212fa340cf
Migration: drop to long repo topics (#14152) 2020-12-27 09:23:57 +08:00
Lunny Xiao
cf9d471631
Change topic name size from 25 to 50 (#14150)
* Change topic name size from 25 to 50

* recreateTable requires full bean definition

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

Co-authored-by: zeripath <art27@cantab.net>
2020-12-26 23:28:47 +00:00
zeripath
236e70f135
Fix escaping issue in diff (#14153)
Ensure that linecontent is escaped before passing to template.HTML

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-26 21:58:21 +00:00
GiteaBot
5a1ccacac7 [skip ci] Updated translations via Crowdin 2020-12-26 18:23:50 +00:00
Norwin
24ecdbdb0d
Fix UI on edit auth source page (#14137)
* do not override OAuth URLs with default values when editing an auth source (fixes #12014)
* show custom url inputs by default for providers that don't provide an official hosted service
2020-12-26 18:22:42 +00:00
zeripath
ad1164f73b
Disable SSH key deletion of externally managed Keys (#13985)
* Disable SSH key addition and deletion when externally managed

When a user has a login source which has SSH key management
key addition and deletion using the UI should be disabled.

Fix #13983

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

* Make only externally managed keys disabled

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-25 23:24:47 -05:00
6543
a19447aed1
migrate from com.* to alternatives (#14103)
* remove github.com/unknwon/com from models

* dont use "com.ToStr()"

* replace "com.ToStr" with "fmt.Sprint" where its easy to do

* more refactor

* fix test

* just "proxy" Copy func for now

* as per @lunny
2020-12-25 11:59:32 +02:00
silverwind
04ae0f2f3f
Disable Fomantic's custom scrollbars (#14109)
We already have custom scrollbars in our own CSS which are superior to
Fomantic's so diable them to save a few bytes and prevent interference.
2020-12-24 22:34:49 +00:00
Lunny Xiao
2c8d302eb1
Fix heatmap total contributions (#14141) 2020-12-24 20:58:30 +00:00
Daniil Pankratov
5a94db37ed
Fix creating OAuth2 auth source from CLI (#14116)
Fix creation OAuth2 auth source from CLI.

Fix #8356

Co-authored-by: Daniil Pankratov <daniil.pankratov@t-systems.com>
2020-12-24 19:47:17 +00:00
Norwin
bdeccc3688
Fix api doc response code (#14123)
Fixes #14120
2020-12-24 18:14:01 +00:00
zeripath
fa2e34928d
Ensure that search term and page are not lost on adoption page-turn (#14133)
Fix #14111

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-24 23:26:19 +08:00
GiteaBot
4c2a1c01a8 [skip ci] Updated translations via Crowdin 2020-12-24 04:26:32 +00:00
Lunny Xiao
19ae6439b0
Improve vfsgen to not unzip bindata files but send to browser directly (#7109)
* Don't unzip files from bindata but send to browser directly

* remove dependent for httpgzip

* Add tests for parseAcceptEncoding

* Update docs for ENABLE_GZIP

* Fix bug

* Fix bug

Co-authored-by: zeripath <art27@cantab.net>
2020-12-24 12:25:17 +08:00
silverwind
87a0396719
Fix admin monitoring margin (#14134) 2020-12-23 21:38:29 +01:00
6543
5b958315c1
API: Make BasicAuth Prefix case insensitive (#14106) 2020-12-23 20:52:46 +01:00
GiteaBot
a9876bca82 [skip ci] Updated translations via Crowdin 2020-12-23 19:11:05 +00:00
silverwind
cd5278a44c
Fix manifest encoding (#14114)
The previous URL encoding would encode spaces to '+' for the app name
which is incorrect. Use base64 encoding instead which does not have such
issues.
2020-12-23 19:09:54 +00:00
Jimmy Praet
e0c753e770
Fix spelling avator -> avatar (#14115) 2020-12-22 22:28:03 +01:00
6543
27fa4814b8
Fix git.parseTagData (#14105)
* Fix git.parseTagData()
close #14092

* Add Test

* add message to test

* limit readers

* git tag -m trims and terminates with a newline

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
2020-12-22 21:44:25 +01:00
GiteaBot
30edcd5c71 [skip ci] Updated translations via Crowdin 2020-12-22 15:55:30 +00:00
Donlon
4d22e2423f
Fix incorrect generated link in documentation page (#14112) 2020-12-22 15:54:12 +00:00
GiteaBot
c236fe2f10 [skip ci] Updated translations via Crowdin 2020-12-22 11:15:05 +00:00
silverwind
3a21f8a986
Inline manifest.json (#14038)
* Inline manifest.json

Improve performance by eliminating this separate request and just inline
this small JSON in HTML directly as a data uri.

Also update previously static app name scripts to use AppName.

I've confirmed this as working via "Add to Homescreen" feature which
offered to save the shortcut under the new app name.

* prerender manifest data on startup

* move to settings

* restore setting.AppStartTime and use it on admin page

* use double quotes because template.URL escapes everything

* fix lint

* move variable to global context variable

* delete template file

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-12-22 19:13:50 +08:00
GiteaBot
cd607b5f98 [skip ci] Updated translations via Crowdin 2020-12-22 03:48:23 +00:00
Norwin
c2ae432489
Add user filter to issueTrackedTimes, enable usage for issue managers (#14081)
* add user filter to issueTrackedTimes

fixes #14024

* update swagger

* allow user filter for issue writers

* improve swagger doc

* return 404 on invalid user
2020-12-22 04:47:17 +01:00
GiteaBot
6f1dddf5c3 [skip ci] Updated translations via Crowdin 2020-12-22 02:55:02 +00:00
Norwin
f6bec85296
rework heatmap permissions (#14080)
* now uses the same permission model as for the activity feed:
  only include activities in repos, that the doer has access to.
  this might be somewhat slower.

* also improves handling of user.KeepActivityPrivate (still shows
  the heatmap to self & admins)

* extend tests

* adjust integration test to new behaviour

* add access to actions for admins

* extend heatmap unit tests
2020-12-22 03:53:37 +01:00
Cirno the Strongest
2c9dd71140
Standardize Co-Authored-By / Reviewed-By strings (#14097)
* Standardize Co-Authored-By / Reviewed-By strings

* Use lowercase variant

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-21 21:19:33 -05:00
Lunny Xiao
acd5e5a868
Add StatDir and replace com.StatDir (#14099)
* Add StatDir and replace com.StatDir

* a nit

* Remove wrong file

Co-authored-by: 6543 <6543@obermui.de>
2020-12-22 07:40:57 +08:00
GiteaBot
f8fd8996c0 [skip ci] Updated translations via Crowdin 2020-12-21 23:04:32 +00:00
胡玮文
c21a399646
more test case for STORAGE_TYPE overrides (and fixes) (#14096)
Signed-off-by: 胡玮文 <huww98@outlook.com>
2020-12-22 01:03:18 +02:00
胡玮文
addd4248da
Fix storage config implementation (#14091)
The design is very flexible, but not implemented correctly.
This commit fixes several issues:
* Costom storage type stated in https://docs.gitea.io/en-us/config-cheat-sheet/#storage-storage
  not working
* [storage.attachments], [storage.minio] section not respected

Signed-off-by: 胡玮文 <huww98@outlook.com>
2020-12-21 18:59:18 +01:00
6543
9271040c21
Add Test for Fix #14040 (#14045)
Add Test for Fix #14040
2020-12-21 18:27:23 +01:00
Mura Li
09304db9a5
Use the text of pull-request as the squash commit's message (#13071)
Originally, it was filled by the commit messages of the involved
commits. In this change, we use the headline comment of the pull
request as the commit message when it is a squash merge.

Thanks to @zeripath for suggesting the idea.

Fixes #12365

Co-authored-by: Mura Li <typeless@users.noreply.github.com>
2020-12-21 17:46:14 +01:00
a1012112796
34df4e5df5
Add mentionable teams to tributeValues and change team mention rules to gh's style (#13198)
* Add mentionable teams to tributeValues

Signed-off-by: a1012112796 <1012112796@qq.com>

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

* Change team mention rules to gh's style

* use org's avator as team avator in ui

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update modules/markup/html.go

* Update models/issue.go

Co-authored-by: Lauris BH <lauris@nix.lv>

* Update models/issue.go

* fix a small nit and update test code

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2020-12-21 16:39:28 +01:00
GiteaBot
1b1adab26c [skip ci] Updated translations via Crowdin 2020-12-21 14:41:16 +00:00
Paweł Bogusławski
839daa85aa
Added option to disable migrations (#13114)
* Added option to disable migrations

This patch introduces DISABLE_MIGRATIONS parameter in [repository]
section of app.ini (by default set to false). If set to true
it blocks access to repository migration feature.

This mod hides also local repo import option in user editor if
local repo importing or migrations is disabled.

* Alter Example config

DISABLE_MIGRATIONS set to false in example config to
match its default value.

* HTTP error 403 instead of 500 on denied access to migration

* Parameter DISABLE_MIGRATIONS exposed via API

Fixes: 04b04cf854bcb3ed7659442bcf79822bdebe29e9
Author-Change-Id: IB#1105130
2020-12-21 15:39:41 +01:00
GiteaBot
3a500cf8c4 [skip ci] Updated translations via Crowdin 2020-12-21 13:13:27 +00:00
Norwin
7a3c71433a
expose translation of previously hardcoded string (#14087)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-21 21:12:13 +08:00
GiteaBot
7dd32276b7 [skip ci] Updated translations via Crowdin 2020-12-21 08:32:25 +00:00
Cirno the Strongest
29d12cff92
Present repository name as {{name}}#{{index}} instead of label on dashboard issuelist (#14085)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-12-21 16:31:20 +08:00
DuckDuckWhale
e8a354f819
Locale: say another issue instead of this issue (#14082)
Saying "this issue" is confusing because it could be understood as the
issue that the user is currently viewing, not which the "issue" link
points to.
2020-12-21 08:11:39 +02:00
Jimmy Praet
14ac3e617f
Add repo name label again on dashboard issue / pulls page (#14073)
The label got removed in PR #13594

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-20 17:52:29 -05:00
silverwind
b4f8da533e
Search and Diff CSS enhancements (#14050)
* Search and Diff CSS enhancements

- Use flexbox for language stats
- Improve labels and code boxes on repo and code search
- Use flexbox on diff header and improve suppressed diff text
- Add dedicated color for diff expander

* more diff tweaks, less vertical padding on header

* more minor tweaks

* always show fold icon, image diff improvments

* remove margin

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-20 13:00:03 -05:00
techknowlogick
e0a84d7880
dep: update crypto. info: https://golangtutorial.dev/news/fix-in-crypto-package/ (#14067)
Co-authored-by: zeripath <art27@cantab.net>
2020-12-20 17:36:07 +02:00
Cirno the Strongest
f3c4baa84b
Show dropdown with all statuses for commit (#13977)
* Show dropdown with all statuses for commit

* Use popups

* Remove unnecessary change

* Style popup

* Use divided list

* As per @silverwind

* Refactor GetLastCommitStatus

* Missing dropdown on repo home and commit page

* Fix tests

* Make status icon be a part of a link on PR list

* Fix missing translation call

* Indent fix

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-20 11:13:12 +08:00
GiteaBot
029836c34c [skip ci] Updated translations via Crowdin 2020-12-20 01:32:15 +00:00
Jiri Vlasak
d7c67a9fb2
Manually approve new registration (#13083)
* Add register manual confirm settings option

The new settings option is used when manually approving new
registrations.

* Enable manual confirmation of new registered user

When manual registration confirmation is desired (by default `false`)
create new user in the database that is *not active*. The user must then
be activated manually.

This change speeds up the process of adding new confirmed users for
Gitea instances without external auth mechanism. (Currently the option
is to manually create new user by admin.)

* Update docs/content/doc/advanced/config-cheat-sheet.zh-cn.md

Co-authored-by: a1012112796 <1012112796@qq.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-19 20:31:06 -05:00
Lunny Xiao
36bd5d70cd
Fix feed push tag (#14064)
* Fix dashboard feed bug when push tag

* Fix variable name

* Fix delete tag

Co-authored-by: 6543 <6543@obermui.de>
2020-12-20 07:46:28 +08:00
GiteaBot
e674478227 [skip ci] Updated translations via Crowdin 2020-12-19 22:31:48 +00:00
Lunny Xiao
1d3a580a3e
Refactor get tag to remove unnecessary steps (#14058)
* Fix tag cache bug
2020-12-20 00:30:39 +02:00
silverwind
4aabbacdfe
Fix merge button dropdown triangle alignment (#14041)
https://github.com/go-gitea/gitea/pull/14028 had improved dropdown
triangle display for buttons with text but had regressed it for buttons
without. Fix this by adding a class to prevent horizontal margin adjustment.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-18 22:57:25 -05:00
Kyle D
4ef751215c
put ${CURDIR} in quotes to prevent make from splitting paths with spaces into separate strings (#14056) 2020-12-18 21:54:01 -05:00
Kyle D
4cd94e3689
gitea png to logo (#13974)
* gitea png to logo.svg

* gitea safari svg to logo

* minify svgs

* Update english docs

* Update missing section on customizing logo
2020-12-18 20:17:27 -05:00
silverwind
e25e7b9598
Commit list display tweaks (#14043)
- Make plain <pre> inherit our monospace fonts, overriding fomantic's
  css reset which means expanded commit messages now follow the font
  settings.
- Adjust link styling and keyword highlighting in commit message
- Consolidate .commit-summary styles to single selector group

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-18 15:00:07 -05:00
zeripath
e2b069e577
Accept multiple SSH keys in single LDAP SSHPublicKey attribute (#13989)
* Accept multiple SSH keys in single LDAP SSHPublicKey attribute

Fix #13984

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-18 17:44:18 +00:00
Cirno the Strongest
efa9a8a6e3
Show status check for merged PRs (#13975)
* Show status check for merged PRs

* Handle PRs with no commits

* Styling

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2020-12-18 13:37:55 +01:00
Cirno the Strongest
48bd02e753
Add whiteline after label on Signing Verification Settings (#14042) 2020-12-18 11:27:42 +01:00
6543
e483220ea3
[Refactor] CombinedStatus and CommitStatus related functions & structs (#14026)
* RM unused struct

* rename (*CommitStatus) loadRepo() -> loadAttributes()

* move ToCommitStatus into its own file

* use CommitStatusState instead of StatusState

* move CombinedStatus convertion into convert package

* let models.GetLatestCommitStatus use repoID direct and accept ListOptions

* update swagger docs

* fix tests

* Fix swagger docs

* rm page

* fix swagger docs!!!

* return json null

* always return json

* rename api.Status to api.CommitStatus

* fix swagger docs

* sec swagger fix
2020-12-18 11:33:32 +08:00
silverwind
27edc1aa19
Fix panic in BasicAuthDecode (#14046)
* Fix panic in BasicAuthDecode

If the string does not contain ":" that function would run into an
`index out of range [1] with length 1` error. prevent that.

* Update BasicAuthDecode()

Co-authored-by: 6543 <6543@obermui.de>
2020-12-17 20:51:28 -05:00
silverwind
e9cc613c24
Makefile cleanup & double golangci-lint timeout (#14044)
* Makefile cleanup

The xmldom dependency is no longer required since #13680. Also,
whitespace cleanup.

* double the golangci-lint timeout
2020-12-17 23:55:52 +01:00
techknowlogick
f8a668ab0c
Clean up SVG (#13680)
* Clean up SVG

* update per feedback

* fix css style

* Delete gitea.png

* no new line at end of file

* fix newline?

Co-authored-by: 6543 <6543@obermui.de>
2020-12-17 16:33:53 -05:00
zeripath
e4567d4285
Fix bug in commit verification introduced in #13673 (#14040)
There is a slight bug in the commit_reader introduced in #13673 whereby
commit messages which have a final unterminated line miss their final line.

This PR fixes this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-17 21:42:33 +01:00
silverwind
3260e15668
Dashboard search tweaks (#14008)
- Fix color of inactive pagination parts caused by overreaching CSS
selector.
- Slightly reduce horizontal padding on list items
- Add spacing around pagination and move it outside of <ul>
2020-12-17 19:58:21 +00:00
silverwind
8af9df0036
Diff and code review refactors and improvements (#13922)
* Diff CSS refactors and misc tweaks

- Simplify Diff CSS styling
- Add color variables for diff
- Fix vertical centering of inline comment button
- Slightly adjust text colors, e.g. in comment header

* Code review improvments

* selector tweak

* fix diff issues, add inactive bg color

Co-authored-by: 6543 <6543@obermui.de>
2020-12-17 23:52:58 +08:00
silverwind
a8fa380c25
Dropdown triangle fixes (#14028)
* Dropdown triangle fixes

Fomantic's CSS assumes the dropdown triangles are fonts but we've recently
swapped them for SVG so we need to wrestle a bit with Fomantic to get it
to display properly and not cause buttons to resize.

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

* move css and add link
2020-12-17 15:37:56 +01:00
zeripath
511f6138d4
Use native git variants by default with go-git variants as build tag (#13673)
* Move last commit cache back into modules/git

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

* Remove go-git from the interface for last commit cache

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

* move cacheref to last_commit_cache

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

* Remove go-git from routers/private/hook

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

* Move FindLFSFiles to pipeline

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

* Make no-go-git variants

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

* Submodule RefID

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

* fix issue with GetCommitsInfo

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

* fix GetLastCommitForPaths

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

* Improve efficiency

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

* More efficiency

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

* even faster

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

* Reduce duplication

* As per @lunny

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

* attempt to fix drone

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

* fix test-tags

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

* default to use no-go-git variants and add gogit build tag

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

* placate lint

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

* as per @6543

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-17 22:00:47 +08:00
zeripath
0851a89581
Cause NotifyMigrateRepository to emit a repo create webhook (#14004)
* Cause NotifyMigrateRepository to emit a repo create webhook

This PR simply makes NotifyMigrateRepository emit a Create Repo webhook.
The reason for no new payload is that the information sent to
NotifyMigrateRepository is only essentially the same as
NotifyCreateRepository

Fix #13996

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-17 13:26:22 +01:00
zeripath
80a299d307
Always wait for the cmd to finish (#14006)
After cancelling the context we still need to wait for the
command to finish otherwise zombie processes may occur

Fix #13987

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

Co-authored-by: 6543 <6543@obermui.de>
2020-12-17 12:50:21 +01:00
zeripath
5e09de174c
fix label of --id in admin delete user (#14005)
* fix label of --id in admin delete user

This pr fixes the label descriptor of `gitea admin delete user`
but also adds a `--username` option.

Fix #13995

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

* fix-spacing

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

* Add delete email support

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-17 02:57:32 -05:00
Bo-Yi Wu
c57e1f2653
docs(docker): fix diff format. (#14035)
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
2020-12-17 00:00:43 -05:00
6543
9e456b5a56
HotFix: Hide private partisipation in Orgs (#13994)
* HotFix: Hide private partisipation in Orgs

* refactor & add node to fuc GetOrganizations
2020-12-17 00:39:12 +01:00
6543
069acf6a21
Add FAQ link to Issue template (#14020) 2020-12-16 20:18:36 +01:00
Cirno the Strongest
5f55bab70e
Fix webhook list styling (#14001)
* Fix webhook list styling

* As per @silverwind
2020-12-16 19:22:21 +01:00
Cirno the Strongest
53308de0bf
Send webhook when tag is removed via Web UI (#14015)
* Send webhook when tag is removed via Web UI

* Stray code
2020-12-16 10:00:46 -06:00
Cirno the Strongest
66379ba7ae
Send push event when tag is created or deleted (#13999)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-16 14:41:21 +02:00
Jimmy Praet
e7a77d32cc
Fix correct diff view for PR review comments in PR view page (#14002)
Fixes #13683.

The diff snippet that provides context for a code review comment on the pull request timeline page used to be calculated based on the headCommitID. But in 1.13, with PR #13448, this changed to the commitID from the blame for the commented line, which seems to cause these incorrect review comment diff snippets.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-16 11:54:58 +02:00
techknowlogick
88b585c2e0
Store repository data in data path if not previously set (#13991)
* Store repository data in data path if not previously set

* update docs

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: silverwind <me@silverwind.io>

* update docs

Co-authored-by: silverwind <me@silverwind.io>
2020-12-15 16:52:59 -05:00
Norwin
b8c58edf39
add @noerw to maintainers (#13997)
* add @noerw to maintainers

* format

Co-authored-by: 6543 <6543@obermui.de>
2020-12-15 14:19:26 -05:00
6543
e2aa701812
[API] Add ref to create/edit issue options & deprecated assignee (#13992)
* API: Add ref to create/edit issue options

* deprecate Assignee in favour of Assignees
2020-12-15 19:38:10 +01:00
zeripath
980b0df829
Standardise logging of failed authentication attempts in internal SSH (#13962)
Continuing on from #13953 continue to improve and standardise
logging from internal SSH.

Also updates the fail2ban setup

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-15 08:45:13 +00:00
silverwind
f547b27347
Fix markdown checkboxes on Blink (#13988)
Blink still requires a vendor prefix for `mask-image` and `mask-size`,
so add that here to fix the rendering.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-15 02:00:41 -05:00
Cirno the Strongest
27d0a5554f
Hide command line instructions when merge form is visible (#13956)
* Hide commandline instructions when merge form is visible

* As per @silverwind

Co-authored-by: zeripath <art27@cantab.net>
2020-12-15 01:09:24 -05:00
zeripath
c3fc190372
Trim the branch prefix from action.GetBranch (#13981)
* Trim the branch prefix from action.GetBranch

 #13882 has revealed that the refname of an action is actually only a
refname pattern and necessarily a branch. For examplem pushing to
refs/heads/master will result in action with refname refs/heads/master
but pushing to master will result in a refname master.

The simplest solution to providing a fix here is to trim the prefix
therefore this PR proposes this.

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

* Update models/action.go

Co-authored-by: a1012112796 <1012112796@qq.com>

Co-authored-by: a1012112796 <1012112796@qq.com>
2020-12-14 19:08:37 +02:00
Rakshith Ravi
729f0f5f7b
Add emoji in label to project boards (#13978)
* Update view.tmpl

Added rendering of emoji to project label

* Add RenderEmojiPlain to the title and remove has-emoji

Co-authored-by: zeripath <art27@cantab.net>
2020-12-14 11:06:58 +01:00
Cirno the Strongest
633dc80077
Do not display org avatar near icon for internal repos (#13957)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-12-13 16:51:15 -05:00
bobemoe
b35c1b5784
add thumbnail preview section to issue attachments (#13826)
* add thumbnail preview section to attachments

* dont show thumbnail if the image is already shown inline

* update router to pass the `content` to the attachemnts template

* limit attachment preview height to 150px (same as width)

* remove unused css (referance removed in https://github.com/go-gitea/gitea/pull/11141/files#diff-9faae32445ed9673de2830c9fc35e93f44487f0a0068202988adaf00a5bac850L66 )

* dont show divider after edit if no attachemnts

Co-authored-by: James <inbox.dev@jhodges.co.uk>
Co-authored-by: 6543 <6543@obermui.de>
2020-12-13 21:12:27 +02:00
zeripath
825efa2605
[API] Add Ref to Issue (#13946)
* Add Ref to api.Issue

This PR adds Ref to api.Issue and adds the backend parts to the migrator.

Fix #13918

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-13 11:34:11 +00:00
GiteaBot
cf6f8b22ca [skip ci] Updated translations via Crowdin 2020-12-13 02:49:02 +00:00
WeebDataHoarder
de0986d782
Removes dangling < on emails/list.tmpl (#13970)
This dangling character was leftover from commit c85bb62635 from PR #13860
2020-12-13 10:48:03 +08:00
GiteaBot
de06ee6a30 [skip ci] Updated translations via Crowdin 2020-12-13 01:06:57 +00:00
silverwind
41e8b834af
Markdown task list improvements (#13952)
* Markdown task list improvements

- Remove `.ui` class and wrappers to prevent fomantic from messing with it.
- Change rendered HTML to match GitHub.
- Add custom styling for the checkboxes.

* fix unittest

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-13 09:05:50 +08:00
zeripath
287b594803
Whenever the password is updated ensure that the hash algorithm is too (#13966)
`user.HashPassword` may potentially - and in fact now likely does - change
the `passwd_hash_algo` therefore whenever the `passwd` is updated, this
also needs to be updated.

Fix #13832

Thanks @fblaese for the hint

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-12 19:59:49 +01:00
GiteaBot
d07b8a75d7 [skip ci] Updated translations via Crowdin 2020-12-12 15:34:20 +00:00
Lunny Xiao
9f100a45c6
Possible fix the webhook API creation (#13960)
* Possible fix the webhook API creation

* Fix api create webhook bug
2020-12-12 16:33:19 +01:00
Cirno the Strongest
6074e13c8d
Fix missing username on dashboard context switch navbar (#13959) 2020-12-12 14:10:20 +01:00
GiteaBot
f8e9a3df40 [skip ci] Updated translations via Crowdin 2020-12-12 11:21:18 +00:00
zeripath
f9c0737a86
Enforce setting HEAD in wiki to master (#13950)
The default branch in wikis must be master - therefore forcibly set the HEAD
to master.

Fix #13846

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

Co-authored-by: 6543 <6543@obermui.de>
2020-12-12 12:20:14 +01:00
silverwind
1837e647eb
Diff stat improvements (#13954)
* Diff stat improvements

- Combine number to just total number of changes
- Add tooltip over stats bar
- Increase contrast on file name
- Refactor classes and CSS to be more reusable

* misc tweaks

* make count bold
2020-12-12 02:06:22 +01:00
6543
3285babcae
Update github.com/blevesearch/bleve v1.0.13 -> v1.0.14 (#13947) 2020-12-12 01:16:53 +01:00
zeripath
e46a638e8f
Report permissions denied in internal SSH (#13953)
This PR standardizes reporting of permission denied from the internal ssh.

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

Co-authored-by: 6543 <6543@obermui.de>
2020-12-11 23:52:38 +01:00
zeripath
8e0548ed4a
Ensure that HEAD is updated to match default branch in template generation (#13948)
Fix #13912

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-11 22:41:59 +01:00
zeripath
f2f99a7d0c
Ensure that pusher is not nil preventing panic in push (#13945)
PR #13381 refactored notification actions to call NotifyCreateRef and
NotifyDeleteRef in a slightly different manner. This leads to the pusher
not being set before the call.

This PR ensures that the pusher is updated before the call.

Fix #13940

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-12-11 18:27:00 +01:00
silverwind
160f606a15
Reorganize Chroma styles (#13934)
This moves the Chroma styles into separate files with base,light and
dark variants. Should work exactly as before.
2020-12-11 17:38:47 +01:00
GiteaBot
5fdf500ace [skip ci] Updated translations via Crowdin 2020-12-11 16:05:31 +00:00
Lunny Xiao
ea914d0f7a
Fix bug for webhook and feishu caused by API changed (#13937)
* Fix bug for webhook

* Fix bug for feishu
2020-12-11 17:04:04 +01:00
dependabot[bot]
b35546631e
Bump ini from 1.3.5 to 1.3.7 (#13941)
Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.7.
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](https://github.com/isaacs/ini/compare/v1.3.5...v1.3.7)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-12-11 15:56:57 +01:00
Gary Wang
c11cf4bb39
chore: use octicon-mirror for feeds display (#13928)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-10 18:06:45 -05:00
silverwind
d0043ffb7f
Better vertical align of buttons in headers (#13932)
The previous method used `transform` which formed a CSS stacking context
which caused issues with dropdowns appearing behind other elements which
made `position: static` necessary but that again caused even more
issues.

This method achieves the same as before, but without the additional
stacking context.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-10 15:39:09 -05:00
AdamKorcz
94415f7517
Added 2 fuzzers (#13818)
* Added fuzzer

Signed-off-by: AdamKorcz <adam@adalogics.com>

* Added better fuzzer names

Signed-off-by: AdamKorcz <adam@adalogics.com>

* Moved fuzzer to /tools

* Update tools/fuzz.go

Co-authored-by: 6543 <6543@obermui.de>

* Update tools/fuzz.go

* Update tools/fuzz.go

Co-authored-by: silverwind <me@silverwind.io>

* Added tools to Makefile

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-12-10 20:43:11 +01:00
GiteaBot
0c5fca2d85 [skip ci] Updated translations via Crowdin 2020-12-10 16:20:32 +00:00
silverwind
1cb1fb8a2e
Remove JS globals related to timetracking and due date (#13921)
Refactor to avoid these globals. Should work exactly as before.
2020-12-10 17:19:18 +01:00
GiteaBot
bc1cf6e5d3 [skip ci] Updated translations via Crowdin 2020-12-10 05:45:12 +00:00
silverwind
ccfa40889a
Fix avatar template error on repo collaborator page (#13924)
Fixes error `template: repo/settings/collaboration:16:16: executing
"repo/settings/collaboration" at <.>: wrong type for value; expected
*models.User; got *models.Collaborator` seen on repo collaborator page.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-10 00:44:13 -05:00
GiteaBot
338bfeebe7 [skip ci] Updated translations via Crowdin 2020-12-10 04:48:55 +00:00
mrsdizzie
e63a041bb3
Move diff split code into own template file (#13919)
* Move diff split code into own template file

Separate split diff view same as unified already is. Mainly because I'm working on a separate PR with this change and merge conflicts for each change to box.tmpl are annoying and I'm worried about breaking something subtle while trying to resolve them.

* Fix error

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-09 23:47:48 -05:00
Lunny Xiao
2d71cdb668
Add pull request manually merge instruction (#13840)
* add pull request command line instructions

* Add pull request manually merge instuction

* Fix styles

* Fix lint

* Move inline style to class file

* add space between merge button and hint text

* Add sentence end charcter

* Change the language file

* adjust secondary bg

* further adjustment

Co-authored-by: silverwind <me@silverwind.io>
2020-12-10 03:59:05 +01:00
silverwind
c85bb62635
Replace more icons with SVG, repo search tweaks (#13860)
* Replace more icons with SVG

- Replace remaining icons on admin page with SVG
- Fix vertical menu background on arc-green
- Minor improvments to frontpage repo search
- More icon replacements here and there

* fix integration

* whitespace tweak

* add comment

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-09 14:03:19 -05:00
Lunny Xiao
6edfa6bc88
Fix broken migration on webhook (#13911)
* Fix broken migration on webhook

* Fix lint

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-12-09 17:20:13 +00:00
Karl Heinz Marbaise
18e4477ad4
Add Karl Heinz Marbaise as maintainer. (#13915) 2020-12-09 09:39:14 -05:00
silverwind
48dd0e21f9
Markdown: Enable wrapping in code blocks and a color tweak (#13894)
- Enable wrapping of long lines in code blocks like already done in code
  view.
- Slightly lighten the background of code blocks on default theme
- Darken the background on inline code and kbd elements on arc-green

Co-authored-by: 6543 <6543@obermui.de>
2020-12-09 15:03:45 +01:00
Patrick Schratz
af79677a44
Reformat docs (#13897)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-12-09 07:47:06 +01:00
silverwind
97ab820acc
Fix action avatar loading (#13909)
Fixes #13883

Co-authored-by: 6543 <6543@obermui.de>
2020-12-09 07:11:15 +02:00
Jimmy Praet
10b9a6df0d
Don't show dashboard links for globally disabled repo units (#13908)
This applias the same checks from base/head_navbar.tmpl to user/dashboard/navbar.tmpl so no links are shown for globally disabled repo units

Co-authored-by: 6543 <6543@obermui.de>
2020-12-08 20:58:38 -05:00
silverwind
c05701dd7d
Fix frontpage avatars (#13853)
The frontpage uses a rather strange method to obtain the commit's avatar
which I've overlooked earlier. I don't exactly understand how it works
but this change fixes the wrong default avatars by using the function
that was in previous use.

Also introduced a few constants for size an size increase factor.

Fixes: https://github.com/go-gitea/gitea/issues/13844
2020-12-09 01:12:15 +01:00
6543
658e90a114
[Docu] Fix Location of Comments in migrations.go (#13900) 2020-12-09 00:24:23 +01:00
Jimmy Praet
1a372e5b21
Allow 20 characters for "View [organization]" button (#13906)
In the "View [organization]" button on the dashboard, the organization name is currenly shortened to 10 chars.
This is a bit too limited. In all other places in the code the name is also shortened to 20 instead of 10.

Co-authored-by: 6543 <6543@obermui.de>
2020-12-08 16:18:02 -05:00
Lunny Xiao
6a370363d4
log error when login failed (#13903)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-08 21:37:47 +01:00
Eric Lesiuta
abb9cffe4a
Log IP on SSH authentication failure for Built-in SSH server (#13150)
* Log IP on SSH authentication failure

fixes https://github.com/go-gitea/gitea/issues/13094

* include string 'Failed authentication attempt' in error

* update fail2ban docs

also match failed authentication over command line

* better logging of authentication errors with IP addresses

* format ...

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2020-12-08 18:54:33 +01:00
Lunny Xiao
42354dfe45
Move webhook type from int to string (#13664)
* Move webhook type from int to string

* rename webhook_services

* finish refactor

* Fix merge

* Ignore unnecessary ci

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2020-12-08 11:41:14 +01:00
Jimmy Praet
4d66ee1f74
Fix Quote Reply button on review diff (#13830)
* Fix Quote Reply #13762

* requestAnimationFrame() instead of setTimeout()

Co-authored-by: 6543 <6543@obermui.de>
2020-12-08 07:11:27 +01:00
6543
6bdcacd73b
Added Table of Contents to long documentation pages (#13890)
* Redo #13836 with new shortcode
(https://gitea.com/gitea/theme/pulls/90)

* add Api Usage

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-07 23:52:26 -05:00
silverwind
e7938c9c44
Repo avatar fixes (#13891)
- Split up avatar rendering helpers for performance
- Fix showing repo SVG icon when no avatar is set
- Make repo SVG and avatar same size at 32px
- Fix fork line by adding vertical flexbox on repo title

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-07 23:14:28 -05:00
techknowlogick
9b22ada0a7
Self-host cloudron image for docs (#13895)
* Add cloudron image to docs itself

* rm cloudron csp

* Update from-package.en-us.md
2020-12-07 22:20:37 -05:00
silverwind
b7b5c3368d
Fix issue participants (#13893)
* Fix issue participants

* use list class for margin

* remove wrapper and don't render on zero participants

* keep whitespace

* remove participants class

* add some margin for timetracking stuff

Co-authored-by: 6543 <6543@obermui.de>
2020-12-07 22:20:12 -05:00
Lunny Xiao
ab22ab4a37
Refactor push update (#13381)
* Refactor Push update

* Remove the push_test since the function has been removed.

* Use default branch setting instead master
2020-12-08 03:23:18 +01:00
a1012112796
682f0b0460
Fix Pull Merge when tag with same name as base branch exist (#13882)
fix dst refspec error in 'Push back to upstream' when base branch have
same name with a tag.

fix #13851
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2020-12-08 02:46:50 +01:00
John Olheiser
a33db35b38
Fully qualify cloudron CSP (#13892)
* Wildcard cloudron

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Just use FQDN

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-12-07 16:17:27 -06:00
John Olheiser
991ab899ff
Add cloudron to img-src CSP (#13887)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-12-07 10:33:22 -06:00
GiteaBot
b830eca720 [skip ci] Updated translations via Crowdin 2020-12-07 12:09:02 +00:00
Eric Belhomme
6ddf881245
issue #12450: return original URL in original_url JSON field (#13885)
Co-authored-by: Gitea <gitea@fake.local>
2020-12-07 13:07:48 +01:00
Patrick Schratz
f74a094fd5
README: Add more contents to the "further information" section. (#13871) 2020-12-06 21:56:46 +08:00
silverwind
173e512700
Fix mermaid chart size (#13863)
* Fix mermaid chart size

Seems like one of the recent updates to the module unexpectedly shrunk
these charts, bring them back up to full width.

* don't stretch to full width

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-06 11:05:22 +08:00
techknowlogick
9c71c6c4a5
Add link to shop in docs (#13864)
Replaced link to code.gitea.io as that subdomain isn't meant for human consumption, but rather for our vanity go import URLs
Only replaced link for english, open to adding links for other languages if anyone is able/willing to add them
2020-12-05 17:34:29 -05:00
Lauris BH
4a510e08e4
Update go-enry dependency to v2.6.0 (#13861) 2020-12-05 13:31:18 -05:00
manuelluis
8561f26695
Fix branch/tag notifications in mirror sync (#13855)
* Fix branch/tag notifications in mirror sync

* Fix gofmt

Co-authored-by: Gitea <gitea@fake.local>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-12-05 23:13:11 +08:00
silverwind
d0d59e3730
Font weight tweaks (#13854)
Font weight 500 is not discernible from 400 on some fonts/operating
systems so push them back to previous value 600 except for
fomantic-ui elements which stay at 500.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
2020-12-05 19:00:36 +08:00
silverwind
61d6c191d5
Improve migrate page and add card CSS (#13751)
- Use original gitea logo on migrate page
- Add card styles and map colors to css vars
- Tweak migrate page, adding hover effect to cards

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-12-05 12:09:09 +02:00
Nuno Silva
1a768e547c
[Docs] fix typos and reference to structs package (#13856) 2020-12-05 00:08:46 -05:00
silverwind
d8c2c6cd59
Remove Noto Color Emoji fallback (#13838)
It's causing browser errors logged in Firefox under certain
circumstances, and I think we're better off recommending Linux users to
install a proper emoji font into their system.
2020-12-04 16:01:47 +01:00
GiteaBot
654c480c99 [skip ci] Updated translations via Crowdin 2020-12-04 11:19:46 +00:00
silverwind
bb50ab2861
Style and template tweaks (#13828)
* Style and template tweaks

- Get red and green buttons on arc green closer to base theme
- EasyMDE adjustments, toolbar and focus border
- Fix header on 404 repo page
- Tweaks to frontpage search, add 'Create Repo' button
- Fix misaligned box headers
- Fix pagination on arc-green
- Fix background and footer on explore and repo search

* better fix for header button alignment

* add label hover for reactions
2020-12-04 12:18:37 +01:00
GiteaBot
557479642d [skip ci] Updated translations via Crowdin 2020-12-04 07:34:40 +00:00
Holger Schmidt
51d70024c2
fixed and updated FAQ table of contents links (#13835)
* fixed and updated FAQ table of contents links, rewording one heading that wouldn't generate a working link

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-12-04 08:33:38 +01:00
6543
48a3bb7a32
User Settings: Ignore empty language codes & validate (#13755) 2020-12-04 08:20:30 +02:00
mrsdizzie
3512c7e40f
Fix crash in short link processor (#13839)
Fixes #13819
2020-12-04 03:01:42 +01:00
silverwind
c9effd5364
Update font stack to bootstrap's latest (#13834)
Update to latest Bootstrap font stack [1].

Should fix https://github.com/go-gitea/gitea/issues/13784.

[1] bf3c4d0b68/scss/_variables.scss (L396)

Co-authored-by: 6543 <6543@obermui.de>
2020-12-04 00:12:16 +00:00
silverwind
118aeddcd3
Fix avatar template error (#13833)
Fixes: https://github.com/go-gitea/gitea/issues/13831
2020-12-03 23:12:59 +00:00
John Olheiser
f0cc29761d
Make sure email recipients can see issue (#13820)
* Initial pass

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove over-op

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-12-03 14:25:49 -06:00
GiteaBot
5d43d2965a [skip ci] Updated translations via Crowdin 2020-12-03 18:47:16 +00:00
silverwind
9269a038a4
Direct avatar rendering (#13649)
* Direct avatar rendering

This adds new template helpers for avatar rendering which output image
elements with direct links to avatars which makes them cacheable by the
browsers.

This should be a major performance improvment for pages with many avatars.

* fix avatars of other user's profile pages

* fix top border on user avatar name

* uncircle avatars

* remove old incomplete avatar selector

* use title attribute for name and add it back on blame

* minor refactor

* tweak comments

* fix url path join and adjust test to new result

* dedupe functions
2020-12-03 19:46:11 +01:00
silverwind
0d35ef5b43
Fix various CSS issues (#13769)
- Fix black text being white on base theme
- Fix file/blame button group
- Fix label margin in dropdown (regression from graph pr)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-03 18:05:35 +01:00
Jimmy Praet
47e4d1a4e2
Reply button is not removed when deleting a code review comment (#13774)
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
2020-12-03 17:05:27 +02:00
6543
4353cf96c0
Move LFSLock APIFormat into convert package (#13808) 2020-12-03 16:05:48 +02:00
John Olheiser
e306c292ac
Expose default theme in meta and API (#13809)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: 6543 <6543@obermui.de>
2020-12-03 13:53:21 +01:00
Jimmy Praet
056b8f5b52
Clickable links in pull request (and issue) titles (#13695)
* clickable links in pull request (and issue) titles #13658

reuses the existing logic to render clickable links in commit messages

* dedicated RenderIssueTitle function

applied patch from @mrsdizzie
2020-12-03 11:50:47 +01:00
silverwind
18712eab79
Reduce make verbosity (#13803)
Various make targets log huge lists of files to the terminal which are
generally useless to read. Replace those cases with short replacement
messages.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-03 09:54:30 +08:00
zeripath
5e0a3784ea
When reinitialising DBConfig reset the database use flags (#13796)
One perennial issue is users running the install page,
changing the database dialect and then suffering with issues

This PR simply resets all of the database.Use flags on
initDBConfig. This should prevent this issue from occuring.

Fix #13788
Fix #5480

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-02 19:39:48 -05:00
Patrick Schratz
c3893a8bd1
Update docker ssh passthrough docs (#13732)
* update docker ssh passthrough docs

* remove mailto:git part in SSH forwarding call

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-02 18:23:54 -05:00
6543
7ac8a770e1
Move Repo APIFormat to convert package (#13787)
* Move Repo APIFormat to convert package

* tweek
2020-12-02 16:38:30 -05:00
6543
2b4a08e962
Migrations: Use Process Manager to create own Context (#13792) 2020-12-02 18:36:06 +00:00
techknowlogick
fd1c3519c3
frontport 1.13.0 changelog (#13790) 2020-12-02 11:39:22 -05:00
6543
594cc4aa2a
Update Gitea Version & Fix Migration Comments (#13789)
* correct migration version comments

* update lates version in docs
2020-12-03 00:04:19 +08:00
6543
4f5ff1ef08
move notification APIFormat (#13783) 2020-12-02 09:24:35 +00:00
zeripath
4569339a4b
Refactor doctor (#12264)
* Refactor Logger

Refactor Logger to make a logger interface and make it possible to
wrap loggers for specific purposes.

* Refactor Doctor

    Move the gitea doctor functions into its own module.
    Use a logger for its messages instead of returning a results string[]

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

* Update modules/doctor/misc.go

Co-authored-by: 6543 <6543@obermui.de>

* Update modules/doctor/misc.go

Co-authored-by: 6543 <6543@obermui.de>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-12-02 06:56:04 +02:00
silverwind
253add883d
Swap swagger-ui with swagger-ui-dist (#13777)
* Swap swagger-ui with swagger-ui-dist

The prebuilt version of swagger-ui is identical to the regular one but
brings the benefit of faster webpack compilation and less npm
dependencies so it npm installs will speed up too.

* use bundle file directly
2020-12-01 20:18:39 -05:00
silverwind
b1cf7f4df1
Add class to page content to unify top margin (#13766)
* Add class to page content to unify top margin

Previously pages would individually set this margin but some didn't so
content would stick to the header without any space. Resolve this by
adding a new class that is added on all pages. The only place where we
remove this margin again is on the pages with menu or wrapper in the
header.

* fix admin notices

* fix team pages

* fix loading segment on gitgraph for arc-green

* fix last missing case

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-30 23:00:14 -05:00
silverwind
14e8ef9ecb
Flip RUN_MODE detection in router (#13768)
Missed that part in https://github.com/go-gitea/gitea/pull/13765. It's
already in the 1.13 backport so this forward-ports that change again.
2020-12-01 09:54:44 +08:00
silverwind
bc455ed257
Set RUN_MODE prod by default (#13765)
I think it's a bad default to have "dev" as the default run mode which
enables debugging and now also disables HTTP caching. It's better to
just default to a value suitable for general deployments.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-30 14:52:04 -05:00
Jeremie Deray
870fd53320
set git-core paths in snap (#13711)
Signed-off-by: artivis <deray.jeremie@gmail.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-30 13:49:11 -05:00
silverwind
21cf205dc7
Fix bogus http requests on diffs (#13760)
The .blob-excerpt elements don't have these data attributes in some
cases resulting in bogus http request when expanding a diff and clicking
into the expanded area. This prevents those.

Should backport to 1.13.

Fixes: https://github.com/go-gitea/gitea/issues/13759
2020-11-30 12:47:01 -05:00
Cirno the Strongest
d7ab72681d
Fix avatar offset on PR/issue timeline view (#13753)
* Fix avatar offset on PR/issue timeline view

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
2020-11-30 18:11:17 +02:00
silverwind
63aeb0a859
Fix webpack build warnings (#13752)
Turns out some of the dependencies make use of optional dependencies
like the vue-template-compiler. Install them again and install
fomantic-ui only when it's being build to fix webpack warnings.
2020-11-30 01:16:04 +02:00
silverwind
e81edc02b9
Update JS dependencies and misc tweaks (#13741)
* Update JS dependencies and misc tweaks

- Update all JS dependencies minus webpack
- Adapt CodeMirrors styling to new CSS parent introduced by EasyMDE
- Set eslint parser to latest and add new eslint 7.14 rule
- Speed up npm install by disabling audit and fund checks
- Move fomantic-ui to optional dependencies to further speed up npm
- Enable syntax highlighting on GH for .eslintrc and .stylelintrc
- Makefile cleanups

* disable audit in npmrc

* add missing dash

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-29 16:39:36 -05:00
6543
c4deb97ed1
[Vendor] Update Batch 2020-11 (#13746)
* github.com/alecthomas/chroma v0.8.1 -> v0.8.2

Changelog: https://github.com/alecthomas/chroma/releases/tag/v0.8.2

* github.com/blevesearch/bleve v1.0.12 -> v1.0.13

Changelog: https://github.com/blevesearch/bleve/releases/tag/v1.0.13

* github.com/editorconfig/editorconfig-core-go v2.3.8 -> v2.3.9

Changelog: https://github.com/editorconfig/editorconfig-core-go/releases/tag/v2.3.9

* github.com/klauspost/compress v1.11.2 -> v1.11.3

Changelog: https://github.com/klauspost/compress/releases/tag/v1.11.3

* github.com/minio/minio-go v7.0.5 -> v7.0.6

Changelog: https://github.com/minio/minio-go/releases/tag/v7.0.6

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-29 15:54:08 -05:00
hana
e8a6c425ec
Update discord domain (#13747)
Update discord domain in webhook repository settings.
2020-11-29 18:33:33 +01:00
GiteaBot
c2ac1c73f2 [skip ci] Updated translations via Crowdin 2020-11-29 15:53:10 +00:00
silverwind
295fc99607
Markdown and Repo header tweaks (#13744)
* Markdown and Repo header tweaks

- Use CSS vars for all markdown colors
- Tweak repo header, removing double borders and adjust sizes
- Use menu instead of buttons for issue open/close switcher
- Add emoji inversion for select emoji glyphs in arc-green
- Use border over box-shadow for all buttons
- Add spacing element to login form without openid

* repo settings navbar fix

* use shared template in more places and adjust dashboard

* fix remaining open/close combos
2020-11-29 17:52:11 +02:00
silverwind
e00a355427
Dropdowns, Labels fixes and more CSS tweaks (#13733)
* Dropdowns and Labels fixes

- Rework dropdown, menu and label styles
- Improve issue sidebar milestone and label sections
- Fix archived repo and private org badge
- Move more colors to CSS vars
- Move issue number to end of title on issue page

* more dropdown fixes

* fix basic blue labels - fixes #13731

* improve class setting on svg

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-29 01:22:04 -05:00
silverwind
da4bb6fc4e
Fix label styles affecting shabox (#13734)
* Fix label styles affecting shabox

Add common parent .labels-list to issue labels lists to prevent
affecting other elements.

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

* Update templates/shared/issuelist.tmpl

* Update templates/shared/issuelist.tmpl

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-28 22:26:03 -05:00
6543
b2435af9be
Add Allow-/Block-List for Migrate & Mirrors (#13610)
* add black list and white list support for migrating repositories

* fix fmt

* fix lint

* fix vendor

* fix modules.txt

* clean diff

* specify log message

* use blocklist/allowlist

* allways use lowercase to match url

* Apply allow/block

* Settings: use existing "migrations" section

* convert domains lower case

* dont store unused value

* Block private addresses for migration by default

* fix lint

* use proposed-upstream func to detect private IP addr

* a nit

* add own error for blocked migration, add tests, imprufe api

* fix test

* fix-if-localhost-is-ipv4

* rename error & error message

* rename setting options

* Apply suggestions from code review

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-28 19:37:58 -05:00
6543
0f14f69e60
Verify password for local-account activation (#13631)
* Verify passwords for activation

This is to prevent 3rd party activation

* Fix function comment

* only veify password on local-account aktivation

* fix lint

* Update templates/user/auth/activate.tmpl

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: Andreas Shimokawa <shimokawa@fsfe.org>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-28 17:41:06 -05:00
silverwind
e82150d41b
Reduce number of docker pulls on ci (#13739)
Should reduce errors like https://drone.gitea.io/go-gitea/gitea/32989/7/2
by only pulling each distinct image once per pipeline.

Co-authored-by: zeripath <art27@cantab.net>
2020-11-28 16:59:05 -05:00
GiteaBot
4f82a0b12e [skip ci] Updated translations via Crowdin 2020-11-28 21:01:53 +00:00
zeripath
911d370dad
Push HEAD instead of master when initialising repositories (#13719)
* Push HEAD instead of master when initialising repositories

It is possible on modern gits to change the initial branch to something other than
master. This breaks initialising repositories because we assume that the initial
branch is going to be master unless specifically changed.

This PR simply bypasses this issue by pushing the HEAD rather than the master branch.

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

* Update modules/repository/init.go

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-28 16:00:38 -05:00
a1012112796
9c26dc1f3a
Add block on official review requests branch protection (#13705)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-28 21:30:46 +02:00
silverwind
7ed5bf8cbe
Fix .editorconfig (#13735)
These whitespaces introduced in #13698 seem to break my editorconfig
plugin in sublime text resulting in tab-indented files getting converted
to spaces on save.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-28 20:29:46 +02:00
Simon
8c996c6505
Fix missing stylesheets on installation page (#13736)
When running gitea for the first time, the stylesheets for the
installation page are broken since the middleware that statically serves
stylesheets does not get executed by chi. This is because if no handlers
are registered in chi, it will drop all middleware.

This commit introduces a "dummy" handler to deal with that quirk.

Closes #13725

Thanks: Lunny Xiao <xiaolunwen@gmail.com> for finding the quirk

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-28 19:52:30 +02:00
a1012112796
1e5247d424
ui: show 'owner' tag for real owner (#13689)
* ui: show 'owner' tag for real owner

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update custom/conf/app.example.ini

* simplify logic

fix logic
fix a small bug about original author

* remove system manager tag

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-28 17:52:29 +02:00
Jimmy Praet
48c9865fce
Fix review request notification issue link when external issue tracker is enabled (#13723)
The issue.HTMLURL() automatically gets converted to the expected #issue format by the post processors
2020-11-28 13:06:59 +02:00
6543
e7b47c5215
Format files (#13698)
* align "make help"

* format

* untouch build/generate-svg.js

* untouch .eslintrc

* combine editorconfig's

* rm editorconfig

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-28 01:12:22 -05:00
zeripath
742e21aeba
Handle and propagate errors when checking if paths are Dirs, Files or Exist (#13186)
* Ensure errors from IsDir propagate

* Handle errors when checking IsFile

* Handle and propagate errors from IsExist

* Update modules/templates/static.go

* Update modules/templates/static.go

* Return after ctx.ServerError

* Apply suggestions from code review

* Fix tests

The previous merge managed to break repo_form.go

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-27 21:42:08 -05:00
Jesse Laprade
5b75f17043
Fixed the log path on fail2ban page (#13726)
* Changed path from /home/git/gitea/log/gitea.log to
  /var/lib/gitea/log/gitea.log on the fail2ban page, so the log matches
  the instructions found on the following binary installation page:
  https://docs.gitea.io/en-us/install-from-binary/#create-required-directory-structure
2020-11-27 20:08:23 -05:00
silverwind
7ab3633598
Enable linting of JS inside templates (#13708)
Indentation-related rules are disabled because indent templates with
tabs but our lint rules expect spaces.

Also had to exclude a few files where using template variables in the JS
is causing syntax errors for the JS parser. I don't think there's a way
to solve this otherwise.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-28 01:01:33 +02:00
Jimmy Praet
3f13e07849
Use trashcan icon for remove review request (#13722) 2020-11-27 22:55:59 +02:00
John Olheiser
979fbe086c
Increment skip to avoid infini-loop (#13703)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-27 22:00:52 +02:00
silverwind
7bc0c8cff6
Prevent clone protocol button flash on page load (#13626)
* Prevent clone protocol button flash on page load

Previously, the saved active buttons would flash on page load because if
delay involved in JS execution. Prevent these flashes bydisabling
transitions on page load and run the script right after. It's not an
ideal solution (which would require server-side storage of user
settings like this) but I'd say better than before.

* add defer

Co-authored-by: zeripath <art27@cantab.net>
2020-11-26 22:31:09 +02:00
silverwind
b2de034278
CSS navbar and color tweaks (#13609)
* CSS and color tweaks

- Unify navbar-style menus
- Fix admin bar overlapping menu bar
- Fixes file edit comment box
- Fix double border on review box
- Fix review timeline icons

* Many fixes to new-menu and navbar layout enhancements

* misc settings fixes

* navbar tweak

* fix pr tabs

* branch tag and arc color tweaks
2020-11-26 19:33:28 +00:00
Jimmy Praet
03fa2eccbc
Use chronological commit order in default squash message (#13661) (#13696) 2020-11-25 15:08:17 -05:00
Lauris BH
57fa9b0f25
Support shortened commit SHAs in URLs (#13686)
* Support shortened commit SHAs in URLs and API

* Add test case for short sha

* Fix format

* Revert API support

* Add canonical link headers for short commit ID URLs
2020-11-25 15:07:39 -05:00
GiteaBot
72e62ac12b [skip ci] Updated translations via Crowdin 2020-11-25 11:21:50 +00:00
silverwind
6d93a3ab18
Issue and Pulls lists rework (#13594)
* Issue and Pulls lists rework

Reorganized and restyled the issue and pull request lists.

* color and layout tweaks

* use new issue list on dashboard as well

* move pagination into template

* misc tweaks

* fix label hover

* fix milestone list

* fix discrepancies between issue and milestone list, add new 'merge' helper

* fmt

* simplify merge helper

* remove whitespace

* fix startIndex

* further simplify dict merging

* rename helper to 'mergeinto' for clarity

* allow bottom-row to wrap

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-25 13:20:40 +02:00
silverwind
00ec651270
CSS table fixes (#13692)
* CSS table fixes

Override the right fomantic selectors.

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

* use flexbox
2020-11-24 21:27:10 +02:00
silverwind
24330f71b6
Fix heatmap rendering in Chrome and Safari (#13645)
* Fix heatmap rendering in Chrome and Safari

Apparently SVG inside flexbox renders slightly different across browsers
where Firefox would stretch to fit the parent while Chrome and safari
wouldn't. Stretch the SVG to the width of the parent for consistent
rendering.

Also did a few minor tweaks on the min-height of the box so it takes up
less space on smaller responsive breakpoints.

Fixes: https://github.com/go-gitea/gitea/issues/13634
Fixes: https://github.com/go-gitea/gitea/pull/13637

* position tweak

Co-authored-by: zeripath <art27@cantab.net>
2020-11-23 17:41:09 -05:00
6543
f88a2eae97
[API] Add more filters to issues search (#13514)
* Add time filter for issue search

* Add limit option for paggination

* Add Filter for: Created by User, Assigned to User, Mentioning User

* update swagger

* Add Tests for limit, before & since
2020-11-23 20:49:36 +00:00
Cirno the Strongest
78204a7a71
Update _repository.less (#13672)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-23 11:42:24 +02:00
Kevin Zúñiga
247ab6a922
Send error message when CSRF token is missing (#13676) 2020-11-23 07:56:04 +00:00
Jimmy Praet
2791cc139e
Don't show a dropdown menu when only 1 merge option is available (#13660) (#13670) 2020-11-22 15:58:12 +02:00
GiteaBot
de1e4b2da9 [skip ci] Updated translations via Crowdin 2020-11-21 22:42:26 +00:00
zeripath
45ca2e4605
Handle incomplete diff files properly (#13662)
* Handle incomplete diff files properly

The code for parsing diff hunks has a bug whereby a very long line
in a very long diff would not be completely read leading to an unexpected
character.

This PR ensures that the line is completely cleared

Fix #13602

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

* Also allow git max line length <4096

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

* Add test case

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-21 17:41:24 -05:00
Norwin
b651409c0a
Improve strings (#13548)
* Correct oauth signup title

When linking accounts, a password is not required anymore,
so this string becomes confusing

* string "remenber me": be more precise

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-20 22:32:27 -05:00
Lunny Xiao
c5f6f8f2f1
Refactor combine label comments with tests (#13619)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-20 17:29:09 -05:00
6543
f915161a2f
skip email validation on empty string (#13627)
- move validation into its own function
- use a session for UpdateUserSetting
2020-11-20 23:45:55 +02:00
6543
1bb5c09b5d
API: Admin EditUser: Make FullName, Email, Website & Location optional (#13562)
* API: Admin EditUser: Make FullName, Email, Website & Location optional

* update swagger docs

* add Tests

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-19 20:56:42 -05:00
6543
24b3b2140a
finaly fix gitlab migration with subdir 2.0 (#13646)
* final fix 2.0?

* ignore Approvals for pulls if not found

* CI.restart()

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-20 01:18:34 +02:00
Karl Heinz Marbaise
702e82d162
Fix issue/pull request list assignee filter (#13647)
* Fixes #13641 - Filtering in Pull Request kept all the time.
 - The URL contains all the time the assignee in cases
   where once a type has been selected.

Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>

* Followup Fixes #13641 - Filtering in Pull Request kept all the time.
 - The URL contains all the time the assignee in cases
   where once a type has been selected.
 - The same behaviour was observed issues viewed via milestones.

Signed-off-by: Karl Heinz Marbaise <kama@soebes.de>
2020-11-19 15:39:55 -06:00
techknowlogick
64bd5f4c66
specific version in docker compose (#13644)
* specific version in docker compose

fix #13643

* update latest version
2020-11-19 11:36:48 -05:00
6543
ad2a288622
finaly fix gitlab migration with subdir (#13629)
* finaly fix #13535

* add logging
2020-11-19 00:17:56 -05:00
GiteaBot
6626a048df [skip ci] Updated translations via Crowdin 2020-11-18 22:01:29 +00:00
silverwind
12c2efb45c
Remove fetch request from heatmap (#13623)
* Remove fetch request from heatmap

Render heatmap data directly to HTML, eliminating one HTTP request on
frontpage and user profile. Also added min-height to the container so
the page content will no longer move after loading.

* rename and error display

* also log the js error

* add error handler

* remove useless inline style and hide divider on small screens

* Update routers/user/home.go

* Update routers/user/profile.go
2020-11-18 16:00:16 -06:00
6543
d02c3508e6
Config lock bot (#13624)
* config lock bot

* Update .github/lock.yml
2020-11-18 14:42:31 -05:00
Lunny Xiao
5a991ec519
Fix a bug when check if owner is active (#13612) 2020-11-18 11:58:25 +02:00
gsilvan
76cdf3b7af
Docs: Installation from package (#13607)
* add Arch Linux

* add Arch Linux ARM

* remove Debian

There is no package in any of Debian's official repositories as of 17.11.2020 17:55 UTC.

* shrink Alpine Linux

* Update docs/content/doc/installation/from-package.en-us.md

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-11-18 01:51:22 +02:00
silverwind
0615b668dc
HTTP cache rework and enable caching for storage assets (#13569)
This enabled HTTP time-based cache for storage assets, primarily
avatars. I have not observed If-Modified-Since from browsers during
tests but I guess it's good to support regardless.

It introduces a new generic httpcache module that can handle both
time-based and etag-based caching.

Additionally, manifest.json and robots.txt are now also cachable.
2020-11-17 17:44:52 -05:00
Lunny Xiao
9ec5e6c40b
Move metrics from macaron to chi (#13601) 2020-11-17 15:50:06 -05:00
Norwin
75ebf7c5bd
fix media query edge case (#13546)
* fix media query edge case

was failing for 768px width before

* code review

* define responsive breakpoints as less variables

* add missing variables.less

* rename variables, drop screen constraints

* fix less import

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

* code review

altough it doesnt matter, LESS lazy evals variables

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-17 00:33:19 -05:00
silverwind
b83825253e
Fix label display on new issues (#13590)
* Fix label display on new issues

PR #13570 broke label rendering for new issues and pulls because
missed the fact that the code was relying on the DOM elements being
toggled by JavaScript.

On top of that, the label rendering for new issues and pull was using
an outdated template which I consolidated in a new shared template.

* remove wrapper element and style tweaks

* style tweaks

* use shared template for whole label list

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-17 07:02:41 +02:00
silverwind
0a6ce3eaf1
Change markdown font weight to 600 (#13584)
Previously it was reduced globally from 700 to 500 but it actually needs
to be 600 to match GitHub's rendering.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2020-11-16 22:33:18 -05:00
silverwind
949e3f53f6
Fix Fomatic Build (#13595)
Port of #13593 to 1.14
2020-11-16 18:00:59 -05:00
GiteaBot
859e3d3db6 [skip ci] Updated translations via Crowdin 2020-11-16 19:23:56 +00:00
6543
77aa742528
Migration: Gitlab: Support Subdirectory (#13563)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-16 21:22:49 +02:00
silverwind
5bd05331ce
Fix comment triangles and tweak inline comment margins (#13554)
- Fix various miscolored comment bubble triangles
- Tweak padding on inline comment boxes
2020-11-16 21:53:04 +08:00
Lunny Xiao
586bfb9f32
Use mount but not register for chi routes (#13555)
* Use mount but not register for chi routes

* Fix test

* Fix test

* Fix test

* Fix comment

* turn back unnecessary change

* Remove the timout middleware since some operations may spend much time.
2020-11-16 15:33:41 +08:00
Lauris BH
8c2b5feeae
When building rootless docker image move chown&chmod to build stage (#13578)
* When building rootless docker image move chown&chmod to build stage

Fixes #13577

* Fix command newlines

* Move chown to COPY command

* Seems to be working also without chmod

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-15 20:44:41 -05:00
Dmitry Doroshev
22a8df3405
Add tab-size support for Firefox (#13576)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-15 20:08:43 -05:00
silverwind
efcba9b011
Render diff stats server-side (#13579)
Eliminates a flash on page load on the diff stat bars.
2020-11-15 23:50:06 +00:00
silverwind
0de546009e
CSS color variables, less bold font weight and more (#13567)
* CSS color variables, less bold font weight

- Define color variables for fully saturated colors and apply them where
  it made sense
- Add background color helper classes
- Globally reduce bold font weight from 700 to 500
- Remove border from timeline icons
- Unify dropzone styling
- Various border style consolidations

* attempt to fix test

* another attempt at tests

* fix contains
2020-11-15 15:58:16 -05:00
silverwind
7a30e97002
Enable syntax highlighting for *.tmpl on GitHub (#13571)
Go templates are syntactically very similar to handlebars, this enabled
their syntax highlighting on GitHub.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-15 14:34:06 -05:00
silverwind
50cbb20481
Fix issue label rendering (#13570)
* Fix issue label rendering

Prevent rendering of inactive labels and make them wrap inline.

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

* also don't render the placeholder

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-15 13:11:58 -05:00
GiteaBot
f0ed71251e [skip ci] Updated translations via Crowdin 2020-11-15 16:29:08 +00:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
3ea237b333
Add markdown support in organization description (#13549)
Similarly to how you can write some markdown in user profile description, you can now use the same feature in organization description.
As discussed in discord.
kudos to @mrsdizzie and @zeripath 

visualization:
![image](https://user-images.githubusercontent.com/61180606/99115919-8004a200-25f3-11eb-8bbd-ab33de2cabb3.png)
2020-11-15 16:28:08 +00:00
Chris Shyi
d025d84d91
Add email validity check (#13475)
* Improve error feedback for duplicate deploy keys

Instead of a generic HTTP 500 error page, a flash message is rendered
with the deploy key page template so inform the user that a key with the
intended title already exists.

* API returns 422 error when key with name exists

* Add email validity checking

Add email validity checking for the following routes:
[Web interface]
1. User registration
2. User creation by admin
3. Adding an email through user settings
[API]
1. POST /admin/users
2. PATCH /admin/users/:username
3. POST /user/emails

* Add further tests

* Add signup email tests

* Add email validity check for linking existing account

* Address PR comments

* Remove unneeded DB session

* Move email check to updateUser

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-14 11:53:43 -05:00
6543
7d2700c8be
[API] Only Return Json (#13511)
* Let Branch and Raw Endpoint return json error if not found

* Revert "RM RepoRefByTypeForAPI and move needed parts into GetRawFile directly"

This reverts commit d826d08577b23765cb3c257e7a861191d1aa9a04.

* more similar to RepoRefByType

* dedub-code

* API should just speak JSON

* nice name

Co-authored-by: zeripath <art27@cantab.net>
2020-11-14 11:13:55 -05:00
6543
3f3447a1ea
API: Fix GetQueryBeforeSince (#13559) 2020-11-14 14:05:40 +00:00
silverwind
374ff60465
Use monaco for the git hook editor (#13552)
Migrate git hook editor to monaco, replacing CodeMirror. Had to do a few
refactors to make the monaco instantiation generic enough to be of use.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 22:57:34 -05:00
Patrick Aljord
a2efcb6acc
missing quotes in default value slice (#13550)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 22:17:58 -05:00
Norwin
e16b0e5a90
unify layout between auth pages (#13547)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 21:46:40 -05:00
silverwind
5c76c5ce44
Fix issue label spacing and hover (#13553)
Fixes: https://github.com/go-gitea/gitea/issues/13545
Regressed by: https://github.com/go-gitea/gitea/pull/13458
2020-11-13 20:16:46 -05:00
mrsdizzie
6280af0324
Use existing analyzer module for language detection for highlighting (#13522)
* Use existing analyzer module for language detction for highlighting

Thanks @lafriks for pointing out we can reuse existing code for more reliable language detection here.

* Update modules/highlight/highlight.go

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 16:13:41 -05:00
silverwind
3cd00c33ce
Make heatmap colors more distinct (#13533)
* Make heatmap colors more distinct

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

* use opaque colors

* make first color less opaque

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 14:49:46 -05:00
Lunny Xiao
dd29ecb333
Add missed sync branch/tag webhook (#13538)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 14:12:33 -05:00
Cacciuc
a31a6e3996
proper signature validation (#13523)
$header_signature could be a typed float (start with 0e and then only numbers) and a float does equal a string when comparing with typed juggle.
eg: 0e123 != "abc" does return false, but 0e123 !== "abc" returns true.

you previously could circumvent the signature check when providing a header signature in the float format (0e...)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-13 13:28:15 -05:00
silverwind
db16275d9e
Fix blame line alignment (#13542)
We can't wrap code in blame because it's essentially two tables
side-by-side which will misalign them when one line gets larger.

Fixes: https://github.com/go-gitea/gitea/issues/13540
Regressed by: https://github.com/go-gitea/gitea/pull/13415

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-13 13:27:36 -05:00
GiteaBot
d0a676c8ff [skip ci] Updated translations via Crowdin 2020-11-13 17:24:39 +00:00
silverwind
a015684069
Reindent manifest.json (#13544)
Now it's properly indented to 2-space.
2020-11-13 12:23:22 -05:00
Lunny Xiao
c296f4fed6
Introduce go chi web framework as frontend of macaron, so that we can move routes from macaron to chi step by step (#7420)
* When route cannot be found on chi, go to macaron

* Stick chi version to 1.5.0

* Follow router log setting
2020-11-13 14:51:07 +02:00
silverwind
0ae35c66f2
Various style fixes (#13534)
* Various style fixes

- Fix the rest of the monochrome borders for arc-green
- Fix close icon position on system notice modal and padding
- Fix selectable table color for arc-green

* proper fix for close icon

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-13 09:31:25 +08:00
Lunny Xiao
ff7341b994
Prevent git operations for inactive users (#13527)
* prevent git operations for inactive users

* Some fixes

* Deny push to the repositories which's owner is inactive

* deny operations also when user is ProhibitLogin

Co-authored-by: zeripath <art27@cantab.net>
2020-11-13 01:29:11 +02:00
GiteaBot
ee7133d135 [skip ci] Updated translations via Crowdin 2020-11-12 16:00:39 +00:00
silverwind
c2e05d9f9a
Form styling adjustments (#13501)
* Form styling adjustments

- Move all form-related styling to _forms.less
- Defined new form-related variables
- Fix spinner on frontpage repo search
- Add new rounded-* helpers and fix repo search radius

* misc arc green tweaks

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-12 23:59:33 +08:00
silverwind
4117a443c2
Lazy-load issue reviewers and assignees avatars (#13526)
The avatars inside the dropdowns were previously fetched every time a
Pull Request was opened resulting in potential unnecessary downloads.
This lazy-loads through the newish loading=lazy attribute.

Also did a few minor adjustments on the file.
2020-11-12 07:55:34 +02:00
GiteaBot
6838bacc4c [skip ci] Updated translations via Crowdin 2020-11-11 20:35:20 +00:00
zeripath
5d932b35ca
Disallow urlencoded new lines in git protocol paths if there is a port (#13521)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-11-11 20:34:16 +00:00
zeripath
3fd060eb37
Include OriginalAuthor in Reaction constraint (#13505)
When migrating repositories with reactions with deleted users, the original
author id may be -1. This means that it is possible to end up attempting
to create multiple reactions with the same [ Type, IssueID, CommentID, UserID,
OriginalAuthorID ] thus breaking the constraints.

On SQLite this appears to cause a deadlock but on other dbs this will
cause the migration to fail.

This PR extends the constraint to include the original author username
in the constraint.

Fix #13271

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-11-10 22:37:11 +00:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
3400928f7a
fix: issue tracker link redirection (#13504)
kudos to @zeripath
* in case there is a remote issue tracker configured, the git graph view
  PR and issue links now correctly point to the issue tracker location,
  whereas if literally pointing at 'pulls', you could have ended up back
  at the local instance after clicking the link (which, obviously haven't
  had the pull/issue)

Signed-off-by: wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf <a_mirre@utb.cz>
2020-11-10 23:27:11 +02:00
silverwind
da4f2c5979
Make heatmap shades linear (#13500)
Previously, shades were 50%, 60%, 70%, 80%, 100%. Make them linearily
increasing instead at 60%, 70%, 80%, 90%, 100%.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-10 14:51:58 -05:00
zeripath
13b8c0b7ae
Switch from SimpleMDE to EasyMDE (#13333)
* Switch from SimpleMDE to EasyMDE

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

* use webpack to webpack the easymde css

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

* move css to only css

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

* move loading codemirror modes and addons back in to footer.tmpl

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

* Fix arc-green

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

* as per @silverwind

* reinstall codemirror

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-10 14:16:30 -05:00
silverwind
21d496364a
Fix tooltips and issue dependency styles (#13458)
- Convert all tooltips to JS-based ones, fixing overflow issues
- Restyle issue dependencies/dependants
- Move popup styles to base style
- CSS Helper tweaks
- Unify pseudo element selectors and lint for it

Fixes: https://github.com/go-gitea/gitea/issues/13400
2020-11-10 20:28:07 +02:00
GiteaBot
9155f13bf8 [skip ci] Updated translations via Crowdin 2020-11-10 11:45:51 +00:00
Lunny Xiao
542edc22c4
Some improvements for v156 (#13497) 2020-11-10 13:44:45 +02:00
Mohammad Hadi Hosseinpour
beab1dd337
Added title and action buttons to Project view page (#13437)
* Added title and action buttons to Project view page

* Changed octicon for project close action

* Fix indentation in templates/repo/projects/view.tmpl

Co-authored-by: zeripath <art27@cantab.net>

* Fix indentation templates/repo/projects/view.tmpl (2nd)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-11-09 22:46:19 -05:00
zeripath
182b5a08ed
Prevent panic on git blame by limiting lines to 4096 bytes at most (#13470)
Fix #12440
Closes #13192

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-09 21:14:02 -05:00
Cirno the Strongest
40c4466641
Fix broken .comment > .content caused by #13457 (#13482)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-09 20:43:08 -05:00
zeripath
77e5081a2e
Fix panic bug in handling multiple references in commit (#13486)
* Fix panic bug in handling multiple references in commit

The issue lay in determining the position of matches on a second run round
a commit message in FindAllIssueReferences.

Fix #13483

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

* Extract function and make testable

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

* Fix the comment

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

* cleaning up the comments a bit more

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-11-10 00:57:47 +02:00
GiteaBot
ffa712e783 [skip ci] Updated translations via Crowdin 2020-11-09 18:22:53 +00:00
silverwind
8bae34c4b2
Change search and filter icons to SVG (#13473)
Unfortunately, the Fomantic CSS relies on i.icon instead of .icon so a
wrapper is necessary for these with an accompanying class to center the
icon.
2020-11-09 18:21:47 +00:00
GiteaBot
ef2ffc6aed [skip ci] Updated translations via Crowdin 2020-11-09 06:16:15 +00:00
zeripath
b091c994b5
Comments on review should have the same sha (#13448)
* When replying to an outdated comment it should not appear on the files page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

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

* fix test

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

* Fix broken migration

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

* fix mssql

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

* Create temporary table because ... well MSSQL ...

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

* Create temporary table because ... well MSSQL ...

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

* Create temporary table because ... well MSSQL ...

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

* fix mssql

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

* move session within the batch

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

* regen the sqlcmd each time round the loop

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

* as per @lunny

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-09 01:15:09 -05:00
Simon Legner
1213301b50
docs(comparison): GitHub Actions (#13474)
https://github.com/features/actions
2020-11-08 17:35:28 -05:00
zeripath
271ab63dfa
Make TestCreateBranch and TestRepoCommitsSearch less noisy (#13471)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-08 16:24:54 -05:00
techknowlogick
8a7101fdd3
Add note about installation on kubernetes to docs (#13469)
Co-authored-by: zeripath <art27@cantab.net>
2020-11-08 15:50:40 -05:00
zeripath
8ae5548188
2nd attempt at re-request APIMergePullRequest (#13468)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-11-08 19:23:00 +00:00
GiteaBot
004b40dad0 [skip ci] Updated translations via Crowdin 2020-11-08 18:03:03 +00:00
silverwind
049a87c402
Override fonts using Fomantic config (#13465)
Saves is from doing it manually and saves a few CSS bytes.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-08 13:01:38 -05:00
zeripath
c05a8abc76
Multiple GitGraph improvements: Exclude PR heads, Add branch/PR links, Show only certain branches, (#12766)
* Multiple GitGraph improvements.

Add backend support for excluding PRs, selecting branches and files.

Fix #10327

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

* as per @silverwind

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

* as per @silverwind

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

* Only show refs in dropdown we display on the graph

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

* as per @silverwind

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

* use flexbox for ui header

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

* Move Hide Pull Request button to the dropdown

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

* Add SHA and user pictures

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

* fix test

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

* fix test 2

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

* fixes

* async

* more tweaks

* use tabs in tmpl

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

* remove commented thing

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

* fix linting

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

* Update web_src/js/features/gitgraph.js

Co-authored-by: silverwind <me@silverwind.io>

* graph tweaks

* more tweaks

* add title

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

* fix loading indicator z-index and position

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-08 12:21:54 -05:00
GiteaBot
d4e0b28655 [skip ci] Updated translations via Crowdin 2020-11-08 16:30:44 +00:00
silverwind
8411cb567a
Fix colors and triangles in issues (#13463)
- Fix misaligned triangles
- Fix triangle and header background colors
- Adjust timeline color
2020-11-08 16:29:18 +00:00
Cirno the Strongest
f719e2e806
Fix double border introduced by #13434 (#13457)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-11-07 18:15:09 -05:00
silverwind
9aa8693e2c
Frontpage and Heatmap CSS tweaks (#13443)
* Frontpage and Heatmap CSS tweaks

- Make heatmap use primary color
- Defined secondary color shades
- Set various blue colors to CSS vars
- Misc tweaks

* remove a useless variable

* remove another useless variable

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-07 23:04:40 +02:00
Kyle Evans
e461f0854f
[RFC] Make archival asynchronous (#11296)
* Make archival asynchronous

The prime benefit being sought here is for large archives to not
clog up the rendering process and cause unsightly proxy timeouts.
As a secondary benefit, archive-in-progress is moved out of the
way into a /tmp file so that new archival requests for the same
commit will not get fulfilled based on an archive that isn't yet
finished.

This asynchronous system is fairly primitive; request comes in, we'll
spawn off a new goroutine to handle it, then we'll mark it as done.
Status requests will see if the file exists in the final location,
and report the archival as done when it exists.

Fixes #11265

* Archive links: drop initial delay to three-quarters of a second

Some, or perhaps even most, archives will not take all that long to archive.
The archive process starts as soon as the download button is initially
clicked, so in theory they could be done quite quickly.  Drop the initial
delay down to three-quarters of a second to make it more responsive in the
common case of the archive being quickly created.

* archiver: restructure a little bit to facilitate testing

This introduces two sync.Cond pointers to the archiver package. If they're
non-nil when we go to process a request, we'll wait until signalled (at all)
to proceed. The tests will then create the sync.Cond so that it can signal
at-will and sanity-check the state of the queue at different phases.

The author believes that nil-checking these two sync.Cond pointers on every
archive processing will introduce minimal overhead with no impact on
maintainability.

* gofmt nit: no space around binary + operator

* services: archiver: appease golangci-lint, lock queueMutex

Locking/unlocking the queueMutex is allowed, but not required, for
Cond.Signal() and Cond.Broadcast().  The magic at play here is just a little
too much for golangci-lint, as we take the address of queueMutex and this is
mostly used in archiver.go; the variable still gets flagged as unused.

* archiver: tests: fix several timing nits

Once we've signaled a cond var, it may take some small amount of time for
the goroutines released to hit the spot we're wanting them to be at. Give
them an appropriate amount of time.

* archiver: tests: no underscore in var name, ungh

* archiver: tests: Test* is run in a separate context than TestMain

We must setup the mutex/cond variables at the beginning of any test that's
going to use it, or else these will be nil when the test is actually ran.

* archiver: tests: hopefully final tweak

Things got shuffled around such that we carefully build up and release
requests from the queue, so we can validate the state of the queue at each
step. Fix some assertions that no longer hold true as fallout.

* repo: Download: restore some semblance of previous behavior

When archival was made async, the GET endpoint was only useful if a previous
POST had initiated the download. This commit restores the previous behavior,
to an extent; we'll now submit the archive request there and return a
"202 Accepted" to indicate that it's processing if we didn't manage to
complete the request within ~2 seconds of submission.

This lets a client directly GET the archive, and gives them some indication
that they may attempt to GET it again at a later time.

* archiver: tests: simplify a bit further

We don't need to risk failure and use time.ParseDuration to get 2 *
time.Second.

else if isn't really necessary if the conditions are simple enough and lead
to the same result.

* archiver: tests: resolve potential source of flakiness

Increase all timeouts to 10 seconds; these aren't hard-coded sleeps, so
there's no guarantee we'll actually take that long. If we need longer to
not have a false-positive, then so be it.

While here, various assert.{Not,}Equal arguments are flipped around so that
the wording in error output reflects reality, where the expected argument is
second and actual third.

* archiver: setup infrastructure for notifying consumers of completion

This API will *not* allow consumers to subscribe to specific requests being
completed, just *any* request being completed. The caller is responsible for
determining if their request is satisfied and waiting again if needed.

* repo: archive: make GET endpoint synchronous again

If the request isn't complete, this endpoint will now submit the request and
wait for completion using the new API. This may still be susceptible to
timeouts for larger repos, but other endpoints now exist that the web
interface will use to negotiate its way through larger archive processes.

* archiver: tests: amend test to include WaitForCompletion()

This is a trivial one, so go ahead and include it.

* archiver: tests: fix test by calling NewContext()

The mutex is otherwise uninitialized, so we need to ensure that we're
actually initializing it if we plan to test it.

* archiver: tests: integrate new WaitForCompletion a little better

We can use this to wait for archives to come in, rather than spinning and
hoping with a timeout.

* archiver: tests: combine numQueued declaration with next-instruction assignment

* routers: repo: reap unused archiving flag from DownloadStatus()

This had some planned usage before, indicating whether this request
initiated the archival process or not. After several rounds of refactoring,
this use was deemed not necessary for much of anything and got boiled down
to !complete in all cases.

* services: archiver: restructure to use a channel

We now offer two forms of waiting for a request:
- WaitForCompletion: wait for completion with no timeout
- TimedWaitForCompletion: wait for completion with timeout

In both cases, we wait for the given request's cchan to close; in the latter
case, we do so with the caller-provided timeout. This completely removes the
need for busy-wait loops in Download/InitiateDownload, as it's fairly clean
to wait on a channel with timeout.

* services: archiver: use defer to unlock now that we can

This previously carried the lock into the goroutine, but an intermediate
step just added the request to archiveInProgress outside of the new
goroutine and removed the need for the goroutine to start out with it.

* Revert "archiver: tests: combine numQueued declaration with next-instruction assignment"

This reverts commit bcc52140238e16680f2e05e448e9be51372afdf5.

Revert "archiver: tests: integrate new WaitForCompletion a little better"

This reverts commit 9fc8bedb5667d24d3a3c7843dc28a229efffb1e6.

Revert "archiver: tests: fix test by calling NewContext()"

This reverts commit 709c35685eaaf261ebbb7d3420e3376a4ee8e7f2.

Revert "archiver: tests: amend test to include WaitForCompletion()"

This reverts commit 75261f56bc05d1fa8ff7e81dcbc0ccd93fdc9d50.

* archiver: tests: first attempt at WaitForCompletion() tests

* archiver: tests: slight improvement, less busy-loop

Just wait for the requests to complete in order, instead of busy-waiting
with a timeout.  This is slightly less fragile.

While here, reverse the arguments of a nearby assert.Equal() so that
expected/actual are correct in any test output.

* archiver: address lint nits

* services: archiver: only close the channel once

* services: archiver: use a struct{} for the wait channel

This makes it obvious that the channel is only being used as a signal,
rather than anything useful being piped through it.

* archiver: tests: fix expectations

Move the close of the channel into doArchive() itself; notably, before these
goroutines move on to waiting on the Release cond.

The tests are adjusted to reflect that we can't WaitForCompletion() after
they've already completed, as WaitForCompletion() doesn't indicate that
they've been released from the queue yet.

* archiver: tests: set cchan to nil for comparison

* archiver: move ctx.Error's back into the route handlers

We shouldn't be setting this in a service, we should just be validating the
request that we were handed.

* services: archiver: use regex to match a hash

This makes sure we don't try and use refName as a hash when it's clearly not
one, e.g. heads/pull/foo.

* routers: repo: remove the weird /archive/status endpoint

We don't need to do this anymore, we can just continue POSTing to the
archive/* endpoint until we're told the download's complete. This avoids a
potential naming conflict, where a ref could start with "status/"

* archiver: tests: bump reasonable timeout to 15s

* archiver: tests: actually release timedReq

* archiver: tests: run through inFlight instead of manually checking

While we're here, add a test for manually re-processing an archive that's
already been complete. Re-open the channel and mark it incomplete, so that
doArchive can just mark it complete again.

* initArchiveLinks: prevent default behavior from clicking

* archiver: alias gitea's context, golang context import pending

* archiver: simplify logic, just reconstruct slices

While the previous logic was perhaps slightly more efficient, the
new variant's readability is much improved.

* archiver: don't block shutdown on waiting for archive

The technique established launches a goroutine to do the wait,
which will close a wait channel upon termination. For the timeout
case, we also send back a value indicating whether the timeout was
hit or not.

The timeouts are expected to be relatively small, but still a multi-
second delay to shutdown due to this could be unfortunate.

* archiver: simplify shutdown logic

We can just grab the shutdown channel from the graceful manager instead of
constructing a channel to halt the caller and/or pass a result back.

* Style issues

* Fix mis-merge

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-07 22:27:28 +02:00
silverwind
1b65536aa0
Update JS dependencies (#13455)
- Update all JS dependencies minus Webpack
- Add postcss again to avoid warnings about missing peerDependencies

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-07 13:44:47 -05:00
silverwind
7c47e24093
Add Vue linting (#13447)
* Add Vue linting

Turns out the .vue files were not linted at all, so I added that as well
as re-indented the file to 2-space and fixed all reasonable issues that
cam up except one case of a unintended side effect for which I have no
idea how to fix it, so the rule was disabled.

* misc tweaks

* update lockfile

* use overrides to include .vue files

* treat warnings as errors on lint-frontend

* also treat stylelint warnings as errors

* use equal sign syntax

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-07 23:11:09 +08:00
GiteaBot
ed47da2e29 [skip ci] Updated translations via Crowdin 2020-11-07 12:55:59 +00:00
Cirno the Strongest
48f8c5e1ae
Fix monospace font size for .mono CSS class (#13453) 2020-11-07 14:54:38 +02:00
a1012112796
82cf67a93e
updateSize when create a repo with init commit (#13441)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-06 23:44:08 -05:00
John Olheiser
172eca1cd3
Add docs command (#13429)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-11-07 08:32:57 +08:00
6543
30ce3731a1
Vendor Update Go Libs (#13444)
* denisenkom/go-mssqldb untagged -> v0.9.0

* github.com/editorconfig/editorconfig-core-go v2.3.7 -> v2.3.8

* github.com/go-testfixtures/testfixtures v3.4.0 -> v3.4.1

* github.com/mholt/archiver v3.3.2 -> v3.5.0

* github.com/olivere/elastic v7.0.20 -> v7.0.21

* github.com/urfave/cli v1.22.4 -> v1.22.5

* github.com/xanzy/go-gitlab v0.38.1 -> v0.39.0

* github.com/yuin/goldmark-meta untagged -> v1.0.0

* github.com/ethantkoenig/rupture 0a76f03a811a -> c3b3b810dc77

* github.com/jaytaylor/html2text 8fb95d837f7d -> 3577fbdbcff7

* github.com/kballard/go-shellquote cd60e84ee657 -> 95032a82bc51

* github.com/msteinert/pam 02ccfbfaf0cc -> 913b8f8cdf8b

* github.com/unknwon/paginater 7748a72e0141 -> 042474bd0eae

* CI.restart()

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-06 13:41:42 -05:00
silverwind
eebaa81f43
Override fomantic monospace fonts and set size (#13435)
We did not override those yet so default `monospace` was applied. Also
added a tweak to slightly reduce font size because monospace fonts
usually render slightly larger than proportional ones.

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-06 12:16:21 -05:00
techknowlogick
c178a36438
use registry mirror for docker-in-docker (#13438)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-06 02:35:10 -05:00
Lunny Xiao
35cc82abbf
Revert "Replies to outdated code comments should also be outdated (#13217)" (#13439)
This reverts commit 3cab3bee57.
2020-11-06 09:04:21 +02:00
GiteaBot
3c7908b51c [skip ci] Updated translations via Crowdin 2020-11-05 19:35:13 +00:00
silverwind
eba0ac5bf6
Rework focused comment styling (#13434)
Had to tweak a few borders to make it work properly in all cases, also
added .comment-body class to specifically target that body.
2020-11-05 21:34:04 +02:00
GiteaBot
5b636bdec7 [skip ci] Updated translations via Crowdin 2020-11-05 14:21:49 +00:00
John Olheiser
7c68ac8f7d
Tags cleanup (#13428)
* Tags cleanup

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-11-05 08:20:42 -06:00
silverwind
05efb33595
Various style tweaks (#13418)
- Change code review '+' to SVG and increase size slightly
- Set placeholder color in both themes
- Set proper font for textareas
- Fix black code in arc-green
- Various arc-green fixes
2020-11-04 20:51:17 -05:00
mrsdizzie
d7e0983780
Alternative fix for HTML diff entity split (#13425)
* Alternative fix for HTML diff entity split

This commit both reverts PR #13357 and uses the exiting implementation alredy used for spans to fix the same issue. That PR duplicates most of logic that is already present elsewhere and still was failing for some cases. This should be simpler as it uses the existing logic that already works for <span>s being split apart.

Added both test cases as well.

* Update gitdiff_test.go

* fmt

* entity can have uppercase letter, also add detailed comment per @zeripath
2020-11-04 19:35:05 -05:00
GiteaBot
dd882f6a69 [skip ci] Updated translations via Crowdin 2020-11-04 22:56:17 +00:00
zeripath
3cab3bee57
Replies to outdated code comments should also be outdated (#13217)
* When replying to an outdated comment it should not appear on the files page

This happened because the comment took the latest commitID as its base instead of the
reviewID that it was replying to.

There was also no way of creating an already outdated comment - and a
reply to a review on an outdated line should be outdated.

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

* fix test

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-04 17:55:15 -05:00
Wim
fb756e7738
Add missing full names when DEFAULT_SHOW_FULL_NAME is enabled (#13417)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-04 11:11:19 +02:00
GiteaBot
59c3cf6388 [skip ci] Updated translations via Crowdin 2020-11-04 07:15:15 +00:00
silverwind
62719cdd2d
Fix whitespace rendering in diff (#13415)
- Introduce new .code-inner class that sets the CSS attributes on
rendered code lines like view,blame and diff.
- Rename .wrap class to .word-break to reflect what it actually does
- Remove .raw which was only used on webhook page
- Set white-space: pre-wrap except on blame where it can break the
layout

Fixes: https://github.com/go-gitea/gitea/issues/13406
2020-11-04 09:14:07 +02:00
GiteaBot
951a333733 [skip ci] Updated translations via Crowdin 2020-11-03 15:49:01 +00:00
Lunny Xiao
afb3a5c1d5
Fix bug on release publisherid migrations (#13410)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-11-03 23:47:54 +08:00
GiteaBot
fa8492fb70 [skip ci] Updated translations via Crowdin 2020-11-03 11:36:19 +00:00
Viktor Suprun
7d16e6db8e
Fixed git args duplication (#13411)
Because newGit() invoked twice (inside PreInstallInit() and
GlobalInit()) and git parameters is global object, all
git commands call with duplicated args
`-c credential.helper= -c protocol.version=2`
2020-11-03 13:35:09 +02:00
GiteaBot
be880d4063 [skip ci] Updated translations via Crowdin 2020-11-03 06:05:23 +00:00
6543
70ea2300ca
[Vendor] update macaron related (#13409)
* Vendor: update gitea.com/macaron/session to a177a270

* make vendor

* Vendor: update gitea.com/macaron/macaron to 0db5d458

* make vendor

* Vendor: update gitea.com/macaron/cache to 905232fb

* make vendor

* Vendor: update gitea.com/macaron/i18n to 4ca3dd0c

* make vendor

* Vendor: update gitea.com/macaron/gzip to efa5e847

* make vendor

* Vendor: update gitea.com/macaron/captcha to e8597820

* make vendor
2020-11-03 08:04:09 +02:00
a1012112796
b687707014
Add the tag list page to the release page (#12096)
* Add the tag list page to the release page

* Add the tags list view
* Add the delete tag way on ui
* Not delete tag and clear message when delete a release

Signed-off-by: a1012112796 <1012112796@qq.com>

* Apply suggestions from code review

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* fix ui

* Add to header

* ui

* permission

* ui

* Update options/locale/locale_en-US.ini

Co-authored-by: Lauris BH <lauris@nix.lv>

* tweaks

* monospace commit hashes

* Add read permission check

* fix permission

* fix nit

* Update web_src/less/_base.less

Co-authored-by: silverwind <me@silverwind.io>

* ui fixes

* title tweaks

* fix lint

* fix test

* fix test and some ui nits

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: silverwind <me@silverwind.io>
2020-11-02 18:10:22 -05:00
Antoine GIRARD
bcb94ed589
fix docker rootless manifest (#13386) 2020-11-02 14:50:13 -05:00
silverwind
842a75776a
Refactor image paste code (#13354)
Some minor refactors I did while investigating another issue.
Functionalily should be pretty much the same as before.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-02 12:08:30 -05:00
GiteaBot
fc40cdfa89 [skip ci] Updated translations via Crowdin 2020-11-02 15:59:27 +00:00
Cirno the Strongest
7f7e7f3ca4
Fix 'add code comment' button being invisible all the time (#13389)
* Fix 'add code comment' button being invisible all the time

* Fix off-center icon

* Remove old JS hover hack

* Show on full-line hover

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-11-02 10:58:14 -05:00
Cirno the Strongest
06268dcf53
Fix reactions on code comments (#13390)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-02 10:56:02 +02:00
Antoine GIRARD
563165abe4
Remove specific indexer path (#13388)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-11-01 18:34:38 -05:00
GiteaBot
8176ba6573 [skip ci] Updated translations via Crowdin 2020-11-01 20:05:29 +00:00
silverwind
4617bb689b
Misc UI fixes, add secondary color (#13378)
* Misc UI fixes, add secondary color

- Add secondary color, primarily used in arc-green currently
- Convert icons on release page to SVG
- Improve resolved conversation placeholder
- Diff fixes on arc-green
- Misc color tweaks

* fix comment header, adjust arc-green dropzone

* label margin, sidebar margin

* flexbox commits table and add primary button styles

* tooltip styles

* file header fixes

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2020-11-01 15:04:26 -05:00
techknowlogick
543697e61e
Set auto-tag to false on rootless manifest (#13383)
Current overrides rootful container
2020-11-01 11:30:01 +00:00
Lunny Xiao
f070249df4
Fix typo (#13380) 2020-10-31 22:09:16 -04:00
Antoine GIRARD
fe458ce877
docker: rootless image (#10154)
* docker: rootless image

* improve docs + remove check for write perm on custom

* add more info on ssh passtrough

* Add comment for internal ssh server in container config
2020-10-31 20:58:22 -04:00
Antoine GIRARD
f3bbd46c49
don't append key file if asked not to (#13368) 2020-10-31 20:57:41 -04:00
silverwind
2ac112d84e
Comment box tweaks and SVG dropdown triangles (#13376)
* Comment box tweaks and SVG dropdown triangles

- Change all dropdown triangles to SVG
- Bring inline review comment box closer to regular comment boxes
- Enhance arc-green checkbox contrast
- Minor reaction tweaks
- Flexbox the diff file header

* remove a border

* fix type marker in arc-green

* add small code padding

* fix position regression and remove useless rules

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-31 18:15:11 -04:00
Lunny Xiao
e4e85a3e51
Storage configuration support [storage] (#13314)
* Fix minio bug

* Add tests for storage configuration

* Change the Seek flag to keep compitable minio?

* Fix test when first-byte-pos of all ranges is greater than the resource length

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-31 16:51:48 -04:00
GiteaBot
e7750e0f6a [skip ci] Updated translations via Crowdin 2020-10-31 17:25:33 +00:00
zeripath
6b7c199f5f
When creating line diffs do not split within an html entity (#13357)
* When creating line diffs do not split within an html entity

Fix #13342

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

* Add test case

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

* improve test

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-31 13:24:32 -04:00
Lunny Xiao
a420beda2a
Fix a bug on refactoring (#13373) 2020-10-31 23:42:54 +08:00
Antoine GIRARD
7cb22d6439
Revert "Dockerfile: Support socat use cases (#13208)" (#13369)
This reverts commit ff50274ff3.
2020-10-31 15:19:41 +02:00
silverwind
0e6bf7e4c9
Comment Header fixes (#13356)
Apply more flexboxes on comment header and remove float hacks. Needs
1.13 backport.

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-31 15:17:52 +02:00
GiteaBot
d01d39d6cf [skip ci] Updated translations via Crowdin 2020-10-31 12:18:38 +00:00
silverwind
de871f7c93
Various style fixes (#13372)
- Add alpha variants for primary color
- Make timeline items solid background color
- Fix reaction styles recently regressed
- Fix diff header and make it flexbox
- Numerous smaller fixes for arc green
2020-10-31 14:17:32 +02:00
zeripath
47dd1cb7ae
Refactor Logger (#13294)
Refactor Logger to make a logger interface and make it possible to
wrap loggers for specific purposes.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-31 01:36:46 -04:00
zeripath
ffc8ce7bae
Fix scrolling to resolved comment anchors (#13343)
* Fix scrolling to resolved comment anchors

As described on discord, when the window.location.hash refers to a
resolved comment then the scroll to functionality does not work.

This PR fixes this.

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

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-31 00:35:35 -04:00
silverwind
6c323678d0
Use CSS Vars for primary color (#13361)
* Use CSS Vars for primary color

- Create 15 color shades derived from primary color
- Change blue-ish colors to use that primary color
- Move styles for scrollbars, selection from arc-green to base
- Remove obsolete arc-green styles that now use those variables

* simplify webkit scrollbar style

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-30 23:52:10 -04:00
John Olheiser
b5e974c8a5
Delete tag API (#13358)
* Delete tag API

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Wording

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add conflict response and fix API tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix other test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-10-30 20:56:34 -05:00
GiteaBot
e16a5bb634 [skip ci] Updated translations via Crowdin 2020-10-30 22:00:02 +00:00
Lunny Xiao
4df2ed29f2
Refactor: Move PushUpdateOptions (#13363)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-10-30 22:59:02 +01:00
zeripath
dd12384f22
Fix --port setting (#13288)
* Fix --port setting

Unfortunately there was an error in #13195 which set the --port
option before the settings were read. This PR fixes this by
moving applying this option to after the the settings are read

However, on looking further into this code I believe that the setPort
code was slightly odd.

Firstly, it may make sense to run the install page on a different
temporary port to the full system and this should be possible with
a --install-port option.

Secondy, if the --port option is provided we should apply it to both
otherwise there will be unusual behaviour on graceful restart

Thirdly, the documentation for --port says that the setting is
temporary - it should therefore not save its result to the configuration

(This however, does mean that authorized_keys and internal links may
not be correct. - I think we need to discuss this option further.)

Fix #13277

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

* Update cmd/web.go

* Apply suggestions from code review

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-30 15:26:03 -04:00
silverwind
20a5eff3e8
Change repo home page icons to SVG (#13364) 2020-10-30 14:54:58 -04:00
GiteaBot
764237e78c [skip ci] Updated translations via Crowdin 2020-10-30 16:28:07 +00:00
zeripath
68bdb9fd4b
Fix links to repositories in /user/setting/repos (#13360)
* Fix links to repositories in /user/setting/repos

somehow the links gained a spurious $ in the links.

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

* And fix #13359

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-30 16:27:01 +00:00
GiteaBot
643a0a691a [skip ci] Updated translations via Crowdin 2020-10-29 21:42:52 +00:00
zeripath
5b2096dd5f
Migrations should not fail for comment reactions (#13352)
An extension to #13444 - where we now ensure that comment reaction failures do not cause migrations failure

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-29 17:41:49 -04:00
zeripath
55801cf4eb
Issue comment reactions should also check pull type (#13349)
* Migrating reactions is just not that important

A failure during migrating reactions should not cause failure of
migration.

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

* When checking issue reactions check the correct permission

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

* And there is another one ...

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-29 20:48:07 +08:00
zeripath
4b33afcd5b
Migration failure during reaction migration from gitea (#13344)
* Migrating reactions is just not that important

A failure during migrating reactions should not cause failure of
migration.

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

* When checking issue reactions check the correct permission

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-28 22:23:31 -04:00
zeripath
beb6bf4261
Remove obsolete change of email on profile page (#13341)
* Remove obsolete change of email on profile page

The change email on the account profile page is out-of-date
and unnecessary.

Changing email should be done using the account page.

Fix #13336

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-28 22:33:14 +00:00
silverwind
b64978d0bc
Fully remove fomantic-ui from frontend build dependencies (#13340)
Followup to https://github.com/go-gitea/gitea/pull/13332. Turns out I
missed this dependency which resulted in fomantic-ui being uselessly
rebuild on CI. This fully removes it from the chain so it's not
attempted to be build as part of the main build process.
2020-10-28 21:51:03 +00:00
Shikaku
008627905d
Fix command-line doc examples (#13337) 2020-10-28 20:47:51 +00:00
silverwind
946bbbe9b5
Precompile fomantic-ui files (#13332)
We rarely change fomantic-ui or its configuration so it's kind of a
waste to have it rebuild on every CI run. These changes remove the
fomantic files from the build and instead add the relevant output files
to the git index, which should shave of 2-3 minutes on every CI run.

`make fomantic` should still work and should be ran whenever fomantic is
updated or its configuration is changed.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-27 19:44:06 -04:00
zeripath
7dfb2fc176
Add migrated pulls to pull request task queue (#13331)
* Add migrated pulls to pull request task queue

Fix #13321

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

* Improve error reports

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-27 17:34:56 -04:00
Elena Neuschild
6c2c521ba5
fix quotation marks in launch.json (#13325)
Co-authored-by: zeripath <art27@cantab.net>
2020-10-27 16:58:09 -04:00
GiteaBot
bb89fa1aaa [skip ci] Updated translations via Crowdin 2020-10-27 20:07:43 +00:00
JustAnotherArchivist
eced03db0a
Add deprecation notice for webhook payload's secret field (#13330) 2020-10-27 20:06:35 +00:00
Pedro Alves
8e368e7065
[UI] Hide consecutive additions and removals of the same label (#13315) 2020-10-27 09:12:01 +02:00
GiteaBot
afe9d79104 [skip ci] Updated translations via Crowdin 2020-10-26 16:43:30 +00:00
Lunny Xiao
38d11eea58
Fix send mail (#13312)
* Fix send mail

* Fix send mail

* Update modules/private/mail.go

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-10-26 12:42:27 -04:00
GiteaBot
dbebc6b0e3 [skip ci] Updated translations via Crowdin 2020-10-26 09:06:29 +00:00
M4RKUS-11111
ff1b00002a
Deny wrong pull (#13308)
* Deny wrong pull

* Update routers/api/v1/repo/pull.go

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: Markus <git+markus@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2020-10-26 11:05:27 +02:00
Pedro Alves
c40df54e28
Group Label Changed Comments in timeline (#13304)
* Create function to group label comments

* Combine multiple label additions into one

* Group removed and added labels in the same comment

* Fix indentation on comments.tmpl

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
2020-10-25 17:49:48 -04:00
GiteaBot
756c090dbe [skip ci] Updated translations via Crowdin 2020-10-25 20:57:54 +00:00
zeripath
66dcf10845
Attempt to handle unready PR in tests (#13305)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-25 20:56:51 +00:00
Divyam Bhasin
7974b34183
#12897 - add mastodon provider (#13293)
* added mastodon provider to oauth code

* changed go.mod and vendor/modules.txt to add updated goth

* vendored mastodon and new goth

* committing result of go mod tidy && go mod vendor

* added pic and mastodon to oauth models

* handled instance url

* applied lafriks suggestion

* Update web_src/js/index.js

Co-authored-by: techknowlogick <matti@mdranta.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-10-25 14:21:49 -04:00
GiteaBot
f565cf5dcf [skip ci] Updated translations via Crowdin 2020-10-25 17:20:28 +00:00
zeripath
172e7ee87f
Fix Storage mapping (#13297)
This PR fixes several bugs in setting storage

* The default STORAGE_TYPE should be the provided type.
* The Storage config should be passed in to NewStorage as a pointer - otherwise the Mappable interface function MapTo will not be found
* There was a bug in the MapTo function.

Fix #13286

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-25 17:19:06 +00:00
zeripath
e2740b32b5
Update Mirror IsEmpty status on synchronize (#13185)
Fix #9630
Fix #13183

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-10-25 15:32:25 +08:00
Lunny Xiao
d130cd147f
Fix bug isEnd detection on getIssues/getPullRequests (#13299) 2020-10-25 01:11:03 -04:00
Bagas Sanjaya
eab5837142
systemd service: Add commented PATH environment option for Git prefix (#13170)
On some setups, Git is installed to directory prefix other than default
PATH (such as /opt/git/bin). For Gitea to know such Git installations,
PATH environment must be specified on service file.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-24 17:13:59 -04:00
Maxim Zhiburt
a1952afc38
Sendmail command (#13079)
* Add SendSync method

Usefull to have when you need to be confident that message was sent.

* Add sendmail command

* add checks that if either title or content is empty then error out

* Add a confirmation step

* Add --force option to bypass confirm step

* Move implementation of runSendMail to a different file

* Add copyrighting comment

* Make content optional

Print waring if it's empty or haven't been set up.
The warning will be skiped if there's a `--force` flag.

* Fix import style

Co-authored-by: 6543 <6543@obermui.de>

* Use batch when getting all users

IterateUsers uses batching by default.

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Send emails one by one instead of as one chunck

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Send messages concurantly

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Use SendAsync+Flush instead of SendSync

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Add timeout parameter to sendemail command

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Fix spelling mistake

Signed-off-by: Maxim Zhiburt <zhiburt@gmail.com>

* Update cmd/admin.go

Co-authored-by: 6543 <6543@obermui.de>

* Connect to a running Gitea instance

* Fix mispelling

* Add copyright comment

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-24 16:38:14 -04:00
silverwind
c5020cff3d
Various UI and arc-green fixes (#13291)
- introduce variable for border-radius value
- fix some white borders in arc-green
- add text selection and placeholder in arc-green
- tweak branch list footer
- more things I forgot

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-10-24 15:15:29 -04:00
GiteaBot
65dc4d0410 [skip ci] Updated translations via Crowdin 2020-10-24 17:50:51 +00:00
Lunny Xiao
b91261cab9
Remove duplicated repository.upload on cheat-sheet docs (#13290)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-24 13:49:52 -04:00
GiteaBot
eef5871042 [skip ci] Updated translations via Crowdin 2020-10-24 16:49:12 +00:00
kolaente
f24392391e
Fix PR/Issue titles on mobile (#13292)
* Start fixing Issue & PR title on mobile

Signed-off-by: kolaente <k@knt.li>

* Make sure the save & cancel buttons float right

Signed-off-by: kolaente <k@knt.li>

* Fix edit buttons and title input on mobile

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-10-24 19:48:08 +03:00
zeripath
4099e4f1b6
Ensure topics added using the API are added to the repository (#13285)
* Ensure topics added using the API are added to the repository

Fix #12426

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-10-24 15:11:30 +01:00
GiteaBot
2fa4c4ad3a [skip ci] Updated translations via Crowdin 2020-10-24 11:55:43 +00:00
silverwind
a69e11209d
Don't show "0" labels on repo tabs (#13289)
If count is zero, don't show the label, matching GH behavior.
2020-10-24 14:54:33 +03:00
zeripath
0800c7e91d
Rearrange the order of the merged by etc. in locale (#13284)
Fix #13260

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-23 23:34:21 -04:00
zeripath
f40a2a4404
Store task errors following migrations and display them (#13246)
* Store task errors following migrations and display them

When migrate tasks fail store the error in the task table
and ensure that they show on the status page.

Fix #13242

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

* Update web_src/js/index.js

* Hide the failed first

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-23 19:46:35 -04:00
Divyam Bhasin
9b11c3e320
#13091 - add new mirror button (#13105)
* added button

* got URL params to carry through to service specific migrate pages

* do not display add mirror button if mirroring turned off

* added corrections by reviewers

* Add silverwind's suggestion

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
2020-10-23 19:01:58 -04:00
Paweł Bogusławski
d2ad4dec63
Avatar autogeneration fixed (#13233)
This mod fixes problem with initial avatar autogeneration and
avatar autogneration after deleting previous avatar.

Related: https://github.com/go-gitea/gitea/issues/13159
Fixes: 80a6b0f5bc
Author-Change-Id: IB#1105243
2020-10-23 20:55:10 +03:00
GiteaBot
e4d9533543 [skip ci] Updated translations via Crowdin 2020-10-23 16:00:48 +00:00
John Olheiser
1d6b565de4
Refactor docs (#13275)
* First pass

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* More changes

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Redirects

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-10-23 11:59:45 -04:00
GiteaBot
bfc553164a [skip ci] Updated translations via Crowdin 2020-10-23 10:12:50 +00:00
John Olheiser
21d621301e
Remove PAM from auth dropdown when unavailable (#13276)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-10-23 11:10:29 +01:00
GiteaBot
9912a11b33 [skip ci] Updated translations via Crowdin 2020-10-22 19:49:54 +00:00
Iván Valdés
26d6c15300
Fix arc theme label backgrounds (#13267)
* Fix arc theme label backgrounds

* Add specific style to yellow labels (background + border color)
* Remove !important from label's background rule to avoid breaking user
  defined labels. Make the rule more specific to override fomantic UI
  default white background

* Remove unnecesary selector

Co-authored-by: zeripath <art27@cantab.net>
2020-10-22 15:48:48 -04:00
GiteaBot
1989fe2ddc [skip ci] Updated translations via Crowdin 2020-10-22 18:03:41 +00:00
Mattias Persson
7b4186720c
Clarify app.example.ini documentation (#13256)
* Clarify app.example.ini documentation

Hard to understand if cron i needed to activate all other cron.

* Added missing "Extended cron tasks" to config-cheat-sheet.en-us.md

cron default is false - setting it true activates all cron. Changed the documentation accordingly

* Fixed spelling

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-22 14:02:28 -04:00
GiteaBot
e9869f59af [skip ci] Updated translations via Crowdin 2020-10-22 17:05:26 +00:00
M4RKUS-11111
a67b2bc30b
add sdk links to docs (#13266)
* add sdk links to docs

* Update docs/content/doc/advanced/api-usage.en-us.md

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: Markus <git+markus@obermui.de>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-10-22 13:04:23 -04:00
GiteaBot
178861952e [skip ci] Updated translations via Crowdin 2020-10-22 15:46:58 +00:00
Lunny Xiao
be82b8f99a
Keep database transactions not too big (#13254)
* Keep database transactions not too big

* Fix #13255

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

* Only cache the last repo

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2020-10-22 11:45:54 -04:00
GiteaBot
e964c6ec18 [skip ci] Updated translations via Crowdin 2020-10-22 05:47:21 +00:00
6543
81d3942bf0
Migrations: Gitea should not fail just because of no apiConfig return (#13229)
* close #13227

* log it

👍

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-22 01:46:18 -04:00
Amoo Hesam
b7deea0284
Inform user of how disable SSH feature when installing using Docker (#13180) 2020-10-22 00:24:20 -04:00
silverwind
dafc634a46
More arc-green fixes (#13247)
- Fix various white borders
- Tweak basic button style to have more contrast
- Add more contrast to hover styles
- Invert Matrix webhook icon

May backport to 1.13.

Co-authored-by: zeripath <art27@cantab.net>
2020-10-21 23:51:12 -04:00
Begley Brothers (Development)
ff50274ff3
Dockerfile: Support socat use cases (#13208)
* Dockerfile: Support socat use cases

In some contexts it is necessary to provide access to Gitea via TCP ports and unix sockets.
Gitea (`gitea web`) can be configured to listen for connections via unix-socket or TCP port, but not both.
When Gitea is installed to the host this limitation can be worked around by installing socat on the host.
When running Gitea from a container this limitation cannot be workaround.

Add socat to Gitea container.

* Removed version

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-21 21:41:49 -04:00
Lanre Adelowo
e918636283
Enhance release list (#6025)
* show author for releases created outside Gitea UI.

Also show the number of commits behind the default branch for tags created outside the UI

don't show the tag date again for tags pushed to the repo. Since it is already on the sidebar and looks like duplication

* add migration for already existing tags

* update as per review

* fix build

* add space

* fix import statments

* Update models/migrations/v113.go

Co-Authored-By: zeripath <art27@cantab.net>

* Update models/migrations/v114.go

Co-authored-by: 6543 <6543@obermui.de>

* Update services/release/release.go

Co-authored-by: 6543 <6543@obermui.de>

* impruve

* remove dependency on models package

* Close the gitrepos in a defer to ensure that they are closed.

* gofmt

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-21 20:55:25 -04:00
Iván Valdés
819901b3e9
Update outdated label to use Fomantic UI style (#13181)
* Update outdated label to use Fomantic UI style

* Use native labels rather than custom style

* Remove leading zero

Co-authored-by: zeripath <art27@cantab.net>
2020-10-21 19:47:16 -04:00
zeripath
327f18c3b2
Fix initial commit page & binary munching problem (#13249)
* Fix initial commit page

Unfortunately as a result of properly fixing ParsePatch the hack that
used git show <initial_commit_id> to get the diff for this failed.

This PR fixes this using the "super-secret" empty tree ref to make the
diff against.

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

* Also fix #13248

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

* Update services/gitdiff/gitdiff.go

Co-authored-by: 6543 <6543@obermui.de>
2020-10-21 19:08:44 -04:00
mrsdizzie
f6ee7ce9b6
Add better error checking for inline html diff code (#13239)
* Add better error checking for inline html diff code

A better fix for #13191 which cleans up this code a bit and adds basic checking which should avoid writing broken HTML in future situations.

* Update gitdiff_test.go

* better regex

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-21 18:14:44 -04:00
silverwind
83106c166d
Replace footer and modal icons with SVG (#13245)
- Replace two font icons with SVG in the footer
- Replace icons in delete modals with SVG
- Horizontally center message text in modals
2020-10-21 22:07:33 +01:00
GiteaBot
a06ea38207 [skip ci] Updated translations via Crowdin 2020-10-21 20:00:31 +00:00
Iwasa Kazmi
16120c059f
fix message key (#13240)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-21 22:59:12 +03:00
GiteaBot
f0fe5683fe [skip ci] Updated translations via Crowdin 2020-10-21 15:43:44 +00:00
zeripath
67b1a88e80
add more clarification to the issue-template.md (#13235)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-21 11:42:47 -04:00
zeripath
de6e427a01
go-version constraints ignore pre-releases (#13234)
Go-version constraints ignore pre-releases.

Rather than change the library further this PR simply changes
the git version comparison to use simple version compare ignoring the
issue of pre-releases.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-21 11:42:08 -04:00
GiteaBot
53359b1861 [skip ci] Updated translations via Crowdin 2020-10-21 11:03:31 +00:00
silverwind
58e1e5ba13
Update some JS dependencies (#13222)
* Update some JS dependencies

- Update selective dependencies that are compatible with webpack 4. We
can not upgrade to webpack 5 yet because `license-webpack-plugin` is
incompatible.
- Enable a few new eslint rules and fix new issues

* fix comment

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-10-21 19:02:24 +08:00
zeripath
965861043a
Return the full rejection message and errors in flash errors (#13221)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-20 19:50:10 -04:00
6543
48a80096bb
Update heatmap fixtures to restore tests (#13224)
* hotfix

* update ...
2020-10-20 17:39:25 -05:00
GiteaBot
70cb9e38e2 [skip ci] Updated translations via Crowdin 2020-10-20 18:19:29 +00:00
a1012112796
b9850375fc
Add review request api (#11355)
* Add review request api

* add : POST /repos/{owner}/{repo}/pulls/{index}/requested_reviewers
* Remove : DELET /repos/{owner}/{repo}/pulls/{index}/requested_reviewers
* fix some request review bug
* block delet request review by models/DeleteReview()

Signed-off-by: a1012112796 <1012112796@qq.com>

* make fmt

* fix bug

* fix test code

* fix typo

* Apply suggestion from code review @jonasfranz

* fix swagger ref

* fix typo

Co-authored-by: Lauris BH <lauris@nix.lv>

* fix comment

* Change response message

* chang response so some simplfy

* Add ErrIllLegalReviewRequest
fix some nits

* make fmt

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

* * Add team support
* fix test
* fix an known bug

* fix nit

* fix test

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* update get api and add test

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-10-20 14:18:25 -04:00
GiteaBot
b50448b286 [skip ci] Updated translations via Crowdin 2020-10-20 12:54:03 +00:00
zeripath
0aec2a294b
When the git ref is unable to be found return broken pr (#13218)
Fix #13216

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-20 20:52:54 +08:00
silverwind
5626811e52
Various arc-green fixes (#13214)
- Style search dropdown
- Fix radio buttons and tweak checkboxes
- Add styling for error form elements
- Make borders brighter and focus more apparent
- Adjust comment box border color to match

Fixes: https://github.com/go-gitea/gitea/pull/12491

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-20 01:22:10 -04:00
a1012112796
1b07db7922
Show stale label for stale code comment which is marked as resolved (#13213)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-20 00:48:04 -04:00
zeripath
2f1353a2f3
Move install pages out of main macaron routes (#13195)
* Move install pages out of main macaron loop

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

* Update templates/post-install.tmpl

Co-authored-by: Lauris BH <lauris@nix.lv>

* remove prefetch

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-19 17:03:08 -04:00
silverwind
3ddf3f93d6
Use CSS Variables for fonts, remove postcss-loader (#13204)
* Use CSS Variables for fonts, remove postcss-loader

- Use CSS variables for fonts, making the fonts easier to customize
- Remove postcss-loader, it's not doing anything useful and is actually
  applying strange transforms on our CSS.

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

* introduce helper variable, mark documented vars

* work around case issue by always quoting specific fonts
2020-10-19 16:01:06 -04:00
GiteaBot
d67172b136 [skip ci] Updated translations via Crowdin 2020-10-19 19:26:52 +00:00
Patrick Schratz
05aa6fd477
Align SSH_AUTHORIZED_KEYS_BACKUP var with the value in app.ini (#13212)
* Align `SSH_AUTHORIZED_KEYS_BACKUP` var with the value in `app.ini`

* Also fix the cheat sheet and move it to below - SSH_CREATE_AUTHORIZED_KEYS_FILE

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2020-10-19 15:25:32 -04:00
silverwind
06eaf74e8a
Fix size and clickable area on file table back link (#13205)
Fixes: https://github.com/go-gitea/gitea/issues/13038

Should backport to 1.13.
2020-10-19 00:59:18 +03:00
GiteaBot
40779938a9 [skip ci] Updated translations via Crowdin 2020-10-18 17:52:36 +00:00
mrsdizzie
9fe4b7b692
Fix error in diff html rendering (#13191)
* Fix error in diff html rendering

Was missing an optional whitespace check in regex. Also noticed a rare case where diff.Type == Equal would be empty and thus get a newline attached. Fixed that too.

Fixes #13177

* Update services/gitdiff/gitdiff.go

Co-authored-by: zeripath <art27@cantab.net>

* Update gitdiff_test.go

* fmt

Co-authored-by: zeripath <art27@cantab.net>
2020-10-18 13:51:38 -04:00
a1012112796
5e34d3d2c0
Apply to become a maintainer (#13201)
Dear gitea's managers and contributors, I apply to become a
maintainer of gitea. I'm interested in this project and has
sent prs to gitea also. I will do more things to make gitea
better and reviw other contributors's pr in my free time.
Thanks.

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-18 12:12:51 -04:00
a1012112796
4099a18ed2
Update CHANGELOG.md (#13200)
Co-authored-by: zeripath <art27@cantab.net>
2020-10-18 18:46:04 +03:00
GiteaBot
27687fa4f0 [skip ci] Updated translations via Crowdin 2020-10-18 14:11:20 +00:00
Lunny Xiao
25f937f99b
Add git command error directory on log (#13194) 2020-10-18 17:10:11 +03:00
zeripath
25b7766673
When handling errors in storageHandler check underlying error (#13178)
Unfortunately there was a mistake in #13164 which fails to handle
os.PathError wrapping an os.ErrNotExist

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-17 21:29:06 -04:00
mrsdizzie
4cc8697a65
Remove not relevant option from issue template (#13188)
Almost every use of "Not relevant" I see is the opposite -- it is relevant to have an example on try.gitea.io and often we can't do anything until the user provides one. Remove the not-relevant option so people have to decide yes/no if they are going to attempt to reproduce it which will hopefully encourage them to do so in simple cases. 

For actual not-relevant issues No should be a fine answer as well as it would be clear to us when you can't reproduce an example there.

Hopefully this will encourage more examples when people file issues which would lead to quicker fixes.
2020-10-17 23:46:59 +08:00
6543
d453533beb
[Refactor] Move APIFormat functions into convert package (#12856)
* USER APIFormat -> ToUser

* Migrate more and mark APIFormat deprecated

* models.Comment APIFormat() -> convert.ToComment

* models.Release APIFormat() -> convert.ToRelease

* models.Attachments APIFormat() -> convert.ToReleaseAttachments

* models.CommitStatus APIFormat() -> convert.ToCommitStatus

* finish migration to convert.ToUser

* Move Test

* Imprufe Test

* fix test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-17 00:23:08 -04:00
GiteaBot
131278ff22 [skip ci] Updated translations via Crowdin 2020-10-16 17:14:34 +00:00
zeripath
6bab678bed
Fix diff skipping lines (#13154)
* Fix diff skipping lines

ParsePatch previously just skipped all lines that start with "+++ " or "--- "
and makes no attempt to see these lines in context.

This PR rewrites ParsePatch to pay attention to context and position
within a patch, ensuring that --- and +++ are only skipped if
appropriate.

This PR also fixes several issues with incomplete files.

Fix https://codeberg.org/Codeberg/Community/issues/308
Fix #13153

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

* Add testcase

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

* fix comment

* simplify error handling

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

* never return io.EOF

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-16 13:13:18 -04:00
6543
b222dbc1d1
Update go-version v1.2.3 -> v1.2.4 (#13169)
Co-authored-by: zeripath <art27@cantab.net>
2020-10-16 12:05:02 +03:00
6543
12a1f914f4
Vendor Update Go Libs (#13166)
* update github.com/alecthomas/chroma v0.8.0 -> v0.8.1

* github.com/blevesearch/bleve v1.0.10 -> v1.0.12

* editorconfig-core-go v2.1.1 -> v2.3.7

* github.com/gliderlabs/ssh v0.2.2 -> v0.3.1

* migrate editorconfig.ParseBytes to Parse

* github.com/shurcooL/vfsgen to 0d455de96546

* github.com/go-git/go-git/v5 v5.1.0 -> v5.2.0

* github.com/google/uuid v1.1.1 -> v1.1.2

* github.com/huandu/xstrings v1.3.0 -> v1.3.2

* github.com/klauspost/compress v1.10.11 -> v1.11.1

* github.com/markbates/goth v1.61.2 -> v1.65.0

* github.com/mattn/go-sqlite3 v1.14.0 -> v1.14.4

* github.com/mholt/archiver v3.3.0 -> v3.3.2

* github.com/microcosm-cc/bluemonday 4f7140c49acb -> v1.0.4

* github.com/minio/minio-go v7.0.4 -> v7.0.5

* github.com/olivere/elastic v7.0.9 -> v7.0.20

* github.com/urfave/cli v1.20.0 -> v1.22.4

* github.com/prometheus/client_golang v1.1.0 -> v1.8.0

* github.com/xanzy/go-gitlab v0.37.0 -> v0.38.1

* mvdan.cc/xurls v2.1.0 -> v2.2.0

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-16 01:06:27 -04:00
zeripath
91f2afdb54
Prevent panics with missing storage (#13164)
* The `.Use` of storageHandler before setting up the template renderer
causes a panic if there is an error to log.
* The error passed to `ctx.Error` in that case may contain sensitive
information and should not be rendered to the end user. We should
instead log the error and render a simple error message.
* There is no handling of missing avatars and this needs a 404. Minio
errors need to be mapped to standard golang errors such as
os.ErrNotExist.
* There is no logging when storage is set up.

Related #13159

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-15 23:51:06 -04:00
ydelafollye
cb171dbd56
Improve users management through the CLI (#6001) (#10492)
* Fix images in wiki edit preview (#11546)

Make sure wiki editor sets wiki to true so gitea renders it as a wiki page.

Also change the context data attr for edit form. This looks wrong but everywhere else in our code assumes the urlPrefix to be just the repo url when rendering and manually adds /wiki to the rendered url regardless.

Fixes #11540
2020-10-15 22:48:38 -04:00
Elena Neuschild
4fbe64572c
Change order of possible-owner organizations to alphabetical (#13160)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-15 18:15:55 -04:00
zeripath
c8f7a6b774
Slightly simplify the queue settings code to help reduce the risk of problems (#12976)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-15 17:40:03 -04:00
6543
e374bb7e2d
[Vendor] Update go-ldap to v3.2.4 (#13163)
* [Vendor] update go-ldap to v3.0.3

* update go-ldap to v3.2.4

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-15 15:27:33 -04:00
GiteaBot
bcf45bb162 [skip ci] Updated translations via Crowdin 2020-10-15 18:31:29 +00:00
Johan Van de Wauw
923f57856a
Update external-renderers.en-us.md (#13165)
Alpine 3.12 (the version used by current master) no longer provides the python-dev package:
https://wiki.alpinelinux.org/wiki/Release_Notes_for_Alpine_3.12.0#python2_no_longer_provides_python_and_python-devel

As the next steps explicitely use python3 it is not needed anyway.
2020-10-15 19:30:25 +01:00
GiteaBot
25f7e1c50b [skip ci] Updated translations via Crowdin 2020-10-15 09:49:02 +00:00
Robin
27b7add2f8
Enhance config cheat sheet on passwd quoting (#13158)
See #13126
2020-10-15 10:48:00 +01:00
GiteaBot
deb0333c96 [skip ci] Updated translations via Crowdin 2020-10-15 08:18:52 +00:00
Iván Valdés
05c7e58742
Show outdated comments in pull request (#13148)
Co-authored-by: zeripath <art27@cantab.net>
2020-10-15 11:17:48 +03:00
GiteaBot
bfb3333528 [skip ci] Updated translations via Crowdin 2020-10-15 04:15:26 +00:00
E14
c962518cc2
Use GO variable in go-check target (#13146) (#13147) 2020-10-15 12:14:22 +08:00
GiteaBot
e4a3785218 [skip ci] Updated translations via Crowdin 2020-10-14 21:45:21 +00:00
techknowlogick
76ac83402b
Clean up mysql service in drone (#13145) 2020-10-14 17:44:18 -04:00
GiteaBot
07c9f6dca4 [skip ci] Updated translations via Crowdin 2020-10-14 18:49:08 +00:00
6543
33e0e37537
Changelog v1.13.0-RC1 (#13142)
* Changelog v1.13.0

* reorder topics

* impruve

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Apply suggestions from code review

* Goldmark ...

* Add 12516

* Apply suggestions from code review

* Update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: techknowlogick <matti@mdranta.net>

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* Update CHANGELOG.md

* Apply suggestions from code review

Co-authored-by: 6543 <6543@obermui.de>

* Securety is more importand than Breaking ...

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: zeripath <art27@cantab.net>
2020-10-14 14:48:03 -04:00
GiteaBot
8fa74045c4 [skip ci] Updated translations via Crowdin 2020-10-14 17:02:15 +00:00
Anders Eurenius Runvald
01f991ac88
Update sshd_config (#13143)
Afaik, adding these lines does nothing unless the file(s) are present. Having them in let's admins supply certs instead of relying on TOFU.

Co-authored-by: zeripath <art27@cantab.net>
2020-10-14 13:01:11 -04:00
GiteaBot
36e41d4764 [skip ci] Updated translations via Crowdin 2020-10-14 13:09:05 +00:00
Lunny Xiao
80a6b0f5bc
Avatars and Repo avatars support storing in minio (#12516)
* Avatar support minio

* Support repo avatar minio storage

* Add missing migration

* Fix bug

* Fix test

* Add test for minio store type on avatars and repo avatars; Add documents

* Fix bug

* Fix bug

* Add back missed avatar link method

* refactor codes

* Simplify the codes

* Code improvements

* Fix lint

* Fix test mysql

* Fix test mysql

* Fix test mysql

* Fix settings

* Fix test

* fix test

* Fix bug
2020-10-14 21:07:51 +08:00
GiteaBot
93f7525061 [skip ci] Updated translations via Crowdin 2020-10-14 12:12:40 +00:00
赵智超
97980146c5
Show original author's reviews on pull summary box (#13127)
follow #12039, show original author's reviews by other way.
fix #11705.

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-10-14 13:11:11 +01:00
GiteaBot
e70df67d47 [skip ci] Updated translations via Crowdin 2020-10-14 11:18:41 +00:00
Lauris BH
a2a05d164b
Fix punctuation in trust model description (#13140) 2020-10-14 14:17:40 +03:00
zeripath
edfebe65b1
Finally fix diff names (#13136)
* Finally fix diff names

#12771 attempted to fix diff by avoiding the git diff line as
it is possible to have an ambiguous line here.

#12254 attempted to fix diff by assuming that names would quoted
if they needed to be and if one was quoted then both would be.

Both of these were wrong.

I have now discovered `--src-prefix` and `--dst-prefix` which
means that we can set this in such a way to force the git diff
to always be unambiguous.

Therefore this PR rollsback most of the changes in #12771 and
uses these options to fix this.

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

* Update services/gitdiff/gitdiff.go

* Update services/gitdiff/gitdiff.go

* Update modules/repofiles/temp_repo.go

* fix test

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-14 07:49:33 +03:00
GiteaBot
aa73b7b7e5 [skip ci] Updated translations via Crowdin 2020-10-14 04:07:05 +00:00
6543
49b1948cb1
Gitea 2 Gitea migration (#12657)
* first draft

* update gitea sdk to 9e280adb4da

* adapt feat of updated sdk

* releases now works

* break the Reactions loop

* use convertGiteaLabel

* fix endless loop because paggination is not supported there !!!

* rename gitea local uploader files

* pagination can bite you in the ass

* Version Checks

* lint

* docs

* rename gitea sdk import to miss future conficts

* go-swagger: dont scan the sdk structs

* make sure gitea can shutdown gracefully

* make GetPullRequests and GetIssues similar

* rm useles

* Add Test: started ...

* ... add tests ...

* Add tests and Fixing things

* Workaround missing SHA

* Adapt: Ensure that all migration requests are cancellable
(714ab71ddc)

* LINT: fix misspells in test set

* adapt ListMergeRequestAwardEmoji

* update sdk

* Return error when creating giteadownloader failed

* update sdk

* adapt new sdk

* adopt new features

* check version before err

* adapt: 'migrate service type switch page'

* optimize

* Fix DefaultBranch

* impruve

* handle subPath

* fix test

* Fix ReviewCommentPosition

* test GetReviews

* add DefaultBranch int test set

* rm unused

* Update SDK to v0.13.0

* addopt sdk changes

* found better link

* format template

* Update Docs

* Update Gitea SDK (v0.13.1)
2020-10-14 07:06:00 +03:00
赵智超
dfa7291f8f
[Enhancement] Allow admin to merge pr with protected file changes (#12078)
* [Enhancement] Allow admin to merge pr with protected file changes

As tilte, show protected message in diff page and merge box.

Signed-off-by: a1012112796 <1012112796@qq.com>

* remove unused ver

* Update options/locale/locale_en-US.ini

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>

* Add TrN

* Apply suggestions from code review

* fix lint

* Update options/locale/locale_en-US.ini

Co-authored-by: zeripath <art27@cantab.net>

* Apply suggestions from code review

* move pr proteced files check to TestPatch
* Call TestPatch when protected branches settings changed

* Apply review suggestion @CirnoT

* move to service @lunny

* slightly restructure routers/private/hook.go

Adds a lot of comments and simplifies the logic

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

* placate lint

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

* skip duplicate protected files check

* fix check logic

* slight refactor of TestPatch

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

* When checking for protected files changes in TestPatch use the temporary repository

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

* fix introduced issue with hook

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

* Remove the check on PR index being greater than 0 as it unnecessary

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

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-13 14:50:57 -04:00
GiteaBot
da32d0e72a [skip ci] Updated translations via Crowdin 2020-10-13 16:25:13 +00:00
zeripath
2d75d6f664
Move update-server-info to hooks (#12826)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-14 00:24:06 +08:00
6543
daa393cb48
Add API Section to Changelog (#13125)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-13 01:39:17 -04:00
zeripath
6b1266b6b3
Provide self-registering storage system (#12978)
* Provide self-registering storage system

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

* More simplification

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

* Remove old strings from setting

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

* oops attachments not attachment

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-10-12 23:58:34 -04:00
6543
ade9c8dc3c
[API] If User is Admin, show 500 error message on PROD mode too (#13115)
* API: show admin 500 error message on PROD mode too

* a nit

* dont miss InternalServerError

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-12 20:41:49 -04:00
6543
f4ffe8ed54
Save TimeStamps for Star, Label, Follow, Watch and Collaboration to Database (#13124)
* Add timestamps to Star, Label, LanguageStat, Follow, Watch and Collaboration

* Star do not need updated

* LanguageStat do not need update (they wont change)

* fix unit-test
2020-10-12 20:01:57 -04:00
zeripath
f2858600af
Return 404 not 500 from API if team does not exist (#13118)
If team does not exist expect ErrTeamNotExist not ErrUserNotEXist

Fix #11336

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-12 17:09:21 -04:00
赵智超
8be3e439c2
Add team support for review request (#12039)
Add team support for review request

Block #11355

Signed-off-by: a1012112796 <1012112796@qq.com>
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Andrew Thornton <art27@cantab.net>
2020-10-12 20:55:13 +01:00
GiteaBot
b546eda7a8 [skip ci] Updated translations via Crowdin 2020-10-12 18:45:03 +00:00
Elena Neuschild
bf6ed724a6
Fix args in tasks.json (#13116) 2020-10-12 14:44:01 -04:00
6543
9513638715
Prohibit automatic downgrades (#13108)
Prohibit automatic downgrades by checking the version of the db and warning if the version number should be lower.

Close #13107

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
2020-10-12 15:35:56 +01:00
Chris Shyi
c752ccee64
Improve error feedback for duplicate deploy keys (#13112)
Instead of a generic HTTP 500 error page, a flash message is rendered with the deploy key page template to inform the user that a key with the intended title already exists. 

Fixes #13110
2020-10-12 14:44:56 +01:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
0e4f663126
chore: update minio image version (#13109)
* 2020-05-16 --> 2020-10-09
2020-10-12 16:45:20 +08:00
6543
845d0afb33
4 line diff (#13103) 2020-10-12 09:15:15 +08:00
kolaente
64133126cd
Update golangci-lint to version 1.31.0 (#13102)
This PR updates golangci-lint to the latest version 1.31.0.

The upgrade introduced a new check for which I've fixed or disabled most cases.

Signed-off-by: kolaente <k@knt.li>
2020-10-11 21:27:20 +01:00
GiteaBot
e35f7e81ae [skip ci] Updated translations via Crowdin 2020-10-11 18:52:13 +00:00
zeripath
7edf7eb46c
Log the underlying panic in runMigrateTask (#13096)
If there is a panic during runMigrateTask we should capture and log the underlying
panic error.

This PR ensures that the panic is logged and captured as part of the task message.

Fix #13095

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-11 14:51:13 -04:00
Wim
9066d09c57
Add ssh certificate support (#12281)
* Add ssh certificate support

* Add ssh certificate support to builtin ssh

* Write trusted-user-ca-keys.pem based on configuration

* Update app.example.ini

* Update templates/user/settings/keys_principal.tmpl

Co-authored-by: silverwind <me@silverwind.io>

* Remove unused locale string

* Update options/locale/locale_en-US.ini

Co-authored-by: silverwind <me@silverwind.io>

* Update options/locale/locale_en-US.ini

Co-authored-by: silverwind <me@silverwind.io>

* Update models/ssh_key.go

Co-authored-by: silverwind <me@silverwind.io>

* Add missing creation of SSH.Rootpath

* Update cheatsheet, example and locale strings

* Update models/ssh_key.go

Co-authored-by: zeripath <art27@cantab.net>

* Update models/ssh_key.go

Co-authored-by: zeripath <art27@cantab.net>

* Update models/ssh_key.go

Co-authored-by: zeripath <art27@cantab.net>

* Update models/ssh_key.go

Co-authored-by: zeripath <art27@cantab.net>

* Update models/ssh_key.go

* Optimizations based on feedback

* Validate CA keys for external sshd

* Add filename option and change default filename

Add a SSH_TRUSTED_USER_CA_KEYS_FILENAME option which default is
RUN_USER/.ssh/gitea-trusted-user-ca-keys.pem

Do not write a file when SSH_TRUSTED_USER_CA_KEYS is empty.

Add some more documentation.

* Remove unneeded principalkey functions

* Add blank line

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

* Add SSH_AUTHORIZED_PRINCIPALS_ALLOW option

This adds a SSH_AUTHORIZED_PRINCIPALS_ALLOW which is default
email,username this means that users only can add the principals
that match their email or username.

To allow anything the admin need to set the option anything.

This allows for a safe default in gitea which protects against malicious
users using other user's prinicipals. (before that user could set it).

This commit also has some small other fixes from the last code review.

* Rewrite principal keys file on user deletion

* Use correct rewrite method

* Set correct AuthorizedPrincipalsBackup default setting

* Rewrite principalsfile when adding principals

* Add update authorized_principals option to admin dashboard

* Handle non-primary emails

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

* Add the command actually to the dashboard template

* Update models/ssh_key.go

Co-authored-by: silverwind <me@silverwind.io>

* By default do not show principal options unless there are CA keys set or they are explicitly set

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

* allow settings when enabled

* Fix typos in TrustedUserCAKeys path

* Allow every CASignatureAlgorithms algorithm

As this depends on the content of TrustedUserCAKeys we should allow all
signature algorithms as admins can choose the specific algorithm on their
signing CA

* Update models/ssh_key.go

Co-authored-by: Lauris BH <lauris@nix.lv>

* Fix linting issue

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-10 20:38:09 -04:00
zeripath
7eb8460132
Fix attachments list in edit comment (#13036)
#11141 broke the appearance of dropzone attachments when editting
comments causing poorly updating lists.

This PR fixes this.

Fix #12583

Signed-off-by: Andrew Thornton art27@cantab.net
2020-10-11 00:49:59 +01:00
zeripath
6f2784911f
Fix deadlock when deleting team user (#13092)
`models.getUserRepoPermission(...)` calls `HasOrgVisible` which
uses `models.x` potentially outside of the transaction `e` provided
as an argument to `getUserRepoPermission`.

This PR switches to use `hasOrgVisible(e, ...)`.

Fix #12983

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-10 22:48:58 +03:00
zeripath
d65cd5677a
Change default log configuration (#13088)
* Change default log configuration

This PR changes the install page and the docker default
logging configuration to match the suggested configuration
that I repeatedly end up suggesting on issues.

It further improves the logging configuration docs to
recommend specific instructions for how to configure logs
for posting to issues.

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

* Update docs/content/doc/advanced/logging-documentation.en-us.md
2020-10-10 18:19:50 +03:00
silverwind
1c523e2129
Set appropriate autocomplete attributes on password fields (#13078)
`new-password` prevents annoying autocompletion in some cases, thought
it's not semantically correct to use that for example on all three
fields on the user account page, so some annoyances remain.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-09 10:32:30 +03:00
zeripath
ea69ec6f0f
Disable DSA ssh keys by default (#13056)
* Disable DSA ssh keys by default

OpenSSH has disabled DSA keys since version 7.0

As the docker runs openssh > v7.0 we should just disable
DSA keys by default.

Refers to #11417

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

* Just disable DSA keys by default

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

* Appears we need to set the minimum key sizes too

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

* Appears we need to set the minimum key sizes too

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

* Remove DSA type

* Fix Tests

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-09 09:52:57 +03:00
Iván Valdés
06f1cdde6e
Fix line break for MS teams webhook (#13081)
Signed-off-by: Ivan Valdes <ivan@vald.es>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-09 01:30:55 -04:00
Melroy van den Berg
508aca1cc0
Improve Docker container name (#13077)
* Improve Docker container name

Use a better Docker container name than the default 'server'

* Changing to gitea and use recommended v3 Docker-compose

Use `gitea` as container name. And use version 3 of the docker-compose, which should now be used: https://docs.docker.com/compose/compose-file/compose-versioning/

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-08 22:31:07 -04:00
Lunny Xiao
9b81193166
Cache last commit when pushing for big repository (#10109)
* Cache last commit when pushing for big repository

* Fix bug

* detect force push

* Refactor cache push

* Finish cache last commit info when push

* Some improvements

* Fix lint

* Remove unused changes

* Move pull request test before cache

* Fix test mysql

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-09 01:17:23 +03:00
Lunny Xiao
f06ee37e24
Hide sync ssh keys button on admin dashboard if ssh disabled or builtin-ssh enabled (#13072)
Co-authored-by: zeripath <art27@cantab.net>
2020-10-08 12:43:15 -04:00
GiteaBot
529c5ffe12 [skip ci] Updated translations via Crowdin 2020-10-08 15:51:23 +00:00
赵智超
a5ba8188da
fix a small nit (#13074)
Signed-off-by: a1012112796 <1012112796@qq.com>
2020-10-08 11:50:17 -04:00
zeripath
144fa5a537
Avoid setting the CONN_STR in issue indexer queue unless it is meant to be set (#13069)
Since the move to common leveldb and common redis the disk queue code (#12385)
will check the connection string before defaulting to the DATADIR.

Therefore we should ensure that the connection string is kept empty
unless it is actually set.

Unforunately the issue indexer was missed in #13025 this PR fixes this omission

Fix #13062

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-07 23:24:41 +01:00
zeripath
1bf40ca0df
Gitea serv, hooks, manager and the like should always display Fatals (#13032)
The gitea cmd/serv.go setup function deletes the console logger to
prevent stdout interference with commands. However, the problem is that
it then calls setting.NewContext which may cause an exit with log.Fatal
- which will then not be shown.

Now, log.Fatal is so disastrous that the interference that logging
causes is wanted. However, we can avoid stdout interference by emitting
on stderr.

This PR forces the creation of a console logger on stderr listening on
Fatal for these commands. Most commands have a `--debug` option now that
will print more reasons too - however, defaulting to give the log for
Fatal seems reasonable.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-07 16:44:16 -04:00
GiteaBot
4df6807b81 [skip ci] Updated translations via Crowdin 2020-10-07 18:25:19 +00:00
techknowlogick
e00e8d8ad3
Disable Git Hooks by default (#13064)
* Disable Git Hooks by default

Related #13058

* pass tests
2020-10-07 14:24:14 -04:00
GiteaBot
e0b7727804 [skip ci] Updated translations via Crowdin 2020-10-07 09:56:17 +00:00
Niklas Goerke
8fe8ab5cbf
Mitigate Security vulnerability in the git hook feature (#13058)
* Extend git hook warning in the UI.

Git hooks are a dangerous feature, administrators should be warned before giving
the git hook privilege to users.

* Disable Git hooks by default and add warning.

Git hooks are a dangerous features (see warning text) that should only
be enabled if the administrator was informed about the risk involved.

Co-authored-by: Niklas Goerke <goerke@fzi.de>
2020-10-07 12:55:13 +03:00
Rongjian Zhang
d49242287d
Update third-party-tools.en-us.md (#13046) 2020-10-06 12:55:51 -04:00
GiteaBot
f5436b4a67 [skip ci] Updated translations via Crowdin 2020-10-06 16:17:17 +00:00
Rongjian Zhang
77f360b1b8
fix: case typo (#13049)
* Update settings.go

* Run swagger generate
2020-10-06 12:16:16 -04:00
GiteaBot
a23c128ba6 [skip ci] Updated translations via Crowdin 2020-10-06 07:24:15 +00:00
6543
c584364b90
[Docs] Update GitNex Link (#13050) 2020-10-06 08:23:10 +01:00
Spencer Taylor
6eea301829
Adding visual cue for "Limited" & "Private" organizations. (#13040)
* Adding visual cue for "Limited" & "Private" organizations.

* Moving org visibility CSS styles to .less files.

Co-authored-by: Gitea <gitea@fake.local>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-06 02:25:43 -04:00
6543
df4bbcd235
Fix error create comment on outdated file (#13041)
* FIX

* more specific

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-05 20:18:55 -04:00
kolaente
b5e76dddb8
Fix Pull Request merge buttons on mobile (#13035)
Signed-off-by: kolaente <k@knt.li>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-05 19:31:25 -04:00
GiteaBot
91118bc73d [skip ci] Updated translations via Crowdin 2020-10-05 22:47:15 +00:00
kolaente
78aded1eaa
Fix Issue & Pull Request comment headers on mobile (#13039)
Signed-off-by: kolaente <k@knt.li>
2020-10-05 18:46:11 -04:00
zeripath
5e1c51cdb6
(Re)Load issue labels when changing them (#13007)
(Re)Load issue labels when labels are added or removed

This means that the label state that the webhooks produce accurately matches
the changes that they are reporting.

Fix #10660

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-05 09:49:11 +03:00
silverwind
cda44750cb
Attachments: Add extension support, allow all types for releases (#12465)
* Attachments: Add extension support, allow all types for releases

- Add support for file extensions, matching the `accept` attribute of `<input type="file">`
- Add support for type wildcard mime types, e.g. `image/*`
- Create repository.release.ALLOWED_TYPES setting (default unrestricted)
- Change default for attachment.ALLOWED_TYPES to a list of extensions
- Split out POST /attachments into two endpoints for issue/pr and
  releases to prevent circumvention of allowed types check

Fixes: https://github.com/go-gitea/gitea/pull/10172
Fixes: https://github.com/go-gitea/gitea/issues/7266
Fixes: https://github.com/go-gitea/gitea/pull/12460
Ref: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Unique_file_type_specifiers

* rename function

* extract GET routes out of RepoMustNotBeArchived

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-10-05 01:49:33 -04:00
Lucas Queiroz
67a5573310
[#13004] Add Timestamp to Tag list API (#13026)
* Add Timestamp to Tag list API

* Add unit test for ToCommitMeta

* Rename timestamp to created

* Reformat files
2020-10-05 12:07:54 +08:00
Divyam Bhasin
48703c3c68
updated docs with caveat for authorized_keys (#13030)
* updated docs with caveat for authorized_keys

* wrapped authorized_keys in ticks

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-04 19:52:40 -04:00
赵智超
01c7204895
Return sample message for login error in api context (#12994)
* Return sample message for login error in api context

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update modules/context/auth.go

Co-authored-by: silverwind <me@silverwind.io>

* Apply suggestions from code review

Co-authored-by: Lauris BH <lauris@nix.lv>

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-04 17:39:31 -04:00
silverwind
922d698842
CSS tweaks to warning/error segments and misc fixes (#13024)
* CSS tweaks to warning/error segments and misc fixes

- Adjust styling for warning/error in arc-green
- Change danger boxes from orange to red
- Fix code highlight text color in arc-green
- Fix warning message in arc-green
- Fix border in org member list in arc-green
- Fix disabled checkbox text in arc-green

* use same selector in gitea theme

* fix blame highlight

Co-authored-by: zeripath <art27@cantab.net>
2020-10-04 16:54:22 -04:00
GiteaBot
10e04da28c [skip ci] Updated translations via Crowdin 2020-10-04 17:13:45 +00:00
zeripath
3f3a4f5b41
Avoid setitng the CONN_STR in queues unless it is meant to be set (#13025)
Since the move to common leveldb and common redis the disk queue code
will check the connection string before defaulting to the DATADIR.

Therefore we should ensure that the connection string is kept empty
unless it is actually set.

Fix #13023

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-04 18:12:26 +01:00
John Olheiser
72636fd664
hCaptcha Support (#12594)
* Initial work on hCaptcha

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Use module

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Format

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* At least return and debug log a captcha error

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Pass context to hCaptcha

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add context to recaptcha

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* fix lint

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

* Finish hcaptcha

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update example config

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Apply error fix for recaptcha

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Change recaptcha ChallengeTS to string

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Andrew Thornton <art27@cantab.net>
2020-10-02 23:37:53 -04:00
zeripath
5460bf8903
Fix formatting of branches ahead-behind on narrow windows (#12989)
Make the bar-groups width 50% with max-width of 90px

Fix #12252

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-02 19:10:43 -04:00
Claudius Ellsel
45727c32c3
Update comparison for GitLab CE (#13019)
* Update comparison for GitLab CE

Fixes #13018.

* Update docs/content/doc/features/comparison.en-us.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update comparison.en-us.md

According to the linked issue it is there and just the documentation is lacking.

* Update docs/content/doc/features/comparison.en-us.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* Update docs/content/doc/features/comparison.en-us.md

Co-authored-by: techknowlogick <matti@mdranta.net>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-10-02 18:08:17 -04:00
rebeckanylander
54091e074c
Fix comment header span. (#13009)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-02 11:13:46 -04:00
mrsdizzie
7a34fc0ae8
Remove code-view class from diff view (#13011)
code-view class seems unecessary here as everything needed style wise comes from various diff classes. This allows comments and comment editor to be styled properly and fixes linked bug.

Fixes #13010

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-10-02 10:38:38 -04:00
zeripath
54dd28f159
Fix 500 on README in submodule (#13006)
If a README file is a symlink to a submodule Gitea the view branch page
will return a 500.

The underlying problem is a missed conversion of an
plumbing.ErrObjectNotFound in git/tree_blob.go.

Fix #12599

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-10-02 09:27:44 -04:00
GiteaBot
86b8c81240 [skip ci] Updated translations via Crowdin 2020-10-02 09:38:47 +00:00
James Lakin
6fc129fe62
Fix repository create/delete event webhooks (#13008)
This small PR changes the webhook trigger behaviour to be more in line with what's expected. (When 'repository' events are enabled, of course)

In other words:

For system-wide or default webhooks, repository events will now trigger said webhook. Previously it had to be under an organization for create events to be visible - a tad unexpected!
Deleting a repository will now fire its own defined webhooks, not just organisational and system ones.
In order to enable the latter the webhook has to now be triggered before the actual repo undergoes deletion. I'm willing to tweak this to try and 'grab' the webhook model beforehand and trigger the webhook notifier directly afterwards, but this may make the code more complex for little benefit.

Closes #11766, #9180.
2020-10-02 10:37:46 +01:00
techknowlogick
77f3dbed6d
latest version is 1.12.5 (#13005) 2020-10-01 15:21:25 -04:00
John Olheiser
b428f9feb5
Changelog 1.12.5 (#13002) (#13003)
* Changelog 1.12.5

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* Apply suggestions from code review

Co-authored-by: techknowlogick <matti@mdranta.net>

Co-authored-by: techknowlogick <matti@mdranta.net>

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-10-01 14:47:54 -04:00
Pranav Nachnekar
1827f892de
fix: media links in org files not liked to media files (#12997)
* fix: media links in org files not liked to media files

* fix: write directly to io.Writer r

as suggested by code review

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
2020-10-01 11:22:34 -04:00
GiteaBot
1d2553abbf [skip ci] Updated translations via Crowdin 2020-10-01 12:50:55 +00:00
techknowlogick
156f54d6e2
allow U2F with default settings for gitea in subpath (#12990)
* allow U2F with default settings for gitea in subpath

* use trim suffix

Co-authored-by: zeripath <art27@cantab.net>
2020-10-01 20:49:49 +08:00
zeripath
c6da033656
Copy missing things from app.example.ini to Cheat Sheet (#12988)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-10-01 07:57:57 +01:00
GiteaBot
992f387139 [skip ci] Updated translations via Crowdin 2020-10-01 05:55:40 +00:00
6543
818d921bbb
Refactor use TrimSuffix instead of TrimRight (#12993)
* Refactor use TrimSuffix instead of TrimRight

* TrimRight right

* has #12990
2020-10-01 06:54:34 +01:00
GiteaBot
551473b294 [skip ci] Updated translations via Crowdin 2020-09-30 21:00:33 +00:00
raoulb
a43cf283de
Fix hugo shortcode typo in faq (#12987)
* Fix hugo shortcode typo in faq

* Switch to using language tags
2020-09-30 16:59:30 -04:00
GiteaBot
7670a9db10 [skip ci] Updated translations via Crowdin 2020-09-30 16:17:15 +00:00
PE1NUT
f2c29f2d25
Clarification on the use of certificate chains (#12986)
* Clarification on the use of certificate chains

* As per @bagasme

Co-authored-by: Bagas Sanjaya <bagasdotme@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Bagas Sanjaya <bagasdotme@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-30 12:16:13 -04:00
GiteaBot
615e784150 [skip ci] Updated translations via Crowdin 2020-09-30 12:28:46 +00:00
Lunny Xiao
0d0e01eaa9
Fix typo on Chinese documents (#12982) 2020-09-30 20:27:41 +08:00
zeripath
fe79b13ab2
Always return a list from GetCommitsFromIDs (#12981)
`GetCommitsFromIDs` is only used in one place: `LoadPushCommits` where
it expects that `c.Commits` is not nil.

This potentially nil set causes a NPE in in #12953

Fix #12953

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-29 22:26:54 +01:00
zeripath
1bcf1ad643
Only set the user password if the password field would have been shown (#12980)
POSTing to /admin/users/:id should only set the password if the the user
IsLocal or IsOauth2

Fix #12952

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-29 21:27:03 +01:00
GiteaBot
9b6361f8a0 [skip ci] Updated translations via Crowdin 2020-09-29 19:27:47 +00:00
zeripath
1267e678fa
Fix admin/config page (#12979)
Change `.LFS.ContentPath` to `.LFS.Path`

Fix #12975

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-29 15:26:45 -04:00
Lunny Xiao
3878e985b6
Add default storage configurations (#12813)
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: zeripath <art27@cantab.net>
2020-09-29 12:05:13 +03:00
zeripath
4c6ac08182
Completely quote AppPath and CustomConf paths (#12955)
* Completely quote AppPath and CustomConf paths

Properly handle spaces in AppPath and CustomConf within hooks and
authorized_keys. Unfortunately here we don't seem to be able to get away
with using go-shellquote as it appears that Windows doesn't play too
well with singlequote quoting - therefore we will avoid singlequote
quoting unless we absolutely cannot get away without it, e.g. \n or !.

Fix #10813

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

* missing change

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

* fix Test_CmdKeys

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-28 21:16:52 -04:00
zeripath
5cfc1f573f
Fix the issue reported on #12385 (#12969)
Missed setting ConnectionString on queuesettings

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-28 19:00:54 -04:00
6543
feb1a8cabc
Docs: Add missing SESSION_LIFE_TIME to Config Cheat Sheet (#12968)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-28 16:39:54 -04:00
Victor
ffa7dd6880
Changed width of signature avatar from auto to 16px (#12961)
Signed-off-by: Victor Roest <victor@xirion.net>

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-09-28 16:39:22 -04:00
GiteaBot
b606f13365 [skip ci] Updated translations via Crowdin 2020-09-28 19:01:59 +00:00
6543
4a654a8d44
Mirror: Update DB on Address-Update too (#12964)
* Mirror: Update DB on Address-Update too

* new name for function to better describe
2020-09-28 15:00:52 -04:00
Antoine GIRARD
14e718695a
Update Dockerfile (#12922) 2020-09-27 18:52:22 -04:00
zeripath
7f8e3192cd
Allow common redis and leveldb connections (#12385)
* Allow common redis and leveldb connections

Prevents multiple reopening of redis and leveldb connections to the same
place by sharing connections.

Further allows for more configurable redis connection type using the
redisURI and a leveldbURI scheme.

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

* add unit-test

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

* as per @lunny

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

* add test

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

* Update modules/cache/cache_redis.go

* Update modules/queue/queue_disk.go

* Update modules/cache/cache_redis.go

* Update modules/cache/cache_redis.go

* Update modules/queue/unique_queue_disk.go

* Update modules/queue/queue_disk.go

* Update modules/queue/unique_queue_disk.go

* Update modules/session/redis.go

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-28 00:09:46 +03:00
GiteaBot
f404bdde9b [skip ci] Updated translations via Crowdin 2020-09-27 19:21:50 +00:00
Tait Hoyem
c85c9d40c2
Add config option to make create-on-push repositories public by default (#12936)
* Add config option to make create-on-push repositories public by default

* Fix linting

* Add option to 'config cheat sheet' page

* Chinese translation

Signed-off-by: a1012112796 <1012112796@qq.com>

* Fix typo in docs

* fix typo

* Add option to example config

Co-authored-by: Tait Hoyem <code@tait.tech>
Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-27 15:20:52 -04:00
GiteaBot
82179a6e81 [skip ci] Updated translations via Crowdin 2020-09-27 02:11:47 +00:00
Bagas Sanjaya
fb467c7e74
Update GitHub docs links for SSH & GPG (#12947)
The links now redirected to docs.github.com. `common SSH problems` link
is misredirected to `Authenticating to GitHub` page, so it has been
corrected to the proper `troubleshooting SSH` page.

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-26 22:10:41 -04:00
GiteaBot
b49ebc2ba8 [skip ci] Updated translations via Crowdin 2020-09-26 17:57:16 +00:00
Bagas Sanjaya
b725c4ee53
Add a step for binding IP address for listening on remote database (#12898)
* Add listen address configuration step
  * Fix numbering order

Signed-off-by: Bagas Sanjaya <bagasdotme@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-26 13:56:13 -04:00
Melroy van den Berg
95ff55991e
Proposals for cheat-sheet docs (#12946)
* Propose additional settings in cheat sheet

Add most used settings of app.ini to cheat sheet docs.

* Fix small typo
2020-09-26 02:05:49 -04:00
Johan Van de Wauw
34d9cb335c
API: Get release by tags endpoint (#12932)
Get a release based on a tag name (for which a release exists).
Based on:
https://developer.github.com/v3/repos/releases/#get-a-release-by-tag-name

Co-authored-by: 赵智超 <1012112796@qq.com>
Co-authored-by: 6543 <6543@obermui.de>
2020-09-25 20:11:43 +01:00
赵智超
d71eaacbf2
[Docs] Add all chooseable cron config options to 'app.example.ini' (#12931)
As title.

ref:
https://github.com/go-gitea/gitea/blob/master/modules/cron/tasks_basic.go
https://github.com/go-gitea/gitea/blob/master/modules/cron/tasks_extended.go
ba20dd7a7b/modules/setting/cron.go (L7-L11)

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-09-25 18:37:33 +01:00
GiteaBot
274430f40b [skip ci] Updated translations via Crowdin 2020-09-25 08:59:15 +00:00
zeripath
f1ab1c532b
Allow extended config on cron settings (#12939)
* Allow extended config on cron settings

Fix #12934

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-25 09:58:09 +01:00
赵智超
3c360801b3
Add IsTemplate option in create repo ui and api (#12942)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-25 13:18:37 +08:00
zeripath
7a7f56044a
Adopt repositories (#12920)
* Don't automatically delete repository files if they are present

Prior to this PR Gitea would delete any repository files if they are
present during creation or migration. This can in certain circumstances
lead to data-loss and is slightly unpleasant.

This PR provides a mechanism for Gitea to adopt repositories on creation
and otherwise requires an explicit flag for deletion.

PushCreate is slightly different - the create will cause adoption if
that is allowed otherwise it will delete the data if that is allowed.

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

* Update swagger

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

* Fix tests and migrate overwrite

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

* as per @lunny

Only offer to adopt or overwrite if the user can do that.

Allow the site administrator to adopt or overwrite in all
circumstances

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

* Use setting.Repository.DefaultBranch for the default branch

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

* Always set setting.Repository.DefaultBranch

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

* update swagger

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

* update templates

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

* ensure repo closed

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

* Rewrite of adoption as per @6543 and @lunny

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

* Apply suggestions from code review

* update swagger

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

* missing not

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

* add modals and flash reporting

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

* Make the unadopted page searchable

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

* Add API

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

* Fix swagger

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

* fix swagger

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

* Handle empty and non-master branched repositories

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

* placate lint

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

* remove commented out code

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-25 07:09:23 +03:00
ひのしば / hinoshiba
6fa19a8458
Fixed count of filtered issues when api request. (#12275)
* Improved total count of issue when filtered.

* Fixed size of slice when  selected 1 repository.

* Improved function of error check.

* improved comment

* Added parameter of return header.

Co-authored-by: 6543 <6543@obermui.de>

* Updated corresponded to the current vendored of "xorm.io/xorm".

* Dedublicated it by store the Options Struct into a variable.

* format code

* Update routers/api/v1/repo/issue.go

Co-authored-by: 6543 <6543@obermui.de>

* Update routers/api/v1/repo/issue.go

Co-authored-by: 6543 <6543@obermui.de>

* Updated number of range.

Co-authored-by: 6543 <6543@obermui.de>

* Updated number of range.

Co-authored-by: 6543 <6543@obermui.de>

* Removed total value.

* make fmt

* Improved value of sql.

Co-authored-by: zeripath <art27@cantab.net>

* Improved value of sql.

* improved message

* improved message

* improved message

* fixed message

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-24 19:30:40 -04:00
GiteaBot
b5109272db [skip ci] Updated translations via Crowdin 2020-09-24 22:38:04 +00:00
6543
efebb824ac
API: GetReleaseByID return 404 if not found (#12933)
* API: GetReleaseByID return 404 if not found

* update swagger docs
2020-09-24 18:36:56 -04:00
6543
ba20dd7a7b
Fix Create Repository Template (#12924)
Co-authored-by: zeripath <art27@cantab.net>
2020-09-23 16:53:06 -05:00
GiteaBot
01ad714715 [skip ci] Updated translations via Crowdin 2020-09-23 20:26:51 +00:00
zeripath
3f522cdaad
Fix handling of migration errors (#12928)
* Fix handling of migration errors

The migration type selection screen PR did not correctly handle errors
and any user input error on the migration page would simply redirect
back to the selection page. This meant that the error would simply be
lost and the user would be none the wiser as to what happened.

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

* make gen-swagger

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-23 15:25:46 -05:00
GiteaBot
f215e015df [skip ci] Updated translations via Crowdin 2020-09-22 17:03:23 +00:00
techknowlogick
1c3278c2fa
update revive lint to latest commit (#12921)
* update revive lint to latest commit

* make fmt

* change import
2020-09-22 20:02:16 +03:00
mrsdizzie
63e8bdaf73
Disable migration items when mirror is selected (#12918)
* Disable migration items when mirror is selected

Disable migration items when mirror option is selected to make it more clear that it isn't possible to mirror anything other than code.

* allow wiki checkbox for mirrors

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-22 01:42:22 +03:00
GiteaBot
060d46dd25 [skip ci] Updated translations via Crowdin 2020-09-21 14:37:57 +00:00
John Olheiser
ec6a35aeb1
Hopefully support GH enterprise (#12863)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-21 10:36:51 -04:00
6543
2dbca92a0f
API: NotificationSubject show Issue/Pull State (#12901) 2020-09-20 19:10:53 -04:00
GiteaBot
3f9eb93cc6 [skip ci] Updated translations via Crowdin 2020-09-20 21:56:51 +00:00
赵智超
b74ed16c41
Fix ListUserOrgs (#12910)
fix #12891

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-21 00:55:48 +03:00
GiteaBot
23f064e813 [skip ci] Updated translations via Crowdin 2020-09-20 20:21:12 +00:00
赵智超
fec1521555
Not using "ctx.ServerError" in api (#12907)
This function will render a whole html page which is not useful for API.

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-09-20 21:20:14 +01:00
GiteaBot
e7ffc67ad5 [skip ci] Updated translations via Crowdin 2020-09-20 17:56:20 +00:00
zeripath
037d5a33a0
Update only the repository columns that need updating (#12900)
We should only update is_empty, default_branch and updated time columns
during commitRepoAction and not update other columns as we risk
overwriting incorrect information.

Fix #11823
Fix #10536

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-20 13:55:15 -04:00
GiteaBot
7e5499575b [skip ci] Updated translations via Crowdin 2020-09-19 23:22:29 +00:00
赵智超
7f966f316b
Add the checkbox quick button to the comment tool bar also (#12885)
Just copy it from the WIKI tool bar :)

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-09-20 07:21:22 +08:00
GiteaBot
355788db46 [skip ci] Updated translations via Crowdin 2020-09-19 16:45:53 +00:00
zeripath
4979f15c3f
Add configurable Trust Models (#11712)
* Add configurable Trust Models

Gitea's default signature verification model differs from GitHub. GitHub
uses signatures to verify that the committer is who they say they are -
meaning that when GitHub makes a signed commit it must be the committer.
The GitHub model prevents re-publishing of commits after revocation of a
key and prevents re-signing of other people's commits to create a
completely trusted repository signed by one key or a set of trusted
keys.

The default behaviour of Gitea in contrast is to always display the
avatar and information related to a signature. This allows signatures to
be decoupled from the committer. That being said, allowing arbitary
users to present other peoples commits as theirs is not necessarily
desired therefore we have a trust model whereby signatures from
collaborators are marked trusted, signatures matching the commit line
are marked untrusted and signatures that match a user in the db but not
the committer line are marked unmatched.

The problem with this model is that this conflicts with Github therefore
we need to provide an option to allow users to choose the Github model
should they wish to.

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

* Adjust locale strings

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

* as per @6543

Co-authored-by: 6543 <6543@obermui.de>

* Update models/gpg_key.go

* Add migration for repository

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

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-20 00:44:55 +08:00
GiteaBot
89c94e2f8e [skip ci] Updated translations via Crowdin 2020-09-18 17:51:09 +00:00
mrsdizzie
25ddf77b51
Fix panic when adding long comment (#12892)
Previous PR #12881 causes out of bounds panic by working on wrong string.
2020-09-18 13:50:06 -04:00
zeripath
54ae448588
Switch to absolute latest pq driver (#12859)
This PR updates the lib/pq driver to the current master head to
pick up the deadlock fix in lib/pq#993

Hopefully this will resolve our CI issues.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-18 17:38:46 +03:00
GiteaBot
7250f5342f [skip ci] Updated translations via Crowdin 2020-09-18 12:10:52 +00:00
6543
1418288734
Refactor: move Commit To APIFormat Code & Lot of StopWatch related things (#12729)
* move GitCommit to APIFormat convertion into convert package

* rename Commit convert functions

* move stopwatch to api convertion into convert package & rm unused code & extend test

* fix compare time

* Gitea not Gogs ;)
2020-09-18 20:09:26 +08:00
赵智超
5995326d51
Add size limit for content of comment on action ui (#12881)
Signed-off-by: a1012112796 <1012112796@qq.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-18 10:38:21 +03:00
Lunny Xiao
1fb5bbd098
Fix pgsql migration test (#12844)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-18 09:36:14 +08:00
6543
06480af472
Convert User expose ID each time (#12855)
* git blame tells me a lot of gitea things happen here around 2018, add header

* move user code int its own file

* expose user id

* adopt things from APIFormat

* fix test

* CI.restart()
2020-09-17 16:33:23 -05:00
GiteaBot
afea4faa33 [skip ci] Updated translations via Crowdin 2020-09-17 18:25:33 +00:00
zeripath
9c439a7c99
Support slashes in release tags (#12864)
Fix #12861

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-17 19:24:23 +01:00
赵智超
a9decf0dac
Use a simple format for the big number on ui (#12822)
* Use a simple format for the big number on ui

Signed-off-by: a1012112796 <1012112796@qq.com>

* make fmt

* Apply review suggestion @silverwind

* Change name 2

* make fmt

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-16 00:07:18 -04:00
赵智超
d8b5235ded
Add ui style for "Open a blank issue" button (#12824)
* Add ui style for "Open a blank issue" button

Signed-off-by: a1012112796 <1012112796@qq.com>

* Apply review suggestion @silverwind

* format

* format 2

* fix message

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-16 10:07:09 +08:00
GiteaBot
ace8a283f1 [skip ci] Updated translations via Crowdin 2020-09-15 23:50:35 +00:00
赵智超
ec5677b7a2
Simplify CheckUnitUser logic (#12854)
if check one user's unit in different repos, it's not necessary to
get user data every time.

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-15 19:49:34 -04:00
6543
07995e2301
Fix [API] [Bug] CreateRepo missing information (#12848)
* Fix [API] [Bug] CreateRepo missing information

* add code comment

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-15 18:42:19 -04:00
zeripath
772b5e0f54
Add migration for password algorithm change (#12784)
* Add migration for password algorithm change

#12688 changed the default for the user table leading to sync2 warnings

Unfortunately changing defaults requires a complete table rewrite in general.

However, just dropping columns could be bad - so this PR leverages the
techniques used in recreate table to recreate from the inferred schema
and recreates the user table.

This is not necessarily the correct thing to do - but code sometimes speaks
louder than words.

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

* oops

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

* ok lets use the shorter bits for other dbs

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

* Update models/migrations/v150.go

* Update models/migrations/v150.go

* fix migration

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

* mv v150 to v151.go

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-15 18:02:41 -04:00
mrsdizzie
88823f3e29
Fix line selection on blame view (#12857)
Blame and regular code view have diverge slightly so line highlighting wasn't working properly anymore. Make work again in lieu of a larger refactor of blame HTML to move it outside of source and into templates to match code view.

Fixes #12836

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-15 16:43:05 -04:00
John Olheiser
d9085fe176
Fix anonymous GL migration (#12862)
* Fix anonymous GL migration

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Rely on password instead

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
2020-09-15 15:32:14 -04:00
zeripath
0d14c2fb93
Don't keep running SetEngine in migration_test (#12860)
There's no need to keep repeatedly running SetEngine in migration_test,
as NewEngine calls it anyway.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-15 19:44:52 +01:00
GiteaBot
81ed47c29d [skip ci] Updated translations via Crowdin 2020-09-15 14:38:30 +00:00
6543
6c61f498ea
On Migration respect old DefaultBranch (#12843)
* On Migration respect old DefaultBranch

* add DefaultBranch int test set

Co-authored-by: zeripath <art27@cantab.net>
2020-09-15 22:37:44 +08:00
GiteaBot
3d0ad2885a [skip ci] Updated translations via Crowdin 2020-09-15 11:29:56 +00:00
zeripath
d5e6211987
Fix notifications page links (#12838)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-15 07:06:08 +01:00
zeripath
342e49e325
Stop cloning unnecessarily on PR update (#12839)
* Stop cloning unnecessarily on PR update

Fix #12740

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

* Remove unnecessary delete

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

* fix lint

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-14 23:32:31 -04:00
Johan Van de Wauw
08a905f614
Fix external renderers example (#12841)
* libffi-dev is required for building jupyter
* matplotlib can not be installed using wheels on the used version of alpine
  linux, which means it must be compiled and  a large number of other packages
  have to be installed as well.
  This is very inefficient: see eg.
  https://pythonspeed.com/articles/alpine-docker-python/

  Apart from that, matplotlib is actually not required for rendering
  notebook files in gitea and it will pull in other dependencies which take some
  time to build (ie numpy).
2020-09-14 18:11:11 -04:00
zeripath
ed2bdf455c
Fix background of signed-commits on arc-green (#12837)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-14 21:18:04 +01:00
GiteaBot
c950ea10ab [skip ci] Updated translations via Crowdin 2020-09-14 18:43:45 +00:00
Lunny Xiao
642c3c258b
Fix git open close bug (#12834) 2020-09-14 19:42:40 +01:00
GiteaBot
6a1a6332de [skip ci] Updated translations via Crowdin 2020-09-14 11:49:03 +00:00
6543
00a806de68
[API] Milestone endpoints accept names too (#12649)
* API: Milestone endpoints accept names too

* add test

* rename

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-14 14:48:03 +03:00
GiteaBot
33f606ce4c [skip ci] Updated translations via Crowdin 2020-09-14 10:41:18 +00:00
Jui-Nan Lin
6c4e9623cc
fix: use Base36 for all code indexers (#12830) 2020-09-14 13:40:07 +03:00
GiteaBot
53b656582e [skip ci] Updated translations via Crowdin 2020-09-13 01:49:50 +00:00
John Olheiser
b2bda11595
Fix markdown meta parsing (#12817)
* Fix meta parsing and add minimal test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add license

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Require first separator and add more tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Make fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Go lets this work gracefully 🙏

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-12 21:48:47 -04:00
zeripath
f91bb745d6
Don't replace underscores in auto-generated IDs in goldmark (#12805)
Fix #12196

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-12 12:00:48 -04:00
GiteaBot
55e05ad1ce [skip ci] Updated translations via Crowdin 2020-09-12 12:32:50 +00:00
Lunny Xiao
8ce10fb6e1
Fix bug on elastic search (#12811)
* Fix bug on elastic search

* Add more comments for elastic search result startIndex and endIndex

* refactor indexPos

* refactor indexPos

* Fix bug
2020-09-12 20:31:52 +08:00
赵智超
ae528d8321
Translate two small lables on commit statuse list (#12821)
* Requested
* Details

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-09-12 15:29:50 +08:00
GiteaBot
c18c6cf4cf [skip ci] Updated translations via Crowdin 2020-09-11 20:20:02 +00:00
silverwind
ffddf3f8a6
Make SVG size argument optional (#12814)
Now defaults to 16 on both frontend and backend.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-11 16:19:00 -04:00
John Olheiser
26c4a049da
Issue templates directory (#11450)
* Issue templates

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add some comments, appease the linter

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add docs and re-use dir candidates

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add default labels to issue templates

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Generate swagger

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Suggested changes

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update issue.go

* Suggestions

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Extract metadata from legacy if possible

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-11 10:48:39 -04:00
Lunny Xiao
dd1a651b58
Move all push update operations to a queue (#10133)
* Fix test

* Add no queue for test only

* improve code

* Auto watch whatever branch operation

* Fix lint

* Rename noqueue to immediate

* Remove old PushUpdate function

* Fix tests

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-11 10:14:48 -04:00
GiteaBot
910947fbcd [skip ci] Updated translations via Crowdin 2020-09-11 12:39:57 +00:00
zeripath
7777017b43
Show PR settings on empty repos (#12808)
Fix #12788

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-11 13:39:01 +01:00
zeripath
4eb0a1dfaf
Disable watch and star if not signed in (#12807)
Fix #12070

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-11 12:01:51 +01:00
zeripath
e0ac545043
Add postgres schema to the search_path on database connection (#12634)
Rather than rely on the user running the gitea server and db setting the
schema search_path correctly - if gitea is run with a schema we should
simply set the search_path to have that schema first in the path.

Fix #12505

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-11 10:30:19 +01:00
zeripath
25c870faa9
Whilst changing the character set to utf8mb4 we should set ROW_FORMAT=dynamic too (#12804)
Fix #12801

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-11 09:25:06 +01:00
GiteaBot
29ac1f9122 [skip ci] Updated translations via Crowdin 2020-09-11 06:45:37 +00:00
zeripath
a064153235
Set opengraph attributes on org pages (#12803)
Fix #12778

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-11 07:41:43 +01:00
zeripath
bfd9ca33b7
Remove double escape on labels addition in comments (#12809)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-11 00:06:41 -04:00
6543
fd60ebfe14
[API] Migration: Change ServiceType String (#12672)
* use different structs for MigrateRepoOptions on UI and API

* Fix TokenAuth and rename UID to an understandable Name

* fix swagger doc

* simplify & mk redable

* R E F A C T O R:
migration has now internal 3 structs to store its options:
 * the Options for WebUI: modules/auth/repo_form.go
 * the Options for API: modules/structs/repo.go
 * the option struct with after validation for internal prossessing: modules/migrations/base/options.go

* Copyright Header

* Deprecate UID - add RepoOwner

* adopt repo.go -> migrate.go

* add comment about each struct purpose

* lint
2020-09-10 23:29:19 +01:00
zeripath
daefdd1385
Update gitea.com/macaron/i18n (#12806)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-10 16:32:58 -05:00
zeripath
47289344e2
Add Primary Key to Topic and RepoTopic (#12639)
Add a primary key to Topic and RepoTopic tables

Fix #8920

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-10 20:45:01 +01:00
赵智超
4f8dad37f8
ui: change commentTag style (#11668)
* ui: change commentTag style

* Add comment tag in first comment (issue content)
* Show CommentTagPoster in other way

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update routers/repo/issue.go

Co-authored-by: Lauris BH <lauris@nix.lv>

* fix lint

* revert CommentTagPoster

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-10 14:09:14 -04:00
GiteaBot
5b10da241b [skip ci] Updated translations via Crowdin 2020-09-10 17:06:38 +00:00
Marshmallow
4d1c41d4e2
fix readme format (#12797)
Originally, the tabbed content under 'If pre-built frontend files are present it is possible to only build the backend:‘ has tab within the tabbed content. This commit fixed it.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-10 13:05:15 -04:00
John Olheiser
c3e8c9441a
Add check for LDAP group membership (#10869)
This is a port of gogs/gogs#4398

The only changes made by myself are:

Add locales
Add some JS to the UI
Otherwise all code credit goes to @aboron

Resolves #10829

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-09-10 16:30:07 +01:00
Bagas Sanjaya
4c42fce401
Add placeholder text for bio profile text form (#12792)
* Add placeholder text
  * Localize
2020-09-10 15:29:26 +01:00
GiteaBot
7354efe702 [skip ci] Updated translations via Crowdin 2020-09-10 13:05:36 +00:00
6543
e10327168d
GitLab DL: normalizeColor (#12793) 2020-09-10 14:04:30 +01:00
Lunny Xiao
0db9043aa7
return error when create gitlabdownloader (#12790) 2020-09-10 11:27:49 +03:00
GiteaBot
b333aa7db4 [skip ci] Updated translations via Crowdin 2020-09-10 04:17:37 +00:00
silverwind
a775428516
Update JS dependencies (#12782)
- Update all dependencies
- Add explicit postcss dependency as dictated by postcss-loader
- Adapt for new postcss-loader syntax
- Move sourceMap options to top for consistency

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-10 12:16:40 +08:00
techknowlogick
33ac0cc125
Set language via AJAX (#12785)
* Set language via AJAX

* fix lint
2020-09-10 09:09:23 +08:00
GiteaBot
fcc410c350 [skip ci] Updated translations via Crowdin 2020-09-09 19:09:54 +00:00
赵智超
ffa12bdb71
Fix "only mail on mention" bug (#12775)
* fix mail mention bug

fix #12774

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-09 15:08:55 -04:00
GiteaBot
0cd49aaebd [skip ci] Updated translations via Crowdin 2020-09-09 18:30:16 +00:00
Lunny Xiao
e153cf07c3
Add a migrate service type switch page (#12697)
* Add a migrat service type switch page

* Improve translations

* remove images

* Fix images

* remove extra create repo button on dashboard

* Follow reviewers' opinions

* Fix frontend lint

* Remove wrong submit file

* Fix tests

* Adjust the size of image

* Apply suggestions from code review

Co-authored-by: 赵智超 <1012112796@qq.com>

* Remove username and password from migration of github/gitlab

* Improve docs

* Improve interface docs

Co-authored-by: 赵智超 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-09 14:29:10 -04:00
GiteaBot
6483dbc8ec [skip ci] Updated translations via Crowdin 2020-09-09 17:32:39 +00:00
zeripath
7be0939332
Add MySQL FAQ section (#12780)
* Add MySQL FAQ section

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

* Update docs/content/doc/help/faq.en-us.md

* Update docs/content/doc/help/faq.en-us.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
2020-09-09 13:31:31 -04:00
GiteaBot
090024db37 [skip ci] Updated translations via Crowdin 2020-09-09 13:09:44 +00:00
zeripath
96969ddec8
Fix yet another bug with diff file names (#12771)
Following further testing it has become apparent that the diff line
cannot be used to determine filenames for diffs with any sort of predictability
the answer therefore is to use the other lines that are provided with a diff

Fix #12768

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-09 14:08:40 +01:00
GiteaBot
1fbc50f974 [skip ci] Updated translations via Crowdin 2020-09-08 22:07:38 +00:00
John Olheiser
c6e4bc53aa
Check passwords against HaveIBeenPwned (#12716)
* Implement pwn

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update module

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Apply suggestions mrsdizzie

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Add link to HIBP

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add more details to admin command

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add context to pwn

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Consistency and making some noise ;)

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-09-08 17:06:39 -05:00
Lunny Xiao
bea343ce09
Upgrade xorm to v1.0.5 (#12765)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-08 13:57:19 -04:00
silverwind
3865ecbf13
File header tweaks, add CSS helpers (#12635)
- replace two instances of fontawesome with octicons
- add new "class" optional argument to "svg" helper
- add many new CSS helpers and move their import to the end for
  increaseed precedence

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-08 13:17:56 -04:00
Vedran
e204398754
Change/remove a branch of an open issue (#9080)
* Add field with isIssueWriter to front end

* Make branch field editable

* Switch frontend to form and POST from javascript

* Add /issue/id/ref endpoint to routes

* Use UpdateIssueTitle model to change ref in backend

* Removed crossreference check and adding comments on branch change

* Use ref returned from POST to update the field

* Prevent calling loadRepo from models/

* Branch/tag refreshed without page reload

* Remove filter for empty branch name

* Add clear option to tag list as well

* Delete button translation and coloring

* Fix for not showing selected branch name in new issue

* Check that branch is not being changed on a PR

* Change logic

* Notification when changing issue ref

* Fix for renamed permission parameter

* Fix for failing build

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: Gitea <gitea@fake.local>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-08 12:29:51 -04:00
GiteaBot
0ed8d268ad [skip ci] Updated translations via Crowdin 2020-09-08 15:46:14 +00:00
Lunny Xiao
7a5465fc56
LFS support to be stored on minio (#12518)
* LFS support to be stored on minio

* Fix test

* Fix lint

* Fix lint

* Fix check

* Fix test

* Update documents and add migration for LFS

* Fix some bugs
2020-09-08 23:45:10 +08:00
techknowlogick
e4b3f35b8d
Removing k8s contrib file (#12761)
We now have a helm chart that users should use instead
2020-09-07 23:22:55 -04:00
mrsdizzie
489c8a1478
Compare SSH_DOMAIN when parsing submodule URLs (#12753)
Right now we only compare the hostname from a submodule with the prefixURL it is viewed from to check if the submodule is hosted on the same Gitea instance. This adds an additional check to compare it against SSH_DOMAIN as well since the same Gitea instance might have a different hostname for SSH and if the submodule uses that hostname we should also detect that and link to the proper DOMAIN value.

Fixes #12747, #9756
2020-09-07 20:08:10 -04:00
GiteaBot
9af60ce0bb [skip ci] Updated translations via Crowdin 2020-09-07 22:28:18 +00:00
6543
cfd8e8a489
gitea dump: include version & Check InstallLock (#12760)
* gitea dump: include version

* Check InstallLock (close #12759)

* fix test

* fix lint
2020-09-07 23:27:17 +01:00
GiteaBot
226aef7e0f [skip ci] Updated translations via Crowdin 2020-09-07 15:06:09 +00:00
Lunny Xiao
91e7ad569a
Add queue for code indexer (#10332)
* Add queue for code indexer

* Fix lint

* Fix test

* Fix lint

* Fix bug

* Fix bug

* Fix lint

* Add noqueue

* Fix tests

* Rename noqueue to immediate
2020-09-07 23:05:08 +08:00
zeripath
a722dd72db
Set setting.AppURL as GITEA_ROOT_URL environment variable during pushes (#12752)
* Set setting.AppURL as GITEA_ROOT_URL environment variable during pushes

Fix #11738

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-06 23:53:42 -04:00
Lunny Xiao
d17efaa114
Upgrade bleve to v1.0.10 (#12737)
* Fix bug on migration 111

* Upgrade bleve to 1.0.10

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-06 18:51:14 -04:00
zeripath
1b9d5074a7
Add command to recreate tables (#12407)
Provides new command: `gitea doctor recreate-table` which will recreate
db tables and copy the old data in to the new table.

This function can be used to remove the old warning of struct defaults being
out of date.

Fix #8868
Fix #3265
Fix #8894

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-06 22:52:01 +01:00
6543
ad2bf376df
RepoInit Respect AlternateDefaultBranch (#12746) 2020-09-06 16:58:54 -04:00
GiteaBot
0b198eb392 [skip ci] Updated translations via Crowdin 2020-09-06 19:54:31 +00:00
6543
f7b3e06026
Fix Avatar Resize (resize algo NearestNeighbor -> Bilinear) (#12745)
* Update Vendor github.com/nfnt/resize

* switch resize algo NearestNeighbor -> Bilinear
2020-09-06 20:53:33 +01:00
GiteaBot
332dbe7393 [skip ci] Updated translations via Crowdin 2020-09-06 16:26:12 +00:00
zeripath
f727e3e1c9
Fix editor.commit_empty_file_text locale string (#12744)
editor.commit_empty_file_text should read `about to commit`
not `about commit`

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-06 12:24:24 -04:00
6543
3408fb73b6
Add better Swagger description and a example for GetArchive (#12743)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-06 12:23:47 -04:00
GiteaBot
43c303d35c [skip ci] Updated translations via Crowdin 2020-09-06 15:39:00 +00:00
6543
0c6a802731
[Vendor] Update xanzy/go-gitlab v0.31.0 => v0.37.0 (#12701)
* update github.com/xanzy/go-gitlab v0.31.0 => v0.37.0

* vendor

* adapt changes

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-06 11:37:53 -04:00
GiteaBot
0ed5e103fe [skip ci] Updated translations via Crowdin 2020-09-06 15:01:20 +00:00
赵智超
b613d70b41
ui: Show git-pull-request icon for closed pull request (#12742)
As title, I think it's more reasonable, and it's the same as GH.

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-09-06 11:00:16 -04:00
GiteaBot
a755e5adeb [skip ci] Updated translations via Crowdin 2020-09-06 10:35:50 +00:00
Lunny Xiao
e8958bfc38
Fix bug of migraition v111 (#12738) 2020-09-06 11:34:51 +01:00
GiteaBot
0cc4aadf58 [skip ci] Updated translations via Crowdin 2020-09-06 08:55:26 +00:00
Lunny Xiao
6590cac89b
Fix bug on migration 111 (#12736)
* Fix bug on migration 111

* Check reviews when migrating v111

* Fix bug

* Fix commit
2020-09-06 16:54:29 +08:00
6543
1c35353c53
implemet Cache for Stopwatches.APIFormat() (#12730)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-05 21:20:27 -04:00
6543
f10d3ea803
[Vendor] Fix Version Compare Lib (#12735)
* switch to patched fork

* vendor

* reference upstream lib and use replace in go.mod

* reference upstream lib and use replace in go.mod

* Apply suggestions from code review

* vendor

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-05 20:44:34 -04:00
GiteaBot
67ec27150e [skip ci] Updated translations via Crowdin 2020-09-05 22:51:54 +00:00
zeripath
69b8d7ba19
use assignment in tests (#12734)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-06 01:50:57 +03:00
GiteaBot
78509b5f9b [skip ci] Updated translations via Crowdin 2020-09-05 20:13:09 +00:00
techknowlogick
9a17e2830b
refactor repo_stats to use os.pipe (#11726)
* refactor repo_stats to use os.pipe

* woops. missing reader.

* stdout not stderr, woops

* Fix copyright date and ensure that the stderr is collected

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
2020-09-05 16:12:14 -04:00
GiteaBot
913ac9cacd [skip ci] Updated translations via Crowdin 2020-09-05 17:39:52 +00:00
6543
1ea1cade85
Add Created & Updated to Milestone (#12662)
* Add Created and Updated to Milestone table and expose via API

* Expose to UI - To Overloaded ?!?

* fix unit test

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-05 13:38:54 -04:00
GiteaBot
7404786420 [skip ci] Updated translations via Crowdin 2020-09-05 16:43:55 +00:00
6543
bc11caff94
[Vendor] Switch go-version lib (#12719)
* vendor: switch from "mcuadros/go-version" to "hashicorp/go-version"

* Adapt P1

* simplify

* fix lint

* adapt

* fix lint & rm old code

* no deadlock

* rm RWMutex and check GoVersion only 1-time

* Copyright header

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-05 12:42:58 -04:00
zeripath
9fdb4f887b
Update to go-org 1.3.2 (#12728)
* Update to go-org 1.3.2

Fix #12727

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

* Fix unit test

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-05 11:45:10 -04:00
GiteaBot
e80eda7d01 [skip ci] Updated translations via Crowdin 2020-09-05 11:59:34 +00:00
Jochen Peters
385433d2f4
additional data for type StopWatch in swagger api (#12458)
* additional data for type StopWatch in swagger api

* fix lint-backend issue with gofmt

* fix format in v1_json with 'make generate-swagger'

* using issue.LoadRepo() instead of getRepositoryByID()

Co-authored-by: jochen@homeland <no-go@localhost>
Co-authored-by: zeripath <art27@cantab.net>
2020-09-05 12:58:33 +01:00
6543
dba5d82f86
Expose Attachemnt Settings by API (#12514)
close #12368
2020-09-05 08:43:06 +01:00
techknowlogick
bab1204db4
Use pre-built hugo binary in release step (#12725)
* Use pre-built hugo binary in release step

* decrease verbosity of tar
2020-09-05 07:24:36 +01:00
Lunny Xiao
b51bd7f1d6
Refactor webhook payload convertion (#12310)
* Refactor webhook payload convertion

* Fix lint

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 22:57:13 -04:00
silverwind
e1535c74cc
Add 'make watch' (#12636)
* Add 'make watch'

This combines frontend and backend watch into a single command that runs
them in parallel on on SIGINT terminates both.

Termination is not super-clean but I guess it does not have to.

* move to tools/, trap more signals, remove gnu-specific flag

* simplify

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 20:55:06 -04:00
GiteaBot
9837b598fc [skip ci] Updated translations via Crowdin 2020-09-04 22:47:21 +00:00
techknowlogick
144de79c1b
Add details re: Kanban (#12721) 2020-09-04 18:46:21 -04:00
zeripath
bda9e51fef
Remove async pre-empt hack if go >= 1.15 (#12718)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 14:59:19 -04:00
techknowlogick
482b0e6d47
Bump min required golang to 1.13 (#12717)
* Bump min required golang to 1.13

* Update config.yaml

* Update Makefile

* per silverwind feedback

* per silverwind

Co-authored-by: zeripath <art27@cantab.net>
2020-09-04 14:12:01 -04:00
6543
2a52aeec49
API: Expose its limitation settings (#12714)
* API: Expose its limitation settings

* TESTs

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 14:10:15 -04:00
GiteaBot
45c0ec3152 [skip ci] Updated translations via Crowdin 2020-09-04 17:30:03 +00:00
6543
fb603825f5
Test ignore migration rate limitation error (#12715) 2020-09-04 13:28:36 -04:00
6543
ca81b6528b
UI: Inform user what meaning hourglass on reviews has (#12713)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 12:36:37 -04:00
Lauris BH
e710a34981
Add spent time to referenced issue in commit message (#12220) 2020-09-04 11:37:37 -04:00
zeripath
4c557eff5d
Add github api token option to generate-license & generate-gitignore (#12700)
* Add github api token option to generate-license & generate-gitignore

Without api toke, Will face rate limit sometimes.

Signed-off-by: a1012112796 <1012112796@qq.com>

* Use Basic authentication with tokens

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

Co-authored-by: a1012112796 <1012112796@qq.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 10:02:37 -04:00
6543
d7456106bf
fix go1.15 lint error in modules/public/public.go (#12707)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-04 16:15:54 +03:00
6543
f083bd70df
Changelog for 1.12.4 release (#12687) (#12709)
* Changelog for 1.12.4 release (#12687)


Co-authored-by: zeripath <art27@cantab.net>

* update gitea version in docs

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-09-03 23:44:34 -04:00
6543
6c5266c9ca
[BugFix] Fix comment broken issue ref dependence (#12651)
* deleteIssuesByRepoID: delete related CommentTypeRemoveDependency & CommentTypeAddDependency comments too

* Ignore ErrIssueNotExist on comment.LoadDepIssueDetails()

* Add migration

* Ignore 'dependent_issue_id = 0' case

* exchange as per @lunny

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-04 09:36:56 +08:00
GiteaBot
42a5e39b3b [skip ci] Updated translations via Crowdin 2020-09-03 21:27:49 +00:00
silverwind
844d9b46f3
Update JS dependencies (#12702)
- Added some new octicons
- Add explicit less dependency as required by upstream
- Enable es2021 environment in eslint
2020-09-04 00:26:50 +03:00
GiteaBot
6d6b5ceaa5 [skip ci] Updated translations via Crowdin 2020-09-03 18:59:33 +00:00
zeripath
5c0697ad1e
Use argon as default password hash algorithm (#12688)
* Restrict TLS connections to 1.2 minimum

* Set Argon2 as the default KDF

* Fix user.yml

* Remove TLS minversion changes

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

* Add migration as per @techknowlogick

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

* set the password algo in the fixtures

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

* Remove the v148 migration - it needs recreate table to change the defaults

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

Co-authored-by: Nadim Kobeissi <nadim@symbolic.software>
2020-09-03 14:58:31 -04:00
GiteaBot
8fa7a4b511 [skip ci] Updated translations via Crowdin 2020-09-03 10:12:22 +00:00
Lunny Xiao
f1a7cd6757
Remove GOPATH set up on hacking (#12698) 2020-09-03 11:11:23 +01:00
GiteaBot
baa93855e8 [skip ci] Updated translations via Crowdin 2020-09-03 07:36:13 +00:00
6543
ad4a644fb3
Migrations: Gitlab Add Reactions Support for Issues & MergeRequests (#12695)
* fix migrations: gitlab_test

* more stable test

* Get Reactions to Pulls

* Reactions for Issues

* Comments are still hard

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-09-03 10:35:17 +03:00
S7evinK
7af2ccd511
Avoid sending "0 new commits" webhooks (#12212)
* Avoid sending "0 new commits" webhook

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Revert "Avoid sending "0 new commits" webhook"

This reverts commit 1f47ccfacd81470e2c33a02bb8d255172aa4ec08.

* Move commit count check to more central place

* Make tests pass

* Update modules/webhook/webhook.go

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-02 22:46:02 -04:00
Lunny Xiao
514201af5d
Upgrade xorm to v1.0.4 (#12694) 2020-09-03 02:58:04 +01:00
zeripath
702e98c5ec
Set TLS minimum version to 1.2 (#12689)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-02 23:37:49 +01:00
zeripath
5fd9f72104
When reading expired sessions - expire them (#12686)
* When reading expired sessions - expire them

Update to latest macaron/session following merge of
https://gitea.com/macaron/session/pulls/11

Also remove old memory provider as 11 updates the memory provider to
make it unnecessary.

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

* and macaron/session/pulls/12

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-02 17:10:35 -04:00
GiteaBot
ed81a95a84 [skip ci] Updated translations via Crowdin 2020-09-02 20:20:42 +00:00
zeripath
dead2a9b2d
Escape failed highlighted code (#12685)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-09-02 16:19:42 -04:00
Daniel Aleksandersen
72eeb13e4d
Set avatar image dimensions (#12654)
Set the avatar image dimensions to help browsers
avoid layout reflows. Helps page load performance and
user experience (less content jank).

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-02 14:42:28 -04:00
zeripath
714ab71ddc
Ensure that all migration requests are cancellable (#12669)
* Ensure that all migration requests are cancellable

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

* Use WithContext as RequestWithContext is go 1.14

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-02 13:49:25 -04:00
6543
84eac6ed6c
Add make targed generate-license & generate-gitignore + Update (#12682)
* Add make targed generate-license & generate-gitignore

* Update Gitignores & Licenses

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-02 12:57:08 -04:00
GiteaBot
3ecd030cd5 [skip ci] Updated translations via Crowdin 2020-09-02 16:56:15 +00:00
赵智超
3981f1b127
Remove duplicate logic in initListSubmits (#12660)
* Remove duplicate logic in initListSubmits

Using the same logic to handle Choosing reviewers and assignees as
choosing label. It's the first step of #10926.

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix choose block

* fix nit

* try fix bug

* simple code

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-09-02 12:55:13 -04:00
GiteaBot
ea775e67fb [skip ci] Updated translations via Crowdin 2020-09-02 15:02:44 +00:00
Martin
a0c4c1ce0d
Fixes cli error for Asciidoctor (#12677)
The original fix for #8676 introduced illegal arguments for Asciidoctor, causing no rendering at all. This PR fixes the command line arguments so that Asciidoctor properly renders the text. See https://asciidoctor.org/docs/user-manual/#piping-content-through-the-cli as reference.
2020-09-02 11:01:28 -04:00
6543
3270e7a443
[Vendor] update go-swagger v0.21.0 -> v0.25.0 (#12670)
* Update go-swagger

* vendor
2020-09-01 10:01:23 -04:00
GiteaBot
66843f2237 [skip ci] Updated translations via Crowdin 2020-08-31 17:13:45 +00:00
zeripath
82b71881d8
Ensure repoNames are lowercased in serv (#12668)
#12624 missed lowering the provided repoPath.

(Additionally make a few fixes to the way the debug flag works.)

Fix #12659
Fix #12667

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-31 18:12:49 +01:00
GiteaBot
807a41ca9a [skip ci] Updated translations via Crowdin 2020-08-30 22:55:54 +00:00
zeripath
58f57b3b6c
Escape provider name in oauth2 provider redirect (#12648)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-30 23:55:01 +01:00
Lunny Xiao
9bc69ff26e
Support elastic search for code search (#10273)
* Support elastic search for code search

* Finished elastic search implementation and add some tests

* Enable test on drone and added docs

* Add new fields to elastic search

* Fix bug

* remove unused changes

* Use indexer alias to keep the gitea indexer version

* Improve codes

* Some code improvements

* The real indexer name changed to xxx.v1

Co-authored-by: zeripath <art27@cantab.net>
2020-08-30 19:08:01 +03:00
zeripath
d257485bc0
Rename models.ProtectedBranchRepoID to models.EnvRepoID and ensure EnvPusherEmail is set (#12646)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-30 08:24:39 +01:00
zeripath
17fbbe97d7
Do not disable commit changes button on repost (#12644)
If the user has pressed commit changes and the post has failed - do not disable
the commit changes button.

Fix #12072

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-29 17:32:46 -04:00
zeripath
9abc16a280
fix documentation for REFRESH_TOKEN_EXPIRATION_TIME (#12642)
REFRESH_TOKEN_EXPIRATION_TIME refers to the refresh token not the access token

Fix #12641

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-29 23:02:38 +03:00
silverwind
7187fdbb1c
Update eslint config (#12609)
- Remove unneeded "Tribute" global
- Separate Node and Browser environments
- Update environment to es2020 to enable new globals like "BigInt"
2020-08-29 16:34:00 +01:00
Mike L
afd89b1767
Dark theme for line numbers in blame view (#12632) 2020-08-29 13:41:04 +03:00
Mike L
e1eee2d00a
Avoid unnecessary system-ui expansion (#12522)
* Avoid unnecessary system-ui expansion (fix #12325)

* extract config to static object

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-28 19:41:28 -04:00
zeripath
7ba6fea0b7
Use shellquote to unpack arguments to gitea serv (#12624)
Fix #12471

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-28 20:55:25 +01:00
GiteaBot
274f9233ab [skip ci] Updated translations via Crowdin 2020-08-28 17:40:33 +00:00
Mike L
1fe909757c
Apply #12576 to top right reaction picker (#12623)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-28 13:39:41 -04:00
GiteaBot
3bf1c4fad0 [skip ci] Updated translations via Crowdin 2020-08-28 14:40:48 +00:00
zeripath
1d47a25759
Fix confusing last_org_owner locale string (#12628)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-28 09:39:50 -05:00
6543
d5b6931dbe
[API] Delete Token accept names too (#12366)
* Delete Token accept names too

* better description

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-28 11:09:33 +03:00
zeripath
eb1bf2377b
Set context for running CreateArchive in to that of the request (#12555)
Set the context for CreateArchive to that of the request to ensure that archives
are only built for as long as a request is requesting them

Fix #11551

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-28 09:55:12 +03:00
zeripath
d3b5edacb6
Escape more things that are passed through str2html (#12622)
* Escape more things that are passed through str2html

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

* Bloody editors!

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update routers/user/oauth.go

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-28 00:37:05 -04:00
GiteaBot
cbc60f5c70 [skip ci] Updated translations via Crowdin 2020-08-28 02:48:16 +00:00
techknowlogick
c5d5d63c9c
Macaron 1.5 (#12596)
* update macaron to v1.5 of fork

* update macaron to v1.5 of fork

* test gzip PR

* add push method impl to context_tests

* use proper gzip commit

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-08-27 22:47:17 -04:00
John Olheiser
211321fb93
Git migration UX (#12619)
* Initial work

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Implementation

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix gitlab and token cloning

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Imports and JS

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Linting

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Generate swagger

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move mirror toggle and rename options

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-08-28 09:36:37 +08:00
GiteaBot
ed2f6e137b [skip ci] Updated translations via Crowdin 2020-08-27 20:46:30 +00:00
silverwind
f8601f3f09
Fix ellipsis in files table (#12617)
Turns out text ellispsis does not work in combination with flexbox and
while wrapping in a display:block can help in some cases, I could not
get this to work properly so this changes the truncate to inline-block
again and reduces the clickable area to just vertical expansion from the
links.
2020-08-27 21:45:37 +01:00
silverwind
e25d4867be
Extract Swagger CSS to its own file (#12616) 2020-08-26 18:42:46 +01:00
赵智超
65444c5ea3
Add link to home page on swagger ui (#12601)
* Add link to home page on swagger ui

Signed-off-by: a1012112796 <1012112796@qq.com>

* translate

* Apply review suggestion

* Move to right, Thanks @silverwind

* tweaks

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-26 12:39:45 -04:00
silverwind
7d14d6c1c1
Fix file table overflows (#12603)
- Fix overflow regression from https://github.com/go-gitea/gitea/pull/12553.
- Fix submodule columns stretching the table
- Refactor template to share more HTML nodes
- Introduce CSS helper classes

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-26 11:52:44 -04:00
zeripath
69b3dd6362
Escape Email in forgot_password.tmpl (#12610)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-26 08:47:38 -05:00
John Olheiser
b611ae1908
Mark Cache with ini tag (#12605)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-08-26 02:04:18 +03:00
silverwind
eb4db0445b
Reindent Less to 2-space (#12602)
Reindent and unify codebase to 2-space indentation.
2020-08-25 22:48:53 +03:00
techknowlogick
e90e122b39
update to latest golangci-lint (v1.30.0) (#12597) 2020-08-25 09:24:37 +03:00
zeripath
f3fb3c6f56
Open transaction when adding Avatar email-hash pairs to the DB (#12577)
When adding Avatar email-hash pairs we simply want the DB table to
represent a Set. We don't care if the hash-pair is already present,
so we just simply Insert and ignore the error.

Unfortunately this seems to cause some DBs to log the duplicate
insert to their logs - looking like a bug a in Gitea.

Now, there is no standard way in SQL to say Insert but if there's
an error ignore it. MySQL has INSERT IGNORE, PostgreSQL >= 9.5 has
INSERT ... ON CONFLICT DO NOTHING, but I do not believe that SQLite
or MSSQL have variants.

This PR places the insert in a transaction which we are happy to fail
if there is an error - hopefully this will stop the unnecessary
logging.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-24 18:39:18 -04:00
techknowlogick
019e577d54
Update JWT docs in example config (#12591)
* Update JWT docs in example config

align with way we have `LFS_JWT_SECRET` in config

Fix #12590

* Update custom/conf/app.example.ini

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-08-24 17:49:26 -04:00
techknowlogick
125ffb87f0
go1.15 on windows (#12589)
* go1.15 on windows

* update xgo to use node14
2020-08-24 17:46:41 -04:00
6543
4b97f9018b
OpenGraph: use repo avatar if exist (#12586) 2020-08-24 22:46:56 +03:00
GiteaBot
63f3c42be9 [skip ci] Updated translations via Crowdin 2020-08-24 15:49:17 +00:00
zeripath
2ae8c7ab1c
Add cron running API (#12421)
* Add cron running API

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

* Apply suggestions from code review

* placate-swagger

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

* return not found

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

* Apply suggestions from code review

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-24 11:48:15 -04:00
silverwind
ee047312a1
Fix emoji replacements, make emoji images consistent (#12567)
- Fix emoji not being replaced in issue title change text
- Make the image attributes consistent, add alt, remove align

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-23 21:44:53 -04:00
silverwind
26bf4c51fb
Change tab width go,tmpl,html to 2 (#12572)
Make it easier to edit deeply nested code. I plan to convert Less to
2-space so that we have standardized indentation width in the codebase.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-23 18:48:40 -04:00
silverwind
0c0f049d09
Reaction picker display improvements (#12576)
- Remove overly thin font-width on counter
- Add hover effect on reaction picker
- Change colors on arc-green to green to match the theme

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-08-23 18:45:21 -04:00
zeripath
1bf7b8d7c1
Fix signing.wont_sign.%!s(<nil>) if Require Signing commits but not signed in (#12581)
signing.wont_sign.%!s(<nil>) will be displayed if the repository needs signed
commits but the user is not logged in.

This is displayed because of complicated logic in the the template repo/issue/view_content/pull.tmpl
and a shortcut in the code of routers/repo/issue.go

This PR adds a default value of notsignedin if users are not signed in, which
although our templates will not show will prevent custom templates from showing
the above.

It also fixes the template to avoid showing signing errors if the user is not
authorized to sign.

Replaces #12564
Close #12564

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-23 22:59:41 +01:00
silverwind
dd8ec12188
Increase clickable area on files table links (#12553) 2020-08-23 20:05:17 +01:00
GiteaBot
d2cee3eea6 [skip ci] Updated translations via Crowdin 2020-08-23 16:03:36 +00:00
John Olheiser
43a397ce9a
Initial support for push options (#12169)
* Initial support for push options

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix misspelling 🤦

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix formatting after conflict resolution

* defer close git repo

* According the GitLab documentation, git >= 2.10

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Words are hard. Thanks @mrsdizzie 😅

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Only update if there are push options

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
2020-08-23 17:02:35 +01:00
赵智超
e7d65cbc6e
Add email notify for new release (#12463)
* Add email notify for new release

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-08-23 16:03:18 +01:00
zeripath
e429c1164e
Ensure that the detected charset order is set in chardet test (#12574)
TestToUTF8WithFallback is the cause of recurrent spurious test failures
even despite code to set the detected charset order.

The reason why this happens is because the preferred detected charset order
is not being initialised for these tests.

This PR simply ensures that this is set at the start of each test and would
allow different tests to be written to allow differing orders.

Replaces #12571
Close #12571

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-23 14:15:29 +01:00
Lunny Xiao
2026d885d6
Fix bug on migration 147 (#12565) 2020-08-22 18:12:40 +01:00
zeripath
7a8a05cc44
Fix diff path unquoting (#12554)
* Fix diff path unquoting

services/gitdiff/gitdiff.go whereby there it assumed that the path would
always be quoted on both sides

This PR simplifies the code here and uses fmt.Fscanf to parse the
strings as necessary.

Fix #12546

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

* Add testcase as per @mrsdizzie

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-22 16:07:37 +01:00
zeripath
fcabbae168
Set utf8mb4 as the default charset on MySQL if CHARSET is unset (#12563)
MySQL in its infinite wisdom determines that UTF8 does not
mean UTF8. Our install scripts know about this and will set
CHARSET to utf8mb4 if we users choose this but... users who
do not explicitly set this variable will default to utf8mb3
without knowing it.

This PR changes the unset CHARSET value to utf8mb4 if users
choose to use mysql.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-22 13:56:33 +01:00
zeripath
b78448e94e
Skip SSPI authentication attempts for /api/internal (#12556)
* Skip SSPI authentication attempts for /api/internal

SSPI fails badly on authentication attempts to /api/internal which
it can never succesfully authenticate.

Fix #11260

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

* Update oauth2.go

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-22 12:09:43 +03:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
d4e35b9dc6
Hide 'New Project board' button for users that are not signed in (#12547)
* hide: 'New Project board' button

* there is no reason to show the button for users that are not signed in

* update template: specifies the condition together with another one

as per lafriks' suggestion in the comment

* chore: add proper user authorization check

* chore: also hide button if repo is archived

* chore: show project board edit/delete menu to authorized users only

* chore: drop the redundant IsSigned check

* CanWriteIssues and CanWritePulls implies (and requires) signed in user

* Add CanWriteProjects and properly assert permissions

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

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-22 02:58:59 -04:00
GiteaBot
a0484890c1 [skip ci] Updated translations via Crowdin 2020-08-22 01:24:01 +00:00
silverwind
9b804f4ed4
Speed up licenses.txt build during development, add additionalModules (#12510)
- Emit static string for licenses.txt during development for faster builds
- Manually add @primer/octicons to licenses.txt because it's never
  directy imported.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-21 21:23:03 -04:00
GiteaBot
d461591aac [skip ci] Updated translations via Crowdin 2020-08-21 22:43:28 +00:00
mrsdizzie
fb70b5d207
Disable password complexity check default (#12557)
* Disable password complexity check default

These features enourange bad passwords/are annoying for people using better password methods, and at minimum we shouldn't force that as a default for obvious reasons. Disable any default check to avoid regular complaints.

* fix copy paste format
2020-08-21 18:42:23 -04:00
zeripath
7c2cf236f8
Allow addition of gpg keyring with multiple keys (#12487)
Related #6778

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-21 13:45:50 +03:00
GiteaBot
ae23bbdae3 [skip ci] Updated translations via Crowdin 2020-08-21 07:54:15 +00:00
zeripath
9c9c3348bb
Prevent NPE on commenting on lines with invalidated comments (with migration) (#12549)
* Prevent NPE on commenting on lines with invalidated comments

Only check for a review if we are replying to a previous review.

Prevent the NPE in #12239 by assuming that a comment without a Review is
non-pending.

Fix #12239

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

* Add hack around to show the broken comments

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

* Add migration and remove template hacks

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-21 10:53:14 +03:00
zeripath
c6943cca52
Support Force-update in Mirror and improve Tracing in mirror (#12242)
* Remove double indirect in NewColoredIDValue

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

* Handle forced-update in mirror.go

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

* Add tracing

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

* As per @lafriks

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-20 16:41:07 -04:00
Success
7c0862b6d9
fix typos (#12545)
* fix typo in app.ini

* fix typo in git hook module

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-20 18:41:08 +01:00
GiteaBot
69a77b2a73 [skip ci] Updated translations via Crowdin 2020-08-20 16:31:53 +00:00
silverwind
f19cac41d2
Use Node 14 on CI (#12512)
* Use Node 14 on CI

Node 14 is sufficiently stable now, use it on CI.

* also run build on node 14

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-08-20 12:30:56 -04:00
Bagas Sanjaya
fff0204cab
Add placeholder text for "Add SSH/GPG Key" forms (#12533)
* Add placeholder text for "Add SSH/GPG Key" forms

This commit add placeholder text for both Add SSH key and Add GPG key
forms.

* Localize placeholders

Changes requested by @zeripath

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-20 11:51:34 -04:00
Gjergji Ramku
0c9eb468e9
Fix typos (#12542)
Signed-off-by: Gjergji Ramku <gjergjiramku@gmail.com>
2020-08-20 09:53:06 -05:00
zeripath
d15bb17b78
Default empty merger list to those with write permissions (#12535)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-08-20 10:48:40 +03:00
6543
dcb543ac2a
Show 2FA info on Admin Pannel: Users List (#12515) 2020-08-20 09:53:49 +08:00
zeripath
a5440fcb1e
Report error if API merge is not allowed (#12528)
#12496 demonstrated that the API merge needs to return some information as
to why a merge has been disallowed with a status code 422.

This PR ensures that a reason is always returned.

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-19 17:35:06 -04:00
zeripath
1701d57fb2
Set z-index for sticky diff box lower (#12537)
Fix #12525

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-19 13:37:57 -05:00
techknowlogick
1ca652c826
Add security policy to repo (#12536) 2020-08-19 17:15:55 +01:00
Wim
e14f6088f8
Remove hardcoded ES indexername (#12521) 2020-08-18 11:08:51 -05:00
GiteaBot
61a172900e [skip ci] Updated translations via Crowdin 2020-08-18 11:22:27 +00:00
Florian Klink
95d478c29c
change PIDFile default from /var/run/gitea.pid to /run/gitea.pid (#12500)
* docs: update heading

This section covers more paths than the 3 listed in the heading.

* setting: change PIDFile default from /var/run/gitea.pid to /run/gitea.pid

On most modern distributions, /var/run is deprecated and only kept for
backwards compat according to
https://refspecs.linuxfoundation.org/FHS_3.0/fhs/ch05s13.html, and is a
symlink to `/run/` on modern distributions.

Old Distros that still don't have `/run` can update the gitea default as
described in from-source.en-us.md to point to the old location.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-08-18 14:21:24 +03:00
GiteaBot
87fbb54abb [skip ci] Updated translations via Crowdin 2020-08-18 04:24:48 +00:00
Lunny Xiao
62e6c9bc6c
Add a storage layer for attachments (#11387)
* Add a storage layer for attachments

* Fix some bug

* fix test

* Fix copyright head and lint

* Fix bug

* Add setting for minio and flags for migrate-storage

* Add documents

* fix lint

* Add test for minio store type on attachments

* fix test

* fix test

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Add warning when storage migrated successfully

* Fix drone

* fix test

* rebase

* Fix test

* display the error on console

* Move minio test to amd64 since minio docker don't support arm64

* refactor the codes

* add trace

* Fix test

* remove log on xorm

* Fi download bug

* Add a storage layer for attachments

* Add setting for minio and flags for migrate-storage

* fix lint

* Add test for minio store type on attachments

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Fix drone

* fix test

* Fix test

* display the error on console

* Move minio test to amd64 since minio docker don't support arm64

* refactor the codes

* add trace

* Fix test

* Add URL function to serve attachments directly from S3/Minio

* Add ability to enable/disable redirection in attachment configuration

* Fix typo

* Add a storage layer for attachments

* Add setting for minio and flags for migrate-storage

* fix lint

* Add test for minio store type on attachments

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Fix drone

* fix test

* Fix test

* display the error on console

* Move minio test to amd64 since minio docker don't support arm64

* don't change unrelated files

* Fix lint

* Fix build

* update go.mod and go.sum

* Use github.com/minio/minio-go/v6

* Remove unused function

* Upgrade minio to v7 and some other improvements

* fix lint

* Fix go mod

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Tyler <tystuyfzand@gmail.com>
2020-08-18 12:23:45 +08:00
GiteaBot
02fbe1e5dc [skip ci] Updated translations via Crowdin 2020-08-17 19:13:00 +00:00
6543
1984b6a11b
Milestone Issue/Pull List: Add octicons type (#12499)
* add octicons based on issue type (pull|issue)

* handle IsRead again

* short code

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-17 15:11:42 -04:00
GiteaBot
5b9e7cf53c [skip ci] Updated translations via Crowdin 2020-08-17 16:59:11 +00:00
silverwind
51463a0a09
Fix 'make help' (#12509)
These targets are actually using plural names, fix help output for them.

Ref: https://github.com/go-gitea/gitea/pull/12352
2020-08-17 12:58:07 -04:00
GiteaBot
9cabd56fc0 [skip ci] Updated translations via Crowdin 2020-08-17 15:59:38 +00:00
6543
05b1af990e
add & correct Translation (#12507) 2020-08-17 11:58:23 -04:00
Lanre Adelowo
4027c5dd7c
Kanban board (#8346)
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>
Co-authored-by: Kerry <flatline-studios@users.noreply.github.com>
Co-authored-by: Jaqra <jaqra@hotmail.com>
Co-authored-by: Kyle Evans <kevans91@users.noreply.github.com>
Co-authored-by: Tsakiridis Ilias <TsakiDev@users.noreply.github.com>
Co-authored-by: Ilias Tsakiridis <ilias.tsakiridis@outlook.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-16 23:07:38 -04:00
silverwind
d285b5d35a
Add 'checks' Make and CI tasks (#12352)
* Add 'checks' Make and CI tasks

Introduce new "checks" targets that perform tasks that we've been piling
onto the linting tasks. This will make the linter tasks faster and
hopefully encourage some users to use them locally.

* add checks to --help

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-16 17:43:09 -04:00
zeripath
d1e67d7ade
Fix bug preventing transfer to private organization (#12497)
* Fix bug preventing transfer to private organization

The code assessing whether a private organization was visible to a user before
allowing transfer was incorrect due to testing membership the wrong way round

This PR fixes this issue and renames the function performing the test to be
clearer.

Further looking at the API for transfer repository - no testing was
performed to ensure that the acting user could actually see the new
owning organization.

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

* change IsUserPartOfOrg everywhere
2020-08-16 16:27:08 -04:00
zeripath
f50364a5b0
Keys should not verify revoked email addresses (#12486)
Fix #6778

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-16 09:44:34 +01:00
zeripath
ac3cfad23d
Make the default PID file compile-time settable (#12485)
#12391 offered to change the default PID file from /var/run/gitea.pid however in discussion it was decided that this could break users of older systems. An alternative was offered that we could make the PID file compile/link time settable.

This PR does this, and changes the name of the setting from CustomPID to simply PIDFile. It also updates the from-source docs to show how to change the compiler settings to do this.

Closes #12391

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Florian Klink <flokli@flokli.de>
2020-08-15 21:15:27 +01:00
6543
ee97e6a66a
Update gitea-vet to v0.2.1 (#12282)
* change to new code location

* vendor

* tagged version v0.2.0

* gitea-vet v0.2.1

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-15 13:13:07 -04:00
techknowlogick
eb60a5d054
Build windows using golang 1.14 (#12489) 2020-08-13 22:29:00 -04:00
techknowlogick
8a0049bb03
go-sqlite3 gomod version (#12490) 2020-08-14 09:54:46 +08:00
techknowlogick
b37c7dd384
Build windows using golang 1.14 (#12489) 2020-08-13 21:18:04 -04:00
zeripath
2ef318e6f1
Add Access-Control-Expose-Headers (#12446)
Fix #12424

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
2020-08-13 18:18:18 +01:00
6543
e266ba30cc
update (#12481)
Co-authored-by: zeripath <art27@cantab.net>
2020-08-13 11:57:08 -04:00
techknowlogick
c9d1e40dfc
UI: Update commit signature view (#12473) 2020-08-13 10:54:54 -04:00
techknowlogick
bd7d6a3d73
go1.15 (#12475)
* go1.15

* update makefile xgo version

* fix vet issue

* update docs to version of go in use

* add TODO for asyncpreemptoff

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-13 10:11:24 -04:00
GiteaBot
e01bac8404 [skip ci] Updated translations via Crowdin 2020-08-13 04:20:08 +00:00
zeripath
be1b33c197
Do not add prefix on http/https submodule links (#12477)
Fix #12345

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-13 00:19:04 -04:00
Lunny Xiao
4e1c7cc4ef
Fix ignored login on compare (#12476) 2020-08-12 12:34:57 +02:00
silverwind
c18b0529ed
Update JS dependencies (#12474)
* Update JS dependencies

- Update worker-loader options (currently unused pending #12459)
- Remove @babel/plugin-proposal-object-rest-spread, it's enabled by
  default
- Switch cssnano-webpack-plugin to css-minimizer-webpack-plugin which
  had been renamed

* switch to css-minimizer-webpack-plugin
2020-08-12 00:30:47 +02:00
zeripath
74bd9691c6
Re-attempt to delete temporary upload if the file is locked by another process (#12447)
Replace all calls to os.Remove/os.RemoveAll by retrying util.Remove/util.RemoveAll and remove circular dependencies from util.

Fix #12339

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
2020-08-11 21:05:34 +01:00
GiteaBot
faa676cc8b [skip ci] Updated translations via Crowdin 2020-08-11 14:49:29 +00:00
techknowlogick
22c952ac7a
Make dashboard newsfeed list length a configurable item (#12469)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-08-11 10:48:13 -04:00
mrsdizzie
73b155d5f2
Add more tests for diff highlighting (#12467)
Adding some more tests for different cases to make sure they keep working

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-11 00:29:25 -04:00
Bagas Sanjaya
a4ba1ad5ed
Add placeholder text for send testing email button in admin/config (#12452)
* Add placeholder text for send testing email button in admin/config

* Change placeholder text to expecting email address

* Localize placeholder text

* Apply suggestion from @silverwind

ok

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-10 22:38:30 -04:00
techknowlogick
0cc21fb72d
use community codecov drone plugin (#12468) 2020-08-10 22:02:09 -04:00
GiteaBot
25a6705b86 [skip ci] Updated translations via Crowdin 2020-08-10 13:02:16 +00:00
zeripath
d87dbd7519
Fix Migration 145 on MSSQL if varchar is changed to nvarchar (#12445)
* Handle MSSQL constraints

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

* Update models/migrations/v145.go

* Prevent hang with Sync2

* Agh it's uniques not indexes

* Let us try a different way of finding constraints on the language column

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

* minor simplification

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

* Try drop index instead?

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-10 16:01:10 +03:00
zeripath
02e990a89b
Prevent redirect back to /user/events (#12462)
This PR prevents 2 further ways of causing the redirect cookie to be set
to redirect back to /user/events

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-08 18:39:40 -04:00
6543
78d17b4b43
Make default StaticRootPath compile time settable (#12371)
Make it possible to compile the default location of StaticRootPath independent from AppWorkPath

Co-authored-by: Andrew Thornton <art27@cantab.net>
2020-08-08 15:02:22 +01:00
mrsdizzie
0171dda728
Improved diff syntax highlighting fix (#12455)
Make previous fix from #12238 more robust since I saw a case where a diff changes only a single character in a chroma class instead of the entire thing. Add another more complicated test to match.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-08 11:17:02 +01:00
zeripath
96add8c319
Do not show arrows on comment diffs on pull comment pages (#12434)
* Do not show arrows on comment diffs on pull comment pages

Prior to this PR it was possible that an expansion arrow could be displayed
on comment diffs displayed on the comments pages of pulls

These arrows would not successfully work because they were not attached to
a commit id - nor can they necessarily be.

This PR prevents these from being shown.

Fix #10851

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

* as per @silverwind

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

* one more indentation fix

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

* one more indentation fix

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-08 09:22:34 +08:00
zeripath
e770c2b850
Detect full references to issues and pulls in commit messages (#12399)
Fix #10269

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-06 20:20:05 +01:00
zeripath
e17e3f71f4
Use transaction in V102 migration (#12395)
The code for dropTableColumns has a slightly confusing portion whereby the session is committed for MSSQL but not for other variants.

The v102 migration doesn't actually start a transaction so this weirdness does not affect it. However it probably should attempt to run this in a transaction.

Signed-off-by: Andrew Thornton art27@cantab.net
2020-08-06 19:16:49 +01:00
GiteaBot
8cd7e93b9a [skip ci] Updated translations via Crowdin 2020-08-06 16:42:54 +00:00
silverwind
0dfbef5f70
Actually fix image diff padding/border (#12381)
https://github.com/go-gitea/gitea/pull/12346 was using the wrong
selector which affected only the single image view. Use the correct
selector for image diffs. Removal of border-radius is still worth to
keep to override the global 3px on <img>.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-08-06 12:41:45 -04:00
zeripath
2c1ae6c82d
Render the git graph on the server (#12333)
Rendering the git graph on the server means that we can properly track flows and switch from the Canvas implementation to a SVG implementation.

* This implementation provides a 16 limited color selection
* The uniqued color numbers are also provided
* And there is also a monochrome version
*In addition is a hover highlight that allows users to highlight commits on the same flow.

Closes #12209

Signed-off-by: Andrew Thornton art27@cantab.net
Co-authored-by: silverwind <me@silverwind.io>
2020-08-06 09:04:08 +01:00
silverwind
f1a42f5d5e
Add SVG favicon (#12437)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-08-06 08:04:51 +01:00
silverwind
983cbb2c9f
Remove librejs header in <head> (#12439)
For the sake of performance and simplicity, remove this seemingly useless
license header. It's related to LibreJS which we already pretty much
killed of in an earlier commit [1]. Initially added in [2]. Note that
the StaticUrlPrefix here was never actually correctly resolved and has
rendered including the template fences.

[1] https://github.com/go-gitea/gitea/pull/11810
[2] a915a09e4f

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-08-06 09:44:27 +08:00
Andreas Shimokawa
e5c5080f26
In issue comments, put issue participants also in completion list when hitting @ (#12433)
Previous behaviour was only to have completion for project members
2020-08-06 00:18:21 +01:00
silverwind
28a7708d69
Collapse Swagger UI tags by default (#12428)
This makes is slightly faster to navigate through the swagger docs by
initially collapsing the tags like 'admin' or 'miscellaneous'.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2020-08-05 22:42:19 +01:00
zeripath
48598a7e83
Mirror System Notice reports are too frequent (#12438)
This PR switches off the success reports from the Update Mirrors cron job
as they are too frequent and not necessarily helpful.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-05 21:40:36 +01:00
Lauris BH
42a31c797b
Fix correct upstream remote HTTPS URL (#12436) 2020-08-05 20:15:57 +01:00
6543
2872a04f27
UserProfile Page: Render Description (#12415)
* If Description contain more that one line render it

* simpler ...

* only render if description exists

* Fix NPE in tests

* Update routers/user/profile.go

Co-authored-by: zeripath <art27@cantab.net>
2020-08-05 15:48:37 +08:00
techknowlogick
6ab4d76ced
Match GH with Commit page (#12425)
Co-authored-by: zeripath <art27@cantab.net>
2020-08-05 09:32:13 +08:00
zeripath
33391e04fe
Prevent empty div when editing comment (#12404)
* Prevent empty div when editing comment

The template for attachments needs to remove whitespace and return empty when there are no attachments.

Fix #10220
2020-08-04 22:30:02 +01:00
赵智超
8a6790b2aa
Add API to update pr headBranch (#12419)
* [API] Add update pr headBranch api

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-08-04 21:55:22 +01:00
silverwind
e61c09ed73
Add loading spinners and mermaid error handling (#12358)
- Add loading spinners on editor and mermaid renderers
- Add error handling and inline error box for mermaid
- Fix Mermaid rendering by using the .init api
2020-08-04 20:56:37 +01:00
zeripath
5e5c893555
Need RepoID in the languagestat field (#12427)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-04 14:38:31 -04:00
zeripath
502e38c33c
Increase size of the language column in language_stat (#12396)
In #12379 it was discovered that enry v2 has a maximum language length
of 34 characters which is larger than the 30 previously provided.

This PR updates the language column to 50.

Fix #12379
2020-08-04 14:54:29 +01:00
赵智超
3585bb73ef
fix a small nit (#12420)
Signed-off-by: a1012112796 <1012112796@qq.com>
2020-08-03 23:50:29 +03:00
silverwind
4d9f59a45d
Split up monaco's language chunks (#12401)
This should speed up monaco's loading time by splitting the current
3.71MB chunk monaco.js into 63 individual files named 1 to 63.js in
the output directory. There seems to be no way to get a better file
naming scheme unfortunately. I opted to exclude those files in the
webpack output for brevity.
2020-08-02 15:06:06 +01:00
6543
7b260acd7b
Add TOTP header to Swagger Documentation (#12402) 2020-08-02 13:01:12 +01:00
zeripath
15300699c4
Fix milestone links (#12405)
The milestone pages links should direct to the milestone pages

Fix #10215

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-08-02 09:18:09 +01:00
zeripath
bac65f1b82
Fix incorrect error logging in Stats indexer and OAuth2 (#12387)
* Fix incorrect logging in oauth2.go

Fix #11945

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

* Handle ErrAlreadyInQueue in stats indexer

Fix #12380

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

* Fixes type in error message of indexer

Add the missing character in the error message.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lieven Hollevoet <hollie@lika.be>
2020-08-01 10:45:26 -04:00
6543
b3e06523c1
[Vendor] upgrade google/go-github to v32.1.0 (#12361)
* upgrate go-github client to v32.1.0

* migrate
2020-07-31 15:22:34 +01:00
GiteaBot
999ae61d01 [skip ci] Updated translations via Crowdin 2020-07-31 13:27:50 +00:00
Lars Lehtonen
e4d6f2e9e5
models: break out of loop (#12386) 2020-07-31 21:26:47 +08:00
silverwind
11dcc17763
Improve HTML escaping helper (#12383)
The previous method did not escape single quotes which under some
circumstances can lead to XSS vulnerabilites and the fact that it
depends on jQuery is also not ideal. Replace it with a lightweight
module.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-30 22:14:04 -04:00
silverwind
24f8625790
Various arc-green fixes (#12384)
- Fix various white borders
- Fix dropdown triangle
- Fix tab backgrounds
- Fix release page timeline dots

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-30 21:27:06 -04:00
S7evinK
bf60146444
Don't use legacy method to send Matrix Webhook (#12348)
* Don't use legacy send for messages

* Add migrations to ensure Matrix webhooks use PUT

* Set HTTP method to PUT as default

* Fix sql condition..

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Rename getTxnID -> getMatrixTxnID

* Use local variable instead of constant value

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-30 18:04:19 -04:00
silverwind
f6d5303e02
Add note to README about make parallelism (#12378)
Alternative to https://github.com/go-gitea/gitea/pull/12367
2020-07-30 17:21:59 -04:00
GiteaBot
838fef2ae8 [skip ci] Updated translations via Crowdin 2020-07-30 16:28:29 +00:00
赵智超
7e96268fb0
Vendor update: github.com/yuin/goldmark v1.2.1 (#12377)
Thanks to @yuin

fix #12376
2020-07-30 12:27:23 -04:00
赵智超
1f12dc8e88
Add action feed for new release (#12324)
* Add action feed for new release

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix lint

* Apply suggestions from code review

* Add ReleaseID to the action table
* Remove error message
* Fold the attachments download list

* remove attchment download list

* simplify code

* fix create release from existing tag

* simplify ui

* translation change

* fix test

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-29 15:20:54 -04:00
silverwind
2fd78c151e
Move jquery-minicolors to npm/webpack (#12305)
* Move jquery-minicolors to npm/webpack

- Unvendor and add as npm dependency
- Removed unneeded backend variable
- Fixed existing bug where picker would previously initizalize to the
  same green color when editing a label.

There was probably a version bump because the previous version was
over 3 years old but it seems to be compatible.

* use file-loader

* trailing comma and comment update

* misc tweaks

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-29 14:44:23 -04:00
zeripath
2f6aadffa8
Git 2.28 no longer permits diff with ... on unrelated branches (#12364)
* Git 2.28 no longer permits diff with ... on unrelated branches

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

* need to check stderr
2020-07-29 13:53:04 -04:00
Gary Wang
f2a6cd6401
Fix clone panel in wiki position not always align right (#12326)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-29 12:30:37 -04:00
Kevin Schweikert
f220286c00
Fix typo in README.md (#12369)
Changed Dockefile to Dockerfile
2020-07-29 09:29:51 -05:00
6543
1de19e0c76
Changelog v1.12.3 (#12356) (#12357) 2020-07-28 16:54:08 -04:00
Richard Mahn
8a36c46a7e
Fixes #12341: Release date should only be set to current time if draft or tag created (#12343)
* Fixes #12341: Release date should only be set to current time if draft or tag created

* Removes old date set

* Adds unit tests

* make fmt

* Fixes tests

* Adds sleep for comparing times

* Adds sleep for comparing times

* Fixes tests

Co-authored-by: Matti R <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-07-28 14:08:45 -04:00
silverwind
cd7f1fd72b
Remove padding/border-radius on image diffs (#12346) 2020-07-28 16:48:48 +01:00
zeripath
63e5bf6ef7
Only use --exclude on name-rev with git >= 2.13 (#12347)
Fix #11917

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-28 15:11:05 +01:00
6543
8bdc9795d8
Add name filter to API for GetMilestoneList (#12336)
Adds a name filter to the API for GetMilestoneList

Includes a small refactor: merge GetMilestones and GetMilestonesByRepoID

Close #12260

Needed for https://gitea.com/gitea/go-sdk/issues/383 and https://gitea.com/gitea/tea/pulls/149
2020-07-28 12:30:40 +01:00
silverwind
78cbd0ca72
Update JS deps and linting config (#12295)
- update js deps to latest versions
- remove eslint-plugin-sonarjs to prevent a warning on install. can be
  added again once it's updated to support eslint 7.x
- enable new linting rules from eslint-plugin-unicorn

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-27 17:01:25 -04:00
silverwind
8d6fa00da0
Detect version of sed in Makefile (#12319)
* Detect version of sed in Makefile

It's possible to install GNU sed on Darwin or FreeBSD so it's better to
not assume BSD sed on those platforms but to instead perform version
detection for the `GNU` string and only use BSD syntax if absent.

* silence stderr

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-27 16:13:15 -04:00
silverwind
e67c042511
Add 'watch-backend' (#12330)
* Add 'watch-backend'

This leverages `air` to watch the backend files and trigger `make
backend` automatically when they change. It seems to work rather well
together with `watch-frontend`.

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

* rework docs to a new section for continuous build

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-27 14:05:42 -04:00
techknowlogick
bfb25e4be1
update chroma to v0.8.0 (#12337) 2020-07-27 13:18:02 -04:00
silverwind
4315e313d1
Add mermaid JS renderer (#12334)
* Add mermaid JS renderer

For feature parity with GitLab. Tested in files, issues, wiki, editor.
arc-green only does an inversion because the renderer seems to like to
render white backgrounds on boxes.

Ref: https://github.com/go-gitea/gitea/issues/3340
Fixes: https://github.com/go-gitea/gitea/issues/12307

* add feature entry, switch to neutral theme, remove border

* add bindFunctions support

* remove unnecessary border-radius

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-27 02:24:09 -04:00
silverwind
46ef562a16
Update vendored .gitattributes (#12322)
These `linguist-vendored` attributes are only for the language stats
seen on github and they mostly haven't been updated with file
reorganizations. Move them to the two actually vendored directories.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-27 00:17:01 -04:00
silverwind
859094ef0a
Disable search box autofocus on issue/pr pages (#12229)
Various pages like the issue list autofocus their search box which I find rather intrusive because more often than not I don't want to type into the search box, it's distracting if the focus jumps after page load. Disable this behaviour.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-26 22:43:14 -04:00
techknowlogick
e6c9f19b8f
Use url.Parse to parse hostname (#12335) 2020-07-26 20:16:22 -04:00
6543
7ecb25b41b
Refactor: Remove Dependencies from Migration v111 (#11646)
* Refactor: Remove Dependencys from Migration v111

* Update models/migrations/v111.go

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-26 17:34:30 -04:00
Wim
4609eba2e7
Fix ipv6 parsing (#12321)
* Fix ipv6 parsing

* Update modules/setting/setting.go

Co-authored-by: 6543 <6543@obermui.de>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-26 16:31:28 -04:00
赵智超
415fc8288f
Show 404 page when release not found (#12328)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-26 15:00:48 -04:00
GiteaBot
d0c690f160 [skip ci] Updated translations via Crowdin 2020-07-26 09:49:14 +00:00
silverwind
7cf23399a0
Rework 'make generate-images' (#12316)
* Rework 'make generate-images'

- Remove external dependencies and replace it with a node script that
  does does the same.
- Move detail removal from gitea-sm.png to favicon.png
- Remove favicon.ico and its generation, it is unused and we already serve
  favicon.png in its place.

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

* use proper centering value for preserveAspectRatio

* fix lint

* use fabric

* better linting fix

* fix typo

* mention detail-remove class in docs
2020-07-26 17:47:51 +08:00
mrsdizzie
ea1ed802a3
Fix emoji detection in certain cases (#12320)
* Fix emoji detection certain cases

Previous tests weren't complicated enough so there were some situations where emojis were't detected properly. Find the earliest occurance in addition to checking for the longest combination.

Fixes #12312

* ok spell bot

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-25 16:40:04 +03:00
silverwind
8baf5ca228
Reduce emoji size (#12317)
* Reduce emoji size

Rendering should now pretty much match GitHub with 1.25em. I verified
that emojis don't increase the line height and removed unecessary size
overrides because now all emojis should appear similar in relation to
the font size.

* fix reaction hover
2020-07-25 12:55:34 +03:00
silverwind
a3afb88f1b
Remove unused svg and improve 'make svg-check' (#12311)
- Remove unused source SVG gitea-settings (it was changed to ociticon)
- Improve 'make svg-check' to also detect added files
2020-07-24 19:41:30 +03:00
赵智超
7744b36e56
Use a small size repo for migrate test (#12300)
Signed-off-by: a1012112796 <1012112796@qq.com>
2020-07-24 12:46:38 +08:00
silverwind
0186497e67
Fix input box value access on repo create (#12299)
Followup to https://github.com/go-gitea/gitea/pull/12202
2020-07-23 11:59:03 -04:00
Alexander Scheel
4497db96e0
Auto-init repo on license, .gitignore select (#12202)
* Auto-init repo on license, .gitignore select

When a .gitignore or LICENSE file is added, the user is expecting the
repository to be auto-initialized. However, nothing sets the auto_init
value, so it remains at its default. We should set it to checked when
a .gitignore or LICENSE file is added, matching user expectations. If
the user clears .gitignore or LICENSE, it will leave repository creation
enabled. If the user changes the value again, it will re-check the box
if the user has since de-checked it. This behavior is at least
consistent.

Resolves: #11071

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-23 13:46:41 +03:00
zeripath
d25f44285a
Fix double-indirection bug in logging IDs (#12294)
This PR fixes a bug in log.NewColoredIDValue() which led to a double
indirection and incorrect IDs being printed out.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-23 12:26:45 +03:00
6543
2753d72773
Migrations (v82,v96,v99,v136) remove dependencies (#12286)
* remove dependencys

* add missing fields

* CI.restart()
2020-07-22 09:27:22 -05:00
Alexander Scheel
8e20daaede
Clarify documentation of SKIP_VERIFY (#12203)
* Clarify documentation of SKIP_VERIFY

The documentation clearly documents the empty value as the default,
however at least one user reported this as being unclear. Mark values
explicitly so it is clear what values it can take. This clarifies that
an empty value in fact leaves certificate verification enabled, whereas
it has to be explicitly set to true to disable certificate verification.

Resolves: #12117

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update custom/conf/app.example.ini

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update custom/conf/app.example.ini

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-21 19:50:25 -04:00
techknowlogick
366ca88eea
merge docker makefile into main one (#12289)
* merge docker makefile into main one

* add readme for docker folder

* don't include a file that doesn't exist anymore

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-21 16:41:03 -04:00
GiteaBot
d489def5ed [skip ci] Updated translations via Crowdin 2020-07-21 12:29:30 +00:00
Lunny Xiao
45631083a4
Support use nvarchar for all varchar columns when using mssql (#12269)
* Support use nvarchar for all varchar columns when using mssql

* fix lint

* Change DEFAULT_VARCHAR to nvarchar

* Remove the config for default varchar since it's unnecessary
2020-07-21 20:28:27 +08:00
GiteaBot
ed8e064f5e [skip ci] Updated translations via Crowdin 2020-07-19 09:54:41 +00:00
Stephen Solka
54513452a1
prefer NoError/Error over Nil/NotNil (#12271) 2020-07-19 12:53:40 +03:00
Alan Pope
b609a25014
Add logic to build stable and edge builds (#12052)
This adds some logic to enable the snapcraft builds of the gitea snap to create both builds of the latest tip of master for edge channels, and stable releases.

The logic simply looks for a new upstream release in github, and if that latest tagged release is not the same as the release in the candidate channel in the snap store, then it must be new, and so we checkout that tag and build that. If the current released tag is the same as what's in candidate, we build whatever is in git master.

The process for using this is:

Initially: When this lands, it will build the latest stable release of gitea and push to the edge channel in the snap store. Someone on the release team can go to https://snapcraft.io/gitea/releases and release that build to stable and candidate.

Ongoing: The next build to be triggered will be a git master build, and can just sit in edge, nothing for the release team to do.

On new release: The next build triggered will contain the stable release, and will be published to edge. Someone on the release team can login to the above URL and release that again to stable & candidate. Alternatively they can release to candidate, do some additional testing on that release before releasing to stable.

Hope that all makes sense. Questions / comments welcome.

I'm super keen to see stable releases of Gitea in the stable channel of the Snap Store. I'd like to promote it but I can't really until it's in stable.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-17 13:27:00 -04:00
silverwind
0e24af6951
Update Octicons to v10 (#12240)
* Update Octicons to v10

Besides a few renames, these icons are no longer present in v10 that we've
used, so had to change:

file-symlink-directory -> file-submodule
internal-repo -> repo
repo-force-push -> repo-push
repo-template-private -> repo-template

Fixes: https://github.com/go-gitea/gitea/issues/11889
Ref: https://github.com/primer/octicons/releases/tag/v10.0.0

* add custom sliders svg for removed octicon-settings

* apply suggestion

* fix triangles and use play on admin dashboard

* add custom mirror svg

* add missing build files

* unify custom svgs

* move to octicon-repo-clone to gitea-mirror

* use octicon-x on conflicts

* tweak timeline icons

* tweak comment buttons

* update settings icon to octicons v1

* switch to octicon-mirror and octicon-tools

* replace two wiki buttons with octicons

* remove whitespace in svg sources

* Fix filepath basename on Windows for SVG bindata (#12241)

* move octicons to devDependencies

* move back to dependencies

* move svgo to devDependencies again

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-17 18:15:12 +03:00
zeripath
4fa2e217c1
Set NoAutoTime when updating is_archived (#12266)
Fix #12246

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-16 17:58:46 -04:00
zeripath
3bcc6e7a9e
Ensure that git commit tree continues properly over the page (#12142)
* Ensure that git commit tree continues properly over the page

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

* Avoid generating strings when skipping

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

* skip initial non-commit-lines

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-16 15:24:36 -04:00
Bagas Sanjaya
07c4ed4cda
[Docs] Logging Configuration - Use logrotate Instead (#9930)
* Logging Configuration - Add logrotate

* Delete instead duplicate

* Apply suggestions from @jolheiser

Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com>

* Quote false

* Replace program with utility

* Whoops, use --debug switch instead

* Optional immediate reload by --force switch

* Update docs/content/doc/advanced/logging-documentation.en-us.md

Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-07-16 12:02:29 -04:00
赵智超
0122cf9cdc
[ui] Link to pr list page on sidebar when view pr (#12256)
Fix #12254

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-16 11:07:13 -04:00
mrsdizzie
9542b7317d
Fix Syntax highlight for token change in added/deleted code (#12238)
* Fix Syntax highlight for token change in added/deleted code

For diffs we first syntax highlight the before and after line then use a 3rd party diff library to find the difference in them and create a substring based on that, which we then highlight a 2nd time to show the specific difference within a line that has changed. In a specific case if the diffrence also changes the chroma class it will split in the middle of the attr and cause broken HTML:

```
<span class="nx">oldtext<span>
<span class="k">var newtext<span>
```

Will then split on

```
<span class="
```

Where the difference starts, and produce something broken like:

```
<span class="<span class="removed-code">nx"oldtext</span></span

```

Fix that by detecting when it happens and putting the HTML back together properly before highlighting the added/deleted code.

Fixes #12235

* fix lint

* apply fix to all diff sections. Also handle case where insert/remove starts with a closing span

* Add a test for this new code

* remove comment

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-16 16:58:54 +03:00
techknowlogick
6ea2701cd9
Release docs as archive (#12253)
It is ok to use go modules at this point as release-source make target has already been run. Otherwise hugo fails to build. Example of failed build: https://drone.gitea.io/go-gitea/gitea/27976/5/3

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-15 22:39:45 +01:00
Tchoupinax
fd9e8951d8
fix: add type=text for user_name (password manager) (#12250)
* fix: add type=text for user_name (password manager)

* Update templates/user/auth/reset_passwd.tmpl

Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>

Co-authored-by: jaqra <48099350+jaqra@users.noreply.github.com>
2020-07-15 16:48:50 +03:00
GiteaBot
670db99f4f [skip ci] Updated translations via Crowdin 2020-07-15 04:38:43 +00:00
Lauris BH
bae5293d24
Show drone status for master branch in README (#12248) 2020-07-15 12:37:38 +08:00
Ben Harris
a4da46d182
Use correct make target for building static assets (#12247)
The webpack make target does not build semantic-ui
2020-07-14 15:45:23 -04:00
GiteaBot
3b498ebc77 [skip ci] Updated translations via Crowdin 2020-07-14 02:10:41 +00:00
Antoine GIRARD
b92a5d8d64
release docs as an archive (#12243)
* release docs along sources

* use a custom offline version

Co-authored-by: Gitea <gitea@fake.local>
2020-07-13 22:09:39 -04:00
Cirno the Strongest
633f52c220
Fix filepath basename on Windows for SVG bindata (#12241) 2020-07-13 21:16:40 +01:00
silverwind
84a419de98
Replace code fold icons with octicons (#12222)
- replace font-awesome icons with octicons
- clean up js and css surrounding the code expansion and file folding
- fix hover color on arc-green
- tweak diff line number colors

Co-authored-by: zeripath <art27@cantab.net>
2020-07-13 16:21:19 +03:00
Lars Lehtonen
b49a195839
models: fix xorm variable clobber (#12231)
NewTestEngine() takes a *xorm.Engine as its argument, and then immediately overwrites it.

This fixes the model package to not take an unneeded variable, and changes the routers package to not create a nil *xorm.Engine that is immediately discarded by model.
2020-07-13 09:58:55 +01:00
silverwind
48ad76c25e
Fix repolist icons (#12228)
Fixes: https://github.com/go-gitea/gitea/issues/12226
2020-07-13 02:48:48 +03:00
mrsdizzie
a60f506dd7
Syntax highlight expanded code blobs (#12223)
Expanded code in diffs wasn't being highlighted properly because it wasn't passing the filename to highlighting code.

Fixes #12218
2020-07-12 21:25:05 +03:00
bobemoe
bac57ab590
When starting new stopwatch stop previous if it is still running (#10533)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-12 13:01:20 +03:00
silverwind
8188176b58
Direct SVG rendering (#12157)
Introduce 'make svg' which calls a node script that compiles svg files
to `public/img/svg`. These files are vendored to not create a dependency
on Node for the backend build.

On the frontend side, configure webpack using `raw-loader` so SVGs can
be imported as string.

Also moved our existing SVGs to web_src/svg for consistency.

Fixes: https://github.com/go-gitea/gitea/issues/11618
2020-07-12 12:10:56 +03:00
zeripath
63591016b3
Extend Notifications API and return pinned notifications by default (#12164)
* Extend notifications API and return pinned notifications in notifications list

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

* fix swagger

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

* Fix swagger again

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

* fix test

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

* remove spurious debugs

* as per @6543

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

* Update models/notification.go

* as per @6543

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-12 00:46:01 +03:00
Lunny Xiao
d08996c7b9
Upgrade xorm to v1.0.3 (#12210)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-11 17:07:52 -04:00
6543
3973a4609e
Frontport Changelog of v1.12.2 (#12216)
* Changelog for v1.12.2 (#12214)

* Changelog for v1.12.2

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Update CHANGELOG.md

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* update docs

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
2020-07-11 16:28:23 -04:00
mrsdizzie
8d081950e6
Ensure syntax highlighting is the same inside diffs (#12205)
Make sure to end up with the same syntax highlighting inside various sections of diffs by processing the code first before detecting specific changes between the lines. Also try and make sure that when highlighting individual lines in a diff that it is tokenized the same as it would be when part of an entire file with more context.

Fixes: #12190
2020-07-11 13:43:12 +08:00
GiteaBot
6a62884782 [skip ci] Updated translations via Crowdin 2020-07-09 21:14:09 +00:00
6543
16980d13ce
Default to showing closed Issues/PR list when there are only closed issues/PRs (#12200)
If all issues are closed, then set the default to show the closed issues.
2020-07-09 22:13:06 +01:00
mrsdizzie
a6168fa25d
Make copy/paste work for source code (#12191)
* Make copy/paste work for source code

Fix regression casued by #12047 so copy/paste works properly in all browsers.

Fixes #12184

Also while looking at this I saw a small display issue for blame view. I think #12023 was merged into original PR through an update branch before #12047 was merged and made one of the css ruules not apply anymore.

* use pseudo-element to prevent copying of comment + symbol even when not visually selected

* remove added newline here should not be necessary anymore

* make sure empty line is newline so there is something to select and copy
2020-07-08 22:02:38 +01:00
Kristian Antonsen
cedbd3684f
Fix regression: Gitea commits API again returns commit summaries, not full messages (#12186)
Closes #12185
2020-07-08 14:53:09 +01:00
silverwind
dbd5e4bb8d
Update JS dependencies (#12181)
- Update all dependencies excluding octicons
- Configure new eslint 7.3.0 rules

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-08 09:47:05 +08:00
William Hilton
3a46d1ef58
Enable cloning via Git Wire Protocol v2 over HTTP (#12170)
* Enable Git Wire Protocol v2 over HTTP

* use RunInDirTimeoutEnv

* pass $HOME environment variable to git upload-pack
2020-07-08 01:31:49 +03:00
mrsdizzie
078d2fbd4c
Remove newline when highlighting random chunks of code (#12180)
* Remove newline when highlighting random chunks of code

Somewhere when tokenizing a newline gets added to code formatted by chroma. This breaks the case of 'added-code' inside of an 'added-line' in a diff. Just remove any newline when processing chunks of code since we don't need it.

Fixes #12172

* don't process empty lines

* This is the proper way to fix this by telling chroma not to add the newline in the first place
2020-07-08 01:30:21 +03:00
Jürgen Hötzel
30399cf04a
Trim to 255 runes instead of bytes (#12150)
* Trim to 255 runes instead of bytes

Prevents invalid UTF-8 encoding for Description and Website. Refs #7905

* Apply suggestions from code review

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-08 00:35:52 +03:00
赵智超
12f9dd8fa9
Decrease the num_stars when deleting a repo (#11954)
* Decrease the  num_stars when deleting a repo

fix #11949

Signed-off-by: a1012112796 <1012112796@qq.com>

* Add migration

* use batch

* Apply suggestions from code review

Co-authored-by: Lauris BH <lauris@nix.lv>

* fix lint

* fix lint

* fix ci

* fix ci2

* add doctor

* duplicate code

* fix migration

* fix some nits

* add start

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-07 15:16:34 -04:00
Cirno the Strongest
88ef04dbe9
Adjust margin-top for repo header label (#12174) 2020-07-07 19:47:18 +08:00
silverwind
075f33c48c
Fix U2F button icon (#12167)
Previously this used a USB icon which required a separate font file used
nowhere else so replace it with a octicon and fix the background color
on arc-green too.
2020-07-07 01:37:48 +03:00
zeripath
8a0bb7cd04
Ensure Subkeys are verified (#12155)
When attempting to verify subkeys the email address verification step
requires checking the emails however, these emails are not stored on
subkeys but instead on the primary key.

This PR will obtain the primaryKey and check against these emails too.

Fix #12128

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-06 14:33:34 -04:00
Stormxx
26e931ae34
fix a spelling error (#12163)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-06 11:58:31 -04:00
Lars Lehtonen
56f222d44c
models: break out of loops (#12159)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-06 13:07:07 +01:00
GiteaBot
ae2916c792 [skip ci] Updated translations via Crowdin 2020-07-06 08:58:05 +00:00
silverwind
62c2c17031
Fonts rework (#12114)
- Use system fonts only for text to avoid FOUT
- Move font-awesome to npm/webpack
- Move NotoColorEmoji to web_src
- Remove presumably unneccesary 'PT Sans Narrow'
- Simplify webpack import exclusions

Fixes: https://github.com/go-gitea/gitea/issues/11818
Fixes: https://github.com/go-gitea/gitea/pull/11814

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-06 11:56:54 +03:00
yisiliang
9fc9c1de98
Update the wiki repository remote origin while update the mirror repository's Clone From URL (#12053)
* update the wiki repository remote origin #12050

* wikiRemoteURL is under repo_module

* export WikiRemoteURL func

* remove redundant space and empty line

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-05 22:08:32 -04:00
zeripath
c5b08f6d5a
Pause, Resume, Release&Reopen, Add and Remove Logging from command line (#11777)
* Make LogDescriptions race safe

* Add manager commands for pausing, resuming, adding and removing loggers

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

* Placate lint

* Ensure that file logger is run!

* Add support for smtp and conn

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

* Add release-and-reopen

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-05 20:07:07 -04:00
GiteaBot
38fb087d19 [skip ci] Updated translations via Crowdin 2020-07-05 22:41:35 +00:00
Lauris BH
4384320db9
Use hash of repo path, ref and entrypath as cache key (#12151) 2020-07-06 01:40:34 +03:00
zeripath
217647f331
Multiple small admin dashboard fixes (#12153)
* Remove spurious spacing between Maintenance Operations and its table on dashboard
* Prevent (EXTRA string) comments in Task headers
* Redirect tasks started from monitor page back to monitor
* Fix #12107 - redirects from process cancel should use AppSubUrl
* When wrapping queues set the name correctly

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-05 22:38:03 +03:00
George Merlocco
0d03fbf2ca
Ensure tabs wrap correctly on user profile page (#12144)
Co-authored-by: zeripath <art27@cantab.net>
2020-07-05 12:09:52 -04:00
xenofem
d1562bfc34
properly set symbolic-ref HEAD when a repo is created with a non-master default branch (#12135)
This fixes an issue I noticed with #10803: when you create a repo with a non-master default branch, gitea doesn't change the remote ref HEAD, so it still points at refs/heads/master. As a result, cloning my repos gives me error messages and doesn't check out the desired default branch, so I need to manually check it out after cloning.
2020-07-05 16:25:46 +01:00
silverwind
15d3aa7b95
Enable a few more eslint rules (#12145)
This gets the config closer to what 1.12 had.

Related: https://github.com/go-gitea/gitea/pull/12129
2020-07-05 11:51:29 +01:00
zeripath
c6d6c51ada
Remove spurious logging (#12139)
Unfortunately #10745 merged a spurious logging message. This PR removes this.

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-05 12:11:02 +08:00
zeripath
2ab185d3ab
Rewrite GitGraph.js (#12137)
The current vendored gitgraph.js is no longer maintained and is
difficult to understand, fix and maintain.

This PR completely rewrites its logic - hopefully in a clearer fashion
and easier to maintain.

It also includes @silverwind's improvements of coloring the commit dots
and preventing the flash of incorrect content.

Further changes to contemplate in future will be abstracting out of the
flows to an object, storing the involved commit references on the flows
etc. However, this is probably a required step for this.

Replaces #12131
Fixes #11981 (part 3)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-05 02:04:24 +01:00
zeripath
3c4388f668
Re-fix #12095 again (#12138)
Unfortunately some of the suggested changes to #12095 introduced
bugs which due to caching behaviour of sharedworkers were not caught
on simple tests.

These are as follows:

* Changing from simple for loop to use includes here:

```js
  register(port) {
    if (!this.clients.includes(port)) return;

    this.clients.push(port);

    port.postMessage({
      type: 'status',
      message: `registered to ${this.url}`,
    });
  }
```

The additional `!` prevents any clients from being added and should
read:

```js
    if (this.clients.includes(port)) return;
```

* Dropping the use of jQuery `$(...)` selection and using DOM
`querySelector` here:

```js
async function receiveUpdateCount(event) {
  try {
    const data = JSON.parse(event.data);

    const notificationCount = document.querySelector('.notification_count');
    if (data.Count > 0) {
      notificationCount.classList.remove('hidden');
    } else {
      notificationCount.classList.add('hidden');
    }

    notificationCount.text() = `${data.Count}`;
    await updateNotificationTable();
  } catch (error) {
    console.error(error, event);
  }
}
```

Requires that `notificationCount.text()` be changed to use `textContent`
instead.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-05 01:04:00 +03:00
zeripath
60cb9fe448
Bugfix for shared event source (#12129)
For some reason our eslint configuration is not working correctly
and a bug has become apparent when trying to backport this to 1.12.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-04 10:01:25 -04:00
Andreas Shimokawa
510e4bd245
templates/repo/empty.tmpl : fix repo setup instructions (#12122)
Co-authored-by: codeberg <codeberg@codeberg.org>
2020-07-03 17:22:14 -04:00
zeripath
ae56411e9f
Move EventSource to SharedWorker (#12095)
Move EventSource to use a SharedWorker. This prevents issues with HTTP/1.1
open browser connections from preventing gitea from opening multiple tabs.

Also allow setting EVENT_SOURCE_UPDATE_TIME to disable EventSource updating

Fix #11978

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

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-07-03 10:55:36 +01:00
赵智超
cd994f6354
Fix ui bug in wiki commit page (#12089)
* Fix ui bug in wiki commit page

TODO: Maybe we should allow wiki to have its own ``.editorconfig`` file.

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix a small nit

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-07-02 18:33:13 +01:00
GiteaBot
480ac25ed5 [skip ci] Updated translations via Crowdin 2020-07-02 14:56:42 +00:00
Clark Boylan
7e401fb026
Fix repo API listing stability (#12057)
Repo listings are paginated in the API now. Unfortunately, they are
ORDER BY updated_unix which only has second resolution. This means that
if you do a listing when multiple projects were created at the same time
you can unstable ordering. If that unstable ordering happens at a page
boundary you may fail to get a complete repo listing.

To make things worse sorting by updated_unix means that we may never get
a complete listing because udpated_unix can change independent of our
API calls.

Fix this by making the API repo listing order by id instead.
2020-07-02 15:55:42 +01:00
zeripath
482ba937ed
Provide option to unlink a fork (#11858)
* Provide option to unlink a fork

Fix #4566

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

* Apply suggestions from code review

Co-authored-by: techknowlogick <matti@mdranta.net>

* Add check that user can create repo

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

* as per @cirnoT

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

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-07-02 15:09:09 +01:00
silverwind
a87a64e6a1
Fix missing gitgraph css import (#12112)
The filter was wrongly excluding the gitGraph.css file. Need to clean
this up later so that imports are always relative to the source file
(which is not the case for fonts right now).

Regressed by: https://github.com/go-gitea/gitea/pull/11997

Co-authored-by: zeripath <art27@cantab.net>
2020-07-01 22:58:59 +01:00
GiteaBot
712d88ea1d [skip ci] Updated translations via Crowdin 2020-07-01 18:17:01 +00:00
silverwind
eea25f8d71
Improve arc-green code colors (#12111)
* Improve arc-green code colors

This should fix all previous colors that had too few contrast on the
background. I took solarized-dark as a baseline and did various
improvments. I removed bold/italic flags because I don't think they
fit and generally other tools also don't use those font flags.

* diff tweak
2020-07-01 21:15:59 +03:00
zeripath
858c35b731
Ensure BlameReaders close at end of request (#12102)
#11716 reports multiple git blame processes hanging around
this was thought to be due to timeouts, however on closer look this
appears to be due to the Close() function of the BlameReader hanging
with a blocked stdout pipe.

This PR fixes this Close function to:

* Cancel the context of the cmd
* Close the StdoutReader - ensuring that the output pipe is closed

Further it makes the context of the `git blame` command a child of the
request context - ensuring that even if Close() is not called, on
cancellation of the Request the blame is command will also be cancelled.

Fixes #11716
Closes #11727

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-07-01 14:01:17 +01:00
Lauris BH
8f489131f3
Fix merge section in dark theme (#12086)
* Fix merge section in dark theme

* Fix lint
2020-07-01 02:03:37 +03:00
mrsdizzie
af7ffaa279
Server-side syntax highlighting for all code (#12047)
* Server-side syntax hilighting for all code

This PR does a few things:

* Remove all traces of highlight.js
* Use chroma library to provide fast syntax hilighting directly on the server
* Provide syntax hilighting for diffs
* Re-style both unified and split diffs views
* Add custom syntax hilighting styling for both regular and arc-green

Fixes #7729
Fixes #10157
Fixes #11825
Fixes #7728
Fixes #3872
Fixes #3682

And perhaps gets closer to #9553

* fix line marker

* fix repo search

* Fix single line select

* properly load settings

* npm uninstall highlight.js

* review suggestion

* code review

* forgot to call function

* fix test

* Apply suggestions from code review

suggestions from @silverwind thanks

Co-authored-by: silverwind <me@silverwind.io>

* code review

* copy/paste error

* Use const for highlight size limit

* Update web_src/less/_repository.less

Co-authored-by: Lauris BH <lauris@nix.lv>

* update size limit to 1MB and other styling tweaks

* fix highlighting for certain diff sections

* fix test

* add worker back as suggested

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-07-01 00:34:03 +03:00
Lauris BH
ce5f2b9845
Fix commit icon position (#12087) 2020-06-29 23:53:30 -04:00
silverwind
e3b719863b
Fix potential make error related to fomantic files (#12079)
This prevents a potential make errors like "No rule to make sticky.js"
that happens when a file is present from a previous build but is not
generated in the current build. We don't use these module files from
fomantic so it's safe to not depend on them.

Related to: 7761245d08
2020-06-28 20:18:12 -04:00
Cirno the Strongest
b918609acc
Use custom SVGs for commit signing lock icon (#12017)
* Use custom SVGs for commit signing lock icon

* missing spans

* editorconfig

* xmlns and remove aria-hidden

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-28 00:05:50 -04:00
silverwind
7761245d08
Move fomantic and jQuery to main webpack bundle (#11997)
This saves around 3 MB binary size by not including useless fomantic
files in the build. Also, this allows us to move jQuery into the main
bundle as well which eliminates a few HTTP requests.

Also included are webpack config changes:

- split less and css loaders to speed up compliation
- enable css sourcemaps
- switch css minfier plugin to cssnano-webpack-plugin which works better
  for sourcemaps than the previous plugin

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-27 22:59:56 -04:00
Cirno the Strongest
2281b048af
Do not override API issue pagination with UI settings (#12068)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-27 17:09:24 -04:00
GiteaBot
9ad04240a6 [skip ci] Updated translations via Crowdin 2020-06-27 20:33:22 +00:00
Cirno the Strongest
1fd2beb6e9
Fix swagger docs for /repos/issues (#12069)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-27 16:32:28 -04:00
Linkjay
2ff585f0da
Fix some periods and language usage in en-US locale (#12067) 2020-06-27 14:11:35 +03:00
silverwind
772df93671
Disable go module when downloading global binaries (#12030)
Prevent `go get` from touching `go.mod` and `go.sum` when executing
global binaries during the build process. Once
https://github.com/golang/go/issues/30515 is fixed, we should is
whatever solution is provided there.

Fixes: https://github.com/go-gitea/gitea/pull/12010

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-26 22:47:34 +03:00
GiteaBot
043ed32ab5 [skip ci] Updated translations via Crowdin 2020-06-26 13:06:41 +00:00
silverwind
9c54fef17c
Shorten markdown heading anchors links (#11903)
This changes the links on headings like '# Usage' in markdown from

  `https://host/user/repo#user-content-usage`

to just

  `https://host/user/repo#usage`

matching GitHub and GitLab. The linked id elements still have the prefix
and this behaviour matches GitHub and GitLab too, so JS is needed to
scroll to the active anchor. I suspect it's like that to avoid namespace
collission between user-generated content and other page content.
Compatibilty for old links is included so they will continue to work.

Also included are some enhancements to make the clickable area for the
link icon larger and fix its color on arc-green.

Fixes: https://github.com/go-gitea/gitea/issues/11896
Fixes: https://github.com/go-gitea/gitea/issues/12062
2020-06-26 21:04:22 +08:00
mrsdizzie
4b66d9ad98
Show description on individual milestone view (#12055)
Fixes #12043

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-25 21:21:13 -04:00
Cirno the Strongest
0ea479561d
Add org avatar on top of internal repo icon (#11895)
* Add org avatar on top of internal repo icon

* add color for arc-green

* use wrapper div to avoid negative margins

* rename class and move div

* move div to icon tmpl

* remove unnecessary margin for lock octicon

* fix label align together with #11891

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-26 03:07:15 +03:00
Cirno the Strongest
6764daf7e5
Use Fomantic's fluid padded for blame full width (#12023)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-25 14:58:12 -04:00
zeripath
0b1bb96441
Fix gitgraph branch continues after merge (#12044)
* Fix gitgraph branch continues after merge

After fixing the initial problem in #11981 another
problem has come to light...

Fix #11981 (part 2)

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

* Update web_src/js/vendor/gitgraph.js

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-25 14:37:28 +03:00
Cornel
ebc35f2b2e
Fix comments webhook panic (#12046)
* Fix webhook comment handling type cast panic

* Handle HookIssueReviewed action in webhook

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-06-24 23:39:43 -04:00
6543
9ef2f62a79
Update Goldmark v1.1.25 -> v1.1.32 (#12048) 2020-06-25 10:43:18 +08:00
6543
c86478ec47
[UI] Sortable Tables Header By Click (#7980)
* [UI] Sortable Tables Header By Click

* get rid of padding above header

* restart CI

* fix lint

* convert getArrow JS to SortArrow go func

* addopt SortArrow funct

* suggestions from @silverwind - tablesort.js

Co-authored-by: silverwind <me@silverwind.io>

* Update web_src/js/features/tablesort.js

Co-authored-by: silverwind <me@silverwind.io>

* Update web_src/js/features/tablesort.js

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
2020-06-24 23:23:05 +01:00
赵智超
ae20de7771
fix bug about can't skip commits base on base branch (#11555)
* fix bug about can't skip commits base on base branch

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update modules/git/commit.go

Co-authored-by: Lauris BH <lauris@nix.lv>

* Update models/issue_comment.go

Co-authored-by: Lauris BH <lauris@nix.lv>

* fix lint

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-24 20:40:52 +01:00
mrsdizzie
8aef7aefd0
Don't use -webkit-font-smoothing (#12029)
Don't change font smoothing via CSS. Linked issue has more details, but this seems fowned upon in general and a was also removed from standards track. Hopefully this will be a part of reverting to a native font stack for Gitea.

Fixes #11931

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-24 11:25:40 -04:00
GiteaBot
5b1327eb56 [skip ci] Updated translations via Crowdin 2020-06-24 04:11:05 +00:00
silverwind
ec0743bab8
Disable dropzone's timeout (#12024)
Dropzone 4.4 introduced a 30s XHR timeout that will kill any upload
still in progress. This disable that timeout again.

Ref: https://www.dropzonejs.com/#config-timeout
Ref: https://github.com/go-gitea/gitea/pull/10645
Ref: https://xhr.spec.whatwg.org/#the-timeout-attribute
Fixes: https://github.com/go-gitea/gitea/issues/12022
Fixes: https://github.com/go-gitea/gitea/issues/11906

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-06-24 00:10:03 -04:00
Cirno the Strongest
d9aa007a9e
Use label to describe repository type (#11891)
* Use label instead of icon to describe repository type when repo avatar is set

* header_icon is not longer duplicated; move out of separate template

* handle archived case too

* use everywhere

* public template -> template

* bring back separate icon in better form

* definitely was overthinking this

* 32

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-22 16:20:51 -04:00
Cirno the Strongest
daf62841f6
Fix sticky diff stats container (#12002)
* Fix sticky diff stats container

* Use pure CSS sticky instead of Fomantic's JS

* add border color to arc-green

* add slight padding on sides

* make linter happy

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-22 15:02:27 -04:00
6543
fc2f2c7602
API: Move AllowedReactions endpoint into GetGenneralUI endpoint + creat new swagger section settings (#11854)
* move Setting function into its own package

* swagger add&use new section "settings"

* move api AllowedReactions into general UI-Settings endpoint

* prepare TEST

* lint
2020-06-22 14:21:31 -04:00
silverwind
b948ecb2d2
Make tabs smaller (#12003)
* Make tabs smaller

Fomantic's tabs are excessively wide and with another tab added on the
repo tabbar (https://github.com/go-gitea/gitea/pull/8346) it would break
the layout on the english language.

Globally reduce tab bar padding to around half of the previous values.

* disable no-duplicate-selectors linter rule

* more tab bar tweaks

* more tweaks

* merge rules and nesting

* remove arc-green weird hover color

* few more arc-green tweaks

* restore to 12px

* tweaks

* use half width height padding

* final tweak

* 10px

* remove min-height

* 11px

* remve new-menu background on light theme too

* background fixes for new-menu

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-22 19:44:06 +03:00
successgo
4dee08a6b4
Fix typo (#12013)
* Fix typo of MSSQL

* Fix typo: validates

* Fix typo

* fix comment with space

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-22 11:21:11 -04:00
Lauris BH
121103fecf
Changelog for v1.11.8 and v1.12.1 (#12006) (#12007)
* Changelog for v1.12.1 (#12006)

* Update gitea version to latest release
2020-06-22 09:58:54 -04:00
Cirno the Strongest
180286da0c
Fix missing styling for dropdown icon on review button (#11998)
* Fix missing styling for dropdown icon on review button

* Remove unnecessary span element

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-22 03:02:22 +03:00
Cirno the Strongest
c1a2887c02
Use octicons for all repo header buttons (#11890)
* Use octicons for all repo header buttons

* ensure margin isn't set on any other svg outside repo buttons

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-22 02:18:42 +03:00
Patrick DeVivo
3b685e1f0d
Adds a TODOs Badge to the README (#11999)
Closes #11210

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-22 01:19:44 +03:00
Cirno the Strongest
81324cf37c
Add pagination headers on endpoints that support total count from database (#11145)
* begin work

* import fmt

* more work

* empty commit

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-21 16:22:06 +08:00
zeripath
a07cc0df76
Handle multiple merges in gitgraph.js (#11996)
* Handle multiple merges in gitgraph.js

There is a bug in web_src/js/vendor/gitgraph.js whereby it fails to
handle multiple merges in a single commit correctly. This PR adds
changes to make this work.

Fix #11981

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

* Update web_src/js/vendor/gitgraph.js
2020-06-20 22:29:44 +03:00
silverwind
d31a9c544f
Add public/img/svg to WEBPACK_DEST_ENTRIES (#11993)
Webpack outputs to this directory so it should be removed during
cleanup. No backport needed.

Co-authored-by: zeripath <art27@cantab.net>
2020-06-20 23:11:37 +08:00
silverwind
e24ee48776
Add serviceworker.js to KnownPublicEntries (#11992)
Fixes a wrong 302 redirect to the login page, see https://github.com/go-gitea/gitea/issues/11989.
Also made it so the reserved username list is extended with those known
entries so we avoid code duplication.

Should be backported to 1.12.
2020-06-20 16:20:25 +03:00
Lauris BH
6891b90303
Use enry language type to detect special languages (#11974) 2020-06-19 15:24:03 +03:00
Lauris BH
5389b6cde1
For language detection do not try to analyze big files by content (#11971) 2020-06-19 11:07:56 +03:00
Cirno the Strongest
92a05f87f0
Use only first line of commit when creating referenced comment (#11960)
* Use only first line of commit when creating referenced comment

* Update modules/repofiles/action.go

* Display first line only on feeds too

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-06-19 15:19:56 +08:00
techknowlogick
ec40e593cf
1.12.0 is latest stable version (#11964) 2020-06-18 15:37:25 -04:00
silverwind
98ddf87b03
Update docs to specify utf8mb4 default (#11962)
Install tool already sets it as the default so we can just update
example ini and docs to it.

Fixes: https://github.com/go-gitea/gitea/issues/11081
2020-06-18 15:36:59 -04:00
Cirno the Strongest
1fb783efb0
Fix scrollable header on dropdowns (#11893)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-18 13:16:26 -04:00
6543
5fcd18a2c4
Changelog v1.12.0 (#11927) (#11957) 2020-06-18 12:11:13 -04:00
6543
c376a8addc
Changelog v1.11.7 (#11953) (#11956)
* Changelog v1.11.7

* Update CHANGELOG.md
2020-06-18 11:45:56 -04:00
techknowlogick
4d2c2962d3
recommend bindata for building (#11938)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-06-18 11:25:58 -04:00
zeripath
654a970644
Fix commenting on non-utf8 encoded files (#11916)
* Add comment on non-unicode line to force fail

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

* Just quote/unquote patch

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-06-18 10:07:09 -04:00
Lunny Xiao
1dd3f19ee3
Use google/uuid to instead satori/go.uuid (#11943)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-18 17:18:44 +08:00
Lunny Xiao
03ba974481
Rename custom/conf/app.ini.sample to custom/conf/app.example.ini for better syntax light on editor (#11926)
* Rename custom/conf/app.ini.sample to custom/conf/app.sample.ini for better syntax light on editor

* rename to app.example.ini

* per @6543 's comment, update all references on docs

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-17 23:16:59 -04:00
Cirno the Strongest
6c81b738f7
Update Fomantic-UI to 2.8.6 and remove old workarounds (#11933)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-17 21:20:07 -04:00
Cirno the Strongest
6c38f371ea
Align show/hide outdated button on code review block (#11932)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-17 20:10:29 -04:00
zeripath
1426126690
Update to go-git v5.1.0 (#11936)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-17 19:29:38 -04:00
techknowlogick
6bf78d2b57
Global default branch setting (#11918)
* Global default branch setting

* add to app.ini example per @silverwind

* update per @lunny

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-06-17 16:53:55 -04:00
techknowlogick
9e6a79bea9
upgrade to use testfixtures v3 (#11904)
* upgrade to use testfixtures v3

* simplify logic

* make vendor

* update per @lunny

* Update templates/repo/empty.tmpl

* Update templates/repo/empty.tmpl

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-17 22:07:58 +03:00
Lunny Xiao
1645d4a5d8
Use ID or Where to instead directly use Get when load object from database (#11925)
* Use ID or Where to instead directly use Get when load object from database

* Apply suggestions from code review

Co-authored-by: 6543 <6543@obermui.de>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2020-06-17 20:50:11 +03:00
Cirno the Strongest
61cd0ce866
Fix double divider on issue sidebar (#11919) 2020-06-17 10:12:06 -04:00
6543
262fce6db4
Update CommitsAhead CommitsBehind on Pull BaseBranch Change too (#11912) 2020-06-16 12:52:33 -05:00
6543
f399cd326b
UI: Fix wrong closing tag (#11910)
* rm wrong closing tag

* Update templates/repo/sub_menu.tmpl

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-06-16 11:27:20 -04:00
techknowlogick
6a4de37f7e
pq -> v1.7.0 (#11905)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-16 19:57:38 +08:00
Cirno the Strongest
80a3745fc8
Make repository size unclickable on repo summary bar (#11887)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-15 21:45:17 -04:00
Lunny Xiao
cdef92b3ff
Upgrade xorm to v1.0.2 (#11900)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-15 16:46:01 -04:00
Cirno the Strongest
492b7d6357
Fix alignment for show/hide outdated link on resolved conversation (#11881)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-15 15:50:12 -04:00
Cirno the Strongest
c8780984f8
Rework blame template and styling (#11885)
* Rework blame template and styling

* cleanup template and add missing NumLines

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-15 14:39:39 -04:00
GiteaBot
a7f7d1399f [skip ci] Updated translations via Crowdin 2020-06-15 17:27:05 +00:00
Cirno the Strongest
26cb7e4b39
Vertically align review icons on repository sidebar (#11880)
* Vertically align review icons on repository sidebar

* Update web_src/less/_repository.less

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-15 13:26:10 -04:00
Cirno the Strongest
5f47835f4c
Better align items using flex within review request box (#11879)
* Better align items using flex within review request box

* use justify-content

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-15 03:37:00 -04:00
GiteaBot
d1c547468a [skip ci] Updated translations via Crowdin 2020-06-14 13:56:16 +00:00
zeripath
48648d1d86
Invalidate comments when file is shortened (#11882)
* Invalidate comments when file is shortened

Fix #10686

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

* handle 1 line

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-06-14 16:55:20 +03:00
zeripath
ae3cfa8449
Only write to global gitconfig if necessary (#11876)
* Only write to global gitconfig if necessary

Fix #11855

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

* placate lint

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-13 17:47:31 -04:00
赵智超
48842ed108
ui: Show update branch item in merge box when it's necessary (#11761)
* ui: Show update branch item in merge box when it's necessary

As title, should show it without care about whether
this pr can be merged.

fix #10959

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix ui

* Fix ui, thanks to @silverwind.

Co-authored-by: silverwind <me@silverwind.io>

* fix lint

* Update templates/repo/issue/view_content/pull.tmpl

Co-authored-by: silverwind <me@silverwind.io>

* Apply review suggestion

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-13 14:49:59 -04:00
Cirno the Strongest
0159851cc3
Rework api/user/repos for pagination (#11827)
* Add count to `GetUserRepositories` so that pagination can be supported for `/user/{username}/repos`
* Rework ListMyRepos to use models.SearchRepository

ListMyRepos was an odd one. It first fetched all user repositories and then tried to supplement them with accessible map. The end result was that:

* Limit for pagination did not work because accessible repos would always be appended
* The amount of pages was incorrect if one were to calculate it
* When paginating, all accessible repos would be shown on every page

Hopefully it should now work properly. Fixes #11800 and does not require any change on Drone-side as it can properly interpret and act on Link header which we now set.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-13 12:35:59 +01:00
silverwind
2447ffc74a
Disable all typographic replacements in markdown renderer (#11871)
* Disable all typographic replacements in markdown renderer

Previously we only disabled some of them. This disables all the default
replacements that goldmark's typographer extension offers, matching
GitHub's renderer.

Ref: https://github.com/yuin/goldmark#typographer-extension
Fixes: https://github.com/go-gitea/gitea/issues/11001

* remove typographer extension completely

* fix test

* really fix test

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-13 02:10:17 -04:00
Cirno the Strongest
b6adf80a80
Fix repo internal icon when avatar is present (#11873)
* Fix repo internal icon when avatar is present

* fix tabs

* move repo icons in header to separate template
2020-06-13 00:24:41 +03:00
GiteaBot
83e9ac57a1 [skip ci] Updated translations via Crowdin 2020-06-12 18:03:15 +00:00
mrsdizzie
d729d685d0
Fix 500 error on repos with no tags (#11870)
#11846 Introduced feature to show exact tag on commit view. However if a repo has no tags at all git prints out a separate and unhandled error " No names found, cannot describe anything."

 Adding --always to the command makes it always use the error in the style of "fatal: no tag exactly matches" even if there are no tags at all.

 Fixes #11869
 Fixes #11868
2020-06-12 14:02:14 -04:00
silverwind
bc4f7ba69b
Add automatic JS license generation (#11810)
* Add automatic JS license generation

Removed librejs file and replaced it with a plaintext file that is built
from all JS dependencies that are included in the webpack build. It does
not cover the few remaining statically vendored files and fomantic is
added manually because it's not yet in the webpack build process.

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

* fix lint

* remove jslicense, we're not librejs compatible any more

* remove license.txt test as it depens on absent files

* small optimization

* trailing comma

* localize and capitalize the word 'licenses'

* reduce text to just 'Licenses'

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-12 14:26:37 +03:00
mrsdizzie
2b573f49cf
Fix nil pointer in default issue mail template (#11862)
* Fix nil pointer in default issue mail template

Fix: template: issue/default:20:17: executing "issue/default" at <.Comment.Type>: nil pointer evaluating interface {}.Type

Introduced in #11167

* another one

Co-authored-by: zeripath <art27@cantab.net>
2020-06-12 11:56:31 +03:00
GiteaBot
13fcd04fe4 [skip ci] Updated translations via Crowdin 2020-06-12 03:35:58 +00:00
Cirno the Strongest
8770bceafa
Fix search form button overlap (#11840)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-11 23:35:03 -04:00
zeripath
0973c03601
Handle more pathological branch and tag names (#11843)
* Handle more pathological branch and tag names

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

* Fix failing test

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-11 19:49:47 -04:00
GiteaBot
6c2a59b50c [skip ci] Updated translations via Crowdin 2020-06-11 21:45:34 +00:00
Cirno the Strongest
5a26192350
Fix commit search in all branches (#11849)
* Fix commit search in all branches

* comments

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-11 17:44:39 -04:00
silverwind
ca8ecf7ffc
Improve label edit buttons labels (#11841)
* Improve label edit buttons labels

Previously when editing the buttons in the "Edit Label" modal were a
strange "Update" and "No". Improved them to "Save" and "Cancel".

Also fixed indentation in the template file, recommended to view changes
with the "Hide whitespace changes" option enabled on GitHub.

* remove unnecessary button icon

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-11 17:06:20 -04:00
zeripath
b9e281265e
Add migration to set IsArchived false if it is null (#11853)
* Add migration to set IsArchived false if it is null

Fix #11824

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

* Add doctor

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-11 16:18:11 -04:00
Cirno the Strongest
b682a2c1b2
Show exact tag for commit on diff view (#11846)
* Show exact tag for commit on diff view

* Fix comment

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-11 15:42:55 -04:00
Girish Ramakrishnan
e282fbe753
cloudron: update link to demo (#11857) 2020-06-11 14:38:26 -04:00
zeripath
9ecf732abc
Prevent panic on empty HOST for mysql (#11850)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-06-11 12:47:55 -04:00
Gernot Eger
a3fe9d87f2
Set the base url when migrating from Gitlab using access token or username without password (#11852)
When migrating from gitlab, set the baseUrl in NewGitlabDownloader when using an access token or username without password

Fix #11851
2020-06-11 16:41:01 +01:00
silverwind
c99ae4cff4
Update JS dependencies (#11842)
Result of `make npm-update`, no noteworthy changes.
2020-06-11 12:02:24 +01:00
Cirno the Strongest
4a4977a1f0
Don't consider tag refs as valid for branch name (#11847)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-10 19:00:39 -04:00
silverwind
a05a30c1c1
Don't add same line code comment box twice (#11837)
* Don't add same line code comment box twice

Clicking the same '+' button multiple times adds multiple comment boxes
to the same line. Prevent this by assigning a unique key to each comment
box and checking if it already exists in the DOM.

Also cleaned up the code around this a bit.

* Update web_src/js/index.js

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-10 18:16:35 -04:00
zeripath
8ffc0ed13f
Re-center the cog on the center of the lock (#11844)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-10 17:01:03 -04:00
silverwind
628ee1d82e
Replace jquery-datetimepicker with native date input (#11684)
This removes the jQuery plugin as well as the associated config options.
Native input[type=date] does not require a language attribute as it is
localized by default, except for the placeholder attribute for which I
currently piggy-back the repo.issues.due_date_form localization option.

Implementation should pretty much match GH. Of note is that Safari does
not provide a UI for this input type, but I don't think providing one is
neccessary and GH did not bother either.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-10 14:35:27 -04:00
Cirno the Strongest
42752f3902
Fix inserting excerpt on compare diff (#11833)
* Fix inserting excerpt on compare diff

* use currentTarget

* remove comment

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-10 13:42:14 -04:00
Cirno the Strongest
2b2b3e4c37
Use DEFAULT_PAGING_NUM instead of MAX_RESPONSE_ITEMS in ListOptions (#11831)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-10 12:23:22 -04:00
赵智超
ac2304f7a0
fix a small nit (#11834)
As title, run this line in one time is enough.

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-06-10 11:26:28 -04:00
GiteaBot
df231b7255 [skip ci] Updated translations via Crowdin 2020-06-10 12:06:44 +00:00
6543
68a2af6d68
API expose usefull General Repo settings settings (#11758)
* GeneralRepoSettings expose MirrorsDisabled, HTTPGitDisabled, MaxCreationLimit

* Apply suggestions from code review

Co-authored-by: proton <25139420+proton-ab@users.noreply.github.com>

* lint

Co-authored-by: proton <25139420+proton-ab@users.noreply.github.com>
2020-06-10 15:05:46 +03:00
6543
1ac46186ff
API allow to create closed milestones (#11745)
* API allow to create closed milestones

* set CloseDate too

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-09 18:01:36 -04:00
silverwind
19db3f4f0a
rework eslint config (#11615)
* rework eslint config

- use explicit config that only enables rules
- upgrade eslint to 7.1.0
- add new plugins with selected rules enabled
- fix discovered issues, remove global wipPrefixes

* remove if

* undo template change

* add disabled rules as well for easier config updating

* add missing disabled rule

* update eslint and plugins

* fix new violation

* remove deprecated rules

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-09 17:31:15 -04:00
6543
363e51d19c
Refactor: Remove Dependencys from Migration v112-v119 (#11811)
* v119

* v116

* v112
2020-06-09 16:34:05 -04:00
John Olheiser
aaff47ad75
Fix reply octicon (#11821)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-06-09 10:13:00 -05:00
Cirno the Strongest
777015c2c2
Use crispEdges rendering for octicon-internal-repo (#11801)
* Use crispEdges rendering for octicon-internal-repo

* Update _svg.less

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-09 01:33:09 -04:00
Cirno the Strongest
27a6e03906
Remove page size limit comment from swagger (#11806)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-09 00:57:38 -04:00
Cirno the Strongest
cefbf73aea
Honor DEFAULT_PAGING_NUM for API (#11805)
* Honor DEFAULT_PAGING_NUM for API

* set pagination to 10 for tests

* lint

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-08 22:46:51 -04:00
6543
5734524378
give gitea time to calculate language stats (#11812) 2020-06-08 20:15:45 -04:00
GiteaBot
218d922d33 [skip ci] Updated translations via Crowdin 2020-06-08 18:08:42 +00:00
zeripath
09f7d84f4c
Ensure rejected push to refs/pull/index/head fails nicely (#11724)
A pre-receive hook that rejects pushes to refs/pull/index/head
will cause a broken PR which causes an internal server error
whenever it is viewed. This PR handles prevents the internal server
error by handling non-existent pr heads and sends a flash error
informing the creator there was a problem.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-06-08 19:07:41 +01:00
6543
5814079bf5
Add option to API to update PullRequest base branch (#11666)
* EditPull: add option to change base

Close #11552
2020-06-07 20:13:40 +01:00
Cirno the Strongest
880ae454db
Work around fomantic 2.8.5 bugs (#11767)
Work around fomantic 2.8.5 bugs 

Closes #11759

Related fomantic/Fomantic-UI#1372 and fomantic/Fomantic-UI#1473
2020-06-07 19:25:52 +01:00
6543
479ef5c379
In File Create/Update API return 404 if Branch does not exist (#11791) 2020-06-07 18:30:58 +01:00
GiteaBot
3f3a081758 [skip ci] Updated translations via Crowdin 2020-06-07 15:24:09 +00:00
赵智超
ba8efe3547
Fix doer of rename repo (#11789)
fix #11725

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: zeripath <art27@cantab.net>
2020-06-07 18:23:13 +03:00
GiteaBot
1cc33c37ff [skip ci] Updated translations via Crowdin 2020-06-07 11:49:39 +00:00
Lauris BH
2874ab54bc
Add language statistics API endpoint (#11737)
* Add language statistics API

* Add tests
2020-06-07 14:48:41 +03:00
Cirno the Strongest
94f60e199b
Fix visibility of forked public repos from private orgs (#11717)
* Fix visibility of forked public repos from private orgs

* update forks visibility when org visibility is changed

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-06 20:45:12 -04:00
Cirno the Strongest
594db7fb43
Fix missing CGO_EXTRA_FLAGS build arg for docker (#11782)
Co-authored-by: zeripath <art27@cantab.net>
2020-06-06 17:42:32 -04:00
GiteaBot
304542af31 [skip ci] Updated translations via Crowdin 2020-06-06 20:31:10 +00:00
Cirno the Strongest
f6315fb477
Fix align issues and decrease avatar size on PR timeline (#11689)
* Fix margin for referenced issue title

* Change avatar size to 20px, align referenced issue title to avatar

* better align
2020-06-06 21:30:10 +01:00
GiteaBot
c8b1c4b10a [skip ci] Updated translations via Crowdin 2020-06-06 14:16:14 +00:00
zeripath
1ee6c13f11
Initialize SimpleMDE when making a code comment (#11749)
Fix #11704

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-Authored-By: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
2020-06-06 15:15:14 +01:00
techknowlogick
cfac97542b
1.11.6 is latest version (#11780) 2020-06-06 09:57:33 +03:00
Cirno the Strongest
a5aa5c58c1
Increase maximum SQLite variables count to 32766 (#11696)
per https://www.sqlite.org/limits.html

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-05 19:57:25 -04:00
GiteaBot
f576756b18 [skip ci] Updated translations via Crowdin 2020-06-05 22:52:05 +00:00
Cirno the Strongest
bbe13b60cd
Fix timezone on issue deadline (#11697)
* Fix timezone on issue deadline

* FormatDate

Co-authored-by: zeripath <art27@cantab.net>
2020-06-05 18:51:10 -04:00
GiteaBot
cc9d2deb60 [skip ci] Updated translations via Crowdin 2020-06-05 20:48:38 +00:00
PhilippHomann
684b7a999f
Dump: add output format tar and output to stdout (#10376)
* Dump: Use mholt/archive/v3 to support tar including many compressions

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* Dump: Allow dump output to stdout

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* Dump: Fixed bug present since #6677 where SessionConfig.Provider is never "file"

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* Dump: never pack RepoRootPath, LFS.ContentPath and LogRootPath when they are below AppDataPath

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* Dump: also dump LFS (fixes #10058)

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* Dump: never dump CustomPath if CustomPath is a subdir of or equal to AppDataPath (fixes #10365)

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* Use log.Info instead of fmt.Fprintf

Signed-off-by: Philipp Homann <homann.philipp@googlemail.com>

* import ordering

* make fmt

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Matti R <matti@mdranta.net>
2020-06-05 16:47:39 -04:00
GiteaBot
209b17c4e2 [skip ci] Updated translations via Crowdin 2020-06-05 20:02:46 +00:00
l-jonas
aa3c0f8eba
Add hide activity option (#11353)
* Add hide activity option

This closes https://github.com/go-gitea/gitea/issues/7927

* Adjust for linter

* Adjust for linter

* Add tests

* Remove info that admins can view the activity

* Adjust new tests for linter

* Rename v139.go to v140.go

* Rename v140.go to v141.go

* properly indent

* gofmt

Co-authored-by: Jonas Lochmann <git@inkompetenz.org>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-05 16:01:53 -04:00
John Olheiser
ac07418011
Add compare link to releases (#11752)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-05 14:44:54 -04:00
GiteaBot
48f24c7b32 [skip ci] Updated translations via Crowdin 2020-06-05 14:35:50 +00:00
successgo
fa1c958f1c
Fix typo (#11773)
* Fix typo of MSSQL

* Fix typo: validates
2020-06-05 10:34:23 -04:00
Cirno the Strongest
5acba4609a
Add internal-repo octicon for public repos of private org (#11529)
* Show multiple octicons on repo list

* fix mixed spaces/tabs

* Internal repo octicon

* show internal icon in dashboard repolist

* swagger

* fix icon for normal repo on repo page

* don't expose owner visibility directly; provide internal in repo api

* fix icons for forks and mirrors

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-05 14:41:06 +03:00
zeripath
f761a37a0f
Provide diff and patch API endpoints (#11751)
* Provide diff and patch API endpoints

The diff and patch endpoints on the main routes are not accessible by token
therefore we provide new API based endpoints for these

Fix #10923

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

* placate swagger

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

* Make the response an actual string

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-05 14:03:12 +03:00
赵智超
17f8de7a54
Fix to allow comment poster to edit or delete his own comments (#11671)
* bug: fix comment update permision check

No the ui only allow poster to update or delet comment, which
is not reasonable and different with handle logic, this pr
change it to allow poster of comment do it

ref code:
e8955173a9/routers/repo/issue.go (L1636)

e8955173a9/routers/repo/issue.go (L1681)

fix #11663

Signed-off-by: a1012112796 <1012112796@qq.com>

* simplify code

* fix sign in

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-05 13:10:10 +03:00
Emanuel Angelo
a39557f8fb
European Portuguese translation (#11568)
This PR includes the modifications necessary to make use of the European Portuguese translation from the default setting.
2020-06-05 09:07:56 +01:00
6543
2c5b3c72e8
Fix bug with globally disabling mirror (#11760)
Ensure we return after `ctx.Error(...)`
2020-06-04 19:06:24 +01:00
6543
0cb22121f4
API: Return error when Mirrors globaly disabled and like to create one (#11757)
* API: return an error when Mirrors globaly disabled

* keep it consistent with UI

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-06-04 12:11:28 -04:00
6543
b534a5164f
[API] Expose allowed Reactions (#11735)
* [API] Expose allowed Reactions

* dont be in soutch a rush

* add TEST

* use ElementsMatch

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-04 12:16:53 +03:00
mrsdizzie
2842f6cf42
Include query in sign in redirect (#11579)
* Include query in sign in redirect

Include query string in ctx.Data["SignInLink"] so people are redirected to the right page after singing in. Fixes case of:

Visit:

 https://try.gitea.io/mrsdizzie/testcase/issues?q=&type=all&sort=&state=open&labels=7071&milestone=0&assignee=0

Sign in, then redirected to:

 https://try.gitea.io/mrsdizzie/testcase/issues

Create a new "SignInLink" instead of updating the existing "Link" because too many places in the code assume "Link" won't have a query

* Apply suggestions from code review

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-03 23:41:02 -04:00
silverwind
3affe9516a
Update fomantic-ui to 2.8.5 (#11736)
Update to [2.8.5](https://github.com/fomantic/Fomantic-UI/releases/tag/2.8.5)
and remove the workaround for the CSS build race condition.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-03 22:24:04 -04:00
techknowlogick
a3b185d54c
Alpine 3.12 (#11720)
* increase alpine to 3.12

* Update .drone.yml
2020-06-03 16:32:51 -04:00
mrsdizzie
2b2373f6c2
Don't put integration test data outside of test folder (#11746)
Some integration test data is being put outside of the integration test folders which means it isn't deleted properly with make clean. Update config so it works as expected.

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-03 15:07:02 -04:00
GiteaBot
c6cee44134 [skip ci] Updated translations via Crowdin 2020-06-03 18:19:35 +00:00
6543
ce7510a80f
[API] on 500 error only show message if gitea in dev mode (#11641)
* add API specific InternalServerError()

* return 500 error msg only if not Production mode

* rm unnessesary change
2020-06-03 14:17:54 -04:00
GiteaBot
19aab76853 [skip ci] Updated translations via Crowdin 2020-06-03 15:38:09 +00:00
zeripath
a730dc1419
Fix verification of subkeys of default gpg key (#11713)
* Fix verification of subkeys of default gpg key

Fix #10309

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

* Remove debug log

* Update models/gpg_key.go

* As per @6543

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-03 11:36:41 -04:00
silverwind
160c23c4ab
export monaco editor on window.codeEditors (#11739)
Fixes: https://github.com/go-gitea/gitea/issues/10409

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-03 14:19:32 +03:00
GiteaBot
4280d44a45 [skip ci] Updated translations via Crowdin 2020-06-03 08:31:48 +00:00
Cirno the Strongest
3ea5d864b9
Fix message wrapping on PR commit list (#11616)
* Fix message wrapping on PR commit list

* Update templates/repo/commits_list_small.tmpl

Co-authored-by: silverwind <me@silverwind.io>
2020-06-03 09:30:34 +01:00
Will 保哥
464b583c6c
Update from-package.zh-tw.md (#11626)
Add translation for `install-from-package` page

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-03 02:11:26 -04:00
GiteaBot
2cf99f89c6 [skip ci] Updated translations via Crowdin 2020-06-03 06:10:22 +00:00
赵智超
de0b2d4e32
bug: fix wrong poster message for code comment on Pull view (#11721)
As title, maybe fix one of issue in #11705

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-03 02:09:03 -04:00
Cirno the Strongest
8e035f81c0
Fix styling for commiter on diff view (#11715)
* Fix styling for commiter on diff view

* Update options/locale/locale_en-US.ini

* Update templates/repo/commit_page.tmpl

Co-authored-by: silverwind <me@silverwind.io>

* Update templates/repo/commit_page.tmpl

Co-authored-by: silverwind <me@silverwind.io>

* Apply suggestions from code review

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-02 22:40:08 -04:00
S7evinK
dcefcc10e6
Add missing templates (#11729)
Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-02 22:04:52 -04:00
Bagas Sanjaya
d9b5c21625
[Contrib] Change License Link to Full CC0 Legalcode (PP and TOS) (#10057)
* Change license link to full (raw link) legal code on options/license

* Replace link to full legal code at CC site

* Update contrib/legal/tos.html.sample

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-02 21:22:17 -04:00
John Olheiser
a6fd2f23f7
Allow site admin to disable mirrors (#11740)
* Allow site admin to disable mirrors

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* No need to run through Safe

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Clarify only disabling NEW mirrors

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Apply suggestions from @guillep2k

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-06-02 21:21:38 -04:00
Cirno the Strongest
d0a18a1270
Show full GPG commit status on PR commit history (#11702)
* Show full GPG commit status on PR commit history

* move shabox badge to separate template

* unnecessary $

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-06-02 20:22:26 -04:00
zeripath
a1ad188326
Fix chardet test and add ordering option (#11621)
* Fix chardet test and add ordering option

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

* minor fixes

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

* remove log

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

* remove log2

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

* only iterate through top results

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

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

* slight restructure of for loop

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-02 19:20:19 -03:00
zeripath
fe2cacf5ea
Properly truncate system notices (#11714)
* Properly truncate system notices

As noted in #11658 the system notifications list will always suffix
system notices with ... even when the notice is longer than 120
characters.

Instead we should use .text.truncate to auto truncate and make the
notices clickable to view their details.

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

* As per @CirnoT make table cell clickable

* ensure that pre wraps

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-02 16:24:18 -04:00
mrsdizzie
3af51f1ab7
Update emoji dataset with skin tone variants (#11678)
* Update emoji dataset with skin tone variants

Since the format of emoji that support skin tone modifiers is predictable we can add different variants into our dataset when generating it so that we can match and properly style most skin tone variants of emoji. No real code change here other than what generates the dataset and the data itself.

* use escape unicode sequence in map

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-02 02:22:40 -04:00
zeripath
14ca111f33
log slow tests (#11487)
* log slow tests

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

* placate lint

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

* More lint placation

Co-authored-by: 6543 <6543@obermui.de>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-06-01 21:39:44 -04:00
6543
dc812f8ba5
Issue/Pull expose IsLocked Property on API (#11708)
Expose IsLocked Property
2020-06-01 22:01:55 +01:00
GiteaBot
7cb1e1f609 [skip ci] Updated translations via Crowdin 2020-05-31 21:00:58 +00:00
6543
b636cd6fd4
Handle expected errors in FileCreate & FileUpdate API (#11643)
as title

needed for #11641
2020-05-31 21:59:34 +01:00
guillep2k
34b6983f56
Add changelog for 1.11.6 (#11695) (#11700)
* Add changelog for 1.11.6

* Update CHANGELOG.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* Update CHANGELOG.md

Co-authored-by: techknowlogick <matti@mdranta.net>

* Apply suggestions from @lafriks

* #11459 is bugfix

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: techknowlogick <matti@mdranta.net>

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-31 01:28:11 -04:00
Cuong Manh Le
d98df0ede3
models: include LFS when calculating repo size (#11060)
Fixes #9369

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-31 00:51:19 -04:00
silverwind
cdec70f3f8
Narrow down Edge version in browser support docs (#11640)
* Narrow down Edge version in browser support docs

I noticed that Edge 14 has a pretty buggy fetch implementation and
because it has already reached end of support I think it's better we
don't specifically state support for it, even if it may work to some
extend.

* mention both edge versions

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-30 23:06:34 -04:00
TLZ
2d1ade3415
Update Caddy reverse-proxy instructions (#11655)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-30 22:16:32 -04:00
Cirno the Strongest
9d652002c6
Fix language stat calculation (#11692)
* Fix language stat calculation

* Group languages and ignore 0 size files

* remove unneeded code
2020-05-31 01:58:55 +03:00
Lauris BH
ea4c139cd2
Change language statistics to save size instead of percentage (#11681)
* Change language statistics to save size instead of percentage in database

Co-Authored-By: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>

* Do not exclude if only language

* Fix edge cases with special langauges

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
2020-05-30 10:46:15 +03:00
Cirno the Strongest
4395c607ed
Make tabular menu styling consistent for arc-green (#11570)
* Make tabular menu styling consistent for arc-green

* rework completely

* transparent borders

* use darker color for active item; override only colors for borders

* Update web_src/less/themes/theme-arc-green.less

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-05-30 00:15:25 +01:00
zeripath
495354c4bd
Add logging to long migrations (#11647)
* Add logging to long migrations

Also fix v136 to not use models

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-29 23:18:24 +01:00
zeripath
6e4480835f
Fix issue with DiffIndex on initial commit (#11677)
Unfortunately #11614 introduced a bug whereby the initial commit of a
repository could not be seen due to there being no parent commit to
create a clear diff from.

Here we create a diffstat from the difference between the parentless SHA and the SHA of the empty tree - a constant known to git. (With thanks to @L0veSunshine for informing me of this SHA)

Thanks to @a1012112796 for initial attempt to fix.

Fix #11650

Closes #11674

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-Authored-By: L0veSunshine <xuan199651@gmail.com>
2020-05-29 22:14:00 +01:00
Terence Le Huu Phuong
141d52cc0f
Add API Endpoint for Branch Creation (#11607)
* [FEATURE] [API] Add Endpoint for Branch Creation

Issue: https://github.com/go-gitea/gitea/issues/11376

This commit introduces an API endpoint for branch creation.

The added route is POST /repos/{owner}/{repo}/branches.
A JSON with the name of the new branch and the name of the old branch is
required as parameters.

Signed-off-by: Terence Le Huu Phuong <terence@qwasar.io>

* Put all the logic into CreateBranch and removed CreateRepoBranch

* - Added the error ErrBranchDoesNotExist in error.go
- Made the CreateNewBranch function return an errBranchDoesNotExist error
when the OldBranch does not exist
- Made the CreateBranch API function checks that the repository is not
empty and that branch exists.

* - Added a resetFixtures helper function in integration_test.go to
fine-tune test env resetting
- Added api test for CreateBranch
- Used resetFixture instead of the more general prepareTestEnv in the
repo_branch_test CreateBranch tests

* Moved the resetFixtures call inside the loop for APICreateBranch function

* Put the prepareTestEnv back in repo_branch_test

* fix import order/sort api branch test

Co-authored-by: zeripath <art27@cantab.net>
2020-05-29 19:16:20 +01:00
Cirno the Strongest
f36104e410
Normalize avatar radius (#11589)
We already made avatars square for .ui avatar.img class but this is not enough, and in some place Fomantic default styling still applied.

This PR updates our override of radius to match all Fomantic classes.
2020-05-29 18:00:39 +01:00
mrsdizzie
4c1ff57f1a
Update emoji regex (#11584)
When matching emoji, use a regex built from the data we have instead of something generic using unicode ranges. A generic regex can't tell the difference between two separate emoji next to each other or one emoji that is built out of two separate emoji next to each other.

This means that emoji that are next to each other without space in between will be now accurately spanned individually with proper title etc...
2020-05-29 17:08:36 +01:00
Cirno the Strongest
02fa329a7c
Fix missing authorization check on pull for public repos of private/limited org (#11656)
Fixes #11651
2020-05-29 15:47:17 +01:00
GiteaBot
0d9f9f7de1 [skip ci] Updated translations via Crowdin 2020-05-29 13:25:34 +00:00
6543
726e1e5279
Doctor check & fix db consistency (#11111)
needed to fix issue as described in #10280

* rename check-db to check-db-version
* add check-db-consistency:
* find issues without existing repository
* find pulls without existing issues
* find tracked times without existing issues/pulls
* find labels without repository or org reference

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-05-29 14:24:15 +01:00
赵智超
ab73b56575
translate: Change translate for admin.config.enable_captcha (#11657)
* translate: Change translate for admin.config.enable_captcha

add 'register' to make it more accurate

Signed-off-by: a1012112796 <1012112796@qq.com>

* Update options/locale/locale_en-US.ini

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>

Co-authored-by: Cirno the Strongest <1447794+CirnoT@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-29 11:36:51 +03:00
Lauris BH
bd2335671f
Exclude generated files from language statistics (#11653)
* Update go-enry to v2.5.2
2020-05-29 09:20:01 +03:00
zeripath
e8955173a9
Default MSSQL port 0 to allow automatic detection by default (#11642)
Fix #11633

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-28 23:59:59 -04:00
zeripath
8730b091e3
Add debug option to hooks (#11624)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-28 23:04:44 -04:00
6543
560744fb33
Handle expected errors in AddGPGkey API (#11644)
* handle GPG Parse & Email Errors

* correct TEST

* update Swagger

* more Docu
2020-05-28 17:25:54 -04:00
6543
9f55769804
Return json on 500 error from API (#11574)
* add API specific InternalServerError()

Co-authored-by: zeripath <art27@cantab.net>

* return 500 error msg only if not Production mode

* Revert "return 500 error msg only if not Production mode"

This reverts commit 8467b2cee674ad205b452780ca88abb1b27643c8.

* InternalServerError

Co-authored-by: zeripath <art27@cantab.net>
2020-05-28 13:58:11 -03:00
zeripath
3aedc795c4
Use -1 to disable key algorithm type in ssh.minimum_key_sizes (#11635)
Fix #11634

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-28 16:29:15 +03:00
GiteaBot
cd5b0e262e [skip ci] Updated translations via Crowdin 2020-05-27 20:33:27 +00:00
mrsdizzie
5d78792385
Fix alignment for commits on dashboard (#11595)
Fix alignment issue between commit SHA and commit message
2020-05-27 21:31:12 +01:00
zeripath
a00974c3b8
When must change password only show Signout (#11600)
When "Must Change Password" simplify the navbar header to only show the
signout button as all other links will redirect back. This prevents the
notifications icon from showing preventing initialization of the
event-source and hence preventing redirect_to being set, however in
addition do not set the redirect_to cookie if we are looking at the
/user/events page.

Fix #11554

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-26 23:39:39 +01:00
GiteaBot
926e63bb9e [skip ci] Updated translations via Crowdin 2020-05-26 21:12:40 +00:00
Sandro Santilli
24be06d7a6
Add link to owners election tickets, reorder to most-recent first (#11632) 2020-05-26 16:11:26 -05:00
zeripath
5cb201dc93
Fix numbr of files, total additions, and deletions (#11614)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-26 01:58:07 -04:00
Cirno the Strongest
b97917a6e7
Apply padding to approval icons on PR list (#11622)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-05-26 00:48:23 -04:00
GiteaBot
55b4b4e8a5 [skip ci] Updated translations via Crowdin 2020-05-26 03:50:57 +00:00
Cirno the Strongest
793719a50d
Fix missing styling for shabox on PR commit history (#11625) 2020-05-26 04:49:53 +01:00
Cirno the Strongest
8443ca109b
Make issues.force_push_codes message shorter (#11575)
Also removes stray dot and whitespace.

Trying to make base message shorter; I don't envy translators, the message can easily get multi-line in English, I'm sure that is even bigger problem in other languages.
2020-05-25 20:50:52 +01:00
Cirno the Strongest
75739d00cb
Fix styling for PR merge section when no checks (#11609)
Makes styling consistent between two cases. Also removed unnecessary double border.
2020-05-25 20:08:06 +01:00
Cirno the Strongest
0a7c5623d7
Style code review comment for arc-green (#11572)
* Style code review comment for arc-green

* change border around review for light; update border around textarea to match #11570

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-25 12:12:49 -04:00
Cirno the Strongest
f32bf902e7
Right-align status icon on pull request commit history (#11594)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-25 09:51:13 -04:00
Cirno the Strongest
f2a0be1683
Fix margin on PR form (#11566) 2020-05-25 11:04:02 +01:00
Cirno the Strongest
e682a92295
Fix margin for attached top header on code review (#11571)
Introduced naively by #11463

The margin was being applied too widely.
2020-05-25 09:18:48 +01:00
zeripath
02a52d683b
Add warning to mailer documentation about authentication (#11563)
* Add warning to mailer documentation about authentication

References #7966

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

* As per @guillep2k and @mrsdizzie

* as per @mrsdizzie

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

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-24 23:56:18 +01:00
Cirno the Strongest
39b792f424
Do not show avatar for "{{user}} added X commits" (#11591)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-24 16:26:03 -04:00
Will 保哥
7305b555d3
Add chocolatey package install instructions (#11586)
* Update from-package.en-us.md

https://github.com/go-gitea/gitea/issues/10800

* Update docs/content/doc/installation/from-package.en-us.md

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-24 15:17:33 -04:00
Cirno the Strongest
04afd9d1e2
Fix inconsistent font size for markdown preview on new PR view (#11565)
We use same method for new issue form and issue view, but was missing from new PR view making it one place where markdown preview is inconsistent in font size.
2020-05-24 18:53:37 +01:00
zeripath
3547e84a05
When initialising repositories ensure that the user doing the creation is the initializer (#11601)
Fix #10760

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-24 18:12:40 +01:00
GiteaBot
e25348da88 [skip ci] Updated translations via Crowdin 2020-05-24 14:40:08 +00:00
Gary Kim
5c55793e0e
Fix wrong milestone in webhook message (#11596)
Fixes #11295

Signed-off-by: Gary Kim gary@garykim.dev
2020-05-24 15:38:34 +01:00
zeripath
788b8b1440
Prevent empty query parameter being set on dashboard (#11561)
Prevent the dashboard from setting an empty query parameter

Fix #11543

Signed-off-by: Andrew Thornton art27@cantab.net
2020-05-24 14:02:16 +01:00
mrsdizzie
ae55dc7a6b
Fix images in wiki edit preview (#11546)
Make sure wiki editor sets wiki to true so gitea renders it as a wiki page.

Also change the context data attr for edit form. This looks wrong but everywhere else in our code assumes the urlPrefix to be just the repo url when rendering and manually adds /wiki to the rendered url regardless.

Fixes #11540
2020-05-24 11:41:33 +01:00
zeripath
814ca9ffea
Allow different HardBreaks settings for documents and comments (#11515)
GH has different HardBreaks behaviour for markdown comments and documents.

Comments have hard breaks and documents have soft breaks - therefore Gitea's rendering will always be different from GH's if we only provide one setting.

Here we split the setting in to two - one for documents and one for comments and other things.

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

Changes to index.js as per @silverwind 
Co-authored-by: silverwind <me@silverwind.io>

Changes to docs as per @guillep2k 
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-24 09:14:26 +01:00
silverwind
3761bdb640
Fix serviceworker output file and misc improvements (#11562)
* Fix serviceworker output file and misc improvements

- Fix output file location for production build
- Cache more asset types: fonts and worker variants
- Parallelize a few tasks during initalization
- Only invalidate caches starting with our prefix
- Remove public/serviceworker.js before building
- Remove font preloads, they cause strange cors issues
- Misc eslint config adjustments

* remove webpack output files on watch-frontend
2020-05-24 08:36:40 +01:00
Cirno the Strongest
8d9f9c3237
Add missing padding for multi-commit list on PR view (#11593) 2020-05-24 06:54:18 +01:00
zeripath
f7e3767929
Prevent (caught) panic on login (#11590)
Unfortunately when the virtual session is released it requires that the
real session does not exist. This worked fine when sessions were only
saved at the end of request/response cycle however, now sessions are
saved proactively this does not hold.

The result is a caught panic in the logs during every log-in.  This
panic has no significant side-effects but should not occur.

This PR marks the virtual session as released when released and updates
it if the same session is released again.

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

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-23 20:59:04 -03:00
Cirno the Strongest
ac3c467770
Fix styling and padding for commit list on PR view (#11588)
* Fix styling and padding for commit list on PR view

* fix bold on author
2020-05-24 01:05:20 +03:00
Cirno the Strongest
31df012968
Properly handle and return empty string for dangling commits in GetBranchName (#11587) 2020-05-23 20:49:48 +01:00
zeripath
723b199271
Ensure serviceworker is created as /serviceworker.js (#11577)
#11538 moved the serviceworker to webbox but unfortunately
created the serviceworker in public/js rather than public/

This PR fixes this, fixing multiple issues with broken js
as a result of that change.

Signed-off-by: Andrew Thornton art27@cantab.net
2020-05-23 14:58:58 +01:00
Cirno the Strongest
38c773d8a5
Enforce transparent background on editor toolbar elements (#11569)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-23 14:59:40 +03:00
silverwind
1752a976e1
Fix Enter not working in SimpleMDE (#11564)
* Fix Enter not working in SimpleMDE

This condition was wrongly inverted, leading to all enter keys being
blocked.

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

* fix it for absent tribute too
2020-05-22 21:29:57 -04:00
mrsdizzie
5789e60316
Use default commit message for wiki edits (#11550)
Use a default commit message when a user doesn't add one (same as repo editor) to avoid commit lists with no message
2020-05-22 14:14:02 +01:00
silverwind
6af13dbac2
Close EventSource before unloading the page (#11539)
Should eliminate a error in the Firefox console regarding the connection
being interrupted while the page was loading.
2020-05-22 11:57:54 +01:00
silverwind
88fe7b5a72
Move serviceworker to workbox and fix SSE interference (#11538)
* Move serviceworker to workbox and fix SSE interference

Instead of statically hardcoding every frontend asset, this uses a
type-based approach to cache all js,css and manifest.json requests.

This also fixes the issue that the service worker was interfering with
EventSource because it was unconditionally handling all requests which
this new implementation doesn't.

Fixes: https://github.com/go-gitea/gitea/issues/11092
Fixes: https://github.com/go-gitea/gitea/issues/7372

* rethrow error instead of logging

* await .register

* Revert "rethrow error instead of logging"

This reverts commit 043162ba1f18b98a4bf9635959fd28d16e839fc5.

* improve comment

* remove JSRenderer

* add version-based cache invalidation

* refactor

* more refactor

* remove comment

* rename item to fit cache name

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-21 21:45:34 -04:00
GiteaBot
f6f49700cc [skip ci] Updated translations via Crowdin 2020-05-22 00:03:16 +00:00
silverwind
035db78018
Ensure emoji render with regular font-weight (#11541)
Emoji characters don't support bold attributes and may do weird things
like rendering monochrome when bolded.
2020-05-21 21:01:58 -03:00
GiteaBot
460bc32c71 [skip ci] Updated translations via Crowdin 2020-05-21 13:49:42 +00:00
guillep2k
e963525c5e
Prevent transferring repos to invisible orgs (#11517)
Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
2020-05-21 08:48:01 -05:00
zeripath
0b8b81e029
API PullReviewComment HTMLPullURL should return the HTMLURL (#11501)
Fix #11499

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-20 22:41:30 -04:00
silverwind
b02d2c3772
Move tributejs to npm/webpack (#11497)
* Move tributejs to npm/webpack

- Move vendored bundle to npm and webpack
- Rewrote initialization to single function
- Restyled it (made it a bit smaller)
- Fixed it for arc-green

* fix mention

* also include emoji on #content

* Update web_src/less/_tribute.less

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* rewrite to only use one instance of Tribute

* refactor

* fix copy/paste error

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-20 22:00:43 -04:00
zeripath
3eb323901c
Fix repo-list private and total count bugs (#11500)
* Fix repo-list private and total count bugs

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

* Ensure limited and private org public repos are displayed on "private"

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

* switch from onlyPrivate to is_private

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

* Generate swagger

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

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-20 22:15:30 -03:00
silverwind
b797b76abd
Fix webpack chunk loading with STATIC_URL_PREFIX (#11526)
Previously, we had only set __webpack_public_path__ to a path which
caused webpack chunks to be loaded from the current origin which is
incorrect when STATIC_URL_PREFIX points to another origin.

This should fix the issue curretnly seen on gitea.com.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-20 23:33:31 +01:00
Cirno the Strongest
c7c61778bc
Fix text-transform on wiki revisions page (#11486)
* Fix text-transform on wiki revisions page

* apply global

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-05-20 16:27:14 -04:00
L0veSunshine
b6d01ccdca
Fix the bug that the emoji does not disappear (#11489)
* Fix the bug that the emoticon does not disappear

* Update web_src/js/index.js

Co-authored-by: Lauris BH <lauris@nix.lv>

* Update web_src/js/index.js

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-05-20 15:41:33 -04:00
GiteaBot
7c287b9f0b [skip ci] Updated translations via Crowdin 2020-05-20 18:36:38 +00:00
Matthew R. McDougal
689e7e8831
Fix form action template substitutions on admin pages (#11519)
* Fix form action template substitution on admin dashboard

* Fix form action template substitution on admin monitoring page

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-20 14:35:16 -04:00
GiteaBot
21243bb46f [skip ci] Updated translations via Crowdin 2020-05-20 17:13:30 +00:00
Cirno the Strongest
ee4e8542c7
Fix margin for branch-update grid on PR view when update button is not present (#11521)
* Fix margin for branch-update grid on PR view when update button is not present

* Move padding to row element

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-20 13:12:08 -04:00
GiteaBot
3856fd7c10 [skip ci] Updated translations via Crowdin 2020-05-20 16:17:40 +00:00
zeripath
c81ab17de9
TrimSpace when reading InternalToken from a file (#11502)
InternalTokens are fixed as alphanum strings therefore TrimSpace from these.
Also use isatty to not add a terminal newline when redirecting generate.

Fix #11498

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-20 19:16:06 +03:00
赵智超
0903b1ac8c
Add push commits history comment on PR time-line (#11167)
* Add push commits history comment on PR time-line
* Add notify by email and ui of this comment type also

Signed-off-by: a1012112796 <1012112796@qq.com>

* Add migrations for IsForcePush
* fix wrong force-push judgement
* Apply suggestions from code review
* Remove commit number check
* add own notify fun
* fix some typo

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* fix lint

* fix style again, I forgot something before

* Change email notify way

* fix api

* add number check if It's force-push

* Add repo commit link fuction
remove unnecessary check
skip show push commits comment which not have commits alive

* Update issue_comment.go

* Apply suggestions from code review

Co-authored-by: mrsdizzie <info@mrsdizzie.com>

* Apply suggestions from code review

* fix ui view

Co-authored-by: silverwind <me@silverwind.io>

* fix height

* remove unnecessary style define

* simplify GetBranchName

* Apply suggestions from code review

* save commit ids and isForce push by json
* simplify GetBranchName

* fix bug

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: silverwind <me@silverwind.io>
2020-05-20 09:47:24 -03:00
silverwind
9e0e2a9fcf
Enable stylelint's shorthand-property-no-redundant-values (#11436)
Enabled the rule and --fix'ed issues.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-20 00:06:04 -04:00
silverwind
34e6a4e057
Remove IE11 support (#11470)
* Remove IE11 support

With master now on 1.13, it's time to drop IE11 for good. The woff
variants are also in use by Opera Mini but it has even less market share
and I can only imagine how broken the UI is in it.

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

* update docs

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-19 23:28:59 -04:00
Cirno the Strongest
6da87eda8b
Fix selected line color in arc-green (#11492)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-19 22:49:48 -04:00
Cirno the Strongest
c572ee2b61
Fix dropzone color on arc-green (#11514)
* Fix dropzone color on arc-green

* fix missing ;

* use same color as textarea and fix border

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-19 18:54:20 -04:00
GiteaBot
b5851b7d1a [skip ci] Updated translations via Crowdin 2020-05-19 20:25:38 +00:00
wULLSnpAXbWZGYDYyhWTKKspEQoaYxXyhoisqHf
a2d7999e93
Insert ui divider directly in templates instead of from inside heatmap vue component (#11508)
* ui: remove the divider between heatmap and feeds in the dashboard view

* this commit reverses 6ccd19ef86

Signed-off-by: surtur <a_mirre@utb.cz>

* add a divider to the default user dashboard view

* another one-line change, this time as a direct complement of
  2bfc71614c0c5470162825a21c13838e15ccf5a6 to implement a divider of
  sorts (as per 6ccd19ef86 originally)

Signed-off-by: surtur <a_mirre@utb.cz>

* removed the divider in heatmap.tmpl

* the separator is added by partial templates as needed

Signed-off-by: surtur <a_mirre@utb.cz>

* load proper dashboard template code in profile.tmpl

* as discussed in Discord
* includes a divider of its own

Signed-off-by: surtur <a_mirre@utb.cz>
2020-05-19 21:24:14 +01:00
silverwind
50a97272b9
Tweak reaction buttons (#11496)
- Vertical centering using flexbox
- Very slightly decreased size of the boxes

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-19 03:17:37 -04:00
赵智超
6ccd19ef86
ui: Add dividing line between heatmap and feeds in dashboard view (#11437)
* ui: Add dividing line between heatmap and feeds in dashboard view

I think it's necessary to add dividing line between heatmap
and feeds in dashboard view, or the first items in feed is too
near with heatmap which is not a good view.

Signed-off-by: a1012112796 <1012112796@qq.com>

* Change the implementation method

* change style

* restart ci

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-19 02:42:43 -04:00
Cirno the Strongest
7b66400f55
Use more toned colors for selected line (#11493)
Co-authored-by: zeripath <art27@cantab.net>
2020-05-19 01:58:45 -04:00
Cirno the Strongest
29fbe63ba9
Add myself to MAINTAINERS (#11494) 2020-05-18 16:50:22 -05:00
L0veSunshine
eb8abffcc1
Make localstorage read ssh or https correctly (#11483)
* Make localstorage read ssh or https correctly

* Update index.js

If not login there is only a "https" button, This commit fix  the "https" button hasn't blue border.

* Keep user selected whether or not to log in

* Update index.js
2020-05-18 12:44:39 -05:00
Cirno the Strongest
6b798feaf6
Fix top margin for bottom attached header (#11480) 2020-05-18 11:27:09 +01:00
Cirno the Strongest
e7e0097148
Fix footer padding for comment code reply form on issue event view (#11469) 2020-05-18 06:33:47 +01:00
GiteaBot
b72af7ee71 [skip ci] Updated translations via Crowdin 2020-05-17 23:29:05 +00:00
zeripath
a4cd1f12f8
Ensure public repositories in private organizations are visible and fix admin organizations list (#11465)
* Ensure that we can see public repositories in private organization

Fix #10144 (Again)

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

* Fix Admin users and organizations page

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

* Update models/repo_list.go

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-18 00:27:54 +01:00
6543
9a829b98f0
Fix "Unknown task: git_fsck" error on admin dashboard (#11468) 2020-05-17 23:14:33 +01:00
Cirno the Strongest
7fd60c6d8d
Fix styling of resolved code comment box (#11463)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 23:43:04 +03:00
Cirno the Strongest
ef5f176517
Fix .comment-code-cloud not being removed when cancelling new code comment (#11464) 2020-05-17 23:36:34 +03:00
Cirno the Strongest
03b7e11bd6
Do not show lock icon on repo list for public repos in private org (#11445)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 19:59:25 +03:00
GiteaBot
fb43fbe0aa [skip ci] Updated translations via Crowdin 2020-05-17 15:36:19 +00:00
Cirno the Strongest
17f652a91c
Increase width for authors on commit view (#11441)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 18:35:07 +03:00
GiteaBot
580f73ad79 [skip ci] Updated translations via Crowdin 2020-05-17 14:16:15 +00:00
silverwind
97cabf39cd
Change tab width for .go files to 4 (#11455)
* Change tab width for .go files to 4

I thing 8-wide tabs are kind of archaic and inconsisten with template
files which already use 4-wide.

Also did some misc cleanups in the .editorconfig files.

* add css

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 17:14:36 +03:00
GiteaBot
4e302baa4c [skip ci] Updated translations via Crowdin 2020-05-17 12:44:33 +00:00
zeripath
76053ac31a
Whenever the ctx.Session is updated, release it to save it before sending the redirect (#11456)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 15:43:29 +03:00
GiteaBot
50932ce8af [skip ci] Updated translations via Crowdin 2020-05-17 11:11:07 +00:00
6543
7d9946f989
Docs: add AlpineLinux packages (#11446)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 14:09:56 +03:00
Lauris BH
75918d9dc6
Fix translation to be compatible with crowdin (#11453) 2020-05-17 12:18:59 +03:00
zeripath
c642cd0676
Allow all members of private orgs to see public repos (#11442)
* Allow all members of private orgs to see public repos

Fix #10144

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

* Update models/repo_list.go

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 16:22:17 +08:00
zeripath
a0d35fb6ad
Forcibly clean and destroy the session on logout (#11447)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-17 14:05:11 +08:00
GiteaBot
5cf224abe3 [skip ci] Updated translations via Crowdin 2020-05-17 00:49:40 +00:00
6543
84bcb3451a
Check Push permissions on IsUserAllowedToUpdate (#11448) 2020-05-16 20:48:30 -04:00
GiteaBot
dcb0cf7470 [skip ci] Updated translations via Crowdin 2020-05-16 23:33:25 +00:00
zeripath
9a2e47b23a
Refactor Cron and merge dashboard tasks (#10745)
* Refactor Cron and merge dashboard tasks

* Merge Cron and Dashboard tasks
* Make every cron task report a system notice on completion
* Refactor the creation of these tasks
* Ensure that execution counts of tasks is correct
* Allow cron tasks to be started from the cron page

* golangci-lint fixes

* Enforce that only one task with the same name can be registered

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

* fix name check

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

* as per @guillep2k

* as per @lafriks

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

* Add git.CommandContext variants

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-16 19:31:38 -04:00
zeripath
c18144086f
Hide archived repos by default in repo-list (#11440)
As discussed in #11268 hide archived repos by default in the
dashboard repo-list

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-17 01:12:03 +03:00
GiteaBot
aaaaeb7050 [skip ci] Updated translations via Crowdin 2020-05-16 21:07:43 +00:00
L0veSunshine
9cc9e47158
[UI] Adjust CSS details for adding emoticons (#11435)
* Adjust CSS details for added emoticons

* fix lint

* avoid git conflict
2020-05-17 00:06:34 +03:00
zeripath
414c9ee76a
Make API EditIssue and EditPullRequest issue notifications (#11123)
* Make API EditIssue and EditPullRequest issue notifications

Restructure models.UpdateIssueByAPI and EditIssue/EditPullRequest
to issue notifications

Fix #10014

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

* As per @6543

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

* update status!

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-17 00:05:19 +03:00
zeripath
c86bc8e061
Add paging and archive/private repository filtering to dashboard list (#11321)
* Add archived options to SearchRepository

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

* Add only-private search

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

* Add filter options and paging to dashboard repository page

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

* swagger generate

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

* fix-swagger-again

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

* as per @mrsdizzie also remember state

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-16 23:07:01 +03:00
guillep2k
c3d9a5f846
Use session for retrieving org teams (#11438)
Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
2020-05-16 20:29:29 +01:00
Cirno the Strongest
4744e1e0f7
Fix buttons left-margin (#11427)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-16 20:45:44 +03:00
mrsdizzie
b2b86ea870
Support view individual commit for wiki pages (#11415)
Currently you can see a list of commit history for wiki pages but aren't able to view the commit diff itself. This adds the feature to view an individual commit to a wiki repo.

Closes #8999

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-05-16 19:38:40 +03:00
Cirno the Strongest
6603045476
Better styling for code review comment textarea (#11428)
* Better styling for code review comment textarea

* align tabular menu with textarea

* border around active tab instead of textarea

* border radius

* use .28571429rem
2020-05-16 23:50:36 +08:00
zeripath
0052d788da
Allow log.xxx.default to set logging settings for the default logger only (#11292)
* Allow log.xxx.default to set logging settings for the default logger only

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

* Update modules/setting/log.go

* as per @silverwind add some documentation

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-15 22:38:52 -04:00
Cirno the Strongest
1d54479585
Fix margin on attached segment headers when they are separated by other element (#11425)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-15 21:35:22 -04:00
Cirno the Strongest
d833ca3be5
Fix yellow background on active elements in code review (#11414)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-15 20:55:19 -04:00
Cirno the Strongest
c483419184
Better styling for code review comment form (#11413)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-15 18:54:18 -04:00
zeripath
db87e91227 Check that the ctx.User is not nil before checking its ID (#11424)
Fix #11423

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-15 16:44:33 -04:00
silverwind
f7f04e94bd
Update JS dependencies (#11412)
A bugfix for JS syntax in highlight.js and some misc updates.
2020-05-15 20:46:49 +01:00
kolaente
c72a471215
Fix webhook template when validation errors occur (#11421)
Signed-off-by: kolaente <k@knt.li>
2020-05-15 22:02:46 +03:00
kolaente
57217cabe3
Fix issue ref migration (#11419)
The migration introduced in #8742 breaks mysql installations. This pr fixes that by correctly using CONCAT.

Signed-off-by: kolaente <k@knt.li>
2020-05-15 15:05:18 +01:00
zeripath
4a04740daf
Handle panics that percolate up to the graceful module (#11291)
* Handle panics in graceful goroutines

Adds a some deferred functions to handle panics in graceful goroutines

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

* Handle panic in webhook.Deliver

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

* Handle panic in mirror.syncMirror

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

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-14 20:06:00 -04:00
赵智超
4159866528
docs: update 'Testing redux' in CONTRIBUTING.md (#11386)
* docs: update 'Testing redux' in CONTRIBUTING.md

try simplfy it to make it more easy for contributor to follow it to
test their work by themselves.

Signed-off-by: a1012112796 <1012112796@qq.com>

* align help message strings

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-14 19:28:26 -04:00
Sijmen Schoon
66a9ef9036
Fix ref links in issue overviews for tags (#8742)
* Properly generate ref URLs

Tags used to not generate correct URLs (src/branch/tags/1.0.0 instead of
src/tags/1.0.0).

Also cleans up some code around it with the created helper functions.

* Fix formatting and create migration

* Add copyright head to utils_test

* Use a raw query for the ref migration

* Remove semicolon

* Quote column and table names in migration SQL

* Change || to CONCAT, since MSSQL does not support ||

* Make migration engine aware

* Add missing import

* Move ref EndName and URL to the issue service

* Fix tests

* Add test for commit refs

* Update issue.go

* Use the right command for building JavaScript bundles

* Prepare for merge

* Check for refs/* before prepending in migration

* Update services/issue/issue_test.go

* Update modules/git/utils_test.go

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-05-14 18:55:43 -04:00
GiteaBot
591ca030f0 [skip ci] Updated translations via Crowdin 2020-05-14 21:35:09 +00:00
John Olheiser
c8f0613741
Add localization docs (#11411)
* Add localization docs

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Clarify bleeding edge vs release

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Capitalize Crowdin

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-14 17:33:52 -04:00
Sorien
1982194dc5
Prettify timeline 3 (#11139)
* Fix timeline comments sections borders

* Fix files dropzone right alignment

* Update review comment form and controls

* Clear segment style from comment form tabs

* Remove segment class from pulls tab

* Fix Time Tracker - Add Time button border

* Fix buttons right alignment

* Markdown tab minimal height

* Fix DropZone hover effect

* Fix Lint + remove unused controls class

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-05-14 15:15:21 -04:00
GiteaBot
a552af8f0d [skip ci] Updated translations via Crowdin 2020-05-14 18:00:33 +00:00
Cirno the Strongest
5df72ef7e7
Fix svg octicon-key placement (#11410) 2020-05-14 18:59:18 +01:00
silverwind
9249c810b8
Switch code editor to Monaco (#11366)
* Switch code editor to Monaco

This switches out CodeMirror for Monaco which is based on the same code
base as VS code and should work pretty similar to it.

It does add a few async chunks, totalling around 10MB to our build. It
currently supports around 65 languages and in the default configuration,
each language would emit one ugly [number].js chunk, so I opted to
combine them all into a single file for now.

CodeMirror is still being used under the hood by SimpleMDE so it can not
be removed yet.

* inline editorconfig, fix diff, use for markdown, remove more dead code

* refactors, remove jquery usage

* use tab_width

* fix intellisense

* rename function for clarity

* misc tweaks, enable webpack progress display

* only use --progress on dev build

* remove useless borders in arc-green

* fix typo

* remove obsolete comment

* small refactor

* fix file creation and various refactors

* unset useTabStops too when no editorconfig

* small refactor

* disable webpack's [big] warnings

* remove useless await

* fix dark theme check

* rename chunk to 'monaco'

* add to .gitignore and delete webpack dest before build

* increase editor height

* support more editorconfig properties

* remove empty element filter

* rename

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-05-14 19:06:01 +03:00
GiteaBot
984ee0113b [skip ci] Updated translations via Crowdin 2020-05-13 23:00:00 +00:00
John Olheiser
41be230867
Add awesome-gitea reference on install from package docs (#11405)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-05-14 01:58:49 +03:00
John Olheiser
0ba610011b
Change install description (#11395)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-13 12:08:44 +03:00
GiteaBot
2f9e6cae48 [skip ci] Updated translations via Crowdin 2020-05-13 07:52:13 +00:00
zeripath
8d212f778c
Revert "Avoid 0 new commits messages to be send (#11082)" (#11397)
This reverts commit 6034f8bcaa.
2020-05-13 10:50:56 +03:00
Cirno the Strongest
e9dc3bcb79
Add missing card component to semantic.json (#11394)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-13 09:43:06 +08:00
6543
7257c39ddf
Refactor Milestone related (#11225) 2020-05-12 22:54:35 +01:00
zeripath
ba40263fdd
Unfortunately go template if does not shortcut (#11392)
Go template's `{{if ...}}` does not shortcut its tests therefore it is
possible to cause a NPE unless you separate ifs into two.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-12 17:01:27 -04:00
zeripath
aa29f1c2b9
Ensure search action button coalesced to adjacent input (#11385)
Fomantic-ui's action button syntax requires that the button is
the next sibling of the input it is attached to and that they
are both children of a div.action.

Fix #11375

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-12 15:08:43 -04:00
赵智超
b00e62c12b
ui: Replenish the missing ‘PageIsSignUp’ in sign up view (#11390)
Signed-off-by: a1012112796 <1012112796@qq.com>
2020-05-12 19:01:15 +01:00
techknowlogick
08611fb765
Update docs to reflect new location of homebrew repo (#11384)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2020-05-12 20:51:41 +08:00
zeripath
0198bbedc1
Allow compare page to look up base, head, own-fork, forkbase-of-head (#11327)
* Allow compare page to look up base, head, own-fork, forkbase-of-head

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

* as per @guillep2k

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

* Update routers/repo/compare.go

* as per @guillep2k

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

* Rationalise the names a little

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

* Rationalise the names a little (2)

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

* Fix 500 with fork of fork

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

* Prevent 500 on compare different trees

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

* dotdotdot is perfectly valid in both usernames and repo names

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

* ensure we can set the head and base repos too

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

* ensure we can set the head and base repos too (2)

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

* fix lint

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

* only set headRepo == baseRepo if isSameRepo

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-12 08:52:46 +03:00
Cirno the Strongest
a4c7ad99e5
Fix usage of removed jqXHR.success (#11379)
Introduced by b57a735 via removal of jQuery-Migrate.

This PR changes usage of .success on jqXHR to .done.

Fixes #11228 and few other places, such as removal of code comments.
2020-05-12 04:34:48 +01:00
GiteaBot
6a02a4f57a [skip ci] Updated translations via Crowdin 2020-05-11 22:05:16 +00:00
zeripath
c42c31a111
Correctly set the organization num repos (#11339)
* Correctly set the organization num repos

Correctly set the organization num repos to the number of
accessible repos for the user

Fix #11194

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

* as per @lunny

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

* attempt to fix mssql

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

* Update models/user.go

* Explicit columns

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

* Add test and fix 0 counted orgs

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

* remove orgname from api

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-12 01:04:08 +03:00
GiteaBot
45968b9f44 [skip ci] Updated translations via Crowdin 2020-05-11 09:45:39 +00:00
Cirno the Strongest
32b8172e56
Consolidate API for getting single commit (#11368)
* Allow Git ref for /repos/{owner}/{repo}/git/commits/{sha}

* Consolidate API for getting single commit

* Fix tests and do it differently

Co-authored-by: zeripath <art27@cantab.net>
2020-05-11 12:44:36 +03:00
GiteaBot
59b9b77a0d [skip ci] Updated translations via Crowdin 2020-05-11 08:39:13 +00:00
burbon
d8e6acda8c
Support Range header end in lfs (#11314)
* Initial support of end Range header option in lfs

* Allow end range option to be unspecified

* Declare toByte for consistency

* Factor out content encoding tests from doLfs

This is so Range tests could still use doLfs but without repeating
not related tests

* Add Range header test

* implemented extraHeader
* parametrized expectedStatus

* Add more test cases of Range header

* Fix S1030: should use resp.Body.String()

* Add more tests for edge cases

* Fix tests

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

Co-authored-by: zeripath <art27@cantab.net>
2020-05-11 11:37:59 +03:00
zeripath
742e26f5a5
Prevent 500 with badly formed task list (#11328)
Fix #11317

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-11 00:14:49 +01:00
Cirno the Strongest
c9187b8116
Add gnupg to Dockerfile (#11365)
Co-authored-by: zeripath <art27@cantab.net>
2020-05-10 23:41:34 +03:00
6543
6e23a1b843
[Vendor] mssqldb: 2019-11-28 -> 2020-04-28 (#11364)
update go-mssqldb 2019-11-28 (1d7a30a10f73) -> 2020-04-28 (06a60b6afbbc)
2020-05-10 18:42:52 +01:00
Leo
da5e3fa299
Changed image of openid-connect logo for better look on arc-green theme (#11312)
* Set background of openIDConnect logo to white in arc-green theme

* Fixed linting off arc-green theme

Signed-off-by: Leo Maroni <git@em0lar.de>

* Revert changes of first commit (white background) and replaced the image

* Updated openid_connect (part 2)

* Update public/img/auth/openid_connect.svg

Now in one line

Co-authored-by: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-10 17:55:22 +03:00
zeripath
f8e015e8e4
Move LFS directory creation out of NewContext (#11362)
Fix #9481
(probably others too)

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-10 16:30:46 +03:00
6543
43bb85908d
Update github.com/pquerna/otp from untagged to v1.2.0 (#11358) 2020-05-10 15:50:16 +03:00
6543
57b6f83191
Update github.com/issue9/identicon from untagged to v1.0.1 (#11359)
Co-authored-by: zeripath <art27@cantab.net>
2020-05-10 06:23:17 -04:00
6543
dbb74978f7
github.com/yohcop/openid-go update to first tagged version (#11357) 2020-05-10 09:53:04 +01:00
6543
fdf750e4d4
[Vendor] blevesearch v0.8.1 -> v1.0.7 (#11360)
* Update blevesearch v0.8.1 -> v1.0.7

* make vendor

Co-authored-by: zeripath <art27@cantab.net>
2020-05-10 06:40:54 +01:00
silverwind
a44854c287
Few tweaks in the hacking guide (#11345)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-09 18:11:30 -04:00
6543
18f4aaee64
Frontport Changelog for v1.11.5 (#11356)
* Changelog v1.11.5 (#11329)

* Changelog v1.11.5

* Apply suggestions from code review

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Update Changelog for 1.11.5 (#11347)

* Update Changelog for 1.11.5

* bumb version in docs

* Update CHANGELOG.md

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-09 16:24:46 -04:00
6543
cd4f7ba5bf
Fix tracked time issues (#11349)
* Fix nil exeption: #11313

* fix 500

* activate test 😆

* move logic
2020-05-09 11:18:44 -03:00
Alan Pope
b9df5da1f4
Limit snap build architectures (#11346)
Builds will fail on s390x, i386 and ppc64el because we depend on nodejs, which is only published for armhf, arm64 and amd64. This change merely tells the snap build farm to not waste time trying to build on architectures will will guarantee failure. Apologies for overlooking this in our previous PR.

Example build failures can be seen at [i386](https://launchpad.net/~build.snapcraft.io/+snap/53d5570c233b8b3663242f8d94dc21ad/+build/945935), [ppc64el](https://launchpad.net/~build.snapcraft.io/+snap/53d5570c233b8b3663242f8d94dc21ad/+build/945939), [s390x](https://launchpad.net/~build.snapcraft.io/+snap/53d5570c233b8b3663242f8d94dc21ad/+build/945940)
2020-05-09 12:39:19 +08:00
Sergio Schvezov
b09ec508c3
update snapcraft.yaml for core18 and latest features (#11300)
Removing some of the complexity, together with the install and
configure hook.

Signed-off-by: Sergio Schvezov <sergio.schvezov@canonical.com>
2020-05-08 21:21:28 +01:00
赵智超
119173130a
Add default CommitID for create pull review api (#11334)
If user create pull review through api but not set CommitID,
I think it's necessary to use last headCommitID as default seting,
or this review will be considered as stale review which is wrong

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-05-08 19:50:23 +01:00
zeripath
c58bc4bf80
Prevent timer leaks in Workerpool and others (#11333)
There is a potential memory leak in `Workerpool` due to the intricacies of
`time.Timer` stopping.

Whenever a `time.Timer` is `Stop`ped its channel must be cleared using a
`select` if the result of the `Stop()` is `false`.

Unfortunately in `Workerpool` these were checked the wrong way round.

However, there were a few other places that were not being checked.

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-05-08 16:46:05 +01:00
zeripath
6f6edb8fab
Add NotifySyncPushCommits to indexer notifier (#11309)
Thanks to @simon-on-gh for tracking down the issue.

Fix #11200

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-08 15:58:40 +01:00
L0veSunshine
866ce126ec
Split some words from template to improve translation. (#11221)
* split some words from template

* split some words from template

* add " " to mustache expression

* split some words from template

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-05-08 13:39:17 +01:00
zeripath
791353c03b
Add EventSource support (#11235)
If the browser supports EventSource switch to use this instead of
polling notifications.

Signed-off-by: Andrew Thornton art27@cantab.net
2020-05-07 22:49:00 +01:00
6543
486e4c8087
When deleting a tracked time through the API return 404 not 500 (#11319) 2020-05-07 18:54:33 +01:00
zeripath
71e73db2ff
Manage port in submodule refurl (#11305)
* Manage port in submodule refurl

Fix #11304

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

* fix lint

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

* URLJoin is causes a cyclic dependency and possibly isn't what what we want anyway

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

* Protect against leading .. in scp syntax

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-07 11:25:52 -03:00
6543
507d0ec57a
Prevent multiple listings of organization when creating a repository (#11303)
prevent double entries in results of GetOrgsCanCreateRepoByUserID

I first try to only add GroupBy directly but xorm return broken user objects ...

... solution was to just query related UserIDs(OrgIDs) first and return OrgUsers based on this IDs

close #11258

Co-authored-by: zeripath <art27@cantab.net>
2020-05-07 14:24:59 +01:00
GiteaBot
a6b8de282c [skip ci] Updated translations via Crowdin 2020-05-07 06:48:52 +00:00
opyale
b16534b0e4
Adding advanced label set. (#11298)
Add an advanced label set to contrib
2020-05-07 07:47:34 +01:00
6543
505e456f26
Protect default branch against deletion (#11115)
Although default branch is not offered for deletion in the templates, we need to prevent it both at the router level and in the pre-receive hook.

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-06 12:08:45 +01:00
6543
a1f11a05e9
Load Repo Topics on blame view (#11307)
Fix #11280
2020-05-05 22:51:49 +01:00
zeripath
d9de58beee
api.Context.NotFound(...) should tolerate nil (#11288)
There is an unfortunate signature change with the api.Context
NotFound function; whereas the normal modules/context/Context
NotFound function requires an error or nil, the api.Context
variant will panic with an NPE if a nil is provided.

This PR will allow api.Context.NotFound to tolerate a being
passed a nil.

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-05 21:52:13 +03:00
赵智超
0396fcf4b5
Change the style in admin notice content view from <p> to <pre> (#11301)
That's because many notic have more than one lines. So I think
pre is more better to used in here than p

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-05-05 10:16:55 -05:00
silverwind
a104864da2
Update JS dependencies (#11297)
Contains an apparently important bug fix for highlight.js [1],
otherwise nothing of interest.

[1] https://github.com/highlightjs/highlight.js/releases/tag/10.0.2

Co-authored-by: zeripath <art27@cantab.net>
2020-05-05 00:48:52 -03:00
Kyle Evans
38cd9ba47b
Allow unauthenticated users to compare (#11240)
* routers: make /compare route available to unauthenticated users

Remove some bits of the compare interface if the user isn't signed in.
Notably, they don't need to see the "New Pull Request" button box nor the
hidden form that would fail to submit due to the POST request continuing to
require proper privileges.

Follow-up commits will improve the UI a bit around this, removing some
"Pull Request" verbiage in favor of "Compare."

* ui: home: show "compare" button for unauthenticated users

This change requires pulling in the BaseRepo unconditionally and
recording if the pull request is in-fact not allowed
(.PullRequestCtx.Allowed). If the user isn't allowed to create a pull
request, either because this isn't a fork or same-fork branch PRs aren't
allowed, then we'll name the button "Compare" instead of "Pull Request."

* ui: branch list: use the new Compare language when available

When viewing the branch listing as an unauthenticated user, you'll get
"Pull Request" buttons. use the new "Compare" verbiage instead, which
matches GitHub behavior when you can't issue a pull request from the
branches.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-05-04 19:44:30 -03:00
zeripath
680dfab2ee
Fix Create new branch (#11294)
Fix #11212

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-04 16:55:52 -04:00
Adrian POIGET
99082eebd7
Fix; declare DOMAIN variable for docker setup (#10780)
In the /install form, the value for SSH Server Domain is taken form the DOMAIN variable
and overwrites SSH_DOMAIN environment variable set the first time if nothing done

Co-authored-by: Adrian POIGET <adrian.poiget@viveris.fr>
2020-05-04 10:50:29 +01:00
guillep2k
64029e1468
Update lunny/levelqueue to 0.3.0 (#11285)
Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
2020-05-04 07:51:09 +01:00
Cirno the Strongest
b7c82cd1a9
Fix orgs not being displayed on create repo form (#11279) 2020-05-03 18:08:24 -03:00
zeripath
ce66ca7f9f
Restore checkbox rendering and prevent poor sanitization of spans (#11277)
* Add test

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

* Restore checkbox rendering and prevent poor sanitization of spans

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

* Also fix preview context

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

* Also fix preview context

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-03 17:17:24 -03:00
Kyle Evans
940ed92392
repo: milestone: make /milestone/:id endpoint accessible (#11264)
Previously, this required authentication, but there's not actually
any privileged information on this page.  Move the endpoint out of
the group that requires sign-in.  It still requires the ability to
read issues and pull requests, so private repositories (for instance)
will not be exposed.

Fixes #10312 
Fixes #11233
2020-05-03 10:07:04 +01:00
GiteaBot
472a7702a7 [skip ci] Updated translations via Crowdin 2020-05-03 03:59:30 +00:00
Kyle Evans
a5018d099d
cmd: dump: check value of skip-repository flag (#11254)
This is a boolean flag; simply checking if it's set isn't enough, we must check the value as well.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-05-03 00:57:45 -03:00
zeripath
4f9d59be17
Sendmail should create a process on the gitea system and have a default timeout (#11256)
* Make sure that sendmail processes register with the process manager
* Provide a timeout for these (initially of 5 minutes)
* Add configurable value and tie in to documentation
* Tie in to the admin config page.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-05-03 00:04:31 +01:00
GiteaBot
319eb83112 [skip ci] Updated translations via Crowdin 2020-05-02 14:05:12 +00:00
Lunny Xiao
71e4c75a61
Fix bug about comment attachment (#11272) 2020-05-02 15:03:47 +01:00
zeripath
28f8308d47
Show pull request selection even when unrelated branches (#11239)
Fix #10525

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

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-05-02 16:06:01 +08:00
GiteaBot
452b69b71e [skip ci] Updated translations via Crowdin 2020-05-02 00:22:11 +00:00
6543
c97494a4f4
API: Add pull review endpoints (#11224)
* API: Added pull review read only endpoints

* Update Structs, move Conversion, Refactor

* refactor

* lint & co

* fix lint + refactor

* add new Review state, rm unessesary, refacotr loadAttributes, convert patch to diff

* add DeletePullReview

* add paggination

* draft1: Create & submit review

* fix lint

* fix lint

* impruve test

* DONT use GhostUser for loadReviewer

* expose comments_count of a PullReview

* infent GetCodeCommentsCount()

* fixes

* fix+impruve

* some nits

* Handle Ghosts 👻

* add TEST for GET apis

* complete TESTS

* add HTMLURL to PullReview responce

* code format as per @lafriks

* update swagger definition

* Update routers/api/v1/repo/pull_review.go

Co-authored-by: David Svantesson <davidsvantesson@gmail.com>

* add comments

Co-authored-by: Thomas Berger <loki@lokis-chaos.de>
Co-authored-by: David Svantesson <davidsvantesson@gmail.com>
2020-05-02 03:20:51 +03:00
mrsdizzie
4ed7d2a2bb
Remove last traces of has-emoji class (#11263)
Now that emojify.js has been removed, get rid of all instances of has-emoji class that was only used for that. Support for rendering shortcodes should remain in all of these places so it should still work the same.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-05-01 20:58:45 +03:00
Kyle Evans
1bdffefc05
cmd: dump: add an -L/--skip-log option (#11253)
Not all dumps need to include the logs, in a similar vain to not all dumps
needing to include repositories; these may be subject to different backup
mechanisms/constraints. Add a simple option to let them be excluded from the
dump to simplify workflows that need to exclude them or not collect in the
first place.

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: zeripath <art27@cantab.net>
2020-04-30 21:30:31 -04:00
6543
e9e8638f18
Return issue subscription status from API subscribe (#10966)
* [API] issue subscription indicate by http status

* CI.restart()
2020-04-30 23:55:24 +01:00
zeripath
4974b7c120
Fix spelling mistake with Rewiew (#11262)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-30 21:24:08 +01:00
6543
ab69b9b1a6
Refactor UpdateOAuth2Application (#11034)
Following on from #11008 refactor UpdateOAuth2Application
2020-04-30 18:50:47 +01:00
GiteaBot
c25969e694 [skip ci] Updated translations via Crowdin 2020-04-30 15:14:00 +00:00
Andrew Bezold
3dc6af3d70
Fix creation of Organization repos by Users with max created personal repos (#11183)
* Fix creation of Org repos

Fix go-gitea#9269

* Change variable name to appease linter

* Update PR with suggestions

Add a note for user.CanCreateRepo() about failure assumptions
Change repo.create help message

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-30 16:11:56 +01:00
silverwind
28e5e7fcbc
Add a 'this' to issue close/reopened messages (#11204)
* add a 'this' to issue close/reopened messages

* add 'this issue/pull request' and create new localization entries

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-30 14:49:12 +01:00
Jason Duan
4468b0b2b2
When using API CreateRelease set created_unix to the tag commit time (#11218) 2020-04-30 14:10:42 +01:00
Km
d0e7361bd9
Propose an explanation how to restart gracefully gitea after an update (#10866)
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-30 15:14:27 +03:00
silverwind
606d9d63f6
Update JS dependencies, min Node.js version 10.13 (#11246)
`less-loader` now dictates a minimum Node.js version of 10.13.0,
released 2018-10-30 so I've updated this requirement to match.

https://github.com/webpack-contrib/less-loader/releases/tag/v6.0.0
2020-04-30 11:37:01 +01:00
zeripath
1853131d42
Use keys.openpgp.org instead of pgp.mit.edu (#11249)
The SKS Keyserver network has been under attack with poisoned
certificates since at least 2019. Downloading a poisoned certificate has
the awful side-effect of completely breaking your keyring and most
software has now moved off the network and uses the keys.openpgp.org
which has a different protocol instead - in fact one whereby emails are
verified.

For more details regarding the attack see: https://gist.github.com/rjhansen/67ab921ffb4084c865b3618d6955275f

See: https://keys.openpgp.org/about and https://keys.openpgp.org/about/faq

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

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-30 12:08:43 +03:00
mrsdizzie
a2683e5ddb
Allow emoji short code in labels (#11250)
* Allow emoji short code in labels

As title, turn :alias: type short code into emojis when rendering labels to match previous behavior

* Update models/issue_label.go

Co-Authored-By: John Olheiser <john.olheiser@gmail.com>

* render text in templates not code

* remove has-emoji class

🧙‍♀️

* fix new issue form

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-30 09:10:15 +01:00
silverwind
310699bca7
Patch fomantic-ui to workaround build issue (#11244)
* Patch fomantic-ui to workaround build issue

Better workaround than https://github.com/go-gitea/gitea/issues/10653
for https://github.com/fomantic/Fomantic-UI/issues/1356. It does not
seem like we're getting a new Fomantic-UI release anytime soon, so
this patches it after node_modules installation.

Fixes: https://github.com/go-gitea/gitea/issues/11243
Fixes: https://github.com/go-gitea/gitea/issues/10679

* copy instead of patch

* update package-lock.json

* Update Makefile

Co-Authored-By: Sorien <Sorien@users.noreply.github.com>

* Update web_src/fomantic/css.js

Co-Authored-By: zeripath <art27@cantab.net>

Co-authored-by: Sorien <Sorien@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-30 07:26:37 +01:00
6543
bfda0f3864
[API] ListIssues add filter for milestones (#10148)
* Refactor Issue Filter Func

* ListIssues add filter for milestones

* as per @lafriks

* documentation ...
2020-04-30 01:15:39 -03:00
zeripath
cbf5dffaf2
Fix submit review form (#11252)
* Fix submit review form

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

* placate lint

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

* try something different

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

* Update web_src/less/_base.less

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-30 09:59:47 +08:00
n0emis
33738ff91b
Don't allow registration via the web form, when AllowOnlyExternalRegistration is True (#11248)
* Don't allow registration via the web form, when AllowOnlyExternalRegistration is True

* Show Disabled Registration message if DisableRegistration or AllowOnlyExternalRegistration options are true
2020-04-29 22:46:43 +01:00
Alexander Scheel
1bf9e44bda
Fix sanitizer config - multiple rules (#11133)
In #9888, it was reported that my earlier pull request #9075 didn't quite function as expected. I was quite hopeful the `ValuesWithShadow()` worked as expected (and, I thought my testing showed it did) but I guess not. @zeripath proposed an alternative syntax which I like:

```ini
[markup.sanitizer.1]
ELEMENT=a
ALLOW_ATTR=target
REGEXP=something
[markup.sanitizer.2]
ELEMENT=a
ALLOW_ATTR=target
REGEXP=something
```

This was quite easy to adopt into the existing code. I've done so in a semi-backwards-compatible manner:

 - The value from `.Value()` is used for each element.
 - We parse `[markup.sanitizer]` and all `[markup.sanitizer.*]` sections and add them as rules.

This means that existing configs will load one rule (not all rules). It also means people can use string identifiers (`[markup.sanitiser.KaTeX]`) if they prefer, instead of numbered ones.

Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-29 12:34:59 +01:00
6543
6b6f20b6d4
BugFix: updateLabel can updated not allowed fields #11242 (#11242) 2020-04-28 19:28:56 -04:00
mrsdizzie
4563eb873d
Support unicode emojis and remove emojify.js (#11032)
* Support unicode emojis and remove emojify.js

This PR replaces all use of emojify.js and adds unicode emoji support to various areas of gitea.

This works in a few ways:

First it adds emoji parsing support into gitea itself. This allows us to

 * Render emojis from valid alias (😄)
 * Detect unicode emojis and let us put them in their own class with proper aria-labels and styling
 * Easily allow for custom "emoji"
 * Support all emoji rendering and features without javascript
 * Uses plain unicode and lets the system render in appropriate emoji font
 * Doesn't leave us relying on external sources for updates/fixes/features

That same list of emoji is also used to create a json file which replaces the part of emojify.js that populates the emoji search tribute. This file is about 35KB with GZIP turned on and I've set it to load after the page renders to not hinder page load time (and this removes loading emojify.js also)

For custom "emoji" it uses a pretty simple scheme of just looking for /emojis/img/name.png where name is something a user has put in the "allowed reactions" setting we already have. The gitea reaction that was previously hard coded into a forked copy of emojify.js is included and works as a custom reaction under this method.

The emoji data sourced here is from https://github.com/github/gemoji which is the gem library Github uses for their emoji rendering (and a data source for other sites). So we should be able to easily render any emoji and :alias: that Github can, removing any errors from migrated content. They also update it as well, so we can sync when there are new unicode emoji lists released.

I've included a slimmed down and slightly modified forked copy of https://github.com/knq/emoji to make up our own emoji module. The code is pretty straight forward and again allows us to have a lot of flexibility in what happens.

I had seen a few comments about performance in some of the other threads if we render this ourselves, but there doesn't seem to be any issue here. In a test it can parse, convert, and render 1,000 emojis inside of a large markdown table in about 100ms on my laptop (which is many more emojis than will ever be in any normal issue). This also prevents any flickering and other weirdness from using javascript to render some things while using go for others.

Not included here are image fall back URLS. I don't really think they are necessary for anything new being written in 2020. However, managing the emoji ourselves would allow us to add these as a feature later on if it seems necessary.

Fixes: https://github.com/go-gitea/gitea/issues/9182
Fixes: https://github.com/go-gitea/gitea/issues/8974
Fixes: https://github.com/go-gitea/gitea/issues/8953
Fixes: https://github.com/go-gitea/gitea/issues/6628
Fixes: https://github.com/go-gitea/gitea/issues/5130

* add new shared function emojiHTML

* don't increase emoji size in issue title

* Update templates/repo/issue/view_content/add_reaction.tmpl

Co-Authored-By: 6543 <6543@obermui.de>

* Support for emoji rendering in various templates

* Render code and review comments as they should be

* Better way to handle mail subjects

* insert unicode from tribute selection

* Add template helper for plain text when needed

* Use existing replace function I forgot about

* Don't include emoji greater than Unicode Version 12

Only include emoji and aliases in JSON

* Update build/generate-emoji.go

* Tweak regex slightly to really match everything including random invisible characters. Run tests for every emoji we have

* final updates

* code review

* code review

* hard code gitea custom emoji to match previous behavior

* Update .eslintrc

Co-Authored-By: silverwind <me@silverwind.io>

* disable preempt

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-28 15:05:39 -03:00
mrsdizzie
922a239079
Disable new signal-based asynchronous goroutine preemption from GO 1.14 in git env (#11237)
As seen in trouble shooting #11032 the new feature of Go 1.14 is causing several second delays in startup in certain situations. Debugging shows it spending several seconds handling SIGURG commands during init:

```
6922:04:51.984234 trace init() ./modules/queue/unique_queue_wrapped.go
remote: ) = 69 <0.000012>
remote: [pid 15984] 22:04:51 write(1, "\ttime taken: 236.761\302\265s\n\n", 25    time taken: 236.761µs
remote:
remote: ) = 25 <0.000011>
remote: [pid 15984] 22:04:51 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=15984, si_uid=0} ---
remote: [pid 15984] 22:04:52 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=15984, si_uid=0} ---
remote: [pid 15984] 22:04:52 --- SIGURG {si_signo=SIGURG, si_code=SI_TKILL, si_pid=15984, si_uid=0} ---
```

This causes up to 20 seconds added to a push in some cases as it happens for each call of the gitea hook command. This is likely the cause of #10661 as well and would start to effect users once we release 1.12 which would be the first release compiled with Go 1.14. I suspect this is just a slight issue with the upstream implementatation as there have been a few very similar bugs fixed and reported:

 https://github.com/golang/go/issues/37741
 https://github.com/golang/go/issues/37942

We should revisit this in the future and see if a newer version of Go has solved it, but for now disable this option in the environment that gitea hook runs in to avoid it.
2020-04-28 11:45:32 -04:00
zeripath
1f0b797ddc
Make the PushCreate test declarative (#11229)
Reduce the code duplication in the PushCreate test and switch
to a declarative format.

* Instead of explicitly creating the repository re-use functions from the other declarative tests and add comments
* Ensure that the test repository is deleted at the end of test
* Slightly reorder the sub-tests

Also reduce the code duplication in MergeFork and add some comments there too and make doGitCloneFail be self-contained.

Signed-off-by: Andrew Thornton art27@cantab.net
2020-04-28 09:32:23 +01:00
GiteaBot
b0849abf3d [skip ci] Updated translations via Crowdin 2020-04-27 23:43:08 +00:00
Bagas Sanjaya
b52ec4a19e
[Docs] Config Cheat Sheet - Task Edit (#9972)
* backwards compatibility typo

* Unlist description and separate from list by an empty line

* redis needs password edit

* Update docs/content/doc/advanced/config-cheat-sheet.en-us.md

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-04-27 19:41:59 -04:00
6543
41cebeb8fa
Make error pages translatable (#11163)
* make error pages translatable

* dont translate ":"

* link need Safe
2020-04-27 18:03:15 -05:00
GiteaBot
6a3de9e25f [skip ci] Updated translations via Crowdin 2020-04-27 11:21:30 +00:00
zeripath
d26aee3830
Slight performance changes to integrations/git_test.go (#11227)
* switch to use pseudorandom generator and stop cloning in pushcreate

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

* Add some logging of BranchProtectPRMerge

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

* Stop running prepareTestEnv so often for TestAPIGetBranch

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-27 14:20:09 +03:00
zeripath
0e799c26ba
Prevent panic during wrappedConn close at hammertime (#11219)
* Prevent panic during wrappedConn close at hammertime

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

* Update modules/graceful/server.go

* Fix extraneous debug in goldmark.go

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-26 21:01:06 -03:00
zeripath
9f959ac064
Make TaskCheckBox render correctly (#11214)
* Fix checkbox rendering

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

* Normalize checkbox rendering

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

* set the checkboxes to readonly instead of disabled

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-26 02:09:08 -03:00
colorfulberry
f1f56da4d1
On logout redirect to start page and clear redirect cookie (#11202)
when one user logout should clear redirect to value, otherwise switch the account will occur error.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-25 23:11:32 +01:00
silverwind
e008b68c9c
Update JS dependencies, highlight.js 10.0.0 (#11195)
Breaking changes in higlight.js do not affect us.

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-24 21:13:01 +02:00
6543
4ddfe0d07a
Fix GetContents(): Dont't ignore Executables (#11192)
* Refactor: dont expose help functions

* repofiles GetContents: dont ignore executables

* CI.restart()
2020-04-24 19:20:22 +03:00
zeripath
812cfd0ad9
Use markdown frontmatter to provide Table of contents, language and frontmatter rendering (#11047)
* Add control for the rendering of the frontmatter
* Add control to include a TOC
* Add control to set language - allows control of ToC header and CJK glyph choice.

Signed-off-by: Andrew Thornton art27@cantab.net
2020-04-24 14:22:36 +01:00
赵智超
d3fc9c08c8
[ui] Change icon type for review action in action page (#11191)
* as title, do same changs on action view with #10737
* chage default icon from "invalid type" to "question" , because  "invalid type" is not a meaningfull icon type

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-04-24 01:58:14 -03:00
zeripath
b10c416f9e
Use AJAX for notifications table (#10961)
* Use AJAX for notifications table

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

* move to separate js

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

* placate golangci-lint

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

* Add autoupdating notification count

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

* Fix wipeall

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

* placate tests

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

* Try hidden

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

* Try hide and hidden

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

* More auto-update improvements

Only run checker on pages that have a count
Change starting checker to 10s with a back-off to 60s if there is no change

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

* string comparison!

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

* as per @silverwind

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

* add configurability as per @6543

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

* Add documentation as per @6543

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

* Use CSRF header not query

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

* Further JS improvements

Fix @etzelia update notification table request
Fix @silverwind comments

Co-Authored-By: silverwind <me@silverwind.io>
Signed-off-by: Andrew Thornton <art27@cantab.net>

* Simplify the notification count fns

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

Co-authored-by: silverwind <me@silverwind.io>
2020-04-24 00:57:38 -03:00
zeripath
e74c4e1be9
Add option to increase provided OAuth2 token maximum size (#11180)
Some OAuth2 providers return quite large structured tokens >32767 bytes.
Gitea currently has a fixed maximum of 32767 bytes for these and
unfortunately due to the convoluted nature of the dependent libraries the
error returned is rather opaque.

Here we manage the error a little better - detecting the rather opaque
github.com/gorilla/securecookie.errEncodedValueTooLong and converting
it to a more readable error.

Further we provide a configurable option to increase the maximum size of
the provided OAuth2 tokens.

Fix #9907

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

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-23 00:47:23 +02:00
zeripath
b51fd30522
Log the indexer path on failure (#11172)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-22 16:16:58 -04:00
Antoine GIRARD
316db0fe79
Add documentation to display STL preview (#11181)
* Update customizing-gitea.en-us.md

* Update customizing-gitea.en-us.md

* only load assets when needed

* remove useless var

* fix missing 'i' modifier
2020-04-22 20:02:54 +03:00
Lunny Xiao
fcc8cdd446
Improve config logging when WrappedQueue times out (#11174)
Before
```sh
Unable to set the internal queue for -wrapper Error: Timedout creating queue redis with cfg []byte{0x7b, 0x22, 0x41, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x65, 0x73, 0x22, 0x3a, 0x22, 0x31, 0x32, 0x37, 0x2e, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x3a, 0x36, 0x33, 0x37, 0x39, 0x22, 0x2c, 0x22, 0x42, 0x61, 0x74, 0x63, 0x68, 0x4c, 0x65, 0x6e, 0x67, 0x74, 0x68, 0x22, 0x3a, 0x32, 0x30, 0x2c, 0x22, 0x42, 0x6c, 0x6f, 0x63, 0x6b, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x3a, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x2c, 0x22, 0x42, 0x6f, 0x6f, 0x73, 0x74, 0x54, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x3a, 0x33, 0x30, 0x30, 0x30, 0x30, 0x30
......
```

After
```sh
Unable to set the internal queue for -wrapper Error: Timedout creating queue redis with cfg "{\"Addresses\":\"127.0.0.1:6379\",\"BatchLength\":20,\"BlockTimeout\":1000000000,\"BoostTimeout\":300000000000,\"BoostWorkers\":5,\"DBIndex\":0,\"DataDir\":\".../data/queues/mail\",\"MaxWorkers\":10,\"Name\":\"mail\",\"Network\":\"\",\"Password\":\"\",\"QueueLength\":20,\"QueueName\":\"mail_queue\",\"SetName\":\"\",\"Workers\":1}" in
```
2020-04-22 13:38:40 +01:00
GiteaBot
c0d71f5e26 [skip ci] Updated translations via Crowdin 2020-04-22 10:36:05 +00:00
zeripath
4ee70a9ec9
Fix submodule paths when AppSubUrl is not root (#11098)
Fix submodule paths when AppSubUrl is not root

Fix #11002

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-22 11:34:50 +01:00
silverwind
7e20f1cb5b
enable ENABLE_HARD_LINE_BREAK by default (#11162)
enable ENABLE_HARD_LINE_BREAK by default

This matches GitHub's rendering.

Fix #11155
2020-04-21 23:13:56 +01:00
6543
49f8b20570
make pagination optional for notifications (#10714) 2020-04-21 22:21:46 +01:00
Johan Van de Wauw
dfca884b15
doc: Fix package name in external renderer example (#11170)
The py3-zmq package does not exist in alpine linux 3.11, used in both master and 1.11.4 . The py3-pyzmq package exists however:
https://pkgs.alpinelinux.org/packages?name=py3-pyzmq&branch=v3.11
2020-04-21 16:36:27 -04:00
Shashvat Kedia
74cc3c5e18
Allow list collaborators for users with Read access to repo (#9995)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-21 11:22:04 -04:00
6543
bb4261a5ed
Add issue subscription check to API (#10967)
close #10962

Adds `GET /api/v1​/repos​/{owner}​/{repo}​/issues​/{index}​/subscriptions​/check`
 -> return a `WachInfo`
2020-04-21 14:48:53 +01:00
Matthias Schoettle
33176e8d27
Improve representation of attachments in issues (#11141)
* Improves representation of attachments in issues to a list showing the file name and file size (see #6500 and #6089).

Signed-off-by: Matthias Schoettle <git@mattsch.com>

* Fixes indentation.

Co-authored-by: zeripath <art27@cantab.net>
2020-04-21 01:15:41 -03:00
silverwind
50475fff06
Skip frontend build where unnecessary (#11159)
The testing pipelines and build-backend steps do not depend on
frontend files, skip their build for them.
2020-04-20 15:13:38 -04:00
GiteaBot
cac69903ae [skip ci] Updated translations via Crowdin 2020-04-20 16:48:24 +00:00
6543
b9ed8d8497
make branch parameter optional for /api/v1/repos/{owner}/{repo}/contents/{filepath} (#11067) 2020-04-20 17:47:05 +01:00
GiteaBot
7179e49881 [skip ci] Updated translations via Crowdin 2020-04-20 13:11:58 +00:00
CirnoT
d2693f18de
Support organization labels for PRs in API (#11135)
Fix `/repos/{owner}/{repo}/pulls` and `/repos/{owner}/{repo}/pulls/{index}` to accept organization labels during PR creation and edition.
2020-04-20 14:10:45 +01:00
6543
5bfb9bc2b6
When migrating from Gitlab map Approvals to approving Reviews (#11147)
When migrating from Gitlab map Gitlab Approvals to approving Reviews

Co-Authored-By: zeripath <art27@cantab.net>
2020-04-20 13:30:46 +01:00
zeripath
067eff8eba
Ensure that relative paths in edit preview work (#11143)
Fix #10131

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-20 13:32:44 +03:00
GiteaBot
da3e85a502 [skip ci] Updated translations via Crowdin 2020-04-20 09:09:35 +00:00
silverwind
74c6414250
Update JS dependencies (#11146)
Result of `make npm-update`. Some minor updates to build tools, no
runtime dependencies affected.
2020-04-20 10:08:20 +01:00
6543
77171abcad
Prevent xorm nil insert in Review.Comments (#11150) 2020-04-20 04:04:08 +01:00
6543
e37e217602
[Fix] RetryDownloader (add GetReviews()) (#11093)
* add GetReviews() to RetryDownloader
2020-04-20 03:23:28 +01:00
silverwind
842bba94ac
Fix max-width of selection dropdowns (#11144)
Fix a regression added by
https://github.com/go-gitea/gitea/pull/10897/files.
2020-04-20 01:24:46 +03:00
GiteaBot
77fecec64f [skip ci] Updated translations via Crowdin 2020-04-19 20:24:31 +00:00
6543
82dbb34c9c
Vendor Update: go-gitlab v0.22.1 -> v0.31.0 (#11136)
* vendor update: go-gitlab to v0.31.0

* migrate client init to v0.31.0

* refactor
2020-04-19 21:23:05 +01:00
Jordan
5c092eb0ef
Add support for migrating from Gitlab (#9084)
* First stab at a Gitlab migrations interface.

* Modify JS to show migration for Gitlab

* Properly strip out #gitlab tag from repo name

* Working Gitlab migrations!
Still need to figure out how to hide tokens/etc from showing up in opts.CloneAddr

* Try #2 at trying to hide credentials.
CloneAddr was being used as OriginalURL.
Now passing OriginalURL through from the form and saving it.

* Add go-gitlab dependency

* Vendor go-gitlab

* Use gitlab.BasicAuthClient
Correct CloneURL.
This should be functioning!
Previous commits fixed "Migrated from"
from including the migration credentials.

* Replaced repoPath with repoID globally.
RepoID is grabbed in NewGitlabDownloader

* Logging touchup

* Properly set private repo status.
Properly set milestone deadline time.
Consistently use Gitlab username for 'Name'.

* Add go-gitlab vendor cache

* Fix PR migrations:
- Count of issues is kept to set a non-conflicting PR.ID
- Bool is used to tell whether to fetch Issue or PR comments

* Ensure merged PRs are closed and set with the proper time

* Remove copyright and some commented code

* Rip out '#gitlab' based self-hosted Gitlab support

* Hide given credentials for migrated repos.

CloneAddr was being saved as OriginalURL.

Now passing OriginalURL through from the form and
saving it in it's place

* Use asset.URL directly, no point in parsing.
Opened PRs should fall through to false.

* Fix importing Milestones.
Allow importing using Personal Tokens or anonymous access.

* Fix Gitlab Milestone migration if DueDate isn't set

* Empty Milestone due dates properly return nil, not zero time

* Add GITLAB_READ_TOKEN to drone unit-test step

* Add working gitlab_test.go.
A Personal Access Token, given in env variable GITLAB_READ_TOKEN
is required to run the test.

* Fix linting issues

* Add modified JS files

* Remove pre-build JS files

* Only merged PRs are marged as merged/closed

* Test topics

* Skip test if gitlab is inaccessible

* Grab personal token from username, not password.
Matches Github migration implementation

* Add SetContext() to GitlabDownloader.

* Checking Updated field in Issues.

* Actually fetch Issue Updated time from Gitlab

* Add Gitlab migration GetReviews() stub

* Fix Patch and Clone URLs

* check Updated too

* fix mod

* make vendor with go1.14

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-19 23:44:11 +08:00
zeripath
41f05588ed
Prevent clones and pushes to disabled wiki (#11131)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-19 15:26:58 +01:00
zeripath
9588d2c622
Remove errant third curly brackets from account.tmpl and pull.tmpl and send account ID in account.tmpl (#11129)
* Remove errant third } from account.tmpl

Fix #11128

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

* Remove errant third curly bracket from pull.tmpl

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

* Update templates/user/settings/account.tmpl
2020-04-19 20:31:56 +08:00
guillep2k
23163e98a3
Use /tmp for test repositories (#11126)
* Add option to use /tmp for test repositories

* Fix exit status

* Add feedback about using tmp repos

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-19 14:17:02 +03:00
GiteaBot
16f39ce426 [skip ci] Updated translations via Crowdin 2020-04-19 02:39:34 +00:00
6543
3c5a4d094a
[API] Add branch delete (#11112)
* use same process as in routers/repo/branch.go/deleteBranch

* make sure default branch can not be deleted

* remove IsDefaultBranch from UI process - it is worth its own pull

* permissions
2020-04-19 10:38:09 +08:00
Sorien
0ef11ff2c9
consolidate author name across timeline (#11053)
* consolidate author name across timeline

* Sync with master

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-19 03:15:07 +03:00
silverwind
b57a735e77
Upgrade jQuery to 3.5.0, remove jQuery-Migrate, fix deprecations (#11055)
- Removed jQuery-Migrate as it seems to no longer be needed.
- Removed a dead code section.
- Fixed some deprecations detected by jQuery-Migrate.

Ref: https://jquery.com/upgrade-guide/3.5/
Ref: https://github.com/gogs/gogs/search?q=repo-name-change-prompt
Ref: https://github.com/go-gitea/gitea/search?q=repo-name-change-prompt
Fixes: https://github.com/go-gitea/gitea/issues/9372

Co-authored-by: zeripath <art27@cantab.net>
2020-04-18 18:46:29 -04:00
6543
4be7cf0405
On Repo Deletion: Delete related TrackedTimes too (#11110) 2020-04-18 22:39:23 +01:00
silverwind
5180deb819
Send 404 immediately for known public requests (#11117)
Instead of further handling requests to public which causes issues like #11088, immediately terminate requests to directories js, css, fomantic if no file is found which is checked against a hardcoded list. Maybe there is a way to retrieve the top-level entries below public in a dynamic fashion.

I also added fomantic to the reserved usernames and sorted the list.

Fixes: #11088
2020-04-18 22:01:06 +01:00
Cornel
6034f8bcaa
Avoid 0 new commits messages to be send (#11082)
Fixes #10498
2020-04-18 21:02:59 +01:00
John Olheiser
4f597b1866
Add single release page and latest redirect (#11102)
* Add single release and latest release routes

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update API and move latest search to models

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix swagger

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-18 11:47:15 -03:00
赵智超
1b86f174ce
Add a way to mark Conversation (code comment) resolved (#11037)
* Add a way to mark Conversation (code comment) resolved

mark Conversation is a way to mark a Conversation is stale
or be solved. when it's marked as stale, will be hided like
stale. all Pull Request writer , Offical Reviewers and poster
can add or remove Conversation resolved mark.

Signed-off-by: a1012112796 <1012112796@qq.com>

* fix lint

* Apply suggestions from code review

* Add ResolveDoer
* fix ui

Co-Authored-By: Lauris BH <lauris@nix.lv>
Co-Authored-By: 6543 <6543@obermui.de>

* change IsResolved to an function
Add permission check in UpdateResolveConversation

* Apply suggestions from code review

* change return error for permisson check
* add default message for deleted user
* get issue message from comment
* add migration for ``ResolveDoerID`` column

another  change:
* block mark pending review as resolved because it's not necessary

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

* change button color

* resolve button size

* fix code style

* remove unusefull code

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-18 10:50:25 -03:00
CirnoT
38d5f88a81
Add X-Total-Count on /repos/{owner]/{repo}/pulls API (#11113)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-18 02:53:56 -04:00
GiteaBot
7eace60bb6 [skip ci] Updated translations via Crowdin 2020-04-18 04:20:32 +00:00
zeripath
731bdef4be
Refresh codemirror on show pull comment tab (#11100)
Fix #10975

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

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-18 01:19:19 -03:00
6543
12960b9d18
[BugFix] remove nil inserts in models (#11096)
* Fix InsertReleases Nil Insert on Attachments

* FIX "No element on slice when insert" & smal refactor

* again

* impruve

* rm useles newline

* Apply suggestions from code review

Co-Authored-By: zeripath <art27@cantab.net>

* process insert as a whole

Co-authored-by: zeripath <art27@cantab.net>
2020-04-17 20:42:57 +03:00
GiteaBot
0010fde8a2 [skip ci] Updated translations via Crowdin 2020-04-17 16:36:23 +00:00
赵智超
6e4baee91d
ui: fix status label on branches list vertical alignment (#11109)
change status icon for merged PR to git-merge

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-04-17 12:35:12 -04:00
6543
c52d48aae4
Prevent merge of outdated PRs on protected branches (#11012)
* Block PR on Outdated Branch

* finalize

* cleanup

* fix typo and sentences

thanks @guillep2k

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-16 22:00:36 -03:00
GiteaBot
2cb5878529 [skip ci] Updated translations via Crowdin 2020-04-16 21:27:45 +00:00
guillep2k
3d6f1731b5
Fix and simplify some tmpl conditions (#11080) 2020-04-16 16:26:24 -05:00
GiteaBot
eeb968eab5 [skip ci] Updated translations via Crowdin 2020-04-16 19:09:25 +00:00
CirnoT
e93826675c
Add missing commit states to PR checks template (#11085)
* Add missing commit states to PR checks template

* Add separate translation strings for warning and error

* Fix failure status string

* Revert accidental change with whitespace
2020-04-16 14:08:20 -05:00
GiteaBot
9ffa89249e [skip ci] Updated translations via Crowdin 2020-04-16 15:35:01 +00:00
silverwind
90577853ce
Remove nonexistant serviceworker entries (#11091) 2020-04-16 10:33:22 -05:00
GiteaBot
1b1b51d919 [skip ci] Updated translations via Crowdin 2020-04-16 10:45:52 +00:00
6543
a4cab2bbfa
[BugFix] ReviewCount: GetApprovalCounts func sorted wrong (#11086)
* FIX by simplify

* code reformat and optimize
2020-04-16 13:44:34 +03:00
GiteaBot
0040f8bf67 [skip ci] Updated translations via Crowdin 2020-04-15 20:36:28 +00:00
6543
a88f3663eb
Fix merge dialog on protected branch with missing required statuses (#11074)
It is possible for misconfigured protected branches to have required status checks that are not in any of the current statuses: Pending, Success, Error, Failure, or Warning - presumably because the CI has not contacted us as yet.

Fix #10636 by adding case: missing StatusChecks when these are missing
2020-04-15 21:35:18 +01:00
CirnoT
8cdb6662c8
Align review-item svg octicons (#11065) 2020-04-15 15:41:55 -03:00
GiteaBot
30690f6644 [skip ci] Updated translations via Crowdin 2020-04-15 17:42:06 +00:00
Lauris BH
4dc62dadce
Migrate to go-enry new version (#10906) 2020-04-15 20:40:39 +03:00
GiteaBot
7a67bcc204 [skip ci] Updated translations via Crowdin 2020-04-15 13:04:26 +00:00
6543
70fab7e26a
document 404 responce and meaning (#11073) 2020-04-15 16:03:05 +03:00
zeripath
2e85ad665a
Contents API should return 404 on not exist (#10323)
* Return 404 on not exist

* swagger update and use git.IsErrNotExist

* Handle delete too

* Handle delete too x2

* Fix pr 10323 (#3)

* fix TESTS

* leafe a note for fututre

* placate golangci-lint

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

* Update integrations/api_repo_file_delete_test.go

Co-Authored-By: 6543 <6543@obermui.de>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-15 02:18:51 -03:00
Lunny Xiao
7c8e116987
Add translation head on docs site (#11063)
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-15 01:42:09 -03:00
Kristian Antonsen
0e4e14d0f5
Replace references to cron.update_migration_post_id with cron.update_migration_poster_id in docs (#11068)
Across several files, references to cron.update_migration_post_id are made, although the actual setting is called cron.update_migration_poster_id according to modules/setting/cron.go (10e2f29144/modules/setting/cron.go (L54)).

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-04-15 02:44:08 +02:00
6543
d66b9a4690
Fix Migration 136 (be less aggressive to open pulls missing git files) (#11072)
* be less aggressife to open pulls when migrating

* remove unused
2020-04-14 17:16:07 -05:00
GiteaBot
0ad0357233 [skip ci] Updated translations via Crowdin 2020-04-14 18:33:15 +00:00
zeripath
7c48085ff4
Remove check on username if AccessToken authentication (#11015)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-14 13:32:03 -05:00
6543
f7ecc2bee7
fix (#11066) 2020-04-14 19:29:31 +03:00
6543
10e2f29144
Cache PullRequest Divergence (#10914)
* Cache PullRequest Divergence

* only re-calc divergence if AddTestPullRequestTask() is exec

* migrate already open pulls

* finalize

* take care of closed&not-merged+deleted-branch pull requests

* fix nil pointer exeption

Signed-off-by: 6543 <6543@obermui.de>

* try this

* no error its a warn

* init gitea-repositories-meta

* dont use gitDivergence type

* CI.restart()

* CI.restart()

* CI.restart()

* CI.restart()

* check IsUserAllowedToUpdate independend from CommitsBehind
2020-04-14 09:53:34 -04:00
GiteaBot
c571c5bb28 [skip ci] Updated translations via Crowdin 2020-04-14 11:38:33 +00:00
赵智超
09aa122bd1
ui: Change icon on title for merged PR to git-merge (#11064)
Signed-off-by: a1012112796 <1012112796@qq.com>
2020-04-14 19:37:10 +08:00
maxm123
9b7737df2d
Add charset handling to backup/restore doc (#11062)
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-13 23:55:20 -03:00
赵智超
281029529b
ui: Add MergePull comment type instead of close for merge PR (#11058)
Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-14 09:06:23 +08:00
silverwind
063b1d260f
Fix language label vertical alignment (#11061)
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-13 17:00:32 -03:00
6543
ad5c43ae5d
Reject duplicate AccessToken names (#10994)
* make sure duplicate token names cannot be used

* add check to api routes too

* add @lunny s suggestion

* fix & don't forget User.ID

* AccessTokenByNameExists() return error too

* unique token for each test

* fix lint

Signed-off-by: 6543 <6543@obermui.de>

Co-authored-by: Lanre Adelowo <yo@lanre.wtf>
2020-04-13 22:02:48 +03:00
GiteaBot
980ef24251 [skip ci] Updated translations via Crowdin 2020-04-13 13:03:35 +00:00
silverwind
27e3cddfbe
Move syntax highlighting to web worker (#11017)
This should eliminate page freezes when loading big files/diff.
`highlightBlock` is needed to preserve existing nodes when highlighting
and for that, highlight.js needs access to the DOM API so I added a DOM
implementation to make it work, which adds around 300kB to the output
file size of the lazy-loaded `highlight.js`.

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-13 16:02:31 +03:00
silverwind
cc4da79fb6
add 'make watch-frontend' and expand docs (#10931)
* add 'make watch-frontend' and expand docs

* add bindata note

* add .PHONY

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-12 00:50:59 -03:00
赵智超
59c31b490f
fix 404 and 500 image size in small size screen (#11043)
do it by define Semantic UI image class

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-11 17:31:17 -03:00
silverwind
7ac116c9b5
Tweak app.ini.sample (#11042)
Few misc tweaks to the sample config
2020-04-11 11:59:29 -04:00
赵智超
cc07b9ca37
Fix CreateComment for SQLite and JS click event on Request Review (#11040)
* fix some bug about Request review

* fix ``CreateComment`` wrong using ,it will not work when use Sqlite
* fix wrong js click event code , it will send wrong data when it has
many choices

Signed-off-by: a1012112796 <1012112796@qq.com>

* Apply suggestions from code review

Co-Authored-By: Lauris BH <lauris@nix.lv>

* add getReviewerByIssueIDAndUserID
fix wrong conditions check in initIssueComments after #10972

* call CI again

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-11 01:44:50 -03:00
Bagas Sanjaya
8592fb7121
[Docs] Cross Build Gitea from Source (#10999)
* Add cross-build docs

Note that C cross compiler is required for building Gitea with `TAGS`.

* Apply suggestion from @mrsdizzie

Co-Authored-By: mrsdizzie <info@mrsdizzie.com>

* Apply suggestion from @guillep2k

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-04-11 00:13:31 -03:00
6543
0dadea19bc
[Api] Check Notify (always return json) (#10059)
* BEAKING: check return status based on struct not httpStatus

* update Tests

* CI.restart()
2020-04-10 19:49:39 -04:00
Sorien
c97e988380
Prettify Timeline (#10972)
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
2020-04-11 01:01:41 +03:00
6543
bc362ea3c6
remove package code.gitea.io/gitea/modules/git import out of models (#11025) 2020-04-10 14:26:37 +03:00
GiteaBot
0a2cba972a [skip ci] Updated translations via Crowdin 2020-04-10 10:43:04 +00:00
6543
d21b974f6c
Load pr Issue Poster on API too (#11033) 2020-04-10 13:40:36 +03:00
Dan Molik
743022116d
Add Get/Update for api/v1/user/applications/oauth2 (#11008)
Add api methods for getting and updating user oauth2 applications.

Signed-off-by: Dan Molik <dan@danmolik.com>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-09 19:37:31 -05:00
John Olheiser
4ec7a659ce
Add git hook tooltip (#11030)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-04-09 18:15:09 -05:00
silverwind
8bef490f2f
Match arc-green code tag color to code blocks (#11023)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-09 15:03:14 -04:00
赵智超
ca714db4fd
ui:Add flash notify for email preference seting success (#11027)
* Add flash notify for email preference seting success

Signed-off-by: a1012112796 <1012112796@qq.com>

* add review suggest changes

Co-authored-by: Lauris BH <lauris@nix.lv>

Co-Authored-By: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-09 13:22:17 -04:00
zeripath
0be25e2150
Handle yaml frontmatter (#11016)
Add goldmark-meta to render yaml frontmatter as a table

Fix #5377

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-09 11:54:50 +01:00
Lars Lehtonen
c02dee8bc4
integrations: deprecate HeaderMaps (#11018) 2020-04-08 19:30:03 -04:00
L0veSunshine
08208cdfb8
Fix forked repo has no icon and language stat. (#10791)
* Update header.tmpl

* Update _repository.less

* Update pull.go

* Update indexer.go

* Update pull.go

* Update pull.go

* Update indexer.go

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

* fix forked repo doesn't have language stat

Thanks the advice from lunny and 6543.

* fix forked repo doesn't have language stat

Modified as suggested by 6543.

* fix forked repo doesn't have language stat

simplify the function.

* fix forked repo doesn't have language stat

update the indexer after the loop

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-08 15:13:04 +03:00
j.yao.SUSE
b40107c416
[suggest] change merge strategy: do not check write access if user in merge white list (#10951)
* [suggest] change merge strategy: do not check write access if user in merge white list #10935

(cherry picked from commit ba74fc6389dfcad03c273441a49b54e4d38c86ee)

* fix NPE

* Fix cross compile (#10952)

* Fix cross compile

* Add test for cross compile

* Fix drone

* Fix drone

* Also prevent CC environment not to generate

Co-authored-by: zeripath <art27@cantab.net>

* fix merge box icon color bug (#10974)

that because need some space beturn ``text`` and color defines

Signed-off-by: a1012112796 <1012112796@qq.com>

* [skip ci] Updated translations via Crowdin

* Allow X in addition to x in tasks (#10979)

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

* remove api: merge  reqRepoWriter

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 赵智超 <1012112796@qq.com>
Co-authored-by: GiteaBot <teabot@gitea.io>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-08 14:26:50 +03:00
zeripath
089b34858c
Return error for authorized_keys and mergebase problems (#10990)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-08 02:04:19 -03:00
6543
3d63caa542
[API] Get a single commit via Ref (#10915)
* GET /repos/:owner/:repo/commits/:ref

* add Validation Checks

* Fix & Extend TEST

* add two new tast cases
2020-04-07 22:54:46 -04:00
6543
71979d9663
Automatically remove Watches, Assignments, etc if user loses access due to being removed as collaborator or from a team (#10997)
* remove a user from being assigned to any issue/PR if (s)he is removed as a collaborator

* fix gender specific comment

* do not remove users that still have access to the repo if they are a member of a team that can access the repo

* add context to errors

* updates

* incorporate review fixes

* Update models/repo_collaboration.go

Co-Authored-By: 6543 <6543@obermui.de>

* Update models/repo_collaboration.go

Co-Authored-By: 6543 <6543@obermui.de>

* Fix Rebase Relict

* Fix & Impruve

* use xorm builder

* all in one session

* generalize reconsiderIssueAssignees

* Only Unwatch if have no access anymore

* prepare for reuse

* Same things if remove User from Team

* fix lint

* let mysql take time to react

* add description

* CI.restart()

* CI.restart()

Co-authored-by: Lanre Adelowo <yo@lanre.wtf>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-07 22:52:01 +01:00
techknowlogick
d00ebf445b
upgrade to most recent bluemonday (#11007)
* upgrade to most recent bluemonday

* make vendor

* update tests for bluemonday

* update tests for bluemonday

* update tests for bluemonday
2020-04-07 23:08:47 +03:00
GiteaBot
4c54477bb5 [skip ci] Updated translations via Crowdin 2020-04-07 11:04:55 +00:00
silverwind
d6741de934
tweak code tags in markdown (#11000)
- remove whitespace before and after
- increase horizontal padding
- make blocks more apparant on arc-green
2020-04-07 12:03:49 +01:00
Mura Li
514e269b1d
Support running subtests manually (#10988)
Since GNU Make does not allow '/' in the target patterns,
we tranlate the subsequent '.' into '/' for "go test -run".

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-07 01:31:11 -03:00
Michael Kuhn
ecb176851b
Fix Ctrl-Enter shortcut for issues (#10986)
The js-quick-submit class needs to be applied to SimpleMDE's input
field, which is currently only done for wiki pages.

Fixes #10937

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-07 00:51:21 -03:00
j.yao.SUSE
b252b23f16
[feature] provide OwnerName field for README template (#10981)
Co-Authored-By: 6543 <6543@obermui.de>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-06 21:40:38 -04:00
6543
17837986f0
[Docs] Add Note to Readme-Template about Variable Espansion (#10983)
* add note with Espansion VarNames

* add context of Name
2020-04-06 19:43:17 -04:00
GiteaBot
d79ff1dd32 [skip ci] Updated translations via Crowdin 2020-04-06 20:20:08 +00:00
zeripath
856030c530
Add docs for gmail (#10995)
Fix #10971

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

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-06 16:18:42 -04:00
6543
ad31d6b5e8
Fix release counter on API repository info (#10968)
Use the same mechanism as the webpage for calculating the release count

Fix #10946
2020-04-06 19:42:30 +01:00
赵智超
ef89e75d0e
add request review from specific reviewers feature in pull request (#10756)
* add request review feature in pull request

add a way to notify specific reviewers to review like github , by add  or delet a  special type
review . The acton is  is similar to Assign ,  so many code reuse the function and items of
Assignee, but the meaning and result is different.

The Permission style is is similar to github, that only writer can add a review request from Reviewers,
but the poster can recall and remove a review request after a reviwer has revied even if he don't have
Write Premission. only manager , the poster and reviewer of a request review can remove it.

The reviewers can be requested to review contain all readers for private repo , for public, contain
all writers and watchers.

The offical Review Request will block merge if Reject can block it.

an other change: add ui otify for Assignees.

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>

Signed-off-by: a1012112796 <1012112796@qq.com>

* new change

* add placeholder string

* do some changes follow #10238 to add review requests num on lists also
change icon for review requests to eye

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-06 19:33:34 +03:00
赵智超
88c14326b1
Users should not be able to prohibit their own login (#10970)
* ui: limit managers prohibit themself to login

Because I think it's crazy and not reasonale , that if a user can
prohibit themself to login. so suggest limit this choice on ui

Signed-off-by: a1012112796 <1012112796@qq.com>

* skip self Prohibit Login in post event handle

* fix comment

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-06 10:23:15 -04:00
zeripath
1bec60e02a
Change default charset for MySQL on install to utf8mb4 (#10989)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-06 09:33:15 -04:00
zeripath
d26885e2bf
Mulitple Gitea Doctor improvements (#10943)
* Add `gitea doctor --list` flag to list the checks that will be run, including those by default
* Add `gitea doctor --run` to run specific checks
* Add `gitea doctor --all` to run all checks
* Add db version checker
* Add non-default recalculate merge bases check/fixer to doctor
* Add hook checker (Fix #9878) and ensure hooks are executable (Fix #6319)
* Fix authorized_keys checker - slight change of functionality here because parsing the command is fragile and we should just check if the authorized_keys file is essentially the same as what gitea would produce. (This is still not perfect as order matters - we should probably just md5sum the two files.)
* Add SCRIPT_TYPE check (Fix #10977)
* Add `gitea doctor --fix` to attempt to fix what is possible to easily fix
* Add `gitea doctor --log-file` to set the log-file, be it a file, stdout or to switch off completely. (Fixes previously undetected bug with certain xorm logging configurations - see @6543 comment.)

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-06 11:44:47 +01:00
John Olheiser
1648bf2b60
Turn off go modules for xgo and gxz (#10963)
* Turn off go modules for xgo and gxz

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add test release for PR

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Try with go modules off

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Revert Makefile, force a release test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Turn on GOPROXY for release

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* CI

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* CI

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Final commit

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-04-06 12:48:55 +08:00
Gary Kim
561e7a9a59
Migrate ActivityHeatmap to Vue SFC (#10953)
* Migrate ActivityHeatmap to Vue SFC

Signed-off-by: Gary Kim <gary@garykim.dev>

* Readd vue compiler alias

Signed-off-by: Gary Kim <gary@garykim.dev>

* Remove unneeded use of v-html

Signed-off-by: Gary Kim <gary@garykim.dev>

Co-authored-by: zeripath <art27@cantab.net>
2020-04-06 09:31:11 +08:00
zeripath
ca33a95778
Allow X in addition to x in tasks (#10979)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-05 17:39:05 -05:00
GiteaBot
f072d4566f [skip ci] Updated translations via Crowdin 2020-04-05 17:02:59 +00:00
赵智超
9814dd68ad
fix merge box icon color bug (#10974)
that because need some space beturn ``text`` and color defines

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-04-05 20:01:12 +03:00
Lunny Xiao
686850e21f
Fix cross compile (#10952)
* Fix cross compile

* Add test for cross compile

* Fix drone

* Fix drone

* Also prevent CC environment not to generate

Co-authored-by: zeripath <art27@cantab.net>
2020-04-05 20:28:18 +08:00
John Olheiser
baadb51445
Add gitea-vet (#10948)
* Add copyright

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add gitea-vet and fix non-compliance

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Combine tools.go into build.go and clean up

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove extra GO111MODULE=on

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-04-05 07:20:50 +01:00
guillep2k
b74d30ae27
Prevent support libraries from compiling into Gitea (#10964)
* Prevent support libraries from compiling into Gitea

* Fix tag position

* Fix golangci-lint errors

* Refactor to make it work

Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
2020-04-05 11:35:02 +08:00
silverwind
6cf71ee0e8
Fix scrollbar issues in dropdowns (#10897)
* Fix scrollbar issues in dropdowns

Fixes: https://github.com/go-gitea/gitea/pull/10835

* remove wrapping

* grammar

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-04 18:29:15 -03:00
mrsdizzie
a0cc4b3d08
Adjust label padding (#10957)
* Adjust label padding

* fix less complaint

* Make top/bottom padding a bit smaller to create better label look
2020-04-04 14:39:57 -05:00
Vasil Mikhalenya
240258a3e5
Avoiding directory execution on hook (#10954) (#10955)
* test -x is not enough https://stackoverflow.com/a/39489087
2020-04-04 11:29:58 -05:00
mrsdizzie
2a06d3a590
Enable GO111MODULE=on globally in Makefile (#10939)
Now that our minimum required go version is 1.12 we can remove code that disables GO111MODULE globally and turn it on, so each command doesn't need it set specifically.

Also fixes a small bug with make pr that didn't work because GO111MODULE=on wasn't set

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-04 19:41:00 +08:00
Lunny Xiao
b264c30394
Move gocovmerge as vendor (#10947)
* Move gocovmerge as vendor

* Update Makefile

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-04 11:45:26 +03:00
赵智超
14c97c0501
Add titles and improve messages on sidebar menus (#10872)
* ui: add more message on sidebar menus

* add title on the menus
* show some message instead of hide choose bar when have nothing to choose
* add simply filter for each menus
* do same changes in mew_form.tmpl
* remove some unusefull comments in mew_form.tmpl

Signed-off-by: a1012112796 <1012112796@qq.com>

* do review suggestions

* add filter message  on sidebar filter
* change IsIssueWriter to HasIssuesOrPullsWritePermission

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-04 02:39:48 -03:00
Lunny Xiao
4f63f283c4
Rename scripts to build and add revive command as a new build tool command (#10942)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-04-03 22:29:12 +03:00
techknowlogick
4af7c47b38
Update docs to 1.11.4 (#10941) 2020-04-03 13:08:40 -04:00
zeripath
97eb37e823
Fix rebase conflict detection in git 2.26 (#10929)
* Fix rebase conflict detection in git 2.26

Git changed the technique used in rebase from
simple apply-patches to use merge. This breaks
our conflict detection code.

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

* As per @techknowlogick reduce copying

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-03 19:00:41 +03:00
zeripath
57cca44c5e
Generate Diff and Patch direct from Pull head (#10936)
* Generate Diff and Patch direct from Pull head

Fix #10932
Also fix "Empty Diff/Patch File when pull is merged"

Closes #10934

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Add tests to ensure that diff does not change

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Ensure diffs and pulls pages work if head branch is deleted too

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-04-03 21:21:41 +08:00
赵智超
f685edf510
Change review status icons on PR view style to Github style (#10737)
* change the icon of ApproveReview pr from "eye" to "check" like github
* change the icon of RejectReview pr from "x" to "request-change" like github
* add "-" after "{{" which need to be one line (TODO: may be not change all)

Signed-off-by: a1012112796 <1012112796@qq.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-03 02:12:42 -03:00
j.yao.SUSE
3723b0647f
[UI] language status icon size (#10749)
* language status icon size

change the repository language status icon size

* Update _base.less

* fix: eslint rule  length-zero-no-unit

* [ui] .color-icon change size ti 14px

* Update web_src/less/_base.less

* Update web_src/less/_base.less

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-02 14:18:35 +03:00
GiteaBot
6c27f3e4e5 [skip ci] Updated translations via Crowdin 2020-04-01 19:05:15 +00:00
6543
a291a0eddc
Prevent deadlock in pull_service.GetDiverging(pr) (#10905)
* Switch to use a temporary repository instead of adding remotes to the base gitea repository to prevent deadlocking the base gitea repository.
* Add documentation on how to use func **createTemporaryRepo**
2020-04-01 20:03:08 +01:00
6543
d501aec427
Changelog v1.11.4 (#10916) (#10917)
* output of changelog

* Apply suggestions from code review

* Update CHANGELOG.md

Co-authored-by: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
2020-04-01 12:59:05 -04:00
Bagas Sanjaya
51140a970f
[Docs] Database Preparation - Connection over TLS (#10889)
* Database Preparation - Connection over TLS

* Step 6 MySQL edit

- have been created [before -> earlier]
- recreate user, [and this time]

* Apply suggestions from @guillep2k

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* certificat[e] typo

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-01 12:30:25 -03:00
zeripath
408bc2c8b5
Only update merge_base in checker if not already merged (#10908)
Fix #10766

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-04-01 15:02:11 +03:00
GiteaBot
fbb0880d37 [skip ci] Updated translations via Crowdin 2020-04-01 06:35:41 +00:00
silverwind
848502d04c
Exclude vendor dirs from git CRLF normalization (#10911)
* Exclude vendor dirs from git CRLF normalization

Should get rid of a few warnings like at the end of `lint-backend` like
https://drone.gitea.io/go-gitea/gitea/23117/1/4

* make vendor

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-04-01 09:33:49 +03:00
mrsdizzie
8d99ee2773
Add Organization Wide Labels (#10814)
* Add organization wide labels

Implement organization wide labels similar to organization wide
webhooks. This lets you create individual labels for organizations that can be used
for all repos under that organization (so being able to reuse the same
label across multiple repos).

This makes it possible for small organizations with many repos to use
labels effectively.

Fixes #7406

* Add migration

* remove comments

* fix tests

* Update options/locale/locale_en-US.ini

Removed unused translation string

* show org labels in issue search label filter

* Use more clear var name

* rename migration after merge from master

* comment typo

* update migration again after rebase with master

* check for orgID <=0 per guillep2k review

* fmt

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* remove unused code

* Make sure RepoID is 0 when searching orgID per code review

* more changes/code review requests

* More descriptive translation var per code review

* func description/delete comment when issue label deleted instead of hiding it

* remove comment

* only use issues in that repo when calculating number of open issues for org label on repo label page

* Add integration test for IssuesSearch API with labels

* remove unused function

* Update models/issue_label.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Use subquery in GetLabelIDsInReposByNames

* Fix tests to use correct orgID

* fix more tests

* IssuesSearch api now uses new BuildLabelNamesIssueIDsCondition. Add a few more tests as well

* update comment for clarity

* Revert previous code change now that we can use the new BuildLabelNamesIssueIDsCondition

* Don't sort repos by date in IssuesSearch API

After much debugging I've found a strange issue where in some cases MySQL will return a different result than other enigines if a query is sorted by a null collumn. For example with our integration test data where we don't set updated_unix in repository fixtures:

SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 45

Returns different results for MySQL than other engines. However, the similar query:

SELECT `id`, `owner_id`, `owner_name`, `lower_name`, `name`, `description`, `website`, `original_service_type`, `original_url`, `default_branch`, `num_watches`, `num_stars`, `num_forks`, `num_issues`, `num_closed_issues`, `num_pulls`, `num_closed_pulls`, `num_milestones`, `num_closed_milestones`, `is_private`, `is_empty`, `is_archived`, `is_mirror`, `status`, `is_fork`, `fork_id`, `is_template`, `template_id`, `size`, `is_fsck_enabled`, `close_issues_via_commit_in_any_branch`, `topics`, `avatar`, `created_unix`, `updated_unix` FROM `repository` ORDER BY updated_unix DESC LIMIT 15 OFFSET 30

Returns the same results.

This causes integration tests to fail on MySQL in certain cases but would never show up in a real installation. Since this API call always returns issues based on the optionally provided repo_priority_id or the issueID itself, there is no change to results by changing the repo sorting method used to get ids earlier in the function.

* linter is back!

* code review

* remove now unused option

* Fix newline at end of files

* more unused code

* update to master

* check for matching ids before query

* Update models/issue_label.go

Co-Authored-By: 6543 <6543@obermui.de>

* Update models/issue_label.go

* update comments

* Update routers/org/setting.go

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2020-04-01 01:14:46 -03:00
John Olheiser
36d9237e60
Add accordion to release list and compact non-latest (#10910)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-31 17:39:54 -05:00
zeripath
2c25e75dca
Various Merge Base fixes (#10786)
* Fix broken merge base migration v128 for merged PR

* Allow PRs with deleted base branches to still show diff

* as per @lunny

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-31 16:42:44 +03:00
Lunny Xiao
73cf0e2614
Fix milestones too many SQL variables bug (#10880)
* Fix milestones too many SQL variables bug

* Fix test

* Don't display repositories with no milestone and fix tests

* Remove unused code and add some comments
2020-03-31 10:47:00 +03:00
zeripath
bf847b9397
Upgrade golangci-lint to 1.24.0 (#10894)
* upgrade golangci-lint to 1.24.0 to allow go 1.14 compatibility
* fix golangci-lint errors
* make make golangci-lint work when out of go-path

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-30 21:52:45 +03:00
mrsdizzie
972b3bf3b0
Split dashboard elements into separate template files (#10885)
* Split dashboard elements into separate template files

No code change just Move Heatmap and Repo list/search into separate
template files (like feeds and navbar already are). This will let a
user more easily replace dashboard.tmpl without regularly becoming
out of sync with fixes or changes to the actual code.

Fixes #10870

* End file with an empty line

Co-authored-by: zeripath <art27@cantab.net>
2020-03-30 03:49:54 -03:00
GiteaBot
bdfe4e258f [skip ci] Updated translations via Crowdin 2020-03-30 05:32:25 +00:00
Lunny Xiao
f490291bea
Use subquery to instead In (#10874)
* Use subquery to instead In

* Support excludedLabelNames on issues options

* Fix tests

Co-authored-by: zeripath <art27@cantab.net>
2020-03-30 02:30:39 -03:00
zeripath
5c3be56f7b
Add IIS Reverse Proxy documentation (#10881)
* Add IIS Reverse Proxy documentation

@mahdiit in #10748 described how to set up IIS as a reverse proxy. This
PR adds these to our documentation.

Close #10748

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Update docs/content/doc/usage/reverse-proxies.en-us.md

Co-Authored-By: mrsdizzie <info@mrsdizzie.com>

Co-authored-by: mrsdizzie <info@mrsdizzie.com>
2020-03-30 00:11:15 +03:00
GiteaBot
29ed07ee02 [skip ci] Updated translations via Crowdin 2020-03-29 19:53:00 +00:00
zeripath
d01763ee14
Protect against NPEs in notifications list (#10879)
Unfortunately there appears to be potential race with notifications
being set before the associated issue has been committed.

This PR adds protection in to the notifications list to log any failures
and remove these notifications from the display.

References #10815 - and prevents the panic but does not completely fix
this.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-29 20:51:14 +01:00
zeripath
20d4f9206d
Change the order of issues.closed_by to list opening user first (#10876)
Fix #8266

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-03-29 13:09:23 -03:00
zeripath
209045f55b
Slight simplification of accessibleRepositoryCondition (#10875)
* Slight simplification of accessibleRepositoryCondition

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-29 15:31:10 +01:00
silverwind
ad4026431b
Add 'make lint', restructure 'compliance' pipeline (#10861)
- Added 'lint', 'lint-frontend', 'lint-backend' targets
- Added 'lint-frontend', 'lint-backend' ci steps and restructure the
  'compliance' pipeline to have a clear separation between frontend and
  backend and use parallelism where possible. Also, the main build
  pipelines now depend on 'compliance' so they will skip if it fails.
- Added dependencies on ci steps so they skip when 'compliance' fails
- Moved JS linters to devDependencies
- Removed deprecated 'js' and 'css' targets
2020-03-29 12:56:58 +01:00
John Olheiser
3f0cb8b33a
Remove test from installation directions (#10873)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-29 11:07:40 +01:00
zeripath
e83daf77ad
Avoid logging []byte in queue failures - convert to string first (#10865)
Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-29 15:12:15 +08:00
Lunny Xiao
61f603cd8a
Create a new function to build search repository condition (#10858)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-29 02:27:06 -03:00
zeripath
48890ce546
Allow site admin to check /api/v1/orgs endpoints (#10867)
Fix #9950

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-28 19:45:55 +00:00
zeripath
052bff0cff
Convert plumbing.ErrObjectNotFound to git.ErrNotExist in getCommit (#10862)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-03-28 20:59:21 +02:00
zeripath
ea67e563dd
Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen (#10863)
* Use ErrKeyUnableToVerify if fail to calc fingerprint in ssh-keygen

Fix #3985

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Pass up the unable to verify
2020-03-28 19:24:55 +02:00
赵智超
f9f2c163b1
bug: fix assignees double load bug (#10856)
Because the assigness has been loaded in

compare.go 416:
    RetrieveRepoMetas(ctx, ctx.Repo.Repository, true)
then
issue.go 381
	RetrieveRepoMilestonesAndAssignees(ctx, repo)
then

issue.go 361 -- 365 , they are load assignees

So the code on compare.go 425 -- 427 is double work,
and which is the reason of #10853

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-03-28 14:22:52 +00:00
S7evinK
828a27feeb
Add Matrix webhook (#10831)
* Add Matrix webhook

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Add template and related translations for Matrix hook

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Add actual webhook routes and form

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Add missing file

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Update modules/webhook/matrix_test.go

* Use stricter regex to replace URLs

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Escape url and text

Signed-off-by: Till Faelligen <tfaelligen@gmail.com>

* Remove unnecessary whitespace

* Fix copy and paste mistake

Co-Authored-By: Tulir Asokan <tulir@maunium.net>

* Fix indention inconsistency

* Use Authorization header instead of url parameter

* Add raw commit information to webhook

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Tulir Asokan <tulir@maunium.net>
2020-03-28 15:09:55 +02:00
zeripath
7cd47046ea
Handle push rejection in branch and upload (#10854)
* Handle push rejections and push out-of-date in branch creation and
file upload.
* Remove the duplicated sanitize from services/pull/merge
* Move the errors Err(Merge)PushOutOfDate and ErrPushRejected to
modules/git
* Handle errors better in the upload file dialogs

Fix #10460

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-28 01:13:18 -03:00
Bagas Sanjaya
cac30abefc
[Docs] Config Cheat Sheet: SSL_MODE Value Description (#10834)
* Add description of SSL_MODE values

* Apply suggestions from @guillep2k

Rewording suggestions

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-03-28 00:24:12 -03:00
GiteaBot
7e8ced07b3 [skip ci] Updated translations via Crowdin 2020-03-27 21:28:54 +00:00
zeripath
1737fca220
make gitea admin auth list formatting configurable (#10844)
* make admin auth list formatting configurable

Signed-off-by: Andrew Thornton <art27@cantab.net>

* As per @guillep2k

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-27 22:26:43 +01:00
Success Go
8cffae65a6
Fix typo of MSSQL (#10850) 2020-03-27 16:12:39 +02:00
zeripath
e6baa656f7
make avatar lookup occur at image request (#10540)
speed up page generation by making avatar lookup occur at the browser
not at page generation

* Protect against evil email address ".."

* hash the complete email address

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-Authored-By: Lauris BH <lauris@nix.lv>
2020-03-27 14:34:39 +02:00
Lauris BH
a3f90948d8
Set MySQL rowtype to dynamic for new tables (#10833)
* Set mysql rowtype to dynamic for new tables

* Update models.go
2020-03-27 10:44:05 +02:00
zeripath
453f6e6e5a
In authorized_keys use double-quote for windows compatibility (#10841)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-27 09:49:39 +02:00
zeripath
cf4f2cfa3e
Fix internal server error on checkboxes (#10845)
Annoyingly goldmarks SetAttributeString requires that
the value of the attribute is still a []byte but does
not make it clear in the documentation.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-26 23:47:34 +00:00
Lauris BH
bbd910ed1b
Allow to set protected file patterns that can not be changed under no conditions (#10806)
Co-Authored-By: zeripath <art27@cantab.net>
2020-03-27 00:26:34 +02:00
zeripath
52cfd2743c
Option to set default branch at repository creation (#10803)
* Option to set default branch at repository creation
* Handle template repos with non-default master branch
* Add DefaultBranch handling on creation to API

Fix #9542

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-26 19:14:51 +00:00
silverwind
b1c331c845
Fix repo summary height (#10825)
Extracted the style that keeps the animation of the language bar in
check.

Fixes: https://github.com/go-gitea/gitea/issues/10754

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-25 22:58:25 +00:00
Stefan Bethke
e72c5cb02a
Simplify grep regexp to be more compatible (#10765)
* Simplify grep regexp to be more compatible

The new expression also works with the BSD implementation of grep. Also,
I believe the expression did not work consistently for all possible
version numers, for example a two digit patch version would not have
been matched.

* Fix quote

* Allow for two and three part version numbers

* Select one, two and three part version numbers, reject amd64

* Also allow one to three parts for node version

* Use JS code to print node verion in correct format

* Avoid grep altogether

* Handle go1.14beta1 as well.

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-03-26 00:21:33 +02:00
John Olheiser
ad6f2323b7
Fix milestone template (#10824)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-25 18:08:00 +01:00
Lunny Xiao
73f5ca70de
Upgrade xorm to v1.0.1 and fix start fail with potgres (#10819)
* upgrade xorm to v1.0.1

* fix start fail with postgres

Co-authored-by: zeripath <art27@cantab.net>
2020-03-25 16:32:23 +02:00
GiteaBot
b10cb7b258 [skip ci] Updated translations via Crowdin 2020-03-25 13:34:32 +00:00
Alexander Scheel
61830ace0b
Fix tab indentation in code view (#10671)
Resolves: #5596

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-25 13:33:03 +00:00
zeripath
311ed516ce
log.Fatal on failure to listen to SSH port (#10795)
Fix #10792
2020-03-23 07:59:38 +00:00
zeripath
f036de5a94
Completely fix task-list checkbox styling (#10798)
Continuing on from #10668 this PR makes goldmark apply the task-list styling to task-lists.
2020-03-22 22:25:38 +00:00
Lunny Xiao
c61b902538
Upgrade xorm to v1.0.0 (#10646)
* Upgrade xorm to v1.0.0

* small nit

* Fix tests

* Update xorm

* Update xorm

* fix go.sum

* fix test

* Fix bug when dump

* Fix bug

* update xorm to latest

* Fix migration test

* update xorm to latest

* Fix import order

* Use xorm tag
2020-03-22 11:12:55 -04:00
Lunny Xiao
dcaa5643d7
Fix branch api canPush and canMerge (#10776)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-03-20 23:41:33 -04:00
zeripath
b3f4f812d8
account for empty lines in receive-hook message (#10773)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-03-20 20:21:28 +02:00
techknowlogick
2fa1078911
go 1.14 (#10467) 2020-03-20 10:29:31 -04:00
Lauris BH
e5a008f7b2
Add nowrap to language bar items (#10755) 2020-03-20 10:10:02 +08:00
John Olheiser
7225453d5f
Update Gitea version in docs (#10772) 2020-03-19 16:05:19 -04:00
Lunny Xiao
83fe7d414e
Fix bug on branch API (#10767) 2020-03-19 11:39:08 -04:00
silverwind
661289d480
Move JS build dependencies to 'dependencies' (#10763)
- move all JS build dependencies to 'dependencies'
- update all JS dependencies

Reason for this is that npm will only install 'dependencies' when under
the effect of NODE_ENV=production which may be present on some build
systems.

Linters currently need to be depdendencies because we run linting as
part of the build step, but I plan to move them to a separate 'lint'
target which means they can move to devDependencies then.

Fixes: https://github.com/go-gitea/gitea/pull/10761
2020-03-19 10:45:23 +08:00
Simon Legner
a2809b391d
doc(authentication.en-us): remove superflous line (#10758) 2020-03-18 09:52:51 -05:00
silverwind
ed5140d235
disable webpack's size warnings (#10746)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-03-17 18:57:17 -04:00
silverwind
85fb33a65f
move jquery-datetimepicker to npm/webpack (#10713)
- update to latest version and move to npm
- adapt for api changes and css class rename
- add specificity to arc-green rules as dependency css now loads later
- use imports-loader to make it load correctly
- fix some wrong paths in librejs

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-03-17 15:08:15 -04:00
Lauris BH
43c09134a9
Migrate to go-git/go-git v5.0.0 (#10735) 2020-03-17 12:19:58 -04:00
赵智超
2f928316db
hide gear icon for user who can't use them on sidebar (#10750)
reason:
If user can't choose the Assignees labels and Milestone It's
not usefull to show a gear label , and it It will mislead the
user into thinking that it's a BUG rather than thy don't have
permission to chosse them.

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-03-17 12:19:03 -04:00
Lauris BH
ca181100ca
FIx hiding of fields in authorization source page (#10734) 2020-03-17 10:12:44 +02:00
guillep2k
10e8da1f1a
Change PACKAGES to GO_PACKAGES for FreeBSD compatibility (#10747)
Co-authored-by: Guillermo Prandi <guillep2k@users.noreply.github.com>
2020-03-17 07:37:10 +02:00
John Olheiser
c7f3d1627f
Prevent default for linkAction (#10742)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-16 16:13:41 -05:00
赵智超
19ebe2b956
misc: change the "taskName" to "label" in vscode tasks.json (#10739)
because of vscode suggest
ref ISSUE: Microsoft/vscode-docs#1181

Signed-off-by: a1012112796 <1012112796@qq.com>
2020-03-16 18:46:26 +02:00
Lunny Xiao
cf7ece6245
Fix queue log param (#10733) 2020-03-16 16:59:21 +08:00
silverwind
28b934b3ae
Update JS dependencies (#10726)
Result of `make npm-update`. Only notable change is that `updates` now
requires Node 10 and has been changed to a bundle, so its dependencies
are now no longer installed.
2020-03-14 17:27:20 +02:00
dependabot[bot]
37bd5787fc
Bump acorn from 6.4.0 to 6.4.1 (#10724)
Bumps [acorn](https://github.com/acornjs/acorn) from 6.4.0 to 6.4.1.
- [Release notes](https://github.com/acornjs/acorn/releases)
- [Commits](https://github.com/acornjs/acorn/compare/6.4.0...6.4.1)

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2020-03-13 20:31:49 -05:00
Alex
460e42391e
Update border-color of language bar icon (#10723)
* Update color of border of color-icon

* Update web_src/less/_base.less

Co-Authored-By: 6543 <6543@obermui.de>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2020-03-14 01:19:09 +02:00
8ctopus
2e5d37463e
Documentation - updated email setup (#10695)
* Updated email setup documentation to include sendmail option

* Update docs/content/doc/usage/email-setup.en-us.md

full path to sendmail

Co-Authored-By: mrsdizzie <info@mrsdizzie.com>

* Update docs/content/doc/usage/email-setup.en-us.md

docker image does not have sendmail

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

* Update docs/content/doc/usage/email-setup.en-us.md

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

* Update docs/content/doc/usage/email-setup.en-us.md

Co-Authored-By: James Lakin <jamesorlakin@users.noreply.github.com>

* Update docs/content/doc/usage/email-setup.en-us.md

Co-Authored-By: James Lakin <jamesorlakin@users.noreply.github.com>

Co-authored-by: 8ctopus <hello@octopuslabs.io>
Co-authored-by: mrsdizzie <info@mrsdizzie.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: James Lakin <jamesorlakin@users.noreply.github.com>
2020-03-13 16:20:14 +01:00
Success Go
da1633a5d4
fix miss spelling (#10721) 2020-03-12 14:05:52 +01:00
silverwind
e03d627769
Misc JS linting and naming tweaks (#10652)
- lowercase all js filenames except Vue components
- enable new lint rules, mostly focused on shorter code
- autofix new lint violations
- apply misc transformations indexOf -> includes and onevent-> addEventListener

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-03-11 21:34:54 +02:00
John Olheiser
984b85c1a7
Remove old vendored dropzone from serviceworker (#10703)
* Remove dropzone from serviceworker

* Remove CSS as well

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-11 08:11:19 +00:00
Lunny Xiao
3378fc9149
Add changelog for v1.11.3 (#10700) (#10708)
* Add changelog for v1.11.3

* Apply suggestions from code review

* Update CHANGELOG.md

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-11 13:49:07 +08:00
Lunny Xiao
ac1e411b2b
Changelog for v1.10.6 (#10699) (#10710)
* Changelog for v1.10.6

* Add warnning

* Apply suggestions from code review

Co-Authored-By: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: John Olheiser <john.olheiser@gmail.com>

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-03-11 07:01:07 +02:00
Antoine GIRARD
263c859558
Use better wording for release pipeline and steps (#10701) 2020-03-11 10:03:20 +08:00
Lunny Xiao
6618348e23
cross compile using go 1.13.x (#10684) (#10697)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-03-10 16:36:59 +01:00
GiteaBot
288e487232 [skip ci] Updated translations via Crowdin 2020-03-09 19:57:34 +00:00
zeripath
9269b7f627
Multiple LFS improvements (#10667)
* Add more logging in the LFS server

Adds more logging in the LFS server and stops sending internal server
error information to the client

* Add LFS Lock cursor implementation

* Simplify Claims in LFS and remove the float64 casts

Signed-off-by: Andrew Thornton <art27@cantab.net>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-09 19:56:18 +00:00
zeripath
3fc4f3670c
Fix panic in API pulls when headbranch does not exist (#10676)
* Fix panic in API pulls when headbranch does not exist
* refix other reference to plumbing.ErrReferenceNotFound

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-09 07:06:38 +00:00
silverwind
ec4d0cdd56
Remove svg preload (#10654)
It triggers a warning in the Chrome console about it being unused, so I
think preloading of SVG assets may not be supported properly in current
browsers.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-09 03:06:59 -03:00
silverwind
d6657644a9
Modernize docs/assets/js/search.js (#10621)
- reformated file with eslint's --fix
- did some minor rule adjustments
- removed unneccesary console debug
- fixed a typo
2020-03-08 21:41:52 -03:00
silverwind
11f7fc5621
Use whitelist to find go files, run find only once (#10594)
- Use a whitelist-based approach to find *.go files so we can use
  standard find syntax. Also included is a change that files no
  longer pass a leading './' which should help performance further.

- Instead of running `find` multiple times in make because of the
  lazy evaluation, run it only once and add the bindata files when
  the bindata tag is present

This is another huge speedup on my machine of around 2000%.

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-08 21:11:39 -03:00
GiteaBot
8a0da9ea78 [skip ci] Updated translations via Crowdin 2020-03-08 23:42:21 +00:00
zeripath
671d603684
tidy up go.sum (#10677)
Results of running `go mod tidy`

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-08 20:41:06 -03:00
James Lakin
a9f4489bbc
System-wide webhooks (#10546)
* Create system webhook column (and migration)

* Create system webhook DB methods

Based on the default webhook ones

* Modify router to handle system webhooks and default ones

* Remove old unused admin nav template

* Adjust orgRepoCtx to differentiate system and default webhook URLs

* Assign IsSystemWebhook when creating webhooks

* Correctly use booleans for IsSystemWebhook

* Use system webhooks when preparing webhooks for payload

* Add UI and locale changes

* Use router params to differentiate admin hook pages

* Fix deleting admin webhooks and rename method

* Add clarity to webhook docs

* Revert "Remove old unused admin nav template"

This reverts commit 191a20a7389fe5f6256b0ad6aafd04b9b0e295c5.

* Rename WebHooksNewPost to GiteaHooksNewPost for clarity

* Reintroduce blank line lost during merge conflict

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-09 00:08:05 +02:00
Alexander Scheel
b8551f8532
Fix task-list checkbox styling (#10668)
* Fix task-list checkbox styling

The pandoc renderer will append the class "task-list" to the ul element
wrapping a li with one or more check-boxes. This allows us to select for
them, removing their list-style-type property. However, goldmark and the
gfm spec doesn't specify the "task-list" class name, so we can't use
that to fix the issue there.

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>

* Update to goldmark v1.1.25

This version adds the missing space after a checkbox.

Resolves: #9656

Signed-off-by: Alexander Scheel <alexander.m.scheel@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
2020-03-08 21:17:03 +02:00
zeripath
33c5e5e7fa
Prevent panic in stopwatch (#10670)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-08 14:46:24 -03:00
GiteaBot
1966f421b3 [skip ci] Updated translations via Crowdin 2020-03-08 13:36:49 +00:00
John Olheiser
de63ac046e
Make PR message on pushes configurable (#10664)
* Make PR message on pushes configurable

* Make fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-08 08:34:38 -05:00
John Olheiser
b40428a50a
Check for tag, not just new tag (#10663)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-08 13:27:11 +08:00
GiteaBot
4901096842 [skip ci] Updated translations via Crowdin 2020-03-07 21:07:35 +00:00
silverwind
9d3e69e867
Move dropzone.js to npm/webpack (#10645)
- unvendor dropzone and upgrade it from 4.2.0 to 5.7.0
- make `csrf` available on window.config
2020-03-07 21:06:15 +00:00
silverwind
0c2148c037
Workaround fomantic build issue (#10655)
This blows up the fomantic CSS by around 500kB, but I see no other way.

Ref: https://github.com/go-gitea/gitea/issues/10653
2020-03-07 14:54:44 +02:00
Lunny Xiao
a5281895c7
Fix bug on pull view when required status check no ci result (#10648) 2020-03-07 07:33:20 +00:00
6543
57c7a7aa72
Ensure Update button is enabled even when CI has failed (#10640)
* ignore pull status

* fix css

* fix css
2020-03-07 03:24:42 +02:00
John Olheiser
4a4fc73ee1
Fix migration (#10641)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-06 17:43:37 +02:00
zeripath
f7a6763c58
Changelog for v1.11.2 (#10627) (#10634)
Forward port Changelog for v1.11.2 (#10627)

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: 6543 <6543@obermui.de>
2020-03-06 14:26:30 +00:00
James Lakin
123d386059
Remove admin/nav.tmpl (#10633) 2020-03-06 14:17:33 +02:00
Lunny Xiao
345515a2a5
add changelog for v1.10.5 (#10628) (#10631)
Co-authored-by: zeripath <art27@cantab.net>
2020-03-06 15:39:52 +08:00
GiteaBot
cf7d4109c9 [skip ci] Updated translations via Crowdin 2020-03-06 06:50:20 +00:00
silverwind
334f09d934
Fix makefile syntax error (#10622)
Fix error found via checkmake. It was the only worthwhile issue it reported.
2020-03-06 06:47:40 +00:00
John Olheiser
3f1c0841cb
Granular webhook events (#9626)
* Initial work

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add PR reviews and API coverage

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Split up events

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add migration and locale

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Format

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Revert IsPull

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix comments

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix PR reviews

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix issue_comment

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Make fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Migrations

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Backwards compatible API

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix feishu

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move session commit

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-06 07:10:48 +02:00
zeripath
80db44267c
Add Approval Counts to pulls list (#10238)
* Add Approval Counts to pulls list

Add simple approvals counts to pulls lists

* Remove non-official counts

* Add PR features to milestone_issues.tmpl
2020-03-06 03:44:06 +00:00
John Olheiser
f422a115f4
Issue writers perms can modify issues (#10623)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-06 09:57:18 +08:00
John Olheiser
f5a20250ae
Add node version variable to docs (#10620)
Also adjusted other version mentions so go version is always mentioned
as major.minor and node only as major.

Co-authored-by: silverwind <me@silverwind.io>
2020-03-05 16:36:22 -06:00
zeripath
35027305d1
Handle deleted base branch in PR (#10618)
Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-03-05 18:51:21 +00:00
Antoine GIRARD
ae452d024e
Migration for deleting orphaned dependencies (#10617)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-05 16:54:50 +01:00
John Olheiser
10081f88ed
Add FAQ for markdown (#10611)
* Add FAQ for markdown

* Expand explanation @guillep2k

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-05 09:05:18 -06:00
Lauris BH
fb76136aec
Add notice for awesome-gitea (#10612)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-05 11:55:28 +02:00
Lauris BH
6a57364dc8
Delete dependencies when deleting a repository (#10608)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-05 09:58:02 +02:00
Lauris BH
6420f17fb6
Add migration to fix the old broken merge-bases (#10604)
* Add migration

* Fix migration

* Update models/migrations/v128.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-05 09:18:07 +02:00
Lauris BH
37c3db7be6
Add restricted user filter to LDAP authentication (#10600)
* Add restricted user filter to LDAP authentification

* Fix unit test cases
2020-03-05 08:30:33 +02:00
guillep2k
be544e8e6a
Versions (#10597)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-04 21:37:19 -03:00
Antoine GIRARD
4e65d2b8ea
Ensure executable bit is kept on the web editor (#10607)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-03-05 00:46:12 +01:00
Lauris BH
3d5d21133c
OAuth2: add Yandex provider (#8335) (#10564)
* OAuth2: add Yandex provider (#8335)

* remove changes from locale ru-RU

* fmt modules/auth/oauth2/oauth2.go

Co-Authored-By: 6543 <6543@obermui.de>

* fix fmt

* Update templates/admin/auth/new.tmpl

* fix fmt

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-05 00:08:52 +02:00
John Olheiser
afa1e1af16
Fix templates (#10596)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-04 08:56:53 +02:00
zeripath
4a2b76d9c8
Update mergebase in pr checker (#10586) 2020-03-03 21:53:57 -06:00
zeripath
0b3a9c4f85
Fix LFS max file size enforcement (#10593)
Unfortunately the batch handler also needs to enforce max file size.
Enforce max file size in batch handler
2020-03-03 14:57:27 -06:00
GiteaBot
0e304bbc42 [skip ci] Updated translations via Crowdin 2020-03-03 19:53:16 +00:00
silverwind
fa6ea60c55
Frontend build improvements, fix Fomantic build (#10576)
- add package-lock.json to webpack/fomantic prereqs making them always rebuild when dependencies change.
- remove FOMANTIC_EVIDENCE. It seemed better to just track a few output files instead.
- delete fomantic output files before build to prevent possible bugs in fomantic's build.
- resolve WEBPACK_SOURCES only once for performance
- reorder variables for clarity
- use clean-all in Dockerfile
- detect busybox for find syntax

Fixes: https://github.com/go-gitea/gitea/issues/10569
Fixes: https://github.com/go-gitea/gitea/issues/10565
Fixes: https://github.com/go-gitea/gitea/issues/10570
Fixes: https://github.com/go-gitea/gitea/issues/10568
2020-03-03 13:51:11 -06:00
Felix W. Dekker
aa4a297c16
Rename repo size sorting options (#10587) 2020-03-03 14:27:38 -03:00
zeripath
009990b0c0
Remove unnecessary parentheses in template (#10583)
Fix #10552

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-03 16:00:36 +08:00
John Olheiser
0e2217bd2d
Logout POST action (#10582)
* Change logout to POST

* Update for redirect

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-03-02 22:50:31 -06:00
techknowlogick
bea497ff96
nextcloud oauth (#10562)
Fix #7078
2020-03-02 22:11:45 -05:00
zeripath
07f6ae30e4
Change default value of DefaultCommandExecutionTimeout to match cheatsheet (#10581) 2020-03-02 22:13:01 -03:00
Lunny Xiao
5abe1c52de
Display pull request head branch even the branch deleted or repository deleted (#10413)
* Display pull request head branch even the branch deleted or repository deleted

* Merge getHeadRepo/loadHeadRepo and getBaseRepo/loadBaseRepo on pull and fill repo when pr.Issue.Repo is available

* retrieve sha from pull head when pull request branch deleted and fix tests

* Fix test

* Ensure MustHeadRepoName returns empty string if no head repo

Co-authored-by: zeripath <art27@cantab.net>
2020-03-02 22:31:55 +00:00
GiteaBot
22b7507024 [skip ci] Updated translations via Crowdin 2020-03-02 20:56:37 +00:00
silverwind
ac4f952f73
Fix make find command (#10580)
Continuation of https://github.com/go-gitea/gitea/pull/10577

This version also includes an additional fix for Darwin and FreeBSD
which do not accept the `-regextype` option, but only `-E` and the
argument order is specifically required like this for `-E` to work.

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-03-02 20:55:12 +00:00
guillep2k
5e1438ba92
Admin page for managing user e-mail activation (#10557)
* Implement mail activation admin panel

* Add export comments

* Fix another export comment

* again...

* And again!

* Apply suggestions by @lunny

* Add UI for user activated emails

* Make new activation UI work

* Fix lint

* Prevent admin from self-deactivate; add modal

Co-authored-by: zeripath <art27@cantab.net>
2020-03-02 15:25:36 -03:00
GiteaBot
b5ecc82d6e [skip ci] Updated translations via Crowdin 2020-03-02 15:54:56 +00:00
Lunny Xiao
753c0675c1
Fix migration bug on v96.go (#10572) 2020-03-02 12:53:39 -03:00
silverwind
e9afd74bbe
Speed up make (#10560)
* Speed up make

- stop `find` from venturing into node_modules and other directories
  that do not contain *.go files
- only run `find` once for *.go files
- move image tempdir generation to that task
- rename GOFILES to GO_SOURCES_OWN for consistency and to indicate that
  vendor files are not included
- pre-resolve FOMANTIC_SOURCES

* exclude more

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-02 00:45:08 +02:00
6543
4160bd6ef1
Remove Unused Functions (#10516)
* remove ReplaceLeft

* remove GetRepositoryByOwnerAndName chainload to models.GetRepositoryByOwnerAndName

* remove CheckUnitUser chainload to models.CheckUnitUser

* remove MakeAssigneeList

* remove DownloadDiff & DownloadPatch -> DownloadDiffOrPatch

* remove GetRandomBytesAsBase64

* remove PushUpdateDeleteTags

* remove GetUserByKeyID
(you still can resolve user by "k, err := GetPublicKeyByID; userID := k.OwnerID")

* remove BasicAuthEncode from struct package -> same function in modules/base/tools !

* remove UserID from api.utils

* remove unused func from structs package
2020-03-02 00:05:44 +02:00
James Lakin
c08c975d36
Fix redirection path if Slack webhook channel is invalid (#10548)
The path to the hook config is already defined by orgRepoCtx

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-03-01 11:51:55 -05:00
Antoine GIRARD
f9d34b2c60
vendor: update github.com/yuin/goldmark to v1.1.24 (#10551) 2020-03-01 15:01:44 +02:00
Andreas Shimokawa
14f3593f20
Fix 404 after activating secondary email (#10547) 2020-02-29 23:46:20 +00:00
zeripath
421e7b7875
Fix appearance of unsigned sha box in view_list (#10543)
Unfortunately the fix in #10511 was slightly incorrect and placed the
detail box at one level too far out.

Signed-off-by: Andrew Thornton <art27@cantab.net>
2020-02-29 13:27:19 +00:00
Brad Albright
82be59e633
issue search on my related repositories (#9758)
* adding search capability to user's issues dashboard

* global issue search

* placement of search bar on issues dashboard

* fixed some bugs in the issue dashboard search

* added unit test because IssueIDs option was added to UserIssueStatsOptions

* some renaming of fields in the issue dashboard code to be more clear; also trying to fix issue of searching the right repos based on the filter

* added unit test fro GetRepoIDsForIssuesOptions; fixed search lost on pagination; using shown issue status for open/close count; removed some debugging

* fix issue with all count showing incorrectly

* removed todo comment left in by mistake

* typo pulling wrong count

* fxied all count being off when selecting repositories

* setting the opts.IsClosed after pulling repos to search, this is done so that the list of repo ids to serach for the keyword is not limited, we need to get all the issue ids for the shown issue stats

* added "accessibleRepositoryCondition" check on the query to pull the repo ids to search for issues, this is an added protection to ensure we don't search repos the user does not have access to

* added code so that in the issues search, we won't use an in clause of issues ids that goes over 1000

* fixed unit test

* using 950 as the limit for issue search, removed unneeded group by in GetRepoIDsForIssuesOptions, showing search on pulls dashboard page too (not just issues)

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-29 03:52:05 -03:00
Gustavo Marin
af61b2249a
adds API endpoints to manage OAuth2 Application (list/create/delete) (#10437)
* add API endpoint to create OAuth2 Application.

* move endpoint to /user. Add swagger documentations and proper response type.

* change json tags to snake_case. add CreateOAuth2ApplicationOptions to swagger docs.

* change response status to Created (201)

* add methods to list OAuth2 apps and delete an existing OAuth2 app by ID.

* add APIFormat convert method and file header

* fixed header

* hide secret on oauth2 application list

* add Created time to API response

* add API integration tests for create/list/delete OAuth2 applications.

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-29 03:19:32 -03:00
6543
7e8cdba181
[Refactor] move APIFormat() of Issue and Label to convert package (#10423)
* Label: delete .APIFormat() and use convert.ToLabel()

* move issue APIFormat too

* add missing one

* move TEST too

* handle error -> return empty APIIssue

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-28 23:49:50 -03:00
zeripath
c32f3da33c
Handle panic in indexer initialisation better (#10534)
* Handle panic in indexer initialisation better
* as per @guillep2k
2020-02-28 22:00:09 +00:00
zeripath
154b137b6d
Relax sanitization as per https://github.com/jch/html-pipeline (#10527)
Looking at github/markup#245 it is clear that GH uses https://github.com/jch/html-pipeline to sanitize. This PR relaxes our sanitization to more closely match this.

Fixes #10471
and likely others...
2020-02-28 20:05:12 +00:00
silverwind
e0ecddc11b
Prevent accidential selection of language stats bar (#10537) 2020-02-29 00:59:29 +08:00
Jeff Stein
e661cd0321
Set correct content_type value for Gogs/Gitea webhooks (#9504) (#10456)
The content_type value was defaulting to the string value of the
ContentType, not the integer value as expected by the backend.
2020-02-28 14:33:52 +00:00
6543
ae4eaf02be
vendor: unknown/cae move to taged version (#10521) 2020-02-28 13:46:28 +00:00
6543
15c7738b3a
goldmark v1.1.19 -> v1.1.23 (#10519)
vendor update
2020-02-28 13:06:10 +00:00
FreeCipher
74433c91bf
head.tmpl og:image picture location (#10531)
og:image picture location
2020-02-28 19:30:23 +08:00
6543
8d2059a201
update: macaron cores,gzip,session (#10522)
Co-authored-by: zeripath <art27@cantab.net>
2020-02-28 10:51:18 +01:00
6543
694f44660f
inform participants on UI too (#10473)
* inform participants on UI too

* ajust test

* refactor getParticipantIDsByIssue
2020-02-28 05:16:41 -03:00
zeripath
513b962c1d
Add max-file-size to LFS (#10463)
* Add max-file-size to LFS

* Update modules/lfs/server.go

* As per @silverwind

Co-Authored-By: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-28 01:46:57 -03:00
zeripath
9ad2aa8f4d
Use media links for img in post-process (#10515)
* use media links for img in post-process

* do not visit text of anchors
2020-02-28 01:16:05 -03:00
zeripath
efec0d393b
Fix the signing icon in the view_list.tmpl page (#10511)
* Fix the view_list.tmpl page

* fix-centerlock

* Update web_src/less/_base.less

as per @silverwind

Co-Authored-By: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-27 23:03:17 -03:00
6543
e57ac841de
Fix potential bugs (#10513)
* use e if it is an option
* potential nil so check err first
* check err first
* m == nil already checked
2020-02-27 20:10:27 -03:00
John Olheiser
15fbf509d3
Org action fixes and form cleanup (#10512)
* More org fixes

* Move form action query to inputs

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-27 16:00:13 -06:00
zeripath
90919bb37e
Show Signer in commit lists and add basic trust (#10425)
* Show Signer in commit lists and add basic trust

Show the avatar of the signer in the commit list pages as we do not
enforce that the signer is an author or committer. This makes it
clearer who has signed the commit.

Also display commits signed by non-members differently from
members and in particular make it clear when a non-member signer
is different from the committer to help reduce the risk of
spoofing.

Signed-off-by: Andrew Thornton <art27@cantab.net>

* ensure orange text and background is available

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Update gpg_key.go

* Update models/gpg_key.go

* Apply suggestions from code review

* Require team collaborators to have access to UnitTypeCode

* as per @6543

* fix position of sha as per @silverwind

* as per @guillep2k
2020-02-27 16:20:55 -03:00
zeripath
858aebc2d8
Use [:space:] instead of \s (#10508) 2020-02-27 18:03:21 +00:00
6543
a924a90349
[BugFix] Avoid mailing explicit unwatched (#10475)
* Avoid mailing explicit unwatched

* CI.restart()

* back to normal

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-27 10:07:05 +00:00
silverwind
9a476113f0
Add fluid-icon (#10491)
This provides Firefox (and possible other browsers) with a
high-resolution rich icon, in place of the previously removed
apple-touch-icon without having to use that one as it lacks an
alpha channel. This is the same method GH uses.

https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/UI_considerations#Rich_icons

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-27 11:40:14 +08:00
guillep2k
4a2d23981d
Fix SQLite concurrency problems by using BEGIN IMMEDIATE (#10368)
* Test locking immediate for SQLite3

* fix url field separator

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-02-27 07:51:37 +08:00
James Lakin
7ffc2427da
Show the username as a fallback on feeds if full name is blank (#10438)
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-26 22:08:24 +00:00
silverwind
ef798d4b84
Tweak language stats bar (#10487)
- Ensure bar does not overflow parent
- Remove unneccessary borders/background
- Fix shaky animation caused by JS animation miscalculation by setting
  fixed height on the summary box. Box itself is still shaky during
  animation, but better it then the whole page.

Fixes: https://github.com/go-gitea/gitea/issues/10474
2020-02-26 22:44:14 +02:00
Karsten Lehmann
17581252e4
Fixed formatting (#10485)
Co-authored-by: John Olheiser <john.olheiser@gmail.com>
2020-02-26 13:28:39 -05:00
John Olheiser
78585b1cd7
Fix double PR notification from API (#10482)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-26 12:12:34 -06:00
John Olheiser
bcd16cec63
Fix admin notices (#10480)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-26 10:25:54 -06:00
6543
084a2b0026
Code Refactor of IssueWatch related things (#10401)
* refactor

* optimize

* remove Iretating function
LoadWatchUsers do not load Users into IW object and it is used only in api ... so move this logic

* remove unessesary

* Apply suggestions from code review

Thx

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* make Tests more robust

* fix rebase

* restart CI

* CI no dont hit sqlites deadlock

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-26 03:32:22 -03:00
John Olheiser
e5944a9521
Change admin dashboard to POST (#10465)
* Add form and convert to POST

* Redirect for flash

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-25 16:54:13 -06:00
John Olheiser
c161bb013e
Change action GETs to POST (#10462)
* Change action GETs to POST

* submite = submit + smite

* No more # href

* Fix test

* Match other tests

* Explicit csrf

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-25 14:28:47 -06:00
6543
4427a936b4
[API] enable paggination for ListRepoTags (#10454)
* enable paggination for repoTags

* precalculate first, cut slice second

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-25 14:07:07 -05:00
Ask Bjørn Hansen
b098cc24c5
Use documentation IPs for example IPs (#10434)
See https://tools.ietf.org/html/rfc5737

Co-authored-by: John Olheiser <john.olheiser@gmail.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-25 13:25:17 -05:00
6543
fa3381610c
update discord link (#10455) 2020-02-25 12:36:45 -05:00
GiteaBot
804d9ffa9f [skip ci] Updated translations via Crowdin 2020-02-25 16:01:35 +00:00
Philipp A. Beckmann
bab6e1ed87
Fixed wrong AppSubUrl in multiple templates (#10447)
* Fixed wrong AppSubUrl in OAuth2 app edit page

* Replaced all other occurrences of $.AppSubURL for support of sub-paths
2020-02-25 09:58:37 -06:00
silverwind
85e6a1267c
Update JS dependencies (#10450)
Fomantic's update process did fail to update via 'npm install' because
of our config initially but it did work after manually bumping the
version in semantic.json.

Fomantic changes:

https://github.com/fomantic/Fomantic-UI/blob/master/CHANGELOG.md#284
2020-02-25 01:56:59 -03:00
6543
dc88b786e9
Use local timezone to compare (#10446) 2020-02-25 11:05:00 +08:00
GiteaBot
6baa07ddf3 [skip ci] Updated translations via Crowdin 2020-02-24 22:53:36 +00:00
6543
b65e954f73
FIX Pagination of ListAccessTokens and GetIssueWatchers (#10449)
* fix a pagination bug

* fix pagination of ListAccessTokens
2020-02-24 16:50:32 -06:00
oscar.lofwenhamn
0eeee9c721
Update markbates/goth (#10444)
- Fixes a JWT decoding issue in the OpenID provider
- Updates the GitHub provider to use the authorization header for authentication
- Updates the Twitch provider for Twitch's v5 API changes
- Adds the email and is_private_email fields to the Apple provider's GetUser implementation
- Modifies gothic to export a non-collidable context key for setting the Provider in a context.Context
- Adds new scopes to the Spotify provider
- Adds the IDToken from OpenID providers on the user struct
- Make Apple provider's SecretParams public
- Adds support for sign in with Apple, and drops support for Go versions 1.7 and 1.8
- Fixes the Slack provider's FetchURL logic to use the appropriate scope for the info it needs
Signed-off-by: Oscar LÃfwenhamn <oscar.lofwenhamn@cgi.com>
2020-02-24 12:08:43 -05:00
Ask Bjørn Hansen
c97433d07d
docs: Fix MySQL create database syntax (#10436)
Signed-off-by: Ask Bjørn Hansen <ask@develooper.com>
2020-02-24 14:15:15 +02:00
6543
39b507e3c4
Trigger webhooks on issue label-change via API too (#10421)
* trigger webhooks with api too

* fix comment

* notify report old too

* CI restart

* restart CI again

* remove duplicated code
2020-02-23 22:53:08 +00:00
silverwind
062f35109d
move vue and vue-calendar-heatmap to webpack (#10188)
- unvendor vue and vue-calendar-heatmap
- remove unused moment.js leftover from previous heatmap version
- ensure webpack loads the full version of vue
- fix vue devmode warning related to 'searchLimit' type

I wanted to name the chunk heatmap.js but adblockers don't like that
filename [1].

[1] 3899d5dff3/easyprivacy/easyprivacy_general.txt (L2095)
2020-02-23 21:34:28 +00:00
guillep2k
09dbd85a3a
Various fixes in login sources (#10428) 2020-02-23 13:52:05 -06:00
Lunny Xiao
542bd59239
Fix webhook bug (#10427)
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-23 13:49:40 -05:00
silverwind
4e912d2ed8
Disallow leading zeroes in Less (#10407) 2020-02-23 13:48:27 -03:00
silverwind
71d5a090df
Prevent Firefox from using apple-touch-icon (#10402)
* Prevent Firefox from using apple-touch-icon

The opaque background does not work well in Firefox which uses the icon
as a "rich icon". Prevent this by not specifying it in HTML. Real Apple
devices will still request the icon on the static path.

Fixes: https://github.com/go-gitea/gitea/issues/10394

Also adjust gitignore so app.ini.sample becomes searchable and fixed a
variable name in app.ini.sample.

* fix gitignore
2020-02-23 08:34:53 -06:00
silverwind
9ed4aeeaf1
Support NODE_ENV in webpack (#10245)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-02-23 10:47:42 +02:00
silverwind
0bba3f9cf6
Various dark theme fixes (#10416)
- beatify simplemde, remove header hover effect (does not play well with
  border colors), remove double border separators
- fix colored outline buttons
- fix disabled style
- fix positive messages
- fix markdown header border and quote block
- adjust footer color
- adjust file icons and release list timeline
2020-02-22 22:32:15 -06:00
6543
fe26ca53c1
update integration README (#10400) 2020-02-23 00:45:20 +02:00
John Olheiser
f4370639be
Fix profile page CSS (#10406)
* Fix profile page

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove redundant CSS

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix .username and change em to rem

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-22 16:06:07 +02:00
zeripath
089ccb0c80
Handle push rejection message in Merge & Web Editor (#10373)
* Handle push rejection message in Merge

* placate golangci-lint

* Fix sanitize, adjust message handling

* oops

* Oops

* Handle push-rejection in webeditor CRUD too

* Apply suggestions from code review

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-22 15:08:48 +02:00
silverwind
2ed9ead6de
Add frontend/backend make targets, fix source release (#10325)
* Add frontend/backend make targets, fix source release

- Add 'make backend' and 'make frontend' make targets which are used to
  build go and js/css/svg files respectively.

- The 'backend' target can be invoked without requiring Node.js to be
  present on the system if pre-built frontend assets are present like
  in the release source tarballs.

- Fix source releases missing 'dist' folders inside 'node_modules' which
  were erronously excluded from tar.

- Store VERSION in file VERSION for the release tarballs and prefer that
  file over git-derived version.

* fix release task

* fix typo

* fix another typo
2020-02-22 17:15:11 +08:00
zeripath
c8d1c38129
Render READMEs in docs/ .gitea or .github from root (#10361)
* Render READMEs in docs/ .gitea or .github from root
2020-02-21 17:04:20 -06:00
GiteaBot
6b019724f3 [skip ci] Updated translations via Crowdin 2020-02-21 18:19:29 +00:00
zeripath
cadec9bc22
Prevent panic on merge to PR (#10403)
If you attempt to merge to a branch which on a PR there will be a nil pointer error in the pull request checker.

This panic is uncaught and will bring down the gitea server.

This PR adds protection to prevent this.
2020-02-21 18:18:13 +00:00
guillep2k
cfcd8e4146
Ensure only own addresses are updated (#10397) 2020-02-21 10:08:04 -03:00
John Olheiser
ac18c3f6f2
Fixes (#10386)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-20 17:44:13 -06:00
silverwind
4efc365c02
fix input[type=file] on dark theme (#10382) 2020-02-20 16:36:47 -06:00
GiteaBot
872f832a1a [skip ci] Updated translations via Crowdin 2020-02-20 21:04:58 +00:00
techknowlogick
63a6e71ac2
update crypto vendors (#10385) 2020-02-20 16:03:34 -05:00
Lauris BH
3c45cf8494
Add detected file language to code search (#10256)
Move langauge detection to separate module to be more reusable

Add option to disable vendored file exclusion from file search

Allways show all language stats for search
2020-02-20 16:53:55 -03:00
Lunny Xiao
efbd7ca39b
Fix wrong num closed issues on repository when close issue via commit (#10364)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-20 09:46:46 +02:00
silverwind
5dc634dace
optimize public/img/loading.png (#10372) 2020-02-19 16:16:30 -06:00
Andres Mazzo
194ef0b590
fix typo of english content page (#10370) 2020-02-19 15:48:33 -06:00
Lauris BH
e461852e73
Change loading animation frame order (#10358) 2020-02-19 22:59:55 +02:00
Lunny Xiao
8db20e807d
Fix test (#10363) 2020-02-19 10:46:14 -05:00
silverwind
17445bbbfa
remove release-dirs make target (#10350)
- only `mkdir`the dist dirs when they are absent
- add the dist dirs as prereqs so targets like `make release-sources`
  can run standalone

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-18 21:10:24 -06:00
John Olheiser
dc822d5291
Re-order GPG signing docs and fix code blocks (#10349)
* Move chunk and format

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* word

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-19 02:23:45 +01:00
zeripath
41294b53b3
Reading pull attachments should depend on read UnitTypePullRequests (#10346)
* Make pull attachments depend on read UnitTypePullRequests

Fixes #10336

* Fix test
2020-02-18 21:36:19 -03:00
zeripath
9f1f2e6675
Set max-width on review-box comment box (#10348) 2020-02-18 23:07:00 +00:00
Bagas Sanjaya
530f8963f3
[Docs] Database Preparation (#9826)
* Database Preparation

* Apply suggestions from @guillep2k

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Repeat strong password notice on PostgreSQL

* Add prerequisite note

* Use utf8mb4 instead of utf8

* Use utf8mb4 if complete character coverage wanted

* utf8mb4 recommended

* Reword utf8mb4 recommendation

* Set InnoDB global variables may be needed

* Reorder step number

* Whoops, bump year date

* Remove `SET GLOBAL`s and step number reorder

It is assumed that such global variables value are already as default on MySQL 5.7 and later, so those are redundant.

* Syntax edit on MySQL GRANT PRIVILEGEs

* DB engine uniformity intro edit

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-18 16:51:24 -05:00
zeripath
a6dc8f7caa
Revert "Do docker releases for pushes to release branches (#10330)" (#10345)
This reverts commit 69f80fd9f6.
2020-02-18 20:46:21 +00:00
zeripath
13c6681a07
Prevent nil pointer in GetPullRequestCommitStatusState (#10342)
Ensure that pr.HeadRepo is loaded before using it in GetPullRequestCommitStatusState.

Fixes error on merging with successful commit merge statuses.
2020-02-18 19:34:08 +00:00
John Olheiser
29efa9c3fb
Fix status check enable (#10341)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-18 12:58:16 -06:00
zeripath
69f80fd9f6
Do docker releases for pushes to release branches (#10330)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-18 10:24:09 +00:00
Lunny Xiao
21e771c41b
Fix notification (#10331) 2020-02-18 10:52:57 +02:00
GiteaBot
f0a43a068f [skip ci] Updated translations via Crowdin 2020-02-18 06:11:13 +00:00
John Olheiser
d3f618362a
Fix JS and Vue (#10328)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-18 08:07:57 +02:00
GiteaBot
83801663ce [skip ci] Updated translations via Crowdin 2020-02-18 03:17:09 +00:00
Mike Gerber
a67630deb2
Fix cron.repo_health_check schedule example in config cheat sheet (#10324)
Fixes #10274.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-02-17 22:14:11 -05:00
Lunny Xiao
ce0413ff88
Fix migration information update bug when linked github account (#10310)
* Fix bug on upgrade migrated reactions

* Fix migration information update bug when linked github account

Co-authored-by: zeripath <art27@cantab.net>
2020-02-17 19:42:13 -05:00
John Olheiser
e76a64dda1
Inject SVG sprite via ajax (#10320)
* AJAX SVG
* Fix PWA
* Remove unused PWA assets

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-Authored-by: silverwind <me@silverwind.io>
2020-02-17 23:11:59 +00:00
zeripath
05c1f2b45c
Create Changelog for v1.11.1 release (#10286) (#10321)
* Create Changelog
* Update CHANGELOG.md
* Include

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-17 21:43:20 +00:00
zeripath
e96f3542d0
Set the initial commit status to Success otherwise it will always be Pending (#10317)
The commit status code has a bug whereby setting the initial status to Pending means you can never have the status of Success - it should be set to Success.
2020-02-17 20:22:36 +00:00
zeripath
314740e215
Truncate long commit message header (#10301)
* Truncate long commit message header

* Fix overflow in view commit table

* Use @media less

* Further improvements

* Fix the commit message on small screens

* adjust width of minimal table
2020-02-17 19:45:55 +02:00
mrsdizzie
b5f28d154d
Don't manually replace whitespace during render (#10291)
* Don't manually replace whitespace during render

For historical reasons Gitea manually alters the urlPrefix and replaces
a whitespace with a +. This Works for URLs, but we're also passing
urlPrefix to git calls and adding the + is breaking the tree path.

Goldmark will automatically convert a white space to the proper %20, so
we should leave the string as is which lets us pass it to git unmodified
and then let Goldmark fix it.

Also fixed separate bug in URLJoin I noticed while testing where it will
silently discard sections of a path that have # in them (possibly
others). We should just escape it first.

Fixes 10156

* Escape elems as well

* Revert "Escape elems as well"

This reverts commit 8bf49596fee6fac4d9da256cd1e90a0ec0183671.

* restart ci

* remove changes to URLJoin

* restart ci

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-17 07:46:51 +02:00
GiteaBot
7af6f8b465 [skip ci] Updated translations via Crowdin 2020-02-16 21:43:17 +00:00
zeripath
8bba797252
v1.10.4 Changelog (#10294) (#10306)
* v1.10.4 Changelog

* Add backport identifier for #10261

* Update CHANGELOG.md entry for #9884

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-16 16:38:24 -05:00
Antoine GIRARD
5a46ec647b
fix: set explicit POSTGRES_PASSWORD for pgsql on drone CI (#10302) 2020-02-16 22:46:29 +02:00
Antoine GIRARD
cdda5c4b90
ui: better mobile review-box sizing (#10297) 2020-02-16 22:44:52 +02:00
Antoine GIRARD
9bada628f2
make: add release-sources (#10295)
* make: add release-sources

* make: release-sources exclude .git and make_evidence
2020-02-16 12:53:02 -05:00
Antoine GIRARD
df758f3cc9
make/pr: enforce vendor for run (#10296) 2020-02-16 16:30:09 +00:00
techknowlogick
c0bc9871be
Blacklist manifest.json & milestones user (#10292)
Fix #10290
2020-02-16 02:56:49 -05:00
zeripath
791b109d6f
Notification: queue ui.go notification-service (#10281)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-15 19:29:43 -05:00
Gary Kim
5563d56a32
Update static resources documentation (#10270)
Signed-off-by: Gary Kim <gary@garykim.dev>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2020-02-16 01:00:40 +02:00
GiteaBot
78859ba274 [skip ci] Updated translations via Crowdin 2020-02-15 18:47:31 +00:00
zeripath
88986746d5
Fix Workerpool deadlock (#10283)
* Prevent deadlock on boost

* Force a boost in testchannelqueue
2020-02-15 18:44:58 +00:00
guillep2k
15614a8368
Divide GetIssueStats query in smaller chunks (#10176)
* Divide GetIssueStats query in smaller chunks

* Skip chunking if count is low enough

* Fix lint

* Define maxQueryParameters

* Remove absMaxQueryParameters because of lint

* Restart CI

* Restart CI

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-15 11:51:25 +01:00
guillep2k
7e920703f9
Move fixture generation to contrib and add test (#10277)
* Add fixture gen tool and fix "access" test

* Close file before exiting

* Add missing repo_unit for repo id: 5

* Fix count on TestAPIOrgRepos

* Generate access fixture from contrib and add test

* Remove old access fixture generation

* Fix lint

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-02-15 10:59:43 +02:00
guillep2k
62a1322cf9
Fix "access" fixtures and tests (#10247)
* Add fixture gen tool and fix "access" test

* Close file before exiting

* Add missing repo_unit for repo id: 5

* Fix count on TestAPIOrgRepos

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-02-15 12:29:06 +08:00
GiteaBot
a97fe76950 [skip ci] Updated translations via Crowdin 2020-02-14 12:44:14 +00:00
Lauris BH
a1d796f521
Index code and stats only for non-empty repositories (#10251)
Fix test and switch to unique queue

Fix MySQL support when deleting old statistics
2020-02-14 13:42:30 +01:00
GiteaBot
ff261dafc4 [skip ci] Updated translations via Crowdin 2020-02-14 03:09:58 +00:00
John Olheiser
41d61d470e
Update discord link (#10263) 2020-02-13 22:07:10 -05:00
Lunny Xiao
5dbf36f356
Issue search support elasticsearch (#9428)
* Issue search support elasticsearch

* Fix lint

* Add indexer name on app.ini

* add a warnning on SearchIssuesByKeyword

* improve code
2020-02-13 14:06:17 +08:00
Lunny Xiao
17656021f1
Fix reply on code review (#10227)
Co-authored-by: zeripath <art27@cantab.net>
2020-02-13 13:22:15 +08:00
David Svantesson
9ff4e1d2d9
Add API branch protection endpoint (#9311)
* add API branch protection endpoint

* lint

* Change to use team names instead of ids.

* Status codes.

* fix

* Fix

* Add new branch protection options (BlockOnRejectedReviews, DismissStaleApprovals, RequireSignedCommits)

* Do xorm query directly

* fix xorm GetUserNamesByIDs

* Add some tests

* Improved GetTeamNamesByID

* http status created for CreateBranchProtection

* Correct status code in integration test

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-02-12 23:19:35 +00:00
GiteaBot
908f8952be [skip ci] Updated translations via Crowdin 2020-02-12 19:33:28 +00:00
techknowlogick
7791d904b4
Add note about which version embedded tool is implemented (#10255) 2020-02-12 14:30:48 -05:00
Lunny Xiao
3d69bbd58f
Fix queue pop error and stat empty repository error (#10248)
* Fix queue pop error and stat empty repository error

* Fix error
2020-02-12 18:12:27 +08:00
Lunny Xiao
83a8944fcf
Add feishu webhook support (#10229)
Add feishu webhook support
2020-02-12 08:48:28 +00:00
silverwind
ea7ad382e7
fix margin on attached segments with headers (#10235)
Fixes: https://github.com/go-gitea/gitea/issues/10210

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-11 22:38:32 -05:00
GiteaBot
685a0037d2 [skip ci] Updated translations via Crowdin 2020-02-12 01:54:51 +00:00
John Olheiser
d67e9b9629
SVG Octicon fixes (#10237)
* SVG fixes

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Colorize span->svg only

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* @silverwind suggestions

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Alphabetical

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Convert suburl and staticPrefix to window.config

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* De-structure

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-11 20:53:18 -05:00
jaqra
2399bad1f1
fix label menu text on miletone issues (#10242)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-12 01:07:07 +01:00
zeripath
1125d1453b
Stop hanging issue indexer initialisation from preventing shutdown (#10243)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-12 00:21:20 +01:00
jaqra
6c823c7560
fix filter label emoji width (#10241) 2020-02-11 22:25:41 +01:00
James Lakin
54af3c90c7
Fix issue sidebar menus having an infinite height (#10239)
* Revert "Limit label list height on edit issue page"

* Fix issue sidebar menus having an infinite height
2020-02-11 22:40:47 +02:00
silverwind
d9c79986ea
add TAGS variable prereq on make targets that use it (#10219)
Write out TAGS to .make_evidence/tags and compare it to the previous
invocation. If they differ, insert the evidence file into the prereqs
of targets that use TAGS. I made it .PHONY so it always builds.

I did not include the prereq on release tasks, asssuming the will always
do a clean build.

Fixes: https://github.com/go-gitea/gitea/issues/10196

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-11 20:42:03 +01:00
6543
bfd62b6f01
update vendor keybase/go-crypto (#10234) 2020-02-11 20:58:23 +02:00
John Olheiser
86fdba177a
Add Octicon SVG spritemap (#10107)
* Add octicon SVG sprite

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Static prefix

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* SVG for all repo icons

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* make vendor

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Swap out octicons

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move octicons to top of less imports

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix JS

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Definitely not a search/replace

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Missed regex

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move to more generic calls and webpack

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* make svg -> make webpack

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove svg-sprite

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Missed a test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove svg from makefile

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Suggestions

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Attempt to fix test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Update tests

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Revert timetracking test

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Swap .octicon for .svg in less

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add aria-hidden

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Replace mega-octicon

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix webpack globbing on Windows

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Revert

Co-Authored-By: silverwind <me@silverwind.io>

* Fix octions from upstream

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix Vue and missed JS function

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add JS helper and PWA

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Preload SVG

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-11 12:02:41 -05:00
GiteaBot
e704f7fae7 [skip ci] Updated translations via Crowdin 2020-02-11 15:44:26 +00:00
jaqra
602b29e965
Limit label list height on edit issue page (#10216) 2020-02-11 16:41:48 +01:00
Lauris BH
ad2642a8aa
Language statistics bar for repositories (#8037)
* Implementation for calculating language statistics

Impement saving code language statistics to database

Implement rendering langauge stats

Add primary laguage to show in repository list

Implement repository stats indexer queue

Add indexer test

Refactor to use queue module

* Do not timeout for queues
2020-02-11 11:34:17 +02:00
zeripath
37892be635
Restore graceful restart on SIGHUP (#10224)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-11 13:29:45 +08:00
GiteaBot
b3255921af [skip ci] Updated translations via Crowdin 2020-02-10 23:07:55 +00:00
Lauris BH
852aeeffc0
Fix commit between two commits calculation if there is only last commit (#10225) 2020-02-11 01:04:43 +02:00
GiteaBot
26eaebf4de [skip ci] Updated translations via Crowdin 2020-02-10 19:26:08 +00:00
guillep2k
069a96ebe2
Improve 404 error message (#10214) 2020-02-10 21:23:35 +02:00
John Olheiser
b5418a6443
Changelog 1.11.0 (#10204) (#10211)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-10 11:16:31 -05:00
zeripath
9789e0ad53
Only show conflicted files if not merged (#10197)
* Only show conflicted files if not merged

* try again

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-09 21:53:41 -05:00
zeripath
875c5e1305 Only check for conflicts/merging if the PR has not been merged in the interim (#10132)
* Only check for merging if the PR has not been merged in the interim

* fixup! Only check for merging if the PR has not been merged in the interim

* Try to fix test failure

* Use PR2 not PR1 in tests as PR1 merges automatically

* return already merged error

* enforce locking

* enforce locking - fix-test

* enforce locking - fix-testx2

* enforce locking - fix-testx3

* move pullrequest checking to after merge

This might improve the chance that the race does not affect us but does not prevent it.

* Remove minor race with getting merge commit id

* fixup

* move check pr after merge

* Remove unnecessary prepareTestEnv - onGiteaRun does this for us

* Add information about when merging occuring

* fix fmt

* More logging

* Attempt to fix mysql

* Try MySQL fix again

* try again

* Try again?!

* Try again?!

* Sigh

* remove the count - perhaps that will help

* next remove the update id

* next remove the update id - make it updated_unix instead

* On failure to merge ensure that the pr is rechecked for conflict errors

* On failure to merge ensure that the pr is rechecked for conflict errors

* Update models/pull.go

* Update models/pull.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-02-10 01:09:31 +02:00
6543
585316f3bf
[API] let admin check org membership on other users (#10201)
* fix

* fix lint on master

Co-authored-by: zeripath <art27@cantab.net>
2020-02-09 23:54:53 +02:00
GiteaBot
e414fc18a9 [skip ci] Updated translations via Crowdin 2020-02-09 20:20:33 +00:00
Lauris BH
fe00886bef
Fix followers and following tabs in profile (#10202) 2020-02-09 22:18:01 +02:00
6543
e273817154
[API] Fix inconsistent label color format (#10129)
* update and use labelColorPattern

* add TestCases

* fix lint

* # optional for templates

* fix typo

* some more

* fix lint of **master**
2020-02-09 14:33:03 +00:00
mavenbline
74a4a1e17f
Fix invalid repo urls after change username (#10150)
* Fix invalid repo urls after change username

* Update user.go

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-08 16:59:40 +02:00
jaqra
7d8a2d05cf
Allow emoji on popup label (#10166)
* allow emoji on popup label

* Make emojify work

* Remove unnecessary class

Co-Authored-By: silverwind <me@silverwind.io>

Co-authored-by: silverwind <me@silverwind.io>
2020-02-08 12:48:17 +01:00
Antoine GIRARD
632df9b996
Improve make PR (force build and help message) (#10178)
* Force build of assets

* Add make pr to make help

* apply @jolheiser suggestion

Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com>

* Run clean-all before make pr

Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com>
2020-02-08 01:14:43 +01:00
silverwind
4721d45c2a
move clipboard.js to npm/webpack (#10183)
- created lazy-loaded webpack chunk for clipboard.js
- upgraded clipboard.js from 1.5.9 to 2.0.4
- parallelize initialization of all lazy-loaded features

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-08 00:03:42 +01:00
Lars Lehtonen
0754ceca5b
modules/log: remove noop written variables (#10182)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-07 21:35:30 +01:00
6543
11789aebb0
Fix code-expansion arc-green theme bug (#10180)
* fix code-expansion theme bug

* working solution without important

* no new color

* the midle
2020-02-07 20:19:50 +01:00
GiteaBot
11995bf2ee [skip ci] Updated translations via Crowdin 2020-02-07 17:11:26 +00:00
silverwind
fdf6d25915
Reorganize frontend files and tooling (#10168)
- move "vendor" files to js/vendor and less/vendor
- move swagger to js/standalone (meant for standalone pages)
- move gitgraph to features and streamline its loading
- add linting configs to webpack dependencies in make
- set ignored files for eslint/stylelint directly in their configs

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-07 18:09:30 +01:00
James Lakin
6e6da2c276
Tweak locale to respect singular conflicting file message in P… (#10177)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-02-07 17:38:18 +01:00
John Olheiser
cf33a18a5c
Fix commit view (#10169)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-02-07 18:38:50 +08:00
zeripath
c512bfd09c
Prevent double waitgroup decrement (#10170)
* Prevent double waitgroup decrement
2020-02-07 09:08:09 +00:00
John Olheiser
d32b65ab68
Fix topics dropdown (#10167)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-02-07 07:46:09 +02:00
Antoine GIRARD
730f026c6e
make: improve make pr (#10165) 2020-02-06 23:40:27 +02:00
guillep2k
08c9160e71
Allow emoji on review head comments (#10159)
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-02-06 20:35:53 +02:00
guillep2k
727fc42db7
Fix issue/pull link (#10158) 2020-02-06 13:12:15 -05:00
silverwind
70dd3faad3
update JS dependencies (#10155)
result of `make npm-update`. no real notable changes, the breaking
change in styleline is Node.js 10 which we already require.
2020-02-05 21:22:21 -05:00
GiteaBot
77431599f6 [skip ci] Updated translations via Crowdin 2020-02-05 09:48:57 +00:00
John Olheiser
95013fde60
Fix push-create SSH bugs (#10145)
* Attempt to fix push-create SSH bugs

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Fix binding

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Invalid ctx

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-02-05 10:40:35 +01:00
GiteaBot
7dcd305424 [skip ci] Updated translations via Crowdin 2020-02-04 14:28:42 +00:00
6543
d4096ab6a2
Ensure DeleteUser is not allowed to Delete Orgs and visa versa (#10134)
* add check to DeleteUser

* add check to DeleteOrganization

* add Test

* remove redundancy (deleteOrg is only used in DeleteOrganization)

* Update models/org.go

Co-authored-by: zeripath <art27@cantab.net>
2020-02-04 16:27:18 +02:00
6543
b3c72a7c4a
[API] expose RepoOwner on Issue responce (#10126)
* add RepoOwner on issue api responce

* CI.restart()
2020-02-04 00:05:17 -05:00
James Lakin
3ff95cef60
Show if a PR has conflicting files on the PR lists (#10130)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-04 00:14:38 +02:00
Lauris BH
20c513be6e
Show download count info in release list (#10124)
* Show download count info in release list

* Use go-humanize
2020-02-03 21:50:37 +02:00
6543
ea50f60df2
Prevent DeleteUser API abuse (#10125)
* fix & co

* word suggestions from @jolheiser
2020-02-03 18:46:33 +02:00
GiteaBot
29151b90c6 [skip ci] Updated translations via Crowdin 2020-02-03 08:48:26 +00:00
Lunny Xiao
48ce135cc9
Move PushUpdateAddDeleteTags to repository module from models (#10106)
* Move PushUpdateAddDeleteTags to repository module from models

* Fix deadlock on sqlite
2020-02-03 09:47:04 +01:00
6543
e959d1a48b
working part of #9998 (#10114)
Co-authored-by: zeripath <art27@cantab.net>
2020-02-03 10:21:50 +08:00
zeripath
2c903383b5
Add Unique Queue infrastructure and move TestPullRequests to this (#9856)
* Upgrade levelqueue to version 0.2.0

This adds functionality for Unique Queues

* Add UniqueQueue interface and functions to create them

* Add UniqueQueue implementations

* Move TestPullRequests over to use UniqueQueue

* Reduce code duplication

* Add bytefifos

* Ensure invalid types are logged

* Fix close race in PersistableChannelQueue Shutdown
2020-02-02 23:19:58 +00:00
zeripath
b4914249ee
Update aria-fixed semantic-dropdown to fomantic master (#10096)
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-02-02 17:28:00 -05:00
Lunny Xiao
bf1970d0bd
Improve push update options (#10105)
* Improve push update options

* fix test

* More refactor and fix lint

* fix lint

* Fix lint

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-02 15:27:34 -05:00
guillep2k
70aa629ae7
Add warning when using relative path to app.ini (#10104)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-02 18:20:20 +02:00
zeripath
391e0638cc
Check if go exists before generating the GOPATH (#10100)
* Check if go exists before generating the GOPATH

* Move export PATH into Go protected section

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-02-01 21:43:35 -05:00
guillep2k
bcb52aef09
Implement "embedded" command to extract static resources (#9982)
* draft

* Implement extract command

* Fix nits and force args on extract

* Add !bindata stub, support Windows, fmt

* fix vendored flag

* Remove leading slash for matching

* Add docs

* Fix typos

* Add embedded view command

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-02-02 10:17:44 +08:00
zeripath
9b9dd19d7d
Fix broken FlushAll (#10101)
* go function contexting is not what you expect

* Apply suggestions from code review

Co-Authored-By: Lauris BH <lauris@nix.lv>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-02-01 23:43:50 +00:00
guillep2k
72f9cfc8f0
Use a file as make evidence for fomantic instead of a directory (#10032)
* Use evidence file as dependency instead of dir

* fix eol

* Update .gitignore

Co-Authored-By: silverwind <me@silverwind.io>

* Use FOMANTIC_SOURCES to establish dependencies as per @silverwind

Co-authored-by: silverwind <me@silverwind.io>
2020-02-01 20:15:32 +00:00
Lunny Xiao
ce7062a422
Cache last commit to accelerate the repository directory page visit (#10069)
* Cache last commit to accelerate the repository directory page visit

* Default use default cache configuration

* add tests for last commit cache

* Simplify last commit cache

* Revert Enabled back

* Change the last commit cache default ttl to 8760h

* Fix test
2020-02-01 19:11:32 +00:00
silverwind
046bb05979
remove VERSIONS file (#10070)
It serves no clear purpose and is not used anywhere to my knowledge.
Also, it's name to version mapping doesn't work with bundling.
2020-02-01 18:25:27 +00:00
guillep2k
131baa26be
Accept punctuation after simple+cross repository issue references (#10091)
* Support references ending in , . and ;

* Accept :;, in simple refs; fix 2+ consecutive refs

* Include cross-repository references

* Add ?!, fix spacing problem
2020-02-01 18:01:30 +00:00
zeripath
f8f6adc2a6
Add button to revert SimpleMDE to plain textarea (#10099) 2020-02-01 17:06:57 +00:00
silverwind
6dcf110628
enable babel-loader cache (#10083)
this speeds up repeated webpack builds by around 20%. It will use the
default cache directory `node_modules/.cache/babel-loader`.

Also added cache invalidation to workaround https://github.com/babel/babel-loader/issues/690
2020-02-01 15:12:41 +00:00
Lunny Xiao
3ccd271081
Fix branch page pull request title and link error (#10092)
* Fix branch page pull request title and link error

* Fix ui
2020-02-01 15:54:25 +02:00
Lunny Xiao
107a694fd6
Fix IsErrPullClosed (#10093) 2020-02-01 11:24:26 +00:00
6543
8d43563a32
[BugFix] [API] Pull.API.Convert: Only try to get HeadBranch if HeadRepo exist (#10029)
* only try to get HeadBranch if HeadRepo exist

* impruve

* no nil error

* add TEST

* correct error msg
2020-01-31 16:13:51 -05:00
6543
13bc82009c
API endpoint for repo transfer (#9947)
* squash

* optimize

* fail before make any changes

* fix-header
2020-01-31 15:49:04 +00:00
guillep2k
d816f7018b
Remove migration support from versions earlier than 1.6.0 (#10026)
* Remove migration support from versions earlier than 1.6.0

* Remove unused functions

* Update gogs upgrade instructions

* Improve "latest" link as per @jolheiser

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-31 21:42:45 +08:00
Lauris BH
b3d8e2d4f7
Update topics repo count when deleting repository (#10051)
* Update topics repo count when deleting repository

* Add migration to fix incorrect data

* Optimize to use single update to recalculate values
2020-01-31 08:57:19 +02:00
6543
159732dcb7
update (#10079) 2020-01-31 07:01:32 +02:00
John Olheiser
6bb0f20456
Remove unused config on UI (#10078)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-31 00:18:31 +02:00
GiteaBot
68e4f4efc7 [skip ci] Updated translations via Crowdin 2020-01-30 16:12:42 +00:00
Lunny Xiao
eac5142ac7
Fix leveldb test race (#10054)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-01-30 11:09:39 -05:00
silverwind
d7f4f87aaf
fix apple-touch-icon, regenerate images (#10065)
* fix apple-touch-icon, regenerate images

Fixed semi-transparent pixels of apple-touch-icon.png.

I had to manually exclude public/img/loading.png from the commit because
it's an APNG and one of the tools destroys the animation.

* exclude loading.png

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-30 08:05:40 +02:00
guillep2k
04cbdf5c08
Implement basic app.ini and path checks to doctor cmd (#10064)
* Add doctor check of app.ini paths

* Make /custom dir not mandatory

* Fix message and improve interface

* Update cmd/doctor.go

Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com>

* Apaise lint

* Isn't the linter a sweet? (1)

* Isn't the linter a sweet? (2)

* Isn't the linter a sweet?? (3)

* Restart CI

Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-30 10:00:27 +08:00
silverwind
35ada598cc
move jquery.are-you-sure to npm/webpack (#10063) 2020-01-29 21:16:55 +00:00
6543
169bb55ec6
[UI] Show pull icon on pull (#10061)
* make fmt
* show pull icon on pull
2020-01-29 18:54:34 +00:00
Lunny Xiao
e2c505f5ce
Add RACE_ENABLED=1 envs for make test* (#10055) 2020-01-29 15:43:07 +00:00
Lunny Xiao
79ce91fdde
Movde dependents on macaron from modules/setting (#10050)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-29 09:47:46 +02:00
Lunny Xiao
c09e020558
Fix milestone API state parameter unhandled (#10049)
* Fix milestone API state parameter unhandled

* Fix test
2020-01-29 08:36:32 +02:00
6543
f29c301040
Refactor api repo dir (#10048)
* mv migrate

* mv mirror

Co-authored-by: zeripath <art27@cantab.net>
2020-01-29 13:55:23 +08:00
zeripath
82a979707a
Update documentation for the go module era (#9751)
* Update documentation for the go module era

use go env instead of $GOPATH

Update instructions to just use git clone

Slight update to readme

Signed-off-by: Andrew Thornton <art27@cantab.net>

* fixup

* Apply suggestions from code review

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>
Co-Authored-By: Bagas Sanjaya <bagasdotme@gmail.com>

* Apply suggestions from code review

* Fix GOPATH settings

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Bagas Sanjaya <bagasdotme@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-01-28 21:30:02 -05:00
NiTRoeSE
db42a15fa0
add touch-icon with background (#10022)
* add touch-icon with background

...to prevent ugly glitch while minimize app to homescreen

* add / generate apple-touch-icon

* run make command

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-01-28 21:03:39 -05:00
zeripath
c01221e70f
Queue: Make WorkerPools and Queues flushable (#10001)
* Make WorkerPools and Queues flushable

Adds Flush methods to Queues and the WorkerPool
Further abstracts the WorkerPool
Adds a final step to Flush the queues in the defer from PrintCurrentTest
Fixes an issue with Settings inheritance in queues

Signed-off-by: Andrew Thornton <art27@cantab.net>

* Change to for loop

* Add IsEmpty and begin just making the queues composed WorkerPools

* subsume workerpool into the queues and create a flushable interface

* Add manager command

* Move flushall to queue.Manager and add to testlogger

* As per @guillep2k

* as per @guillep2k

* Just make queues all implement flushable and clean up the wrapped queue flushes

* cope with no timeout

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-28 20:01:06 -05:00
silverwind
7c84dbca4f
fix gitgraph commit hashes in dark theme (#10046)
because the CSS was lazy-loaded the rules in arc-green did not win.
included the css file in the main bundle to fix. the black dots can not
be fixed via CSS because they are drawn in a `<canvas>` element
unfortunately.
2020-01-28 23:22:39 +00:00
silverwind
b9690d7c0b move highlight.js to npm/webpack (#10011)
- introduced window.config to help with js-based lazy-loading
- adjusted webpack chunk naming to avoid 'vendors~name.js' that webpack
  defaults to for vendor chunks.
- added theme class to html and prefixed all selectors. this is
  neccesary so that the theme styles win over the lazy-loaded ones.

Co-authored-by: zeripath <art27@cantab.net>
2020-01-28 23:57:20 +02:00
Andy Harrison
d879353632 Minor typo fix (#10043) 2020-01-28 18:45:39 +00:00
John Olheiser
28216bde46 More expansions in template repositories (#10021)
* Super expansion
* Explain which features are in 1.11 vs 1.12
* Move imports

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-28 13:57:15 +00:00
zeripath
206a031b38
Ensure that feeds are appropriately restricted (#10018)
* Always limit results by what is accessible to the user

* Change signature of AccessibleRepoIDsQuery

* Ensure that user with ID <= 0 is handled

* Update models/repo_list.go
2020-01-28 11:39:37 +00:00
zeripath
797e6f8f4c
PRs: Move to use a temporary repo for pushing new prs (#10009)
* Move to use a temporary repo for pushing new prs
2020-01-28 10:23:58 +00:00
Lunny Xiao
c58edc7c78 Fix wiki raw view on sub path (#10002)
* Fix wiki raw view on sub path

* Add test for subpath wiki raw file

* Fix bug
2020-01-28 09:44:08 +00:00
Shashvat Kedia
a08175ac55 Repo name added to automatically generated commit message when mergin… (#9997)
* Repo name added to automatically generated commit message when merging pull request

* As per @lunny

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-28 08:29:30 +00:00
Lunny Xiao
e8860ef4f9 Some refactor on git diff and ignore getting commit information failed on migrating pull request review comments (#9996)
* Some refactor on git diff and ignore getting commit information failed on migrating pull request review comments

* fix test

* fix lint

* Change error log to warn
2020-01-28 08:02:03 +00:00
silverwind
1019913eab move CSS build to webpack (#9983)
- added new 'make webpack' target
- deprecated 'make js' and 'make css'
- extend webpack config to load the less files
- updated docs

I had to rename the source file of `arc-green.less` to avoid generating
a useless JS entrypoint via webpack-fix-style-only-entries which would
not work with different source/destination filenames. I hear that there
should be cleaner solutions possible once we upgrade to Webpack 5.

Co-authored-by: zeripath <art27@cantab.net>
2020-01-28 07:30:39 +00:00
GiteaBot
4377e14304 [skip ci] Updated translations via Crowdin 2020-01-27 22:38:55 +00:00
mrsdizzie
52952d9f0f Style blockquote for default issue mail template (#10024)
Style blockquotes as one might expect for html email to disinguish them
from other text
2020-01-27 22:35:34 +00:00
GiteaBot
3c8a5d8783 [skip ci] Updated translations via Crowdin 2020-01-27 16:27:13 +00:00
6543
88c3ccb897 trim whitespace of MilestoneName at creation/rename (#10017) 2020-01-27 16:23:21 +00:00
zeripath
51f6a7ab10
On merge of already closed PR redirect back to the pulls page (#10010)
* On merge of already closed PR redirect back to the pulls page

* More redirects
* As per @6543

Co-Authored-By: 6543 <6543@obermui.de>
2020-01-27 10:26:53 +00:00
silverwind
03cb168127 add apple-touch-icon (#10006)
fixes: https://github.com/go-gitea/gitea/issues/10003

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-27 13:10:57 +08:00
zeripath
48abe41ea8
Generate Bindata iff TAGS="bindata" and not up-to-date (#10004)
* Only generate bindata if necessary

* Only generate bindata if they are not up-to-date

* generate a hash of the fileinfo and use that to keep up-to-date

* Newer test is redundant

* handle missing bindata and clean

* Only update hash after successful write

* switch to sha1 hash

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-01-27 01:05:38 +00:00
zeripath
d087f4fb73
Sign: Handle ErrTwoFactorNotEnrolled correctly (#10008) 2020-01-26 23:44:12 +00:00
zeripath
20d637a0f8
Enforce tests do not change files in source tree (#9625) 2020-01-26 20:07:12 +00:00
silverwind
6a5e8d0d4f enable fomantic api module (#9994)
Fixes: #9992
2020-01-26 18:26:04 +00:00
silverwind
c640a1818a add explicit dimensions to navbar avatar (#9986)
* add explicit dimensions to navbar avatar

this prevents a temporary layout change when navigating between
pages with cache disabled.

* also add dimensions on frontpage

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-26 18:13:38 +02:00
silverwind
87e1438005 avoid useless fomantic rebuilds (#9999)
the `fomantic` target for some reason does sometimes not update the
timestamp on the directory, leading to useless rebuild. Manually update
the timestamp at the end of the build to avoid this and also added the
same to js/css targets.
2020-01-26 11:31:12 +00:00
silverwind
fd094eea95 fix commit view JS features, reimplement folding (#9968)
* fix commit view JS features, reimplement folding

File content folding was not working so I reimplemented it in a saner
way. Then I noticed the issue was actually because of missing JS
libraries (seen on the console of every commit with error
'SimpleMDE is not defined').

Fixed the libraries. I think the reimplementation is worth to keep.

* add .closest polyfill

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-26 08:17:25 +00:00
Lunny Xiao
8d51f28ba0
Fix wrong paging on org members (#9990) 2020-01-26 15:32:53 +08:00
Lauris BH
59510d6227
Change font to Roboto to support more charsets (#9803) 2020-01-25 23:47:42 +02:00
silverwind
1703a63da6 fix browser warnings related to crossorigin preload (#9984) 2020-01-25 23:18:31 +02:00
GiteaBot
a83c373641 [skip ci] Updated translations via Crowdin 2020-01-25 19:02:32 +00:00
silverwind
75a124b449 remove loadCSS and preload woff2 icon fonts (#9976)
loadCSS was used as a polyfill for rel=preload but it seems we only used
it on a single CSS file which did not help much. Changed the icon CSS to
a blocking load and preload the woff2 variants which does work in modern
browsers (Firefox currently needs the network.preload about:config
setting but should gain proper support soon).

Co-authored-by: zeripath <art27@cantab.net>
2020-01-25 20:58:26 +02:00
silverwind
15af6bec60 combine make calls on drone (#9979)
* combine make calls on drone

combine most make calls on drone into one command. this should give a
speedup of about 5-15 seconds per make invocation because make only
needs to resolve file globs once.

* combine timeout calls as well
2020-01-25 16:42:38 +00:00
GiteaBot
f1dd38b4f5 [skip ci] Updated translations via Crowdin 2020-01-25 14:50:55 +00:00
guillep2k
1b4357a2a1 Fix regexp ranges (#9977) 2020-01-25 14:49:47 +00:00
GiteaBot
cb8f0c22a0 [skip ci] Updated translations via Crowdin 2020-01-25 13:22:15 +00:00
Antoine GIRARD
c6edb25fe2 chore: update default version (#9916)
* chore: update default version

* use develop

Co-Authored-By: 6543 <6543@obermui.de>

* Update main.go

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-01-25 13:21:22 +00:00
silverwind
8ca07305fb make node_modules a order-only prerequisite (#9923)
* make node_modules a order-only prerequisite

Package installations and our fomantic step results in changes inside
node_modules which lead to make triggering that target unnecessarily.

Moved all node_modules prerequisites to order-only which will make skip
the timestamp check on in and eliminate useless npm calls.

Changes in package-lock.json will still result in reinstallation so
node_modules should stay consistent.

* revert change to clean-all
2020-01-25 11:44:36 +00:00
Lunny Xiao
a67c06ce90 Sanitize credentials in mirror form (#9975) 2020-01-25 10:57:42 +00:00
silverwind
5b17bb8f3d add css extraction and minification to webpack (#9944)
This changes the CSS output of webpack to output to the public/css
directory instead of inling CSS in JS. This enables CSS minification and
autoprefixer based on browserslist which would otherwise not be
possible.

The result of this change is two new output files currently:

- public/css/swagger.css
- public/css/gitgraph.css

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-25 16:41:34 +08:00
GiteaBot
89f7dcb13d [skip ci] Updated translations via Crowdin 2020-01-25 06:20:28 +00:00
guillep2k
a47cfdf346 Fix crowdin update script (#9969)
* Fix crowdin update script

* Refine the script to be specific about what it should change

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-25 01:19:35 -05:00
GiteaBot
9d5756989a [skip ci] Updated translations via Crowdin 2020-01-25 02:49:08 +00:00
Lunny Xiao
f2d12f7b03
Fix pull view when head repository or head branch missed and close related pull requests when delete head repository or head branch (#9927)
* fix pull view when head repository or head branch missed and close related pull requests when delete branch

* fix pull view broken when head repository deleted

* close pull requests when head repositories deleted

* Add tests for broken pull request head repository or branch

* fix typo

* ignore special error when close pull request

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-25 10:48:22 +08:00
guillep2k
ee26f042c4 Fix file rename/copy not supported by indexer (#9965)
Co-authored-by: zeripath <art27@cantab.net>
2020-01-24 18:26:49 -05:00
zeripath
700611cc18
Switch to use -f instead of -F for sendmail (#9961)
Fix #9385
2020-01-24 22:59:39 +00:00
John Olheiser
88c212a8a3 Fix image (#9962)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-24 21:23:10 +00:00
SpaWn2KiLl
1f01f53c53 API add/generalize pagination (#9452)
* paginate results

* fixed deadlock

* prevented breaking change

* updated swagger

* go fmt

* fixed find topic

* go mod tidy

* go mod vendor with go1.13.5

* fixed repo find topics

* fixed unit test

* added Limit method to Engine struct; use engine variable when provided; fixed gitignore

* use ItemsPerPage for default pagesize; fix GetWatchers, getOrgUsersByOrgID and GetStargazers; fix GetAllCommits headers; reverted some changed behaviors

* set Page value on Home route

* improved memory allocations

* fixed response headers

* removed logfiles

* fixed import order

* import order

* improved swagger

* added function to get models.ListOptions from context

* removed pagesize diff on unit test

* fixed imports

* removed unnecessary struct field

* fixed go fmt

* scoped PR

* code improvements

* code improvements

* go mod tidy

* fixed import order

* fixed commit statuses session

* fixed files headers

* fixed headers; added pagination for notifications

* go mod tidy

* go fmt

* removed Private from user search options; added setting.UI.IssuePagingNum as default valeu on repo's issues list

* Apply suggestions from code review

Co-Authored-By: 6543 <6543@obermui.de>
Co-Authored-By: zeripath <art27@cantab.net>

* fixed build error

* CI.restart()

* fixed merge conflicts resolve

* fixed conflicts resolve

* improved FindTrackedTimesOptions.ToOptions() method

* added backwards compatibility on ListReleases request; fixed issue tracked time ToSession

* fixed build error; fixed swagger template

* fixed swagger template

* fixed ListReleases backwards compatibility

* added page to user search route

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-24 14:00:29 -05:00
GiteaBot
333401e0fd [skip ci] Updated translations via Crowdin 2020-01-24 18:03:57 +00:00
guillep2k
dbd1fae618 Fix repo indexer not updating upon push (#9957)
* Fix check for push on default branch

* restart CI

Co-authored-by: zeripath <art27@cantab.net>
2020-01-24 20:00:49 +02:00
John Olheiser
514be723b2 Update migration instructions (#9955)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-24 14:23:38 +00:00
guillep2k
ad94a94114 Fix activity count in TestRepoActivity (#9959)
* Fix activity count

* Fix comment
2020-01-24 13:06:40 +00:00
Lunny Xiao
f6067a8465 Migrate reviews when migrating repository from github (#9463)
* fix typo

* Migrate reviews when migrating repository from github

* fix lint

* Added test and migration when external user login

* fix test

* fix commented state

* Some improvements

* fix bug when get pull request and ref original author on code comments

* Fix migrated line; Added comment for review

* Don't load all pull requests attributes

* Fix typo

* wrong change copy head

* fix tests

* fix reactions

* Fix test

* fix fmt

* fix review comment reactions
2020-01-23 19:28:15 +02:00
silverwind
bfdfa9a8b3 move fomantic target, update 'make help' (#9945)
I'd like to run webpack without fomantic in the prereqs so move it to
the `generate` target.

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-23 00:53:57 -05:00
zeripath
c8d7ae1ee3
Make archive prefixing configurable with a global setting (#9943)
* Allow archive prefix setting

* Update copyright

* Update copyright
2020-01-22 23:46:46 +00:00
GiteaBot
608cd58db6 [skip ci] Updated translations via Crowdin 2020-01-22 21:26:56 +00:00
techknowlogick
e6730c9f18
Frontport: Fix regression with tag test running (#9941) (#9942) 2020-01-22 16:25:41 -05:00
GiteaBot
2ff2cddd16 [skip ci] Updated translations via Crowdin 2020-01-22 20:57:03 +00:00
John Olheiser
9d0930d5c6 Changelog 1.11.0-rc2 (#9853) (#9940)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2020-01-22 15:51:38 -05:00
John Olheiser
53f9dbfc7b Don't convert ellipsis in markdown (#9905)
* Don't convert ellipsis

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Formatting

Co-Authored-By: zeripath <art27@cantab.net>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-22 16:30:20 +01:00
guillep2k
4b67989c9d Remove statements not supported by SQLExpress from migration te… (#9929)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-22 15:09:35 +01:00
Antoine GIRARD
eed361638a Improve stale message (#9920)
* Improve stale nessage

* Update .github/stale.yml

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-01-22 12:55:27 +02:00
Lauris BH
3185a13ea5
Check if diff actually contains sections when rendering (#9926) 2020-01-22 09:20:58 +02:00
silverwind
c7fe028db4 misc webpack tweaks (#9924)
- reduce verbosity during build
- use array form `use` to allow easier extension
- disable uninteresting source maps
- disable symlink resolution for a speedup

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-22 14:35:29 +08:00
Lunny Xiao
81daf26878
Fix wrong hint when status checking is running on pull request view (#9886)
* Fix wrong hint when status checking is running on pull request view

* fix lint

* fix test

* fix test

* fix wrong tmpl

* fix import

* rename function name
2020-01-22 11:46:04 +08:00
bobemoe
cca13ae2ac add remote ip to the invalid credentials error message (#9918) 2020-01-21 17:51:39 -05:00
John Olheiser
38a6b11015 Fix RocketChat (#9908)
* Fix RocketChat??

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Don't send attachment for repo create/delete

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Make fmt

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-21 21:29:24 +01:00
zeripath
a315e091e4
Do not try to recreate ldap user if they are already created (#9900)
* Do not try to recreate ldap user if they are already created

* just remove autoregister

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-21 18:49:30 +00:00
Lunny Xiao
ad3a9577a8 fix wrong font url on semantic-ui (#9917)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-21 18:07:34 +00:00
silverwind
2982afe6b4 move jquery and jquery-migrate to npm/webpack (#9813)
Currently, this needs to be its own chunk because fomantic depends
on jQuery being present. The next step is to move fomantic to webpack
too after which we can combine the index,fomantic and jquery files into
one.

jquery-migrate is still neccessary because our ancient version of Dropzone
seems to break without it. I imagine it can be removed after a Dropzone
upgrade.
2020-01-21 19:32:33 +02:00
GiteaBot
0e8b27afe8 [skip ci] Updated translations via Crowdin 2020-01-21 16:27:57 +00:00
Antoine GIRARD
99aad09bd0
Filter locales under 25% (#9893)
* Create update-locales.sh

* Update .drone.yml

* fix file perms +x
2020-01-21 17:26:17 +01:00
zeripath
8cb9b2f016
Update queue_redis.go (#9910)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-21 12:50:27 +00:00
guillep2k
8da863ed15 Fix missing defer prepareTestEnv(t)() on some tests (#9906)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-21 12:40:21 +01:00
GiteaBot
3f1c8970ec [skip ci] Updated translations via Crowdin 2020-01-21 10:21:24 +00:00
Brad Albright
2f7a747e4f Fixed repo link in generated comment for cross repository dependency (#9863)
* fixed link to issue in issue comments after adding/removing a dependency, before links assumed the issue was in the same repository. also changed the format of the displayed issue since the issue will not necessarily be in the same repo

* based on pr comments, changed to use HTMLURL instead of piecing together the issue url, and added an if statement around the issue link display as a nil protection

* only showing repo name in dependency comment if the issue is from another repo

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-21 10:18:52 +00:00
Lunny Xiao
5cf241b312
Use npm to manage fomantic and only build needed components (#9561)
* Use npm to manage fomantic

* Only build needed semantic components

* Fix make

* Don't import fonts from google sites since we have loaded

* [misc] devendor fomantic-ui and rebuild upon src or config changes only

Signed-off-by: Jakob Ackermann <das7pad@outlook.com>

* Change sort alphabetically of semantic components

* Fix trailing slash

* fix makefile

* Remove dependency to gulp from package.json

* Fix something

* Simplife the makefile

* add missed fomantic compnent

Co-authored-by: Jakob Ackermann <das7pad@outlook.com>
2020-01-21 13:17:58 +08:00
GiteaBot
e7322a1138 [skip ci] Updated translations via Crowdin 2020-01-20 23:35:43 +00:00
David Svantesson
9bc8413534 Add documentation how to render PlantUML in code blocks. (#9894)
* Add documentation how to render plantuml in code blocks.

* Review comments

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-21 00:34:23 +01:00
zeripath
d730725e5c fix broken link (#9901)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-20 15:45:16 -05:00
Lunny Xiao
d92781bf94 Refactor repository check and sync functions (#9854)
Move more general repository functions out of models/repo.go
2020-01-20 20:01:19 +00:00
zeripath
27c6b8fc07 Add documentation to add Mermaid.js to Gitea (#9872)
* Add documentation to add mermaid to Gitea

* Update documentation

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-20 11:14:03 -05:00
GiteaBot
1920e5bcaf [skip ci] Updated translations via Crowdin 2020-01-20 15:46:46 +00:00
guillep2k
ad1b6d439f Add support for database schema in PostgreSQL (#8819)
* Add support for database schema

* Require setting search_path for the db user

* Add schema setting to admin/config.tmpl

* Use a schema different from default for psql tests

* Update postgres scripts to use custom schema

* Update to xorm/core 0.7.3 and xorm/xorm c37aff9b3a

* Fix migration test

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-20 16:45:14 +01:00
Lunny Xiao
6d6f1d568e Fix wrong permissions check when issues/prs shared operations (#9885)
* Fix wrong permissions check when issues/prs shared operations

* move redirect to the last of the function

* fix swagger

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-20 13:00:32 +01:00
Lauris BH
81cfe243f9
Add top author stats to activity page (#9615) 2020-01-20 12:07:30 +02:00
John Olheiser
7d7ab1eeae Issue/PR Context Popups (#9822)
* Add data-index attribute to issue anchors

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Init JS

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Add required data to anchor

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Finish popup

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Revert changes to html.go

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Better octicon contexts

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Split out popup function for re-use

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Style changes, test fixes, and cross-reference support

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Prefer em to px

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move label margin to base CSS

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move JS to separate file.

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move JS to features and fix module

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Remove query-string and hash

Co-Authored-By: silverwind <me@silverwind.io>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-19 23:39:21 -05:00
zeripath
c5014a7f2c Add option to prevent LDAP from deactivating everything on empty search (#9879)
* Add option to prevent LDAP from deactivating everything on empty search

* Update options/locale/locale_en-US.ini

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-20 11:47:39 +08:00
zeripath
54c2854cd2 Give the stdout on temp_repo error (#9871)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-20 09:32:47 +08:00
zeripath
dcf7e858cb Check user != nil before checking values (#9881)
* Check user != nil before checking values

* Handle autoAdmin
2020-01-19 18:49:55 -05:00
guillep2k
bec99507a4 Add missing columns to repository and user (#9861) 2020-01-19 22:27:44 +00:00
zeripath
948dec3d75
Allow hyphen in language name (#9873) 2020-01-19 21:36:00 +00:00
zeripath
fb8aea4eeb
Ensure that 2fa is checked on reset-password (#9857)
* Ensure that 2fa is checked on reset-password

* Apply suggestions from code review

Co-Authored-By: Lauris BH <lauris@nix.lv>

* Properly manage scratch_code regeneration

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-19 20:17:36 +00:00
zeripath
92d6bca41e
Ensure that 2fa is checked on reset-password (#9857)
* Ensure that 2fa is checked on reset-password

* Apply suggestions from code review

Co-Authored-By: Lauris BH <lauris@nix.lv>

* Properly manage scratch_code regeneration

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-19 20:17:12 +00:00
zeripath
1d7b7504d0
Make CertFile and KeyFile relative to CustomPath (#9868)
* Make CertFile and KeyFile relative to CustomPath

The current code will absolute CertFile and KeyFile against the current working directory. This is quite unexpected for users. This code makes relative paths absolute against the CustomPath.

Fix #4196

* Improve error reporting when reading certificates

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-01-19 19:07:44 +00:00
GiteaBot
1803b38efc [skip ci] Updated translations via Crowdin 2020-01-19 09:19:29 +00:00
techknowlogick
c437e8e930 run translations pipeline on arm server (#9865) 2020-01-19 10:17:57 +01:00
GiteaBot
20f6acc585 [skip ci] Updated translations via Crowdin 2020-01-19 06:44:47 +00:00
Lunny Xiao
f540d0ac87
Fix issues/pulls dependencies problems (#9842)
* Fix issues/pulls dependencies problems

* fix swagger and api param name

* fix js
2020-01-19 14:43:38 +08:00
David Svantesson
0641965860 Change won't sign information text to black. (#9843)
* Change won't sign information text to black.

* icon and text same color

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-18 12:30:35 +01:00
David Svantesson
aac8250b47 Explicitly refer to PR in squash-merge commit message in case of external tracker (#9844)
* Explicitly refer to PR in squash-merge commit message in case of external tracker

* documentation

Co-authored-by: zeripath <art27@cantab.net>
2020-01-18 12:40:43 +08:00
6543
fec1095f17 [Docs] add usefull info to REQUIRE_SIGNIN_VIEW (#9848) 2020-01-17 18:34:55 -05:00
6543
6140325e98 Changelog 1.10.3 (#9832) (#9850) 2020-01-17 17:03:07 -05:00
GiteaBot
5a02ed5894 [skip ci] Updated translations via Crowdin 2020-01-17 18:35:33 +00:00
Lunny Xiao
b641c68fee Improve notification pager (#9821)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-17 19:31:26 +01:00
6543
2f3a602b3c fix (#9836) 2020-01-17 22:37:46 +08:00
Lunny Xiao
737ea6d83c
Fix download file wrong content-type (#9825)
* Fix download file wrong content-type

* change the error text to be more precise

* fix test
2020-01-17 20:16:05 +08:00
GiteaBot
7c0570d214 [skip ci] Updated translations via Crowdin 2020-01-17 10:24:56 +00:00
Lunny Xiao
088759f180 Fix wrong identify poster on a migrated pull request when submi… (#9827) 2020-01-17 11:23:46 +01:00
David Svantesson
3c07d03c03 Add setting to set default and global disabled repository units. (#8788)
* Add possibility to global disable repo units.

* Add Default Repo Unit app.ini setting.

* Hide units

* Hide disabled repo units

* Minor fixes

* Indicate disabled units in team settings.

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: zeripath <art27@cantab.net>
2020-01-17 09:34:37 +02:00
6543
36943e56d6 Add "Update Branch" button to Pull Requests (#9784)
* add Divergence

* add Update Button

* first working version

* re-use code

* split raw merge commands and db-change functions (notify, cache, ...)

* use rawMerge (remove redundant code)

* own function to get Diverging of PRs

* use FlashError

* correct Error Msg

* hook is triggerd ... so remove comment

* add "branch2" to "user2/repo1" because it unit-test "TestPullView_ReviewerMissed" use it but dont exist jet :/

* move GetPerm to IsUserAllowedToUpdate

* add Flash Success MSG

* imprufe code
- remove useless js chage

* fix-lint

* TEST: add PullRequest ID:5
Repo: user2/repo1
Base: branch1
Head: pr-to-update

* correct comments

* make PR5 outdated

* fix Tests

* WIP: add pull update test

* update revs

* update locales

* working TEST

* update UI

* misspell

* change style

* add 1s delay so rev exist

* move row up (before merge row)

* fix lint nit

* UI remove divider

* Update style

* nits

* do it right

* introduce IsSameRepo

* remove useless check

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-17 08:03:40 +02:00
Lunny Xiao
9f40bb020e fix dump non-exist log directory (#9818) 2020-01-16 21:56:51 -05:00
silverwind
cc2916dc5a remove promise-polyfill (#9812)
promises are polyfilled by babel, it's no longer needed.
2020-01-16 22:52:07 +00:00
David Svantesson
18e0447b3f Fix admin handling at merge of PR (#9749)
* Admin shall be able to bypass merge checks.

* Repository admin should not bypass if merge whitelist is set.

* Add code comment about checks that PR are ready

* notAllOverrideableChecksOk->notAllOverridableChecksOk

* Fix merge, require signed currently not overridable.

* fix

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-16 23:01:22 +02:00
Lunny Xiao
d3468ed79f Fix compare (#9808)
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-16 21:59:07 +02:00
Antoine GIRARD
8dd5ab2a14 ci: simplify tag/release by always running coverage (#9774)
* ci: simplify tag/release by always running coverage

* use mod and vendor for unit test coverage

* remove not needed lfs for unit test
2020-01-16 19:21:35 +00:00
zeripath
c76c70a16c Move mailer to use a queue (#9789)
* Move mailer to use a queue

* Make sectionMap map[string]bool

* Ensure that Message is json encodable
2020-01-16 18:55:36 +01:00
6543
06cd3e03a2 [refactor] notify remove unused praram (#9804) 2020-01-16 17:24:20 +01:00
Antoine GIRARD
11885daaa0
tests: configure github remaining limit + read token (#9800)
* ci: configure remaining github limmit

* prepend with github since package is common to all migrations

* add RefreshRate

* Update github.go

* add missing space

* go fmt

* Read env variable GITHUB_READ_TOKEN for token

* Update .drone.yml
2020-01-16 16:15:44 +01:00
GiteaBot
fdb32ab0f8 [skip ci] Updated translations via Crowdin 2020-01-16 14:22:28 +00:00
Lunny Xiao
dbd89acf98 Remove unnecessary permissions load (#9796)
Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-16 15:18:30 +01:00
Moritz
f740943df4 Fix markdown anchor links (#9673)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-16 12:23:48 +01:00
Damien Cassou
c6a32ddb47 Update go-org to 0.1.9 (#9782)
* Update go-org to 0.1.9

What I did to generate this commit:

$ go get github.com/niklasfasching/go-org

* make vendor
2020-01-16 09:27:41 +01:00
6543
3ae5f8ef11 [Docs] Update Feature 'Reject unsigned commits' (#9793)
* update docs

* add link to feature
2020-01-16 01:43:02 -05:00
John Olheiser
176e7fb5d5 Fix push-to-create (#9772)
* Fix push-to-create

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Check URL path and service

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Send dummy payload on receive-pack GET

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* The space was actually a NUL byte

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Use real bare repo instead of manufactured payload

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-16 10:40:13 +08:00
silverwind
8716752d22 update supported browsers and add a few more (#9734)
Now includes Firefox ESR, Opera and a few more browser with usages
between 0.5% and 1%. defaults resolves to > 0.5%, last 2 versions, Firefox ESR, not dead.

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-16 01:28:03 +01:00
6543
665d7e91a8 Fix signing info on PR view if not signed in (#9788) 2020-01-15 22:55:25 +00:00
zeripath
e7923c4bc0 Fix missing unlock in uniquequeue (#9790) 2020-01-15 23:58:33 +02:00
Lunny Xiao
9343d2fc85 Fix missing msteam webhook on organization (#9781) 2020-01-15 13:38:44 -05:00
David Svantesson
f162a32604 Fix #9662 (#9767)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-15 14:18:02 +01:00
GiteaBot
3ac79b7101 [skip ci] Updated translations via Crowdin 2020-01-15 11:16:35 +00:00
Lunny Xiao
2b3e931cde Migrate reactions when migrating repository from github (#9599)
* Migrate reactions when migrating repository from github

* fix missed sleep

* fix tests

* update reactions when external user binding

* Fix test

* fix tests

* change the copy head

* fix test

* fix migrator add/delete reaction
2020-01-15 12:14:07 +01:00
GiteaBot
4e566df1c6 [skip ci] Updated translations via Crowdin 2020-01-15 09:56:33 +00:00
Bagas Sanjaya
3f1e062d21 err_admin_name_pattern_not_allowed String Clarification (#9731)
* err_admin_name_pattern_not_allowed clarification edit

* Apply suggestion from @zeripath

Context: username that provided as admin

Co-Authored-By: zeripath <art27@cantab.net>

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-15 10:53:30 +01:00
zeripath
66ee9b87f9 Add require signed commit for protected branch (#9708)
* Add require signed commit for protected branch

* Fix fmt

* Make editor show if they will be signed

* bugfix

* Add basic merge check and better information for CRUD

* linting comment

* Add descriptors to merge signing

* Slight refactor

* Slight improvement to appearances

* Handle Merge API

* manage CRUD API

* Move error to error.go

* Remove fix to delete.go

* prep for merge

* need to tolerate \r\n in message

* check protected branch before trying to load it

* Apply suggestions from code review

Co-Authored-By: guillep2k <18600385+guillep2k@users.noreply.github.com>

* fix commit-reader

Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
2020-01-15 09:32:57 +01:00
techknowlogick
6b1fa12359
use arm drone agent for docs (#9776) 2020-01-15 00:59:13 -05:00
GiteaBot
7e44995a51 [skip ci] Updated translations via Crowdin 2020-01-15 04:34:53 +00:00
Antoine GIRARD
203e063846 ci: move some integration tests on arm64 (#9747) 2020-01-14 23:33:54 -05:00
GiteaBot
324672106b [skip ci] Updated translations via Crowdin 2020-01-15 03:55:40 +00:00
Lunny Xiao
d32eac44b1 Move RepoWorkingPool to services/repository package (#9754)
* Move RepoWorkingPool to services/repository package

* Make repoWorkingPool private

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-15 04:14:50 +01:00
Antoine GIRARD
fd761708fe
ci: run notify on arm64 (#9762)
* ci: run notify on arm64

Free one jobs on amrd64

* Update .drone.yml

* Update .drone.yml

* Update .drone.yml

Based on: https://github.com/appleboy/drone-discord/blob/master/.drone.yml#L339

* improve trigger

Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-15 03:14:21 +01:00
GiteaBot
9eb6793576 [skip ci] Updated translations via Crowdin 2020-01-15 00:08:04 +00:00
zeripath
d171cd41b1
Fix #9752 (#9769) 2020-01-14 23:11:08 +00:00
John Olheiser
cd5a44d973 Fix milestones page (#9770)
Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-14 22:57:13 +01:00
John Olheiser
d89022c202 Fix SimpleMDE quote reply (#9757)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: zeripath <art27@cantab.net>
2020-01-14 21:47:38 +01:00
silverwind
f00961abe7 move swagger-ui to webpack/npm (#9714)
Created a second webpack output file for swagger-ui which is loaded on
the /api/swagger route. One notable difference is the absence of the
swagger favicon that was previously used which is now the gitea icon. I
see no easy way to restore that favicon, so I decided to not keep it.
2020-01-14 13:02:08 -05:00
6543
44de66bf50 [API] add endpoint to check notifications [Extend #9488] (#9595)
* introduce GET /notifications/new

* add TEST

* use Sprintf instead of path.Join

* Error more verbose

* return number of notifications if unreaded exist

* 200 http status for available notifications
2020-01-14 16:37:19 +01:00
Bagas Sanjaya
ce274d652f Add Privacy Policy and Terms of Service Page (#9513)
* Add privacy policy page and link

* Add TOS page and link

* Add update date

* [Docs] Add customizing PP and TOS

* Separate h2 user-generated content with its paragraph

* Reimplement Privacy Policy

The document is inspired from GitHub.

* Refactor to contrib

* [Docs] Mention how to add legal pages

* Reimplement Terms of Service

Adapted from GitHub

* Update revision date

* Rename to mark as sample file

* Apply suggestion from @sapk

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

* Apply suggestion from @sapk

Use absolute link instead

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

* Apply suggestion from @zeripath

Change `Last Updated` element to `<h4>`

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Close this `<li>` element instance

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Intentionally grammar fix

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Information grammar

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Cannot guarantee absolute security...

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Use `<h4>` element for last updated date

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Remove trailing `</p>` at the end of API clause

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Migrate privacy email domain to Your Gitea Instance

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestions from @zeripath

Remove `<p>` container for `<ol>` definitions

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestions from @zeripath

Remove `<p>` container that contain `<ol>` user-generated content

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestions from @zeripath

Remove `<p>` container for private repositories `<ol>` listing

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestions from @zeripath

Migrate remaining email domains to Your Gitea Instance

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Offer support

Co-Authored-By: zeripath <art27@cantab.net>

* Apply suggestion from @zeripath

Change "Your Gitea Instance" references to match your situation and Gitea project disclaimer

Co-Authored-By: zeripath <art27@cantab.net>

* Reword transmission data to reflect hosting on third-party provider

* Reword Analytics clause to reflects that not all Gitea instances deploy analytics OOTB

* Remove `<p>` container from account terms

* Migrate support email on tos to your-gitea-instance

* Reword Tracking and Analytics clause for OOTB case

* [Docs] Append privacy.html to cp destination

* Apply suggestion from @6543

Create or append to footer template

Co-Authored-By: 6543 <6543@obermui.de>

* Apply suggestion from myself

@6543 suggest replacing this `cp` line (which assumed that Gitea sources are available) with `wget` to GitHub raw link. At the time of writing this, this returned 404, but when this PR has been merged, this should get the actual page.

* Apply suggestions from @6543

1. Add gpg key to profile information
2. Add Git repos to list of User Personal Information
3. Comment out responsibility for sensitive information

Co-Authored-By: 6543 <6543@obermui.de>

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2020-01-14 14:34:40 +01:00
GiteaBot
a8da7b3b8c [skip ci] Updated translations via Crowdin 2020-01-14 12:54:26 +00:00
Antoine GIRARD
ebaf33873f
ci: use new mssql image (#9720)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-14 13:06:49 +01:00
GiteaBot
35efc7ba4f [skip ci] Updated translations via Crowdin 2020-01-14 10:31:54 +00:00
Lunny Xiao
7f869c061e Fix missing updated time on migrated issues and comments (#9744)
* Fix missing updated time on migrated issues and comments

* Fix testing and missing updated on migrating pullrequest

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-14 10:29:22 +00:00
Lunny Xiao
2677d071f9
Move newbranch to standalone package (#9627)
* Move newbranch to standalone package

* move branch functions to modules to avoid dependencies cycles

* fix tests

* fix lint

* fix lint
2020-01-14 11:38:04 +08:00
GiteaBot
bca367cecc [skip ci] Updated translations via Crowdin 2020-01-14 00:08:14 +00:00
guillep2k
565eb1811c Add test for git + git lfs (#9753) 2020-01-14 00:06:54 +00:00
Manush Dodunekov
1751d5fcf2 Restricted users (#6274)
* Restricted users (#4334): initial implementation

* Add User.IsRestricted & UI to edit it

* Pass user object instead of user id to places where IsRestricted flag matters

* Restricted users: maintain access rows for all referenced repos (incl public)

* Take logged in user & IsRestricted flag into account in org/repo listings, searches and accesses

* Add basic repo access tests for restricted users

Signed-off-by: Manush Dodunekov <manush@stendahls.se>

* Mention restricted users in the faq

Signed-off-by: Manush Dodunekov <manush@stendahls.se>

* Revert unnecessary change `.isUserPartOfOrg` -> `.IsUserPartOfOrg`

Signed-off-by: Manush Dodunekov <manush@stendahls.se>

* Remove unnecessary `org.IsOrganization()` call

Signed-off-by: Manush Dodunekov <manush@stendahls.se>

* Revert to an `int64` keyed `accessMap`

* Add type `userAccess`
* Add convenience func updateUserAccess()
* Turn accessMap into a `map[int64]userAccess`

Signed-off-by: Manush Dodunekov <manush@stendahls.se>

* or even better: `map[int64]*userAccess`

* updateUserAccess(): use tighter syntax as suggested by lafriks

* even tighter

* Avoid extra loop

* Don't disclose limited orgs to unauthenticated users

* Don't assume block only applies to orgs

* Use an array of `VisibleType` for filtering

* fix yet another thinko

* Ok - no need for u

* Revert "Ok - no need for u"

This reverts commit 5c3e886aabd5acd997a3b35687d322439732c200.

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-13 18:33:46 +01:00
6543
0b3aaa6196 [API] Add "before" query to ListIssueComments and ListRepoIssue… (#9685)
* add "before" query to ListIssueComments and ListRepoIssueComments

* Add TEST

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-13 17:02:24 +01:00
GiteaBot
b7ffc6a096 [skip ci] Updated translations via Crowdin 2020-01-13 14:10:01 +00:00
Antoine GIRARD
dfe4564072
ci: go back to golangci-lint 1.20.0 (#9742)
Revert https://github.com/go-gitea/gitea/pull/9711
2020-01-13 15:06:49 +01:00
GiteaBot
bd9d480f99 [skip ci] Updated translations via Crowdin 2020-01-13 10:42:46 +00:00
Antoine GIRARD
b787aafc17
ci: re-ordering Drone CI for optimizing time (#9719)
* ci: try re-ordering for optimizing time

* ci: try re-ordering for optimizing time

* ci: try re-ordering for optimizing time

* ci: try re-ordering for optimizing time

* ci: try re-ordering for optimizing time

* ci: try re-ordering for optimizing time

* ci: try offloading mysql8 to arm64

* Revert "ci: try offloading mysql8 to arm64"

This reverts commit c60de5db1cf8b5984c3014a57da6490f06c8d980.

* ci: try offloading pgsql to arm64

* ci: activate ldap on arm64

* ci: test mysql8 in place pgsql arm64

* chore: clean un-needed move

* typo

* ci: revert runnning mysql on arm64

* ci: run compliance on arm

* chore: limit change

* chore: readd maybe need for release fetch-tags

* ci: remove docker-linux-amd64-dry-run

* ci: remove docker-linux-amd64-dry-run

* Revert "ci: remove docker-linux-amd64-dry-run"

This reverts commit 0715f65b11c37869359aaaa5d22901da512e8184.

Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-13 11:40:10 +01:00
silverwind
80bfd5145c add package-lock=true in .npmrc (#9736)
Some users (like me) have this option disabled in their global npm
config which can lead to package-lock.json not being updated. This
explicitely enables the option for this repo, so that the file is
always updated when adding/removing dependencies.

Co-authored-by: techknowlogick <matti@mdranta.net>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-13 00:11:43 +01:00
Antoine GIRARD
2ecf98ed2d ci: use docker image for golangci-lint (#9737) 2020-01-12 16:26:13 -05:00
silverwind
a3977a3e51 fix webpack polyfills (#9735)
webpack polyfills did not work because useBuiltIns: 'entry' expects a
explicit core-js import. Changed it to 'usage' which does not require
these explicit imports and polyfills based on browserslist.

As a result, the built index.js now went from 128kB to 192kB.

Ref: https://babeljs.io/docs/en/babel-preset-env#usebuiltins

Co-authored-by: zeripath <art27@cantab.net>
2020-01-12 21:53:12 +01:00
silverwind
74e35aae11 remove deprecated targets from Makefile (#9729)
- remove deprecated targets
- ensure 1 empty line between targets

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-12 18:22:26 +01:00
GiteaBot
625057c674 [skip ci] Updated translations via Crowdin 2020-01-12 16:34:48 +00:00
6543
10055bd2b1 [API] add GET /orgs endpoint (#9560)
* introduce `GET /orgs`

* add TEST

* show also other VisibleType's

* update description

* refactor a lot

* SearchUserOptions by default return only public
2020-01-12 23:43:44 +08:00
GiteaBot
497e15fdc2 [skip ci] Updated translations via Crowdin 2020-01-12 12:12:40 +00:00
Lunny Xiao
b465d0d787
Move create/fork repository from models to modules/repository (#9489)
* Move create/fork repository from models to modules/repository

* fix wrong reference

* fix test

* fix test

* fix lint

* Fix DBContext

* remove duplicated TestMain

* fix lint

* fix conflicts
2020-01-12 20:11:17 +08:00
Lunny Xiao
5765212c6d
Add owner_name column for table repository for maintaince reason (#9717)
* Add owner_name column for table repository for maintaince reason

* refactor

* Fix tests

* fix test

* fix bug when fork repository

Co-authored-by: zeripath <art27@cantab.net>
2020-01-12 17:36:21 +08:00
zeripath
65baacf227
Make hook status printing configurable with delay (#9641)
* Delay printing hook statuses until after 1 second

* Move to a 5s delay, wrapped writer structure and add config

* Update cmd/hook.go

* Apply suggestions from code review

* Update cmd/hook.go

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-12 08:46:03 +00:00
6543
83f9359a75 [BugFix] [API] ​/repos​/issues​/search (#9698)
* fix

* fix options

* add TEST

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-12 14:35:11 +08:00
silverwind
86464de0c1 silence fomantic error regarding tabs (#9713)
Fomantic expects all tabs to have a target element with content as
defined by the data-tab attribute. All our usage of the tab module seems
to use <a> element tabs that link to new pages so these content elements
are never present and fomantic complains about that in the console with
an "Activated tab cannot be found" error. This silences that error.
2020-01-12 03:57:32 +01:00
techknowlogick
fef49f5e2e golangci-lint 1.22.2 (#9711) 2020-01-11 22:33:40 +02:00
zeripath
960ac36099
Remove unused lock (#9709) 2020-01-11 19:06:35 +00:00
zeripath
edd31770aa
Missed q.lock.Unlock() will cause panic (#9705) 2020-01-11 17:05:07 +00:00
Lunny Xiao
f69f5a9f10 Add a new command doctor to check if some wrong configurations on gitea instance (#9095)
* add doctor

* Add a new command doctor to check if some wrong configurations on gitea instance

* fix import

* use regex match authorized_keys on doctor

* Add documentation
2020-01-11 15:24:57 +01:00
GiteaBot
f2e6c4538e [skip ci] Updated translations via Crowdin 2020-01-11 10:51:31 +00:00
zeripath
eadb45e891 Restore IsPasswordSet previous value (#9682) 2020-01-11 18:50:05 +08:00
David Svantesson
32fb813133 Allow repo admin to merge PR regardless of review status (#9611)
* Allow repo admin to merge even if review is not ok.
2020-01-11 02:29:34 -05:00
Lunny Xiao
4d06d10dba Move tracked time api convert to convert package (#9665) 2020-01-10 21:59:41 -05:00
guillep2k
705b1e49a8 Don't attempt to close issue if already closed (#9696)
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-11 09:20:11 +08:00
Ryan
438e159d04 Remove deprecation comment for CreateOrgRepo (#9670)
Remove mistakenly added `deprecated: true` swagger comment from the `/orgs/{orgr}/repos` handler
2020-01-10 16:54:46 -05:00
John Olheiser
480ef9d410 Load milestone in API PR list (#9671)
* Load milestone for Issue API format

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Move further down

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: techknowlogick <matti@mdranta.net>
2020-01-10 16:17:56 -05:00
Antoine GIRARD
e90e435f04 Remove un-needed script import since #9554 (#9694)
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-10 15:36:32 -05:00
Lunny Xiao
7a3a90aca3
Fix wrong original git service type on a migrated repository (#9693) 2020-01-10 23:35:17 +08:00
silverwind
3143bb10da update js dependencies (#9676)
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-10 13:39:01 +01:00
Lunny Xiao
99d869fa63
Move push commits from models to modules/repository (#9370)
* Move push commits from models to modules/repository

* fix test

* fix test

* fix test

* fix test

* fix test

Co-authored-by: zeripath <art27@cantab.net>
2020-01-10 17:34:21 +08:00
Lunny Xiao
384c2b342e
Move pull request api convert to convert package (#9664)
* Move pull request api convert to convert package

* Rename ToPullRequest to ToAPIPullRequest
2020-01-10 15:53:53 +08:00
Lunny Xiao
8878cfa4a1
Fix lint (#9688) 2020-01-10 13:50:23 +08:00
zeripath
17b844a3ec Move Errored PRs out of StatusChecking (#9675)
* Set Errored PRs out of StatusChecking

* Ensure that api status is correctly set too

* Update models/pull.go

Co-Authored-By: John Olheiser <42128690+jolheiser@users.noreply.github.com>

Co-authored-by: John Olheiser <42128690+jolheiser@users.noreply.github.com>
2020-01-10 08:14:14 +08:00
zeripath
6c46a56360 Prevent redirect to Host (#9678) 2020-01-09 16:34:25 -05:00
techknowlogick
8f31c2fc76
remove google font call (#9668) 2020-01-09 15:48:47 -05:00
silverwind
b3722114ce eliminate horizontal scroll caused by footer (#9669) 2020-01-09 19:33:39 +00:00
GiteaBot
a311ace354 [skip ci] Updated translations via Crowdin 2020-01-09 16:43:29 +00:00
6543
e8ea0695b0 [API] creat org repo call same as github (#9186)
* deprecate /api/v1/org/{org}/repos in favour of /api/v1/orgs/{org}/repos + cleanup api repository routes a bit

* remove redundant code

* use upstream function for api cal

* make generate-swagger

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-09 16:40:01 +00:00
Bo-Yi Wu
07520431ae chore(PR): Add Reviewed-on in commit message (#9623) 2020-01-09 14:31:09 +00:00
6543
1080c768d3 [API] orgEditTeam make Fields optional (#9556)
* API: orgEditTeam make Fields optional

* add TestCase

* Update integrations/api_team_test.go

* suggestions from lafriks

use len() to check if string is empty

Co-Authored-By: Lauris BH <lauris@nix.lv>

* change ...

* use Where not ID to get mssql

* add return and code format

* fix test

* fix test ... null pointer exept

* update specific colums

* only specific colums too

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-09 13:15:14 +00:00
GiteaBot
71fe018977 [skip ci] Updated translations via Crowdin 2020-01-09 11:58:47 +00:00
6543
6baa5d7588 [API] Add notification endpoint (#9488)
* [API] Add notification endpoints

 * add func GetNotifications(opts FindNotificationOptions)
 * add func (n *Notification) APIFormat()
 * add func (nl NotificationList) APIFormat()
 * add func (n *Notification) APIURL()
 * add func (nl NotificationList) APIFormat()
 * add LoadAttributes functions (loadRepo, loadIssue, loadComment, loadUser)
 * add func (c *Comment) APIURL()
 * add func (issue *Issue) GetLastComment()
 * add endpoint GET /notifications
 * add endpoint PUT /notifications
 * add endpoint GET /repos/{owner}/{repo}/notifications
 * add endpoint PUT /repos/{owner}/{repo}/notifications
 * add endpoint GET /notifications/threads/{id}
 * add endpoint PATCH /notifications/threads/{id}

* Add TEST

* code format

* code format
2020-01-09 11:56:32 +00:00
John Olheiser
ee9ce0cfa9 Fix nil reference in repo generation (#9660)
* Fix nil reference

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Tighten

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2020-01-09 08:22:37 +02:00
David Svantesson
25531c71a7 Mark PR reviews as stale at push and allow to dismiss stale approvals (#9532)
Fix #5997.

If a push causes the patch/diff of a PR towards target branch to change, all existing reviews for the PR will be set and shown as stale.
New branch protection option to dismiss stale approvals are added.
To show that a review is not based on the latest PR changes, an hourglass is shown
2020-01-09 01:47:45 +00:00
John Olheiser
5b2d9333f1 Add HTML URL to API Issues (#9654)
* Add HTML URL to API Issues

Signed-off-by: jolheiser <john.olheiser@gmail.com>

* Swagger

Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Lauris BH <lauris@nix.lv>
2020-01-08 23:10:34 +00:00
6543
14a9687444 times Add filters (#9373)
(extend #9200)
 * add query param for GET functions (created Bevore & after)
 * add test
 * generalize func GetQueryBeforeSince

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-01-08 16:14:00 -05:00
John Olheiser
f8dcc5f9f8 Add PR review webhook to Telegram (#9653)
Signed-off-by: jolheiser <john.olheiser@gmail.com>

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-08 18:45:24 +01:00
Bagas Sanjaya
b822518e39 [Docs] Linux Service Edit (#9633)
* Rename h3 title

* Add intro

Should work on Ubuntu Xenial, but should work on any Linux distros.

* Indirect edit files

Instead of providing `sudo vim`, invite to edit files.

* enable now instead of enable and start

* Re-add systemctl enable && systemctl start

* Revert service enablement back to status quo

* Add enable now counterpart for systemd > v220

* Apply suggestions from @sapk

Strip `vim` from editor usage

Co-Authored-By: Antoine GIRARD <sapk@users.noreply.github.com>

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-08 17:33:13 +01:00
6543
c779ac12c9 fix #9648 | use filepath.IsAbs instead of path.IsAbs (#9651)
* fix #9648

* found next

Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
2020-01-08 15:30:58 +01:00
GiteaBot
98772d376c [skip ci] Updated translations via Crowdin 2020-01-08 12:45:05 +00:00
Shashvat Kedia
632fb5badc Fix #9552: Merge commits generated by pull request capture pull request details (#9635) 2020-01-08 11:53:07 +00:00
Bagas Sanjaya
74d6ec6807 [Docs] Grammar Edit on Enabling HTTPS Using Reverse Proxy (#9649)
* Use infinitives for accept and pass

* Close parentheeses for proxy exposed
2020-01-08 10:20:15 +01:00
6543
e88d67b774 [API] add comments endpoint for single comment (#9494)
* add GET /repos/{owner}/{repo}/issues/comments/{id}
 and complete error list for swagger in other func

* add repo check
2020-01-08 15:00:59 +08:00
techknowlogick
c884735740
Plural form for changelog (#9645)
Fix: https://gitea.com/gitea/changelog/issues/16
2020-01-08 00:08:49 -05:00
techknowlogick
8e132cd16a
Update date for new year (#9644) 2020-01-07 23:06:45 -05:00
Matti R
fe2e812121
empty commit to start 1.12-dev 2020-01-07 22:56:59 -05:00
10408 changed files with 513269 additions and 2002237 deletions

10
.air.toml Normal file
View file

@ -0,0 +1,10 @@
root = "."
tmp_dir = ".air"
[build]
cmd = "make backend"
bin = "gitea"
include_ext = ["go", "tmpl"]
exclude_dir = ["modules/git/tests", "services/gitdiff/testdata", "modules/avatar/testdata", "models/fixtures", "models/migrations/fixtures", "modules/migration/file_format_testdata", "modules/avatar/identicon/testdata"]
include_dir = ["cmd", "models", "modules", "options", "routers", "services"]
exclude_regex = ["_test.go$", "_gen.go$"]

View file

@ -1,44 +1,61 @@
# The full repository name
repo: go-gitea/gitea
# Service type (gitea or github)
service: github
# Base URL for Gitea instance if using gitea service type (optional)
# Default: https://gitea.com
base-url:
# Changelog groups and which labeled PRs to add to each group
groups:
-
-
name: BREAKING
labels:
- kind/breaking
-
name: FEATURE
-
name: SECURITY
labels:
- kind/security
-
name: FEATURES
labels:
- kind/feature
-
name: BUGFIXES
name: API
labels:
- kind/bug
-
name: ENHANCEMENT
- kind/api
-
name: ENHANCEMENTS
labels:
- kind/enhancement
- kind/refactor
- kind/ui
-
name: SECURITY
name: BUGFIXES
labels:
- kind/security
-
- kind/bug
-
name: TESTING
labels:
- kind/testing
-
-
name: TRANSLATION
labels:
- kind/translation
-
-
name: BUILD
labels:
- kind/build
- kind/lint
-
-
name: DOCS
labels:
- kind/docs
-
-
name: MISC
default: true
default: true
# regex indicating which labels to skip for the changelog
skip-labels: skip-changelog|backport\/.+

114
.dockerignore Normal file
View file

@ -0,0 +1,114 @@
# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# IntelliJ
.idea
# Goland's output filename can not be set manually
/go_build_*
# MS VSCode
.vscode
__debug_bin
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
*.prof
*coverage.out
coverage.all
cpu.out
/modules/migration/bindata.go
/modules/migration/bindata.go.hash
/modules/options/bindata.go
/modules/options/bindata.go.hash
/modules/public/bindata.go
/modules/public/bindata.go.hash
/modules/templates/bindata.go
/modules/templates/bindata.go.hash
*.db
*.log
/gitea
/gitea-vet
/debug
/integrations.test
/bin
/dist
/custom/*
!/custom/conf
/custom/conf/*
!/custom/conf/app.example.ini
/data
/indexers
/log
/public/img/avatar
/tests/integration/gitea-integration-*
/tests/integration/indexers-*
/tests/e2e/gitea-e2e-*
/tests/e2e/indexers-*
/tests/e2e/reports
/tests/e2e/test-artifacts
/tests/e2e/test-snapshots
/tests/*.ini
/node_modules
/yarn.lock
/yarn-error.log
/npm-debug.log*
/public/js
/public/serviceworker.js
/public/css
/public/fonts
/public/img/webpack
/vendor
/web_src/fomantic/node_modules
/web_src/fomantic/build/*
!/web_src/fomantic/build/semantic.js
!/web_src/fomantic/build/semantic.css
!/web_src/fomantic/build/themes
/web_src/fomantic/build/themes/*
!/web_src/fomantic/build/themes/default
/web_src/fomantic/build/themes/default/assets/*
!/web_src/fomantic/build/themes/default/assets/fonts
/web_src/fomantic/build/themes/default/assets/fonts/*
!/web_src/fomantic/build/themes/default/assets/fonts/icons.woff2
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
/VERSION
/.air
/.go-licenses
# Snapcraft
snap/.snapcraft/
parts/
stage/
prime/
*.snap
*.snap-build
*_source.tar.bz2
.DS_Store
# Make evidence files
/.make_evidence
# Manpage
/man

1937
.drone.yml

File diff suppressed because it is too large Load diff

View file

@ -1,31 +1,28 @@
# http://editorconfig.org
root = true
[*]
charset = utf-8
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = space
indent_size = 2
tab_width = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.go]
[*.{go,tmpl,html}]
indent_style = tab
indent_size = 8
[*.{tmpl,html}]
indent_style = tab
indent_size = 4
[templates/custom/*.tmpl]
insert_final_newline = false
[*.less]
[templates/swagger/v1_json.tmpl]
indent_style = space
indent_size = 4
[*.{yml,json}]
[templates/user/auth/oidc_wellknown.tmpl]
indent_style = space
indent_size = 2
[*.js]
indent_style = space
indent_size = 2
[Makefile]
indent_style = tab
[*.svg]
insert_final_newline = false

View file

@ -1 +0,0 @@
/web_src/js/semanticDropdown.js

View file

@ -1,53 +0,0 @@
root: true
extends:
- eslint-config-airbnb-base
- eslint:recommended
parserOptions:
ecmaVersion: 2020
env:
browser: true
es6: true
jquery: true
node: true
globals:
__webpack_public_path__: true
Clipboard: false
CodeMirror: false
Dropzone: false
emojify: false
hljs: false
SimpleMDE: false
u2fApi: false
Vue: false
rules:
arrow-body-style: [0]
camelcase: [0]
comma-dangle: [2, only-multiline]
consistent-return: [0]
default-case: [0]
func-names: [0]
import/extensions: [0]
max-len: [0]
newline-per-chained-call: [0]
no-alert: [0]
no-continue: [0]
no-mixed-operators: [0]
no-multi-assign: [0]
no-new: [0]
no-param-reassign: [0]
no-plusplus: [0]
no-restricted-syntax: [0]
no-shadow: [0]
no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, ignoreRestSiblings: true}]
no-use-before-define: [0]
no-var: [2]
one-var-declaration-per-line: [0]
one-var: [0]
prefer-const: [2, {destructuring: all}]
prefer-destructuring: [0]
radix: [2, as-needed]

538
.eslintrc.yaml Normal file
View file

@ -0,0 +1,538 @@
root: true
reportUnusedDisableDirectives: true
ignorePatterns:
- /web_src/js/vendor
parserOptions:
sourceType: module
ecmaVersion: latest
plugins:
- eslint-plugin-unicorn
- eslint-plugin-import
- eslint-plugin-jquery
- eslint-plugin-sonarjs
env:
es2022: true
node: true
globals:
__webpack_public_path__: true
overrides:
- files: ["web_src/**/*.js", "docs/**/*.js"]
env:
browser: true
node: false
- files: ["web_src/**/*worker.js"]
env:
worker: true
rules:
no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, status, statusbar, stop, toolbar, top]
- files: ["build/generate-images.js"]
rules:
import/no-unresolved: [0]
import/no-extraneous-dependencies: [0]
- files: ["*.config.js"]
rules:
import/no-unused-modules: [0]
rules:
accessor-pairs: [2]
array-bracket-newline: [0]
array-bracket-spacing: [2, never]
array-callback-return: [2, {checkForEach: true}]
array-element-newline: [0]
arrow-body-style: [0]
arrow-parens: [2, always]
arrow-spacing: [2, {before: true, after: true}]
block-scoped-var: [2]
brace-style: [2, 1tbs, {allowSingleLine: true}]
camelcase: [0]
capitalized-comments: [0]
class-methods-use-this: [0]
comma-dangle: [2, only-multiline]
comma-spacing: [2, {before: false, after: true}]
comma-style: [2, last]
complexity: [0]
computed-property-spacing: [2, never]
consistent-return: [0]
consistent-this: [0]
constructor-super: [2]
curly: [0]
default-case-last: [2]
default-case: [0]
default-param-last: [0]
dot-location: [2, property]
dot-notation: [0]
eol-last: [2]
eqeqeq: [2]
for-direction: [2]
func-call-spacing: [2, never]
func-name-matching: [2]
func-names: [0]
func-style: [0]
function-call-argument-newline: [0]
function-paren-newline: [0]
generator-star-spacing: [0]
getter-return: [2]
grouped-accessor-pairs: [2]
guard-for-in: [0]
id-blacklist: [0]
id-length: [0]
id-match: [0]
implicit-arrow-linebreak: [0]
import/consistent-type-specifier-style: [0]
import/default: [0]
import/dynamic-import-chunkname: [0]
import/export: [2]
import/exports-last: [0]
import/extensions: [2, always, {ignorePackages: true}]
import/first: [2]
import/group-exports: [0]
import/max-dependencies: [0]
import/named: [2]
import/namespace: [0]
import/newline-after-import: [0]
import/no-absolute-path: [0]
import/no-amd: [0]
import/no-anonymous-default-export: [0]
import/no-commonjs: [0]
import/no-cycle: [2, {ignoreExternal: true, maxDepth: 1}]
import/no-default-export: [0]
import/no-deprecated: [0]
import/no-dynamic-require: [0]
import/no-empty-named-blocks: [2]
import/no-extraneous-dependencies: [2]
import/no-import-module-exports: [0]
import/no-internal-modules: [0]
import/no-mutable-exports: [0]
import/no-named-as-default-member: [0]
import/no-named-as-default: [2]
import/no-named-default: [0]
import/no-named-export: [0]
import/no-namespace: [0]
import/no-nodejs-modules: [0]
import/no-relative-packages: [0]
import/no-relative-parent-imports: [0]
import/no-restricted-paths: [0]
import/no-self-import: [2]
import/no-unassigned-import: [0]
import/no-unresolved: [2, {commonjs: true, ignore: ["\\?.+$"]}]
import/no-unused-modules: [2, {unusedExports: true}]
import/no-useless-path-segments: [2, {commonjs: true}]
import/no-webpack-loader-syntax: [2]
import/order: [0]
import/prefer-default-export: [0]
import/unambiguous: [0]
indent: [2, 2, {SwitchCase: 1}]
init-declarations: [0]
jquery/no-ajax-events: [2]
jquery/no-ajax: [0]
jquery/no-animate: [2]
jquery/no-attr: [0]
jquery/no-bind: [2]
jquery/no-class: [0]
jquery/no-clone: [2]
jquery/no-closest: [0]
jquery/no-css: [0]
jquery/no-data: [0]
jquery/no-deferred: [2]
jquery/no-delegate: [2]
jquery/no-each: [0]
jquery/no-extend: [2]
jquery/no-fade: [0]
jquery/no-filter: [0]
jquery/no-find: [0]
jquery/no-global-eval: [2]
jquery/no-grep: [2]
jquery/no-has: [2]
jquery/no-hide: [2]
jquery/no-html: [0]
jquery/no-in-array: [2]
jquery/no-is-array: [2]
jquery/no-is-function: [2]
jquery/no-is: [0]
jquery/no-load: [2]
jquery/no-map: [0]
jquery/no-merge: [2]
jquery/no-param: [2]
jquery/no-parent: [0]
jquery/no-parents: [0]
jquery/no-parse-html: [2]
jquery/no-prop: [0]
jquery/no-proxy: [2]
jquery/no-ready: [0]
jquery/no-serialize: [2]
jquery/no-show: [2]
jquery/no-size: [2]
jquery/no-sizzle: [0]
jquery/no-slide: [0]
jquery/no-submit: [0]
jquery/no-text: [0]
jquery/no-toggle: [2]
jquery/no-trigger: [0]
jquery/no-trim: [2]
jquery/no-val: [0]
jquery/no-when: [2]
jquery/no-wrap: [2]
key-spacing: [2]
keyword-spacing: [2]
line-comment-position: [0]
linebreak-style: [2, unix]
lines-around-comment: [0]
lines-between-class-members: [0]
logical-assignment-operators: [0]
max-classes-per-file: [0]
max-depth: [0]
max-len: [0]
max-lines-per-function: [0]
max-lines: [0]
max-nested-callbacks: [0]
max-params: [0]
max-statements-per-line: [0]
max-statements: [0]
multiline-comment-style: [2, separate-lines]
multiline-ternary: [0]
new-cap: [0]
new-parens: [2]
newline-per-chained-call: [0]
no-alert: [0]
no-array-constructor: [2]
no-async-promise-executor: [0]
no-await-in-loop: [0]
no-bitwise: [0]
no-buffer-constructor: [0]
no-caller: [2]
no-case-declarations: [2]
no-class-assign: [2]
no-compare-neg-zero: [2]
no-cond-assign: [2, except-parens]
no-confusing-arrow: [0]
no-console: [1, {allow: [debug, info, warn, error]}]
no-const-assign: [2]
no-constant-binary-expression: [2]
no-constant-condition: [0]
no-constructor-return: [2]
no-continue: [0]
no-control-regex: [0]
no-debugger: [1]
no-delete-var: [2]
no-div-regex: [0]
no-dupe-args: [2]
no-dupe-class-members: [2]
no-dupe-else-if: [2]
no-dupe-keys: [2]
no-duplicate-case: [2]
no-duplicate-imports: [2]
no-else-return: [2]
no-empty-character-class: [2]
no-empty-function: [0]
no-empty-pattern: [2]
no-empty-static-block: [2]
no-empty: [2, {allowEmptyCatch: true}]
no-eq-null: [2]
no-eval: [2]
no-ex-assign: [2]
no-extend-native: [2]
no-extra-bind: [2]
no-extra-boolean-cast: [2]
no-extra-label: [0]
no-extra-parens: [0]
no-extra-semi: [2]
no-fallthrough: [2]
no-floating-decimal: [0]
no-func-assign: [2]
no-global-assign: [2]
no-implicit-coercion: [2]
no-implicit-globals: [0]
no-implied-eval: [2]
no-import-assign: [2]
no-inline-comments: [0]
no-inner-declarations: [2]
no-invalid-regexp: [2]
no-invalid-this: [0]
no-irregular-whitespace: [2]
no-iterator: [2]
no-label-var: [2]
no-labels: [0] # handled by no-restricted-syntax
no-lone-blocks: [2]
no-lonely-if: [0]
no-loop-func: [0]
no-loss-of-precision: [2]
no-magic-numbers: [0]
no-misleading-character-class: [2]
no-mixed-operators: [0]
no-mixed-spaces-and-tabs: [2]
no-multi-assign: [0]
no-multi-spaces: [2, {ignoreEOLComments: true, exceptions: {Property: true}}]
no-multi-str: [2]
no-negated-condition: [0]
no-nested-ternary: [0]
no-new-func: [2]
no-new-native-nonconstructor: [2]
no-new-object: [2]
no-new-symbol: [2]
no-new-wrappers: [2]
no-new: [0]
no-nonoctal-decimal-escape: [2]
no-obj-calls: [2]
no-octal-escape: [2]
no-octal: [2]
no-param-reassign: [0]
no-plusplus: [0]
no-promise-executor-return: [0]
no-proto: [2]
no-prototype-builtins: [2]
no-redeclare: [2]
no-regex-spaces: [2]
no-restricted-exports: [0]
no-restricted-globals: [2, addEventListener, blur, close, closed, confirm, defaultStatus, defaultstatus, error, event, external, find, focus, frameElement, frames, history, innerHeight, innerWidth, isFinite, isNaN, length, location, locationbar, menubar, moveBy, moveTo, name, onblur, onerror, onfocus, onload, onresize, onunload, open, opener, opera, outerHeight, outerWidth, pageXOffset, pageYOffset, parent, print, removeEventListener, resizeBy, resizeTo, screen, screenLeft, screenTop, screenX, screenY, scroll, scrollbars, scrollBy, scrollTo, scrollX, scrollY, self, status, statusbar, stop, toolbar, top, __dirname, __filename]
no-restricted-imports: [0]
no-restricted-syntax: [2, WithStatement, ForInStatement, LabeledStatement]
no-return-assign: [0]
no-return-await: [0]
no-script-url: [2]
no-self-assign: [2, {props: true}]
no-self-compare: [2]
no-sequences: [2]
no-setter-return: [2]
no-shadow-restricted-names: [2]
no-shadow: [0]
no-sparse-arrays: [2]
no-tabs: [2]
no-template-curly-in-string: [2]
no-ternary: [0]
no-this-before-super: [2]
no-throw-literal: [2]
no-trailing-spaces: [2]
no-undef-init: [2]
no-undef: [2, {typeof: true}]
no-undefined: [0]
no-underscore-dangle: [0]
no-unexpected-multiline: [2]
no-unmodified-loop-condition: [2]
no-unneeded-ternary: [0]
no-unreachable-loop: [2]
no-unreachable: [2]
no-unsafe-finally: [2]
no-unsafe-negation: [2]
no-unused-expressions: [2]
no-unused-labels: [2]
no-unused-private-class-members: [2]
no-unused-vars: [2, {args: all, argsIgnorePattern: ^_, varsIgnorePattern: ^_, caughtErrorsIgnorePattern: ^_, destructuredArrayIgnorePattern: ^_, ignoreRestSiblings: false}]
no-use-before-define: [2, {functions: false, classes: true, variables: true, allowNamedExports: true}]
no-useless-backreference: [2]
no-useless-call: [2]
no-useless-catch: [2]
no-useless-computed-key: [2]
no-useless-concat: [2]
no-useless-constructor: [2]
no-useless-escape: [2]
no-useless-rename: [2]
no-useless-return: [2]
no-var: [2]
no-void: [2]
no-warning-comments: [0]
no-whitespace-before-property: [2]
no-with: [0] # handled by no-restricted-syntax
nonblock-statement-body-position: [2]
object-curly-newline: [0]
object-curly-spacing: [2, never]
object-shorthand: [2, always]
one-var-declaration-per-line: [0]
one-var: [0]
operator-assignment: [2, always]
operator-linebreak: [2, after]
padded-blocks: [2, never]
padding-line-between-statements: [0]
prefer-arrow-callback: [2, {allowNamedFunctions: true, allowUnboundThis: true}]
prefer-const: [2, {destructuring: all, ignoreReadBeforeAssign: true}]
prefer-destructuring: [0]
prefer-exponentiation-operator: [2]
prefer-named-capture-group: [0]
prefer-numeric-literals: [2]
prefer-object-has-own: [0]
prefer-object-spread: [2]
prefer-promise-reject-errors: [2, {allowEmptyReject: false}]
prefer-regex-literals: [2]
prefer-rest-params: [2]
prefer-spread: [2]
prefer-template: [2]
quote-props: [0]
quotes: [2, single, {avoidEscape: true, allowTemplateLiterals: true}]
radix: [2, as-needed]
require-atomic-updates: [0]
require-await: [0]
require-unicode-regexp: [0]
require-yield: [2]
rest-spread-spacing: [2, never]
semi-spacing: [2, {before: false, after: true}]
semi-style: [2, last]
semi: [2, always, {omitLastInOneLineBlock: true}]
sonarjs/cognitive-complexity: [0]
sonarjs/elseif-without-else: [0]
sonarjs/max-switch-cases: [0]
sonarjs/no-all-duplicated-branches: [2]
sonarjs/no-collapsible-if: [0]
sonarjs/no-collection-size-mischeck: [2]
sonarjs/no-duplicate-string: [0]
sonarjs/no-duplicated-branches: [0]
sonarjs/no-element-overwrite: [2]
sonarjs/no-empty-collection: [2]
sonarjs/no-extra-arguments: [2]
sonarjs/no-gratuitous-expressions: [2]
sonarjs/no-identical-conditions: [2]
sonarjs/no-identical-expressions: [2]
sonarjs/no-identical-functions: [2, 5]
sonarjs/no-ignored-return: [2]
sonarjs/no-inverted-boolean-check: [2]
sonarjs/no-nested-switch: [0]
sonarjs/no-nested-template-literals: [0]
sonarjs/no-one-iteration-loop: [2]
sonarjs/no-redundant-boolean: [2]
sonarjs/no-redundant-jump: [0]
sonarjs/no-same-line-conditional: [2]
sonarjs/no-small-switch: [0]
sonarjs/no-unused-collection: [2]
sonarjs/no-use-of-empty-return-value: [2]
sonarjs/no-useless-catch: [2]
sonarjs/non-existent-operator: [2]
sonarjs/prefer-immediate-return: [0]
sonarjs/prefer-object-literal: [0]
sonarjs/prefer-single-boolean-return: [0]
sonarjs/prefer-while: [2]
sort-imports: [0]
sort-keys: [0]
sort-vars: [0]
space-before-blocks: [2, always]
space-in-parens: [2, never]
space-infix-ops: [2]
space-unary-ops: [2]
spaced-comment: [2, always]
strict: [0]
switch-colon-spacing: [2]
symbol-description: [2]
template-curly-spacing: [2, never]
template-tag-spacing: [2, never]
unicode-bom: [2, never]
unicorn/better-regex: [0]
unicorn/catch-error-name: [0]
unicorn/consistent-destructuring: [2]
unicorn/consistent-function-scoping: [2]
unicorn/custom-error-definition: [0]
unicorn/empty-brace-spaces: [2]
unicorn/error-message: [0]
unicorn/escape-case: [0]
unicorn/expiring-todo-comments: [0]
unicorn/explicit-length-check: [0]
unicorn/filename-case: [0]
unicorn/import-index: [0]
unicorn/import-style: [0]
unicorn/new-for-builtins: [2]
unicorn/no-abusive-eslint-disable: [0]
unicorn/no-array-for-each: [2]
unicorn/no-array-instanceof: [0]
unicorn/no-array-method-this-argument: [2]
unicorn/no-array-push-push: [2]
unicorn/no-await-expression-member: [0]
unicorn/no-console-spaces: [0]
unicorn/no-document-cookie: [2]
unicorn/no-empty-file: [2]
unicorn/no-fn-reference-in-iterator: [0]
unicorn/no-for-loop: [0]
unicorn/no-hex-escape: [0]
unicorn/no-invalid-remove-event-listener: [2]
unicorn/no-keyword-prefix: [0]
unicorn/no-lonely-if: [2]
unicorn/no-negated-condition: [0]
unicorn/no-nested-ternary: [0]
unicorn/no-new-array: [0]
unicorn/no-new-buffer: [0]
unicorn/no-null: [0]
unicorn/no-object-as-default-parameter: [0]
unicorn/no-process-exit: [0]
unicorn/no-reduce: [2]
unicorn/no-static-only-class: [2]
unicorn/no-thenable: [2]
unicorn/no-this-assignment: [2]
unicorn/no-typeof-undefined: [2]
unicorn/no-unnecessary-await: [2]
unicorn/no-unreadable-array-destructuring: [0]
unicorn/no-unreadable-iife: [2]
unicorn/no-unsafe-regex: [0]
unicorn/no-unused-properties: [2]
unicorn/no-useless-fallback-in-spread: [2]
unicorn/no-useless-length-check: [2]
unicorn/no-useless-promise-resolve-reject: [2]
unicorn/no-useless-spread: [2]
unicorn/no-useless-switch-case: [2]
unicorn/no-useless-undefined: [0]
unicorn/no-zero-fractions: [2]
unicorn/number-literal-case: [0]
unicorn/numeric-separators-style: [0]
unicorn/prefer-add-event-listener: [2]
unicorn/prefer-array-find: [2]
unicorn/prefer-array-flat-map: [2]
unicorn/prefer-array-flat: [2]
unicorn/prefer-array-index-of: [2]
unicorn/prefer-array-some: [2]
unicorn/prefer-at: [0]
unicorn/prefer-code-point: [0]
unicorn/prefer-dataset: [2]
unicorn/prefer-date-now: [2]
unicorn/prefer-default-parameters: [0]
unicorn/prefer-event-key: [2]
unicorn/prefer-event-target: [2]
unicorn/prefer-export-from: [2]
unicorn/prefer-includes: [2]
unicorn/prefer-json-parse-buffer: [0]
unicorn/prefer-logical-operator-over-ternary: [2]
unicorn/prefer-math-trunc: [2]
unicorn/prefer-modern-dom-apis: [0]
unicorn/prefer-modern-math-apis: [2]
unicorn/prefer-module: [2]
unicorn/prefer-native-coercion-functions: [2]
unicorn/prefer-negative-index: [2]
unicorn/prefer-node-append: [0]
unicorn/prefer-node-protocol: [2]
unicorn/prefer-node-remove: [0]
unicorn/prefer-number-properties: [0]
unicorn/prefer-object-from-entries: [2]
unicorn/prefer-object-has-own: [0]
unicorn/prefer-optional-catch-binding: [2]
unicorn/prefer-prototype-methods: [0]
unicorn/prefer-query-selector: [0]
unicorn/prefer-reflect-apply: [0]
unicorn/prefer-regexp-test: [2]
unicorn/prefer-replace-all: [0]
unicorn/prefer-set-has: [0]
unicorn/prefer-set-size: [2]
unicorn/prefer-spread: [0]
unicorn/prefer-starts-ends-with: [2]
unicorn/prefer-string-slice: [0]
unicorn/prefer-switch: [0]
unicorn/prefer-ternary: [0]
unicorn/prefer-text-content: [2]
unicorn/prefer-top-level-await: [0]
unicorn/prefer-trim-start-end: [2]
unicorn/prefer-type-error: [0]
unicorn/prevent-abbreviations: [0]
unicorn/relative-url-style: [2]
unicorn/require-array-join-separator: [2]
unicorn/require-number-to-fixed-digits-argument: [2]
unicorn/require-post-message-target-origin: [0]
unicorn/string-content: [0]
unicorn/switch-case-braces: [0]
unicorn/template-indent: [2]
unicorn/text-encoding-identifier-case: [0]
unicorn/throw-new-error: [2]
use-isnan: [2]
valid-typeof: [2, {requireStringLiterals: true}]
vars-on-top: [0]
wrap-iife: [2, inside]
wrap-regex: [0]
yield-star-spacing: [2, after]
yoda: [2, never]

13
.gitattributes vendored
View file

@ -1,7 +1,8 @@
* text=auto eol=lf
conf/* linguist-vendored
docker/* linguist-vendored
options/* linguist-vendored
public/* linguist-vendored
scripts/* linguist-vendored
templates/* linguist-vendored
*.tmpl linguist-language=Handlebars
/assets/*.json linguist-generated
/public/vendor/** -text -eol linguist-vendored
/vendor/** -text -eol linguist-vendored
/web_src/fomantic/build/** linguist-generated
/web_src/js/vendor/** -text -eol linguist-vendored
Dockerfile.* linguist-language=Dockerfile

42
.gitea/issue_template.md Normal file
View file

@ -0,0 +1,42 @@
<!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue -->
<!--
1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Please take a moment to check that your issue doesn't already exist.
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq)
5. Please give all relevant information below for bug reports, because
incomplete details will be handled as an invalid report.
-->
- Gitea version (or commit ref):
- Git version:
- Operating system:
<!-- Please include information on whether you built gitea yourself, used one of our downloads or are using some other package -->
<!-- Please also tell us how you are running gitea, e.g. if it is being run from docker, a command-line, systemd etc. --->
<!-- If you are using a package or systemd tell us what distribution you are using -->
- Database (use `[x]`):
- [ ] PostgreSQL
- [ ] MySQL
- [ ] MSSQL
- [ ] SQLite
- Can you reproduce the bug at https://try.gitea.io:
- [ ] Yes (provide example URL)
- [ ] No
- Log gist:
<!-- It really is important to provide pertinent logs -->
<!-- Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems -->
<!-- In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini -->
## Description
<!-- If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please
disable the proxy/CDN fully and connect to gitea directly to confirm
the issue still persists without those services. -->
...
## Screenshots
<!-- **If this issue involves the Web Interface, please include a screenshot** -->

1
.github/FUNDING.yml vendored
View file

@ -1 +1,2 @@
open_collective: gitea
custom: https://www.bountysource.com/teams/gitea

94
.github/ISSUE_TEMPLATE/bug-report.yaml vendored Normal file
View file

@ -0,0 +1,94 @@
name: Bug Report
description: Found something you weren't expecting? Report it here!
labels: kind/bug
body:
- type: markdown
attributes:
value: |
NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue.
- type: markdown
attributes:
value: |
1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Make sure you are using the latest release and
take a moment to check that your issue hasn't been reported before.
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq)
5. Please give all relevant information below for bug reports, because
incomplete details will be handled as an invalid report.
6. In particular it's really important to provide pertinent logs. You must give us DEBUG level logs.
Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems
In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini
- type: textarea
id: description
attributes:
label: Description
description: |
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below)
If you are using a proxy or a CDN (e.g. Cloudflare) in front of Gitea, please disable the proxy/CDN fully and access Gitea directly to confirm the issue still persists without those services.
- type: input
id: gitea-ver
attributes:
label: Gitea Version
description: Gitea version (or commit reference) of your instance
validations:
required: true
- type: dropdown
id: can-reproduce
attributes:
label: Can you reproduce the bug on the Gitea demo site?
description: |
If so, please provide a URL in the Description field
URL of Gitea demo: https://try.gitea.io
options:
- "Yes"
- "No"
validations:
required: true
- type: markdown
attributes:
value: |
It's really important to provide pertinent logs
Please read https://docs.gitea.io/en-us/logging-configuration/#debugging-problems
In addition, if your problem relates to git commands set `RUN_MODE=dev` at the top of app.ini
- type: input
id: logs
attributes:
label: Log Gist
description: Please provide a gist URL of your logs, with any sensitive information (e.g. API keys) removed/hidden
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If this issue involves the Web Interface, please provide one or more screenshots
- type: input
id: git-ver
attributes:
label: Git Version
description: The version of git running on the server
- type: input
id: os-ver
attributes:
label: Operating System
description: The operating system you are using to run Gitea
- type: textarea
id: run-info
attributes:
label: How are you running Gitea?
description: |
Please include information on whether you built Gitea yourself, used one of our downloads, are using https://try.gitea.io or are using some other package
Please also tell us how you are running Gitea, e.g. if it is being run from docker, a command-line, systemd etc.
If you are using a package or systemd tell us what distribution you are using
validations:
required: true
- type: dropdown
id: database
attributes:
label: Database
description: What database system are you running?
options:
- PostgreSQL
- MySQL
- MSSQL
- SQLite

17
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1,17 @@
blank_issues_enabled: false
contact_links:
- name: Security Concern
url: https://tinyurl.com/security-gitea
about: For security concerns, please send a mail to security@gitea.io instead of opening a public issue.
- name: Discord Server
url: https://discord.gg/Gitea
about: Please ask questions and discuss configuration or deployment problems here.
- name: Discourse Forum
url: https://discourse.gitea.io
about: Questions and configuration or deployment problems can also be discussed on our forum.
- name: Frequently Asked Questions
url: https://docs.gitea.io/en-us/faq
about: Please check if your question isn't mentioned here.
- name: Crowdin Translations
url: https://crowdin.com/project/gitea
about: Translations are managed here.

View file

@ -0,0 +1,24 @@
name: Feature Request
description: Got an idea for a feature that Gitea doesn't have currently? Submit your idea here!
labels: ["kind/feature", "kind/proposal"]
body:
- type: markdown
attributes:
value: |
1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Please take a moment to check that your feature hasn't already been suggested.
- type: textarea
id: description
attributes:
label: Feature Description
placeholder: |
I think it would be great if Gitea had...
validations:
required: true
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: If you can, provide screenshots of an implementation on another site e.g. GitHub

View file

@ -0,0 +1,66 @@
name: Web Interface Bug Report
description: Something doesn't look quite as it should? Report it here!
labels: ["kind/bug", "kind/ui"]
body:
- type: markdown
attributes:
value: |
NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue.
- type: markdown
attributes:
value: |
1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Please take a moment to check that your issue doesn't already exist.
4. Make sure it's not mentioned in the FAQ (https://docs.gitea.io/en-us/faq)
5. Please give all relevant information below for bug reports, because
incomplete details will be handled as an invalid report.
6. In particular it's really important to provide pertinent logs. If you are certain that this is a javascript
error, show us the javascript console. If the error appears to relate to Gitea the server you must also give us
DEBUG level logs. (See https://docs.gitea.io/en-us/logging-configuration/#debugging-problems)
- type: textarea
id: description
attributes:
label: Description
description: |
Please provide a description of your issue here, with a URL if you were able to reproduce the issue (see below)
If using a proxy or a CDN (e.g. CloudFlare) in front of gitea, please disable the proxy/CDN fully and connect to gitea directly to confirm the issue still persists without those services.
- type: textarea
id: screenshots
attributes:
label: Screenshots
description: Please provide at least 1 screenshot showing the issue.
validations:
required: true
- type: input
id: gitea-ver
attributes:
label: Gitea Version
description: Gitea version (or commit reference) your instance is running
validations:
required: true
- type: dropdown
id: can-reproduce
attributes:
label: Can you reproduce the bug on the Gitea demo site?
description: |
If so, please provide a URL in the Description field
URL of Gitea demo: https://try.gitea.io
options:
- "Yes"
- "No"
validations:
required: true
- type: input
id: os-ver
attributes:
label: Operating System
description: The operating system you are using to access Gitea
- type: input
id: browser-ver
attributes:
label: Browser Version
description: The browser and version that you are using to access Gitea
validations:
required: true

View file

@ -1,33 +0,0 @@
<!-- NOTE: If your issue is a security concern, please send an email to security@gitea.io instead of opening a public issue -->
<!--
1. Please speak English, this is the language all maintainers can speak and write.
2. Please ask questions or configuration/deploy problems on our Discord
server (https://discord.gg/gitea) or forum (https://discourse.gitea.io).
3. Please take a moment to check that your issue doesn't already exist.
4. Please give all relevant information below for bug reports, because
incomplete details will be handled as an invalid report.
-->
- Gitea version (or commit ref):
- Git version:
- Operating system:
- Database (use `[x]`):
- [ ] PostgreSQL
- [ ] MySQL
- [ ] MSSQL
- [ ] SQLite
- Can you reproduce the bug at https://try.gitea.io:
- [ ] Yes (provide example URL)
- [ ] No
- [ ] Not relevant
- Log gist:
## Description
...
## Screenshots
<!-- **If this issue involves the Web Interface, please include a screenshot** -->

23
.github/lock.yml vendored Normal file
View file

@ -0,0 +1,23 @@
# Configuration for Lock Threads - https://github.com/dessant/lock-threads-app
# Number of days of inactivity before a closed issue or pull request is locked
daysUntilLock: 60
# Skip issues and pull requests created before a given timestamp. Timestamp must
# follow ISO 8601 (`YYYY-MM-DD`). `false` is disabled
skipCreatedBefore: false
# Issues and pull requests with these labels will be ignored.
exemptLabels: []
# Label to add before locking, such as `outdated`. `false` is disabled
lockLabel: false
# Comment to post before locking.
lockComment: >
This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs and link to relevant comments in this thread.
# Assign `resolved` as the reason for locking. Set to `false` to disable
setLockReason: true

View file

@ -1,7 +1,9 @@
<!-- start tips -->
Please check the following:
1. Make sure you are targeting the `master` branch, pull requests on release branches are only allowed for bug fixes.
2. Read contributing guidelines: https://github.com/go-gitea/gitea/blob/master/CONTRIBUTING.md
3. Describe what your pull request does and which issue you're targeting (if any)
**You MUST delete the content above including this line before posting, otherwise your pull request will be invalid.**
1. Make sure you are targeting the `main` branch, pull requests on release branches are only allowed for backports.
2. Make sure you have read contributing guidelines: https://github.com/go-gitea/gitea/blob/main/CONTRIBUTING.md .
3. Describe what your pull request does and which issue you're targeting (if any).
4. It is recommended to enable "Allow edits by maintainers", so maintainers can help more easily.
5. Your input here will be included in the commit message when this PR has been merged. If you don't want some content to be included, please separate them with a line like `---`.
6. Delete all these tips before posting.
<!-- end tips -->

9
.github/stale.yml vendored
View file

@ -27,9 +27,11 @@ staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs during the next 2 weeks. Thank you
for your contributions.
This issue has been automatically marked as stale because it has not had recent activity.
I am here to help clear issues left open even if solved or waiting for more insight.
This issue will be closed if no further activity occurs during the next 2 weeks.
If the issue is still valid just add a comment to keep it alive.
Thank you for your contributions.
# Comment to post when closing a stale Issue or Pull Request.
closeComment: >
@ -50,4 +52,3 @@ pulls:
closeComment: >
This pull request has been automatically closed because of inactivity.
You can re-open it if needed.

63
.gitignore vendored
View file

@ -9,6 +9,8 @@ _test
# IntelliJ
.idea
# Goland's output filename can not be set manually
/go_build_*
# MS VSCode
.vscode
@ -32,43 +34,68 @@ _testmain.go
*coverage.out
coverage.all
cpu.out
/modules/migration/bindata.go
/modules/migration/bindata.go.hash
/modules/options/bindata.go
/modules/options/bindata.go.hash
/modules/public/bindata.go
/modules/public/bindata.go.hash
/modules/templates/bindata.go
/modules/templates/bindata.go.hash
*.db
*.log
/gitea
/gitea-vet
/debug
/integrations.test
/bin
/dist
/custom
/custom/*
!/custom/conf
/custom/conf/*
!/custom/conf/app.example.ini
/data
/indexers
/log
/public/img/avatar
/integrations/gitea-integration-mysql
/integrations/gitea-integration-mysql8
/integrations/gitea-integration-pgsql
/integrations/gitea-integration-sqlite
/integrations/gitea-integration-mssql
/integrations/indexers-mysql
/integrations/indexers-mysql8
/integrations/indexers-pgsql
/integrations/indexers-sqlite
/integrations/indexers-mssql
/integrations/mysql.ini
/integrations/mysql8.ini
/integrations/pgsql.ini
/integrations/mssql.ini
/tests/integration/gitea-integration-*
/tests/integration/indexers-*
/tests/e2e/gitea-e2e-*
/tests/e2e/indexers-*
/tests/e2e/reports
/tests/e2e/test-artifacts
/tests/e2e/test-snapshots
/tests/*.ini
/node_modules
/yarn.lock
/yarn-error.log
/npm-debug.log*
/public/js
/public/serviceworker.js
/public/css
/public/fonts
/public/img/webpack
/vendor
/web_src/fomantic/node_modules
/web_src/fomantic/build/*
!/web_src/fomantic/build/semantic.js
!/web_src/fomantic/build/semantic.css
!/web_src/fomantic/build/themes
/web_src/fomantic/build/themes/*
!/web_src/fomantic/build/themes/default
/web_src/fomantic/build/themes/default/assets/*
!/web_src/fomantic/build/themes/default/assets/fonts
/web_src/fomantic/build/themes/default/assets/fonts/*
!/web_src/fomantic/build/themes/default/assets/fonts/icons.woff2
!/web_src/fomantic/build/themes/default/assets/fonts/outline-icons.woff2
/VERSION
/.air
/.go-licenses
# Snapcraft
snap/.snapcraft/
@ -79,3 +106,9 @@ prime/
*.snap-build
*_source.tar.bz2
.DS_Store
# Make evidence files
/.make_evidence
# Manpage
/man

47
.gitpod.yml Normal file
View file

@ -0,0 +1,47 @@
tasks:
- name: Setup
init: |
cp -r contrib/ide/vscode .vscode
make deps
make build
command: |
gp sync-done setup
exit 0
- name: Run backend
command: |
gp sync-await setup
if [ ! -f custom/conf/app.ini ]
then
mkdir -p custom/conf/
echo -e "[server]\nROOT_URL=$(gp url 3000)/" > custom/conf/app.ini
echo -e "\n[database]\nDB_TYPE = sqlite3\nPATH = $GITPOD_REPO_ROOT/data/gitea.db" >> custom/conf/app.ini
fi
export TAGS="sqlite sqlite_unlock_notify"
make watch-backend
- name: Run frontend
command: |
gp sync-await setup
make watch-frontend
openMode: split-right
- name: Run docs
before: sudo bash -c "$(grep 'https://github.com/gohugoio/hugo/releases/download' Makefile | tr -d '\')" # install hugo
command: cd docs && make clean update && hugo server -D -F --baseUrl $(gp url 1313) --liveReloadPort=443 --appendPort=false --bind=0.0.0.0
openMode: split-right
vscode:
extensions:
- editorconfig.editorconfig
- dbaeumer.vscode-eslint
- golang.go
- stylelint.vscode-stylelint
- DavidAnson.vscode-markdownlint
- johnsoncodehk.volar
- ms-azuretools.vscode-docker
- zixuanchen.vitest-explorer
- alexcvzz.vscode-sqlite
ports:
- name: Gitea
port: 3000
- name: Docs
port: 1313

View file

@ -1,34 +1,94 @@
linters:
enable:
- gosimple
- deadcode
- typecheck
- govet
- errcheck
- staticcheck
- unused
- structcheck
- varcheck
- golint
- bidichk
# - deadcode # deprecated - https://github.com/golangci/golangci-lint/issues/1841
- depguard
- dupl
#- gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
- gofmt
- misspell
- errcheck
- gocritic
# - gocyclo # The cyclomatic complexety of a lot of functions is too high, we should refactor those another time.
- gofmt
- gofumpt
- gosimple
- govet
- ineffassign
- nakedret
- nolintlint
- revive
- staticcheck
# - structcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
- stylecheck
- typecheck
- unconvert
- unused
# - varcheck # deprecated - https://github.com/golangci/golangci-lint/issues/1841
# - wastedassign # disabled - https://github.com/golangci/golangci-lint/issues/2649
enable-all: false
disable-all: true
fast: false
run:
timeout: 3m
go: "1.20"
timeout: 10m
skip-dirs:
- node_modules
- public
- web_src
linters-settings:
stylecheck:
checks: ["all", "-ST1005", "-ST1003"]
nakedret:
max-func-lines: 0
gocritic:
disabled-checks:
- ifElseChain
- singleCaseSwitch # Every time this occured in the code, there was no other way.
- singleCaseSwitch # Every time this occurred in the code, there was no other way.
revive:
ignore-generated-header: false
severity: warning
confidence: 0.8
errorCode: 1
warningCode: 1
rules:
- name: blank-imports
- name: context-as-argument
- name: context-keys-type
- name: dot-imports
- name: error-return
- name: error-strings
- name: error-naming
- name: exported
- name: if-return
- name: increment-decrement
- name: var-naming
- name: var-declaration
- name: package-comments
- name: range
- name: receiver-naming
- name: time-naming
- name: unexported-return
- name: indent-error-flow
- name: errorf
- name: duplicated-imports
- name: modifies-value-receiver
gofumpt:
extra-rules: true
lang-version: "1.20"
depguard:
list-type: denylist
# Check the list against standard lib.
include-go-root: true
packages-with-error-message:
- encoding/json: "use gitea's modules/json instead of encoding/json"
- github.com/unknwon/com: "use gitea's util and replacements"
- io/ioutil: "use os or io instead"
- golang.org/x/exp: "it's experimental and unreliable."
- code.gitea.io/gitea/modules/git/internal: "do not use the internal package, use AddXxx function instead"
issues:
max-issues-per-linter: 0
max-same-issues: 0
exclude-rules:
# Exclude some linters from running on tests files.
- path: _test\.go
@ -70,9 +130,6 @@ issues:
- path: modules/log/
linters:
- errcheck
- path: routers/routes/routes.go
linters:
- dupl
- path: routers/api/v1/repo/issue_subscription.go
linters:
- dupl
@ -92,6 +149,29 @@ issues:
- path: models/issue_comment_list.go
linters:
- dupl
- linters:
- misspell
text: '`Unknwon` is a misspelling of `Unknown`'
- path: models/update.go
linters:
- unused
- path: cmd/dump.go
linters:
- dupl
- path: services/webhook/webhook.go
linters:
- structcheck
- text: "commentFormatting: put a space between `//` and comment text"
linters:
- gocritic
- text: "exitAfterDefer:"
linters:
- gocritic
- path: modules/graceful/manager_windows.go
linters:
- staticcheck
text: "svc.IsAnInteractiveSession is deprecated: Use IsWindowsService instead."
- path: models/user/openid.go
linters:
- golint
- path: models/user/badge.go
linters:
- revive
text: "exported: type name will be used as user.UserBadge by other packages, and that stutters; consider calling this Badge"

View file

@ -1,5 +1,8 @@
/vendor
/public/vendor
*.min.css
*.min.js
/modules/options/bindata.go
/modules/public/bindata.go
/modules/templates/bindata.go
/public/vendor/plugins
/vendor
node_modules

18
.markdownlint.yaml Normal file
View file

@ -0,0 +1,18 @@
commands-show-output: false
fenced-code-language: false
first-line-h1: false
header-increment: false
line-length: {code_blocks: false, tables: false, stern: true, line_length: -1}
no-alt-text: false
no-bare-urls: false
no-blanks-blockquote: false
no-duplicate-header: {allow_different_nesting: true}
no-emphasis-as-header: false
no-empty-links: false
no-hard-tabs: {code_blocks: false}
no-inline-html: false
no-space-in-code: false
no-space-in-emphasis: false
no-trailing-punctuation: false
no-trailing-spaces: {br_spaces: 0}
single-h1: false

4
.npmrc
View file

@ -1 +1,5 @@
audit=false
fund=false
update-notifier=false
package-lock=true
save-exact=true

View file

@ -1,25 +0,0 @@
ignoreGeneratedHeader = false
severity = "warning"
confidence = 0.8
errorCode = 1
warningCode = 1
[rule.blank-imports]
[rule.context-as-argument]
[rule.context-keys-type]
[rule.dot-imports]
[rule.error-return]
[rule.error-strings]
[rule.error-naming]
[rule.exported]
[rule.if-return]
[rule.increment-decrement]
[rule.var-naming]
[rule.var-declaration]
[rule.package-comments]
[rule.range]
[rule.receiver-naming]
[rule.time-naming]
[rule.unexported-return]
[rule.indent-error-flow]
[rule.errorf]

12
.spectral.yaml Normal file
View file

@ -0,0 +1,12 @@
extends: [[spectral:oas, all]]
rules:
info-contact: off
oas2-api-host: off
oas2-parameter-description: off
oas2-schema: off
oas2-valid-schema-example: off
openapi-tags: off
operation-description: off
operation-singular-tag: off
operation-tag-defined: off

View file

@ -1,11 +0,0 @@
extends: stylelint-config-standard
rules:
block-closing-brace-empty-line-before: null
color-hex-length: null
comment-empty-line-before: null
declaration-empty-line-before: null
indentation: 4
no-descending-specificity: null
rule-empty-line-before: null
selector-pseudo-element-colon-notation: null

139
.stylelintrc.yaml Normal file
View file

@ -0,0 +1,139 @@
plugins:
- stylelint-declaration-strict-value
ignoreFiles:
- "**/*.go"
overrides:
- files: ["**/*.less"]
customSyntax: postcss-less
- files: ["**/chroma/*", "**/codemirror/*", "**/standalone/*", "**/console/*"]
rules:
scale-unlimited/declaration-strict-value: null
- files: ["**/chroma/*", "**/codemirror/*"]
rules:
block-no-empty: null
rules:
alpha-value-notation: null
annotation-no-unknown: true
at-rule-allowed-list: null
at-rule-disallowed-list: null
at-rule-empty-line-before: null
at-rule-no-unknown: true
at-rule-no-vendor-prefix: true
at-rule-property-required-list: null
block-no-empty: true
color-function-notation: null
color-hex-alpha: null
color-hex-length: null
color-named: null
color-no-hex: null
color-no-invalid-hex: true
comment-empty-line-before: null
comment-no-empty: true
comment-pattern: null
comment-whitespace-inside: null
comment-word-disallowed-list: null
custom-media-pattern: null
custom-property-empty-line-before: null
custom-property-no-missing-var-function: true
custom-property-pattern: null
declaration-block-no-duplicate-custom-properties: true
declaration-block-no-duplicate-properties: [true, {ignore: [consecutive-duplicates-with-different-values]}]
declaration-block-no-redundant-longhand-properties: null
declaration-block-no-shorthand-property-overrides: null
declaration-block-single-line-max-declarations: null
declaration-empty-line-before: null
declaration-no-important: null
declaration-property-max-values: null
declaration-property-unit-allowed-list: null
declaration-property-unit-disallowed-list: null
declaration-property-value-allowed-list: null
declaration-property-value-disallowed-list: null
declaration-property-value-no-unknown: true
font-family-name-quotes: always-where-recommended
font-family-no-duplicate-names: true
font-family-no-missing-generic-family-keyword: true
font-weight-notation: null
function-allowed-list: null
function-calc-no-unspaced-operator: true
function-disallowed-list: null
function-linear-gradient-no-nonstandard-direction: true
function-name-case: lower
function-no-unknown: null
function-url-no-scheme-relative: null
function-url-quotes: always
function-url-scheme-allowed-list: null
function-url-scheme-disallowed-list: null
hue-degree-notation: null
import-notation: string
keyframe-block-no-duplicate-selectors: true
keyframe-declaration-no-important: true
keyframe-selector-notation: null
keyframes-name-pattern: null
length-zero-no-unit: true
max-nesting-depth: null
media-feature-name-allowed-list: null
media-feature-name-disallowed-list: null
media-feature-name-no-unknown: true
media-feature-name-no-vendor-prefix: true
media-feature-name-unit-allowed-list: null
media-feature-name-value-allowed-list: null
media-feature-range-notation: null
named-grid-areas-no-invalid: true
no-descending-specificity: null
no-duplicate-at-import-rules: true
no-duplicate-selectors: true
no-empty-source: true
no-invalid-double-slash-comments: true
no-invalid-position-at-import-rule: null
no-irregular-whitespace: true
no-unknown-animations: null
number-max-precision: null
property-allowed-list: null
property-disallowed-list: null
property-no-unknown: true
property-no-vendor-prefix: null
rule-empty-line-before: null
rule-selector-property-disallowed-list: null
scale-unlimited/declaration-strict-value: [color, {ignoreValues: /^(inherit|transparent|unset|initial|currentcolor)$/}]
selector-attribute-name-disallowed-list: null
selector-attribute-operator-allowed-list: null
selector-attribute-operator-disallowed-list: null
selector-attribute-quotes: always
selector-class-pattern: null
selector-combinator-allowed-list: null
selector-combinator-disallowed-list: null
selector-disallowed-list: null
selector-id-pattern: null
selector-max-attribute: null
selector-max-class: null
selector-max-combinators: null
selector-max-compound-selectors: null
selector-max-id: null
selector-max-pseudo-class: null
selector-max-specificity: null
selector-max-type: null
selector-max-universal: null
selector-nested-pattern: null
selector-no-qualifying-type: null
selector-no-vendor-prefix: true
selector-not-notation: null
selector-pseudo-class-allowed-list: null
selector-pseudo-class-disallowed-list: null
selector-pseudo-class-no-unknown: true
selector-pseudo-element-allowed-list: null
selector-pseudo-element-colon-notation: double
selector-pseudo-element-disallowed-list: null
selector-pseudo-element-no-unknown: true
selector-type-case: lower
selector-type-no-unknown: [true, {ignore: [custom-elements]}]
shorthand-property-no-redundant-values: true
string-no-newline: true
time-min-milliseconds: null
unit-allowed-list: null
unit-disallowed-list: null
unit-no-unknown: true
value-keyword-case: null
value-no-vendor-prefix: [true, {ignoreValues: [box, inline-box]}]

File diff suppressed because it is too large Load diff

96
CODE_OF_CONDUCT.md Normal file
View file

@ -0,0 +1,96 @@
# Gitea Community Code of Conduct
## About
Online communities include people from many different backgrounds. The Gitea contributors are committed to providing a friendly, safe and welcoming environment for all, regardless of gender identity and expression, sexual orientation, disabilities, neurodiversity, physical appearance, body size, ethnicity, nationality, race, age, religion, or similar personal characteristics.
The first goal of the Code of Conduct is to specify a baseline standard of behavior so that people with different social values and communication styles can talk about Gitea effectively, productively, and respectfully.
The second goal is to provide a mechanism for resolving conflicts in the community when they arise.
The third goal of the Code of Conduct is to make our community welcoming to people from different backgrounds. Diversity is critical to the project; for Gitea to be successful, it needs contributors and users from all backgrounds.
We believe that healthy debate and disagreement are essential to a healthy project and community. However, it is never ok to be disrespectful. We value diverse opinions, but we value respectful behavior more.
## Community values
These are the values to which people in the Gitea community should aspire.
- **Be friendly and welcoming.**
- **Be patient.**
- Remember that people have varying communication styles and that not everyone is using their native language. (Meaning and tone can be lost in translation.)
- **Be thoughtful.**
- Productive communication requires effort. Think about how your words will be interpreted.
- Remember that sometimes it is best to refrain entirely from commenting.
- **Be respectful.**
- In particular, respect differences of opinion.
- **Be charitable.**
- Interpret the arguments of others in good faith, do not seek to disagree.
- When we do disagree, try to understand why.
- **Be constructive.**
- Avoid derailing: stay on topic; if you want to talk about something else, start a new conversation.
- Avoid unconstructive criticism: don't merely decry the current state of affairs; offer—or at least solicit—suggestions as to how things may be improved.
- Avoid snarking (pithy, unproductive, sniping comments)
- Avoid discussing potentially offensive or sensitive issues; this all too often leads to unnecessary conflict.
- Avoid microaggressions (brief and commonplace verbal, behavioral and environmental indignities that communicate hostile, derogatory or negative slights and insults to a person or group).
- **Be responsible.**
- What you say and do matters. Take responsibility for your words and actions, including their consequences, whether intended or otherwise.
People are complicated. You should expect to be misunderstood and to misunderstand others; when this inevitably occurs, resist the urge to be defensive or assign blame. Try not to take offense where no offense was intended. Give people the benefit of the doubt. Even if the intent was to provoke, do not rise to it. It is the responsibility of all parties to de-escalate conflict when it arises.
## Code of Conduct
### Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
### Our Standards
Examples of behavior that contributes to creating a positive environment include:
- Using welcoming and inclusive language
- Being respectful of differing viewpoints and experiences
- Gracefully accepting constructive criticism
- Focusing on what is best for the community
- Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
- The use of sexualized language or imagery and unwelcome sexual attention or advances
- Trolling, insulting/derogatory comments, and personal or political attacks
- Public or private harassment
- Publishing others private information, such as a physical or electronic address, without explicit permission
- Other conduct which could reasonably be considered inappropriate in a professional setting
### Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject: comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, as well as to ban (temporarily or permanently) any contributor for behaviors that they deem inappropriate, threatening, offensive, or harmful.
### Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
This Code of Conduct also applies outside the project spaces when the Project Stewards have a reasonable belief that an individuals behavior may have a negative impact on the project or its community.
### Conflict Resolution
We do not believe that all conflict is bad; healthy debate and disagreement often yield positive results. However, it is never okay to be disrespectful or to engage in behavior that violates the projects code of conduct.
If you see someone violating the code of conduct, you are encouraged to address the behavior directly with those involved. Many issues can be resolved quickly and easily, and this gives people more control over the outcome of their dispute. If you are unable to resolve the matter for any reason, or if the behavior is threatening or harassing, report it. We are dedicated to providing an environment where participants feel welcome and safe.
Reports should be directed to the Gitea Project Stewards at conduct@gitea.com. It is the Project Stewards duty to receive and address reported violations of the code of conduct. They will then work with a committee consisting of representatives from the technical-oversight-committee.
We will investigate every complaint, but you may not receive a direct response. We will use our discretion in determining when and how to follow up on reported incidents, which may range from not taking action to permanent expulsion from the project and project-sponsored spaces. Under normal circumstances, we will notify the accused of the report and provide them an opportunity to discuss it before any action is taken. If there is a consensus between maintainers that such an endeavor would be useless (i.e. in case of an obvious spammer), we reserve the right to take action without notifying the accused first. The identity of the reporter will be omitted from the details of the report supplied to the accused. In potentially harmful situations, such as ongoing harassment or threats to anyones safety, we may take action without notice.
### Attribution
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
## Summary
- Treat everyone with respect and kindness.
- Be thoughtful in how you communicate.
- Dont be destructive or inflammatory.
- If you encounter an issue, please mail conduct@gitea.com.

View file

@ -3,12 +3,14 @@
## Table of Contents
- [Contribution Guidelines](#contribution-guidelines)
- [Table of Contents](#table-of-contents)
- [Introduction](#introduction)
- [Bug reports](#bug-reports)
- [Discuss your design](#discuss-your-design)
- [Testing redux](#testing-redux)
- [Vendoring](#vendoring)
- [Translation](#translation)
- [Building Gitea](#building-gitea)
- [Code review](#code-review)
- [Styleguide](#styleguide)
- [Design guideline](#design-guideline)
@ -71,33 +73,32 @@ to make sure your changes don't cause regression elsewhere.
Here's how to run the test suite:
- Install the correct version of the drone-cli package. As of this
writing, the correct drone-cli version is
[1.2.0](https://docs.drone.io/cli/install/).
- Ensure you have enough free disk space. You will need at least
15-20 Gb of free disk space to hold all of the containers drone
creates (a default AWS or GCE disk size won't work -- see
[#6243](https://github.com/go-gitea/gitea/issues/6243)).
- Change into the base directory of your copy of the gitea repository,
and run `drone exec --event pull_request`.
- At the moment `drone exec` doesn't support the Docker Toolbox on Windows 10
(see [drone-cli#135](https://github.com/drone/drone-cli/issues/135))
- code lint
The drone version, command line, and disk requirements do change over
time (see [#4053](https://github.com/go-gitea/gitea/issues/4053) and
[#6243](https://github.com/go-gitea/gitea/issues/6243)); if you
discover any issues, please feel free to send us a pull request to
update these instructions.
| | |
| :-------------------- | :---------------------------------------------------------------- |
|``make lint`` | lint everything (not suggest if you only change one type code) |
|``make lint-frontend`` | lint frontend files |
|``make lint-backend`` | lint backend files |
- run test code (Suggest run in Linux)
| | |
| :------------------------------------- | :----------------------------------------------- |
|``make test[\#TestSpecificName]`` | run unit test |
|``make test-sqlite[\#TestSpecificName]``| run [integration](tests/integration) test for SQLite |
|[More details about integration tests](tests/integration/README.md) |
|``make test-e2e-sqlite[\#TestSpecificFileName]``| run [end-to-end](tests/e2e) test for SQLite |
|[More details about e2e tests](tests/e2e/README.md) |
## Vendoring
We keep a cached copy of dependencies within the `vendor/` directory,
managing updates via [Modules](https://golang.org/cmd/go/#hdr-Module_maintenance).
We manage dependencies via [Go Modules](https://golang.org/cmd/go/#hdr-Module_maintenance), more details: [go mod](https://go.dev/ref/mod).
Pull requests should only include `vendor/` updates if they are part of
Pull requests should only include `go.mod`, `go.sum` updates if they are part of
the same change, be it a bugfix or a feature addition.
The `vendor/` update needs to be justified as part of the PR description,
The `go.mod`, `go.sum` update needs to be justified as part of the PR description,
and must be verified by the reviewers and/or merger to always reference
an existing upstream commit.
@ -106,7 +107,7 @@ You can find more information on how to get started with it on the [Modules Wiki
## Translation
We do all translation work inside [Crowdin](https://crowdin.com/project/gitea).
The only translation that is maintained in this git repository is
The only translation that is maintained in this Git repository is
[`en_US.ini`](https://github.com/go-gitea/gitea/blob/master/options/locale/locale_en-US.ini)
and is synced regularly to Crowdin. Once a translation has reached
A SATISFACTORY PERCENTAGE it will be synced back into this repo and
@ -114,15 +115,7 @@ included in the next released version.
## Building Gitea
Generally, the go build tools are installed as-needed in the `Makefile`.
An exception are the tools to build the CSS, JS and images.
- To build CSS and JS: Install [Node.js](https://nodejs.org/en/download/package-manager) at version 10.0 or above
with `npm` and then run `npm install`, `make css` and `make js`.
- To build Images: ImageMagick, inkscape and zopflipng binaries must be
available in your `PATH` to run `make generate-images`.
For more details on how to generate files, build and test Gitea, see the [hacking instructions](https://docs.gitea.io/en-us/hacking-on-gitea/)
See the [hacking instructions](https://docs.gitea.io/en-us/hacking-on-gitea/).
## Code review
@ -136,22 +129,42 @@ the *[How to get faster PR reviews](https://github.com/kubernetes/community/blob
it has lots of useful tips for any project you may want to contribute.
Some of the key points:
* Make small pull requests. The smaller, the faster to review and the
- Make small pull requests. The smaller, the faster to review and the
more likely it will be merged soon.
* Don't make changes unrelated to your PR. Maybe there are typos on
- Don't make changes unrelated to your PR. Maybe there are typos on
some comments, maybe refactoring would be welcome on a function... but
if that is not related to your PR, please make *another* PR for that.
* Split big pull requests into multiple small ones. An incremental change
- Split big pull requests into multiple small ones. An incremental change
will be faster to review than a huge PR.
- Use the first comment as a summary explainer of your PR and you should keep this up-to-date as the PR evolves.
If your PR could cause a breaking change you must add a BREAKING section to this comment e.g.:
```
## :warning: BREAKING :warning:
```
To explain how this could affect users and how to mitigate these changes.
Once code review starts on your PR, do not rebase nor squash your branch as it makes it
difficult to review the new changes. Only if there is a need, sync your branch by merging
the base branch into yours. Don't worry about merge commits messing up your tree as
the final merge process squashes all commits into one, with the visible commit message (first
line) being the PR title + PR index and description being the PR's first comment.
Once your PR gets the `lgtm/done` label, don't worry about keeping it up-to-date or breaking
builds (unless there's a merge conflict or a request is made by a maintainer to make
modifications). It is the maintainer team's responsibility from this point to get it merged.
## Styleguide
For imports you should use the following format (_without_ the comments)
For imports you should use the following format (*without* the comments)
```go
import (
// stdlib
"encoding/json"
"fmt"
"math"
// local packages
"code.gitea.io/gitea/models"
@ -165,56 +178,100 @@ import (
## Design guideline
To maintain understandable code and avoid circular dependencies it is important to have a good structure of the code. The gitea code is divided into the following parts:
To maintain understandable code and avoid circular dependencies it is important to have a good structure of the code. The Gitea code is divided into the following parts:
- **integration:** Integrations tests
- **models:** Contains the data structures used by xorm to construct database tables. It also contains supporting functions to query and update the database. Dependecies to other code in Gitea should be avoided although some modules might be needed (for example for logging).
- **models:** Contains the data structures used by xorm to construct database tables. It also contains supporting functions to query and update the database. Dependencies to other code in Gitea should be avoided although some modules might be needed (for example for logging).
- **models/fixtures:** Sample model data used in integration tests.
- **models/migrations:** Handling of database migrations between versions. PRs that changes a database structure shall also have a migration step.
- **modules:** Different modules to handle specific functionality in Gitea.
- **modules:** Different modules to handle specific functionality in Gitea. Shall only depend on other modules but not other packages (models, services).
- **public:** Frontend files (javascript, images, css, etc.)
- **routers:** Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) shall not depend on routers
- **routers:** Handling of server requests. As it uses other Gitea packages to serve the request, other packages (models, modules or services) shall not depend on routers.
- **services:** Support functions for common routing operations. Uses models and modules to handle the request.
- **templates:** Golang templates for generating the html output.
- **tests/e2e:** End to end tests
- **tests/integration:** Integration tests
- **tests/gitea-repositories-meta:** Sample repos used in integration tests. Adding a new repo requires editing `models/fixtures/repositories.yml` and `models/fixtures/repo_unit.yml` to match.
- **tests/gitea-lfs-meta:** Sample LFS objects used in integration tests. Adding a new object requires editing `models/fixtures/lfs_meta_object.yml` to match.
- **vendor:** External code that Gitea depends on.
## Documentation
If you add a new feature or change an existing aspect of Gitea, the documentation for that feature must be created or updated.
## API v1
The API is documented by [swagger](http://try.gitea.io/api/swagger) and is based on [GitHub API v3](https://developer.github.com/v3/).
Thus, Gitea´s API should use the same endpoints and fields as GitHub´s API as far as possible, unless there are good reasons to deviate.
If Gitea provides functionality that GitHub does not, a new endpoint can be created.
Thus, Gitea´s API should use the same endpoints and fields as GitHub´s API as far as possible, unless there are good reasons to deviate.
If Gitea provides functionality that GitHub does not, a new endpoint can be created.
If information is provided by Gitea that is not provided by the GitHub API, a new field can be used that doesn't collide with any GitHub fields.
Updating an existing API should not remove existing fields unless there is a really good reason to do so.
The same applies to status responses. If you notice a problem, feel free to leave a comment in the code for future refactoring to APIv2 (which is currently not planned).
All expected results (errors, success, fail messages) should be documented
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/repo/issue.go#L319-L327)).
All JSON input types must be defined as a struct in `models/structs/`
All JSON input types must be defined as a struct in [modules/structs/](modules/structs/)
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/modules/structs/issue.go#L76-L91))
and referenced in
[routers/api/v1/swagger/options.go](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/swagger/options.go).
[routers/api/v1/swagger/options.go](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/swagger/options.go).
They can then be used like the following:
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/repo/issue.go#L318)).
All JSON responses must be defined as a struct in `models/structs/`
All JSON responses must be defined as a struct in [modules/structs/](modules/structs/)
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/modules/structs/issue.go#L36-L68))
and referenced in its category in `routers/api/v1/swagger/`
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/swagger/issue.go#L11-L16))
and referenced in its category in [routers/api/v1/swagger/](routers/api/v1/swagger/)
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/swagger/issue.go#L11-L16))
They can be used like the following:
([example](https://github.com/go-gitea/gitea/blob/c620eb5b2d0d874da68ebd734d3864c5224f71f7/routers/api/v1/repo/issue.go#L277-L279))
In general, HTTP methods are chosen as follows:
* **GET** endpoints return requested object and status **OK (200)**
* **DELETE** endpoints return status **No Content (204)**
* **POST** endpoints return status **Created (201)**, used to **create** new objects (e.g. a User)
* **PUT** endpoints return status **No Content (204)**, used to **add/assign** existing Obejcts (e.g. User) to something (e.g. Org-Team)
* **PATCH** endpoints return changed object and status **OK (200)**, used to **edit/change** an existing object
- **GET** endpoints return requested object and status **OK (200)**
- **DELETE** endpoints return status **No Content (204)**
- **POST** endpoints return status **Created (201)**, used to **create** new objects (e.g. a User)
- **PUT** endpoints return status **No Content (204)**, used to **add/assign** existing Objects (e.g. User) to something (e.g. Org-Team)
- **PATCH** endpoints return changed object and status **OK (200)**, used to **edit/change** an existing object
An endpoint which changes/edits an object expects all fields to be optional (except ones to identify the object, which are required).
### Endpoints returning lists should
- support pagination (`page` & `limit` options in query)
- set `X-Total-Count` header via **SetTotalCountHeader** ([example](https://github.com/go-gitea/gitea/blob/7aae98cc5d4113f1e9918b7ee7dd09f67c189e3e/routers/api/v1/repo/issue.go#L444))
## Backports and Frontports
Occasionally backports of PRs are required.
The backported PR title should be:
```
Title of backported PR (#ORIGINAL_PR_NUMBER)
```
The first two lines of the summary of the backporting PR should be:
```
Backport #ORIGINAL_PR_NUMBER
```
with the rest of the summary matching the original PR. Similarly for frontports
---
A command to help create backports can be found in `contrib/backport` and can be installed (from inside the gitea repo root directory) using:
```bash
go install contrib/backport/backport.go
```
## Developer Certificate of Origin (DCO)
@ -227,7 +284,7 @@ Additionally you could add a line at the end of your commit message.
Signed-off-by: Joe Smith <joe.smith@email.com>
```
If you set your `user.name` and `user.email` git configs, you can add the
If you set your `user.name` and `user.email` Git configs, you can add the
line to the end of your commit automatically with `git commit -s`.
We assume in good faith that the information you provide is legally binding.
@ -236,24 +293,32 @@ We assume in good faith that the information you provide is legally binding.
We adopted a release schedule to streamline the process of working
on, finishing, and issuing releases. The overall goal is to make a
minor release every two months, which breaks down into one month of
minor release every three or four months, which breaks down into two or three months of
general development followed by one month of testing and polishing
known as the release freeze. All the feature pull requests should be
merged in the first month of one release period. And, during the frozen
period, a corresponding release branch is open for fixes backported from
master. Release candidates are made during this period for user testing to
obtain a final version that is maintained in this branch. A release is
maintained by issuing patch releases to only correct critical problems
such as crashes or security issues.
merged before feature freeze. And, during the frozen period, a corresponding
release branch is open for fixes backported from main branch. Release candidates
are made during this period for user testing to
obtain a final version that is maintained in this branch.
Major release cycles are bimonthly. They always begin on the 25th and end on
the 24th (i.e., the 25th of December to February 24th).
Major release cycles are seasonal. They always begin on the 25th and end on
the 24th (i.e., the 25th of December to March 24th).
During a development cycle, we may also publish any necessary minor releases
for the previous version. For example, if the latest, published release is
v1.2, then minor changes for the previous release—e.g., v1.1.0 -> v1.1.1—are
still possible.
The previous release gets fixes for:
- Security issues
- Critical bugs
- Regressions
- Build issues
- Necessary enhancements (including necessary UI/UX fixes)
The backported fixes should avoid breaking downgrade between minor releases as much as possible.
## Maintainers
To make sure every PR is checked, we have [team
@ -272,7 +337,7 @@ to the maintainers team. If a maintainer is inactive for more than 3
months and forgets to leave the maintainers team, the owners may move
him or her from the maintainers team to the advisors team.
For security reasons, Maintainers should use 2FA for their accounts and
if possible provide gpg signed commits.
if possible provide GPG signed commits.
https://help.github.com/articles/securing-your-account-with-two-factor-authentication-2fa/
https://help.github.com/articles/signing-commits-with-gpg/
@ -303,60 +368,74 @@ and lead the development of Gitea.
To honor the past owners, here's the history of the owners and the time
they served:
* 2016-11-04 ~ 2017-12-31
* [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
* [Thomas Boerger](https://github.com/tboerger) <thomas@webhippie.de>
* [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
- 2022-01-01 ~ 2022-12-31 - https://github.com/go-gitea/gitea/issues/17872
- [Lunny Xiao](https://gitea.com/lunny) <xiaolunwen@gmail.com>
- [Matti Ranta](https://gitea.com/techknowlogick) <techknowlogick@gitea.io>
- [Andrew Thornton](https://gitea.com/zeripath) <art27@cantab.net>
* 2018-01-01 ~ 2018-12-31
* [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
* [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
* [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
- 2021-01-01 ~ 2021-12-31 - https://github.com/go-gitea/gitea/issues/13801
- [Lunny Xiao](https://gitea.com/lunny) <xiaolunwen@gmail.com>
- [Lauris Bukšis-Haberkorns](https://gitea.com/lafriks) <lauris@nix.lv>
- [Matti Ranta](https://gitea.com/techknowlogick) <techknowlogick@gitea.io>
* 2019-01-01 ~ 2019-12-31
* [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
* [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
* [Matti Ranta](https://github.com/techknowlogick) <techknowlogick@gitea.io>
- 2020-01-01 ~ 2020-12-31 - https://github.com/go-gitea/gitea/issues/9230
- [Lunny Xiao](https://gitea.com/lunny) <xiaolunwen@gmail.com>
- [Lauris Bukšis-Haberkorns](https://gitea.com/lafriks) <lauris@nix.lv>
- [Matti Ranta](https://gitea.com/techknowlogick) <techknowlogick@gitea.io>
* 2020-01-01 ~ 2020-12-31
* [Lunny Xiao](https://gitea.com/lunny) <xiaolunwen@gmail.com>
* [Lauris Bukšis-Haberkorns](https://gitea.com/lafriks) <lauris@nix.lv>
* [Matti Ranta](https://gitea.com/techknowlogick) <techknowlogick@gitea.io>
- 2019-01-01 ~ 2019-12-31 - https://github.com/go-gitea/gitea/issues/5572
- [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
- [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
- [Matti Ranta](https://github.com/techknowlogick) <techknowlogick@gitea.io>
- 2018-01-01 ~ 2018-12-31 - https://github.com/go-gitea/gitea/issues/3255
- [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
- [Lauris Bukšis-Haberkorns](https://github.com/lafriks) <lauris@nix.lv>
- [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
- 2016-11-04 ~ 2017-12-31
- [Lunny Xiao](https://github.com/lunny) <xiaolunwen@gmail.com>
- [Thomas Boerger](https://github.com/tboerger) <thomas@webhippie.de>
- [Kim Carlbäcker](https://github.com/bkcsoft) <kim.carlbacker@gmail.com>
## Versions
Gitea has the `master` branch as a tip branch and has version branches
Gitea has the `main` branch as a tip branch and has version branches
such as `release/v0.9`. `release/v0.9` is a release branch and we will
tag `v0.9.0` for binary download. If `v0.9.0` has bugs, we will accept
pull requests on the `release/v0.9` branch and publish a `v0.9.1` tag,
after bringing the bug fix also to the master branch.
after bringing the bug fix also to the main branch.
Since the `master` branch is a tip version, if you wish to use Gitea
Since the `main` branch is a tip version, if you wish to use Gitea
in production, please download the latest release tag version. All the
branches will be protected via GitHub, all the PRs to every branch must
be reviewed by two maintainers and must pass the automatic tests.
## Releasing Gitea
* Let $vmaj, $vmin and $vpat be Major, Minor and Patch version numbers, $vpat should be rc1, rc2, 0, 1, ...... $vmaj.$vmin will be kept the same as milestones on github or gitea in future.
* Before releasing, confirm all the version's milestone issues or PRs has been resolved. Then discuss the release on discord channel #maintainers and get agreed with almost all the owners and mergers. Or you can declare the version and if nobody against in about serval hours.
* If this is a big version first you have to create PR for changelog on branch `master` with PRs with label `changelog` and after it has been merged do following steps:
* Create `-dev` tag as `git tag -s -F release.notes v$vmaj.$vmin.0-dev` and push the tag as `git push origin v$vmaj.$vmin.0-dev`.
* When CI has finished building tag then you have to create a new branch named `release/v$vmaj.$vmin`
* If it is bugfix version create PR for changelog on branch `release/v$vmaj.$vmin` and wait till it is reviewed and merged.
* Add a tag as `git tag -s -F release.notes v$vmaj.$vmin.$`, release.notes file could be a temporary file to only include the changelog this version which you added to `CHANGELOG.md`.
* And then push the tag as `git push origin v$vmaj.$vmin.$`. Drone CI will automatically created a release and upload all the compiled binary. (But currently it didn't add the release notes automatically. Maybe we should fix that.)
* If needed send PR for changelog on branch `master`.
* Send PR to [blog repository](https://gitea.com/gitea/blog) announcing the release.
- Let $vmaj, $vmin and $vpat be Major, Minor and Patch version numbers, $vpat should be rc1, rc2, 0, 1, ...... $vmaj.$vmin will be kept the same as milestones on github or gitea in future.
- Before releasing, confirm all the version's milestone issues or PRs has been resolved. Then discuss the release on Discord channel #maintainers and get agreed with almost all the owners and mergers. Or you can declare the version and if nobody against in about serval hours.
- If this is a big version first you have to create PR for changelog on branch `main` with PRs with label `changelog` and after it has been merged do following steps:
- Create `-dev` tag as `git tag -s -F release.notes v$vmaj.$vmin.0-dev` and push the tag as `git push origin v$vmaj.$vmin.0-dev`.
- When CI has finished building tag then you have to create a new branch named `release/v$vmaj.$vmin`
- If it is bugfix version create PR for changelog on branch `release/v$vmaj.$vmin` and wait till it is reviewed and merged.
- Add a tag as `git tag -s -F release.notes v$vmaj.$vmin.$`, release.notes file could be a temporary file to only include the changelog this version which you added to `CHANGELOG.md`.
- And then push the tag as `git push origin v$vmaj.$vmin.$`. Drone CI will automatically create a release and upload all the compiled binary. (But currently it doesn't add the release notes automatically. Maybe we should fix that.)
- If needed send a frontport PR for the changelog to branch `main` and update the version in `docs/config.yaml` to refer to the new version.
- Send PR to [blog repository](https://gitea.com/gitea/blog) announcing the release.
- Verify all release assets were correctly published through CI on dl.gitea.io and GitHub releases. Once ACKed:
- bump the version of https://dl.gitea.io/gitea/version.json
- merge the blog post PR
- announce the release in discord `#announcements`
## Copyright
Code that you contribute should use the standard copyright header:
```
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// Copyright <year> The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
```
Files in the repository contain copyright from the year they are added

4
DCO
View file

@ -2,8 +2,6 @@ Developer Certificate of Origin
Version 1.1
Copyright (C) 2004, 2006 The Linux Foundation and its contributors.
660 York Street, Suite 102,
San Francisco, CA 94110 USA
Everyone is permitted to copy and distribute verbatim copies of this
license document, but changing it is not allowed.
@ -33,4 +31,4 @@ By making a contribution to this project, I certify that:
are public and that a record of the contribution (including all
personal information I submit with it, including my sign-off) is
maintained indefinitely and may be redistributed consistent with
this project or the open source license(s) involved.
this project or the open source license(s) involved.

View file

@ -1,14 +1,13 @@
###################################
#Build stage
FROM golang:1.13-alpine3.11 AS build-env
FROM golang:1.20-alpine3.17 AS build-env
ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}
ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata $TAGS"
ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS
#Build deps
RUN apk --no-cache add build-base git nodejs npm
@ -19,9 +18,12 @@ WORKDIR ${GOPATH}/src/code.gitea.io/gitea
#Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean build
&& make clean-all build
FROM alpine:3.11
# Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go
FROM alpine:3.17
LABEL maintainer="maintainers@gitea.io"
EXPOSE 22 3000
@ -37,7 +39,7 @@ RUN apk --no-cache add \
s6 \
sqlite \
su-exec \
tzdata
gnupg
RUN addgroup \
-S -g 1000 \
@ -49,7 +51,7 @@ RUN addgroup \
-u 1000 \
-G git \
git && \
echo "git:$(dd if=/dev/urandom bs=24 count=1 status=none | base64)" | chpasswd
echo "git:*" | chpasswd -e
ENV USER git
ENV GITEA_CUSTOM /data/gitea
@ -61,4 +63,8 @@ CMD ["/bin/s6-svscan", "/etc/s6"]
COPY docker/root /
COPY --from=build-env /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
RUN ln -s /app/gitea/gitea /usr/local/bin/gitea
COPY --from=build-env /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
RUN chmod 755 /usr/bin/entrypoint /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
RUN chmod 755 /etc/s6/gitea/* /etc/s6/openssh/* /etc/s6/.s6-svscan/*
RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh

76
Dockerfile.rootless Normal file
View file

@ -0,0 +1,76 @@
#Build stage
FROM golang:1.20-alpine3.17 AS build-env
ARG GOPROXY
ENV GOPROXY ${GOPROXY:-direct}
ARG GITEA_VERSION
ARG TAGS="sqlite sqlite_unlock_notify"
ENV TAGS "bindata timetzdata $TAGS"
ARG CGO_EXTRA_CFLAGS
#Build deps
RUN apk --no-cache add build-base git nodejs npm
#Setup repo
COPY . ${GOPATH}/src/code.gitea.io/gitea
WORKDIR ${GOPATH}/src/code.gitea.io/gitea
#Checkout version if set
RUN if [ -n "${GITEA_VERSION}" ]; then git checkout "${GITEA_VERSION}"; fi \
&& make clean-all build
# Begin env-to-ini build
RUN go build contrib/environment-to-ini/environment-to-ini.go
FROM alpine:3.17
LABEL maintainer="maintainers@gitea.io"
EXPOSE 2222 3000
RUN apk --no-cache add \
bash \
ca-certificates \
dumb-init \
gettext \
git \
curl \
gnupg
RUN addgroup \
-S -g 1000 \
git && \
adduser \
-S -H -D \
-h /var/lib/gitea/git \
-s /bin/bash \
-u 1000 \
-G git \
git
RUN mkdir -p /var/lib/gitea /etc/gitea
RUN chown git:git /var/lib/gitea /etc/gitea
COPY docker/rootless /
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/gitea /app/gitea/gitea
COPY --from=build-env --chown=root:root /go/src/code.gitea.io/gitea/environment-to-ini /usr/local/bin/environment-to-ini
COPY --from=build-env /go/src/code.gitea.io/gitea/contrib/autocompletion/bash_autocomplete /etc/profile.d/gitea_bash_autocomplete.sh
RUN chmod 755 /usr/local/bin/docker-entrypoint.sh /usr/local/bin/docker-setup.sh /app/gitea/gitea /usr/local/bin/gitea /usr/local/bin/environment-to-ini
RUN chmod 644 /etc/profile.d/gitea_bash_autocomplete.sh
#git:git
USER 1000:1000
ENV GITEA_WORK_DIR /var/lib/gitea
ENV GITEA_CUSTOM /var/lib/gitea/custom
ENV GITEA_TEMP /tmp/gitea
ENV TMPDIR /tmp/gitea
#TODO add to docs the ability to define the ini to load (useful to test and revert a config)
ENV GITEA_APP_INI /etc/gitea/app.ini
ENV HOME "/var/lib/gitea/git"
VOLUME ["/var/lib/gitea", "/etc/gitea"]
WORKDIR /var/lib/gitea
ENTRYPOINT ["/usr/bin/dumb-init", "--", "/usr/local/bin/docker-entrypoint.sh"]
CMD []

47
FEDERATION.md Normal file
View file

@ -0,0 +1,47 @@
# Federation
*This describes Gitea's future federation capabilities, not what it can do currently.*
Gitea is federated using [ActivityPub](https://www.w3.org/TR/activitypub/) and the [ForgeFed extension](https://forgefed.org/) so you can interact with users and repositories from other instances as if they were on your own instance. By using the standardized ActivityPub protocol, users on any fediverse software such as [Mastodon](https://joinmastodon.org/) can follow Gitea users, star repositories, receive activity updates, and comment on issues.
C2S ActivityPub is not supported because Gitea already has an existing API.
## Following
You can use any fediverse software to follow a Gitea user. Gitea will automatically accept follow requests. The usernames of remote users are displayed as `username@instance.com`. To follow a remote user, click follow on their profile page, and a pop-up box will appear for you to type in your instance. You are redirected to your own instance, where the remote user is fetched and rendered, and you can now follow them.
When following a Gitea user, you will receive updates when they star a repo, create, fork, or make a private repo public, or follow a user. If you are using Mastodon or Pleroma, these will show up in your feed.
## Starring
You can star repositories on another instance. The full name of a remote repository is `username@instance.com/reponame`. Similar to following, a pop-up box appears for you to type in your instance, and you are redirected to your own instance, where the remote repository is fetched and rendered.
## Organizations
You can add users from other instances to organizations. An organization has a name and an instance, so its full name would look like `orgname@instance.com`. This indicates that the organization data resides on `instance.com`. To prevent synchronization errors, this data is only synchronized one-way to other instances.
## Collaborators
You can add users from other instances as collaborators. As mentioned previously, a repository has full name `username@instance.com/reponame`, which indicates that the repository data resides on `instance.com`. Each collaborator's instance has a copy of the repository, but to prevent synchronization errors, the copy at `instance.com` is the main copy and it is synchronized one-way to all other instances. When a collaborator tries to modify their copy of the repository, the modification is first sent to the main copy at `instance.com` and then synchronized back to their instance.
## Issues
You can create an issue on a remote repository. Your instance can also render a remote issue that you created so you can edit it or comment on it.
## Forks
When forking a remote repository, the fork is created on your instance, not the remote instance.
## Pull requests
When opening a pull request to a remote repository, the pull request can be rendered on your instance. Federated pull requests use the AGit-flow.
## Comments
You can comment on an issue or pull request using any fediverse software. The issue and existing comments are rendered on your instance.
## Migrations
If you change your username or the name of a repository, Gitea handles this similarly to how Mastodon does. Gitea will send a `Move` activity to your followers and update your actor to point to the new actor and the new actor to point to the old actor.
Changing your instance or a repository's instance is handled in a similar way, but additionally, the data to be migrated between instances.

View file

@ -1,5 +1,4 @@
Alexey Makhov <amakhov@avito.ru> (@makhov)
Andrey Nering <andrey.nering@gmail.com> (@andreynering)
Bo-Yi Wu <appleboy.tw@gmail.com> (@appleboy)
Ethan Koenig <ethantkoenig@gmail.com> (@ethantkoenig)
Kees de Vries <bouwko@gmail.com> (@Bwko)
@ -7,7 +6,6 @@ Kim Carlbäcker <kim.carlbacker@gmail.com> (@bkcsoft)
LefsFlare <nobody@nobody.tld> (@LefsFlarey)
Lunny Xiao <xiaolunwen@gmail.com> (@lunny)
Matthias Loibl <mail@matthiasloibl.com> (@metalmatze)
Morgan Bazalgette <the@howl.moe> (@thehowl)
Rachid Zarouali <nobody@nobody.tld> (@xinity)
Rémy Boulanouar <admin@dblk.org> (@DblK)
Sandro Santilli <strk@kbt.io> (@strk)
@ -36,3 +34,19 @@ Mura Li <typeless@ctli.io> (@typeless)
6543 <6543@obermui.de> (@6543)
jaqra <jaqra@hotmail.com> (@jaqra)
David Svantesson <davidsvantesson@gmail.com> (@davidsvantesson)
a1012112796 <1012112796@qq.com> (@a1012112796)
Karl Heinz Marbaise <kama@soebes.de> (@khmarbaise)
Norwin Roosen <git@nroo.de> (@noerw)
Kyle Dumont <kdumontnu@gmail.com> (@kdumontnu)
Patrick Schratz <patrick.schratz@gmail.com> (@pat-s)
Janis Estelmann <admin@oldschoolhack.me> (@KN4CK3R)
Steven Kriegler <sk.bunsenbrenner@gmail.com> (@justusbunsi)
Jimmy Praet <jimmy.praet@telenet.be> (@jpraet)
Leon Hofmeister <dev.lh@web.de> (@delvh)
Wim <wim@42.be> (@42wim)
Jason Song <i@wolfogre.com> (@wolfogre)
Yarden Shoham <hrsi88@gmail.com> (@yardenshoham)
Yu Tian <zettat123@gmail.com> (@Zettat123)
Eddie Yang <576951401@qq.com> (@yp05327)
Dong Ge <gedong_1994@163.com> (@sillyguodong)
Xinyi Gong <hestergong@gmail.com> (@HesterG)

969
Makefile

File diff suppressed because it is too large Load diff

124
README.md
View file

@ -1,31 +1,71 @@
[简体中文](README_ZH.md)
<p align="center">
<a href="https://gitea.io/">
<img alt="Gitea" src="https://raw.githubusercontent.com/go-gitea/gitea/main/public/img/gitea.svg" width="220"/>
</a>
</p>
<h1 align="center">Gitea - Git with a cup of tea</h1>
<h1> <img src="https://raw.githubusercontent.com/go-gitea/gitea/master/public/img/gitea-192.png" alt="logo" width="30" height="30"> Gitea - Git with a cup of tea</h1>
<p align="center">
<a href="https://drone.gitea.io/go-gitea/gitea" title="Build Status">
<img src="https://drone.gitea.io/api/badges/go-gitea/gitea/status.svg?ref=refs/heads/main">
</a>
<a href="https://discord.gg/Gitea" title="Join the Discord chat at https://discord.gg/Gitea">
<img src="https://img.shields.io/discord/322538954119184384.svg">
</a>
<a href="https://app.codecov.io/gh/go-gitea/gitea" title="Codecov">
<img src="https://codecov.io/gh/go-gitea/gitea/branch/main/graph/badge.svg">
</a>
<a href="https://goreportcard.com/report/code.gitea.io/gitea" title="Go Report Card">
<img src="https://goreportcard.com/badge/code.gitea.io/gitea">
</a>
<a href="https://pkg.go.dev/code.gitea.io/gitea" title="GoDoc">
<img src="https://pkg.go.dev/badge/code.gitea.io/gitea?status.svg">
</a>
<a href="https://github.com/go-gitea/gitea/releases/latest" title="GitHub release">
<img src="https://img.shields.io/github/release/go-gitea/gitea.svg">
</a>
<a href="https://www.codetriage.com/go-gitea/gitea" title="Help Contribute to Open Source">
<img src="https://www.codetriage.com/go-gitea/gitea/badges/users.svg">
</a>
<a href="https://opencollective.com/gitea" title="Become a backer/sponsor of gitea">
<img src="https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen">
</a>
<a href="https://opensource.org/licenses/MIT" title="License: MIT">
<img src="https://img.shields.io/badge/License-MIT-blue.svg">
</a>
<a href="https://gitpod.io/#https://github.com/go-gitea/gitea">
<img
src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod"
alt="Contribute with Gitpod"
/>
</a>
<a href="https://crowdin.com/project/gitea" title="Crowdin">
<img src="https://badges.crowdin.net/gitea/localized.svg">
</a>
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea&branch=main" title="TODOs">
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea/main">
</a>
<a href="https://app.bountysource.com/teams/gitea" title="Bountysource">
<img src="https://img.shields.io/bountysource/team/gitea/activity">
</a>
</p>
[![Build Status](https://drone.gitea.io/api/badges/go-gitea/gitea/status.svg)](https://drone.gitea.io/go-gitea/gitea)
[![Join the Discord chat at https://discord.gg/NsatcWJ](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ)
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
[![codecov](https://codecov.io/gh/go-gitea/gitea/branch/master/graph/badge.svg)](https://codecov.io/gh/go-gitea/gitea)
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea)
[![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
[![GitHub release](https://img.shields.io/github/release/go-gitea/gitea.svg)](https://github.com/go-gitea/gitea/releases/latest)
[![Help Contribute to Open Source](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea)
[![Become a backer/sponsor of gitea](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
<p align="center">
<a href="README_ZH.md">View this document in Chinese</a>
</p>
## Purpose
The goal of this project is to make the easiest, fastest, and most
painless way of setting up a self-hosted Git service.
Using Go, this can be done with an independent binary distribution across
**all platforms** which Go supports, including Linux, macOS, and Windows
on x86, amd64, ARM and PowerPC architectures.
Want to try it before doing anything else?
Do it [with the online demo](https://try.gitea.io/)!
As Gitea is written in Go, it works across **all** the platforms and
architectures that are supported by Go, including Linux, macOS, and
Windows on x86, amd64, ARM and PowerPC architectures.
You can try it out using [the online demo](https://try.gitea.io/).
This project has been
[forked](https://blog.gitea.io/2016/12/welcome-to-gitea/) from
[Gogs](https://gogs.io) since 2016.11 but changed a lot.
[Gogs](https://gogs.io) since November of 2016, but a lot has changed.
## Building
@ -33,6 +73,19 @@ From the root of the source tree, run:
TAGS="bindata" make build
or if SQLite support is required:
TAGS="bindata sqlite sqlite_unlock_notify" make build
The `build` target is split into two sub-targets:
- `make backend` which requires [Go Stable](https://go.dev/dl/), required version is defined in [go.mod](/go.mod).
- `make frontend` which requires [Node.js LTS](https://nodejs.org/en/download/) or greater and Internet connectivity to download npm dependencies.
When building from the official source tarballs which include pre-built frontend files, the `frontend` target will not be triggered, making it possible to build without Node.js and Internet connectivity.
Parallelism (`make -j <num>`) is not supported.
More info: https://docs.gitea.io/en-us/install-from-source/
## Using
@ -51,19 +104,32 @@ NOTES:
1. **YOU MUST READ THE [CONTRIBUTORS GUIDE](CONTRIBUTING.md) BEFORE STARTING TO WORK ON A PULL REQUEST.**
2. If you have found a vulnerability in the project, please write privately to **security@gitea.io**. Thanks!
## Translating
Translations are done through Crowdin. If you want to translate to a new language ask one of the managers in the Crowdin project to add a new language there.
You can also just create an issue for adding a language or ask on discord on the #translation channel. If you need context or find some translation issues, you can leave a comment on the string or ask on Discord. For general translation questions there is a section in the docs. Currently a bit empty but we hope to fill it as questions pop up.
https://docs.gitea.io/en-us/translation-guidelines/
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
## Further information
For more information and instructions about how to install Gitea, please look
at our [documentation](https://docs.gitea.io/en-us/). If you have questions
that are not covered by the documentation, you can get in contact with us on
our [Discord server](https://discord.gg/NsatcWJ),
or [forum](https://discourse.gitea.io/)!
For more information and instructions about how to install Gitea, please look at our [documentation](https://docs.gitea.io/en-us/).
If you have questions that are not covered by the documentation, you can get in contact with us on our [Discord server](https://discord.gg/Gitea) or create a post in the [discourse forum](https://discourse.gitea.io/).
We maintain a list of Gitea-related projects at [gitea/awesome-gitea](https://gitea.com/gitea/awesome-gitea).
The Hugo-based documentation theme is hosted at [gitea/theme](https://gitea.com/gitea/theme).
The official Gitea CLI is developed at [gitea/tea](https://gitea.com/gitea/tea).
## Authors
* [Maintainers](https://github.com/orgs/go-gitea/people)
* [Contributors](https://github.com/go-gitea/gitea/graphs/contributors)
* [Translators](options/locale/TRANSLATORS)
- [Maintainers](https://github.com/orgs/go-gitea/people)
- [Contributors](https://github.com/go-gitea/gitea/graphs/contributors)
- [Translators](options/locale/TRANSLATORS)
## Backers
@ -85,6 +151,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
<a href="https://opencollective.com/gitea/sponsor/7/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/8/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/gitea/sponsor/9/website" target="_blank"><img src="https://opencollective.com/gitea/sponsor/9/avatar.svg"></a>
<a href="https://cynkra.com/" target="_blank"><img src="https://images.opencollective.com/cynkra/logo/square/64/192.png"></a>
## FAQ
@ -99,10 +166,11 @@ We're [working on it](https://github.com/go-gitea/gitea/issues/1029).
## License
This project is licensed under the MIT License.
See the [LICENSE](https://github.com/go-gitea/gitea/blob/master/LICENSE) file
See the [LICENSE](https://github.com/go-gitea/gitea/blob/main/LICENSE) file
for the full license text.
## Screenshots
Looking for an overview of the interface? Check it out!
|![Dashboard](https://dl.gitea.io/screenshots/home_timeline.png)|![User Profile](https://dl.gitea.io/screenshots/user_profile.png)|![Global Issues](https://dl.gitea.io/screenshots/global_issues.png)|

View file

@ -1,18 +1,58 @@
[English](README.md)
<p align="center">
<a href="https://gitea.io/">
<img alt="Gitea" src="https://raw.githubusercontent.com/go-gitea/gitea/main/public/img/gitea.svg" width="220"/>
</a>
</p>
<h1 align="center">Gitea - Git with a cup of tea</h1>
<h1> <img src="https://raw.githubusercontent.com/go-gitea/gitea/master/public/img/gitea-192.png" alt="logo" width="30" height="30"> Gitea - Git with a cup of tea</h1>
<p align="center">
<a href="https://drone.gitea.io/go-gitea/gitea" title="Build Status">
<img src="https://drone.gitea.io/api/badges/go-gitea/gitea/status.svg?ref=refs/heads/main">
</a>
<a href="https://discord.gg/Gitea" title="Join the Discord chat at https://discord.gg/Gitea">
<img src="https://img.shields.io/discord/322538954119184384.svg">
</a>
<a href="https://app.codecov.io/gh/go-gitea/gitea" title="Codecov">
<img src="https://codecov.io/gh/go-gitea/gitea/branch/main/graph/badge.svg">
</a>
<a href="https://goreportcard.com/report/code.gitea.io/gitea" title="Go Report Card">
<img src="https://goreportcard.com/badge/code.gitea.io/gitea">
</a>
<a href="https://pkg.go.dev/code.gitea.io/gitea" title="GoDoc">
<img src="https://pkg.go.dev/badge/code.gitea.io/gitea?status.svg">
</a>
<a href="https://github.com/go-gitea/gitea/releases/latest" title="GitHub release">
<img src="https://img.shields.io/github/release/go-gitea/gitea.svg">
</a>
<a href="https://www.codetriage.com/go-gitea/gitea" title="Help Contribute to Open Source">
<img src="https://www.codetriage.com/go-gitea/gitea/badges/users.svg">
</a>
<a href="https://opencollective.com/gitea" title="Become a backer/sponsor of gitea">
<img src="https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen">
</a>
<a href="https://opensource.org/licenses/MIT" title="License: MIT">
<img src="https://img.shields.io/badge/License-MIT-blue.svg">
</a>
<a href="https://gitpod.io/#https://github.com/go-gitea/gitea">
<img
src="https://img.shields.io/badge/Contribute%20with-Gitpod-908a85?logo=gitpod"
alt="Contribute with Gitpod"
/>
</a>
<a href="https://crowdin.com/project/gitea" title="Crowdin">
<img src="https://badges.crowdin.net/gitea/localized.svg">
</a>
<a href="https://www.tickgit.com/browse?repo=github.com/go-gitea/gitea&branch=main" title="TODOs">
<img src="https://badgen.net/https/api.tickgit.com/badgen/github.com/go-gitea/gitea/main">
</a>
<a href="https://app.bountysource.com/teams/gitea" title="Bountysource">
<img src="https://img.shields.io/bountysource/team/gitea/activity">
</a>
</p>
[![Build Status](https://drone.gitea.io/api/badges/go-gitea/gitea/status.svg)](https://drone.gitea.io/go-gitea/gitea)
[![Join the Discord chat at https://discord.gg/NsatcWJ](https://img.shields.io/discord/322538954119184384.svg)](https://discord.gg/NsatcWJ)
[![](https://images.microbadger.com/badges/image/gitea/gitea.svg)](https://microbadger.com/images/gitea/gitea "Get your own image badge on microbadger.com")
[![codecov](https://codecov.io/gh/go-gitea/gitea/branch/master/graph/badge.svg)](https://codecov.io/gh/go-gitea/gitea)
[![Go Report Card](https://goreportcard.com/badge/code.gitea.io/gitea)](https://goreportcard.com/report/code.gitea.io/gitea)
[![GoDoc](https://godoc.org/code.gitea.io/gitea?status.svg)](https://godoc.org/code.gitea.io/gitea)
[![GitHub release](https://img.shields.io/github/release/go-gitea/gitea.svg)](https://github.com/go-gitea/gitea/releases/latest)
[![Help Contribute to Open Source](https://www.codetriage.com/go-gitea/gitea/badges/users.svg)](https://www.codetriage.com/go-gitea/gitea)
[![Become a backer/sponsor of gitea](https://opencollective.com/gitea/tiers/backers/badge.svg?label=backers&color=brightgreen)](https://opencollective.com/gitea)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
<p align="center">
<a href="README.md">View this document in English</a>
</p>
## 目标
@ -34,6 +74,11 @@ Gitea 的首要目标是创建一个极易安装,运行非常快速,安装
Fork -> Patch -> Push -> Pull Request
## 翻译
多语言翻译是基于Crowdin进行的.
[![Crowdin](https://badges.crowdin.net/gitea/localized.svg)](https://crowdin.com/project/gitea)
## 作者
* [Maintainers](https://github.com/orgs/go-gitea/people)
@ -42,7 +87,7 @@ Fork -> Patch -> Push -> Pull Request
## 授权许可
本项目采用 MIT 开源授权许可证,完整的授权说明已放置在 [LICENSE](https://github.com/go-gitea/gitea/blob/master/LICENSE) 文件中。
本项目采用 MIT 开源授权许可证,完整的授权说明已放置在 [LICENSE](https://github.com/go-gitea/gitea/blob/main/LICENSE) 文件中。
## 截图

83
SECURITY.md Normal file
View file

@ -0,0 +1,83 @@
# Reporting security issues
The Gitea maintainers take security seriously.
If you discover a security issue, please bring it to their attention right away!
## Reporting a Vulnerability
Please **DO NOT** file a public issue, instead send your report privately to `security@gitea.io`.
## Protecting Security Information
Due to the sensitive nature of security information, you can use below GPG public key encrypt your mail body.
The PGP key is valid until June 24, 2024.
```
Key ID: 6FCD2D5B
Key Type: RSA
Expires: 6/24/2024
Key Size: 4096/4096
Fingerprint: 3DE0 3D1E 144A 7F06 9359 99DC AAFD 2381 6FCD 2D5B
```
UserID: Gitea Security <security@gitea.io>
```
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGK1Z/4BEADFMqXA9DeeChmSxUjF0Be5sq99ZUhgrZjcN/wOzz0wuCJZC0l8
4uC+d6mfv7JpJYlzYzOK97/x5UguKHkYNZ6mm1G9KHaXmoIBDLKDzfPdJopVNv2r
OajijaE0uMCnMjadlg5pbhMLRQG8a9J32yyaz7ZEAw72Ab31fvvcA53NkuqO4j2w
k7dtFQzhbNOYV0VffQT90WDZdalYHB1JHyEQ+70U9OjVD5ggNYSzX98Eu3Hjn7V7
kqFrcAxr5TE1elf0IXJcuBJtFzQSTUGlQldKOHtGTGgGjj9r/FFAE5ioBgVD05bV
rEEgIMM/GqYaG/nbNpWE6P3mEc2Mnn3pZaRJL0LuF26TLjnqEcMMDp5iIhLdFzXR
3tMdtKgQFu+Mtzs3ipwWARYgHyU09RJsI2HeBx7RmZO/Xqrec763Z7zdJ7SpCn0Z
q+pHZl24JYR0Kf3T/ZiOC0cGd2QJqpJtg5J6S/OqfX9NH6MsCczO8pUC1N/aHH2X
CTme2nF56izORqDWKoiICteL3GpYsCV9nyCidcCmoQsS+DKvE86YhIhVIVWGRY2F
lzpAjnN9/KLtQroutrm+Ft0mdjDiJUeFVl1cOHDhoyfCsQh62HumoyZoZvqzQd6e
AbN11nq6aViMe2Q3je1AbiBnRnQSHxt1Tc8X4IshO3MQK1Sk7oPI6LA5oQARAQAB
tCJHaXRlYSBTZWN1cml0eSA8c2VjdXJpdHlAZ2l0ZWEuaW8+iQJXBBMBCABBFiEE
PeA9HhRKfwaTWZncqv0jgW/NLVsFAmK1Z/4CGwMFCQPCZwAFCwkIBwICIgIGFQoJ
CAsCBBYCAwECHgcCF4AACgkQqv0jgW/NLVvnyxAAhxyNnWzw/rQO2qhzqicmZM94
njSbOg+U2qMBvCdaqCQQeC+uaMmMzkDPanUUmLcyCkWqfCjPNjeSXAkE9npepVJI
4HtmgxZQ94OU/h3CLbft+9GVRzUkVI29TSYGdvNtV2/BkNGoFFnKWQr119um0o6A
bgha2Uy5uY8o3ZIoiKkiHRaEoWIjjeBxJxYAojsZY4YElUmsQ3ik2joG6rhFesTa
ofVt/bL8G2xzpOG26WGIxBbqf2qjV6OtZ0hu/vtTPHeIWMLq0Mz0V3PEDQWfkGPE
i2RYxxYDs2xzJhSQWqTNVLSq0m5xTJnbHhQPfdCX4C2jvFKgLdfmytQq49S7jiJb
Z03HVOZ/PsyBlQfH9xJi06R5yQCMEA8h8Z5r3/NXW09kQ6OFRe6xshoTcxZGRPTo
srhwr3uPbmCRh+YEl7qBLU6+BC5k8IRTZXqhrj/aPJu3MxgbgwV8u3vLoFSXM2lb
a61FgeCQ0O7lkgVswwF0RppCaH9Ul3ZDapet/vCRg4NVwm9zOI/8q/Vj0FKA1GDR
JhRu8+Ce8zlFL65D34t+PprAzSeTlbv9um3x/ZIjCco7EEKSBylt+AZj/VyA6+e5
kjOQwRRc6dFJWBcorsSI2dG+H+QMF7ZabzmeCcz1v9HjLOPzYHoZAHhCmSppWTvX
AJy6+lhfW2OUTqQeYSi5Ag0EYrVn/gEQALrFLQjCR3GjuHSindz0rd3Fnx/t7Sen
T+p07yCSSoSlmnJHCQmwh4vfg1blyz0zZ4vkIhtpHsEgc+ZAG+WQXSsJ2iRz+eSN
GwoOQl4XC3n+QWkc1ws+btr48+6UqXIQU+F8TPQyx/PIgi2nZXJB7f5+mjCqsk46
XvH4nTr4kJjuqMSR/++wvre2qNQRa/q/dTsK0OaN/mJsdX6Oi+aGNaQJUhIG7F+E
ZDMkn/O6xnwWNzy/+bpg43qH/Gk0eakOmz5NmQLRkV58SZLiJvuCUtkttf6CyhnX
03OcWaajv5W8qA39dBYQgDrrPbBWUnwfO3yMveqhwV4JjDoe8sPAyn1NwzakNYqP
RzsWyLrLS7R7J9s3FkZXhQw/QQcsaSMcGNQO047dm1P83N8JY5aEpiRo9zSWjoiw
qoExANj5lUTZPe8M50lI182FrcjAN7dClO3QI6pg7wy0erMxfFly3j8UQ91ysS9T
s+GsP9I3cmWWQcKYxWHtE8xTXnNCVPFZQj2nwhJzae8ypfOtulBRA3dUKWGKuDH/
axFENhUsT397aOU3qkP/od4a64JyNIEo4CTTSPVeWd7njsGqli2U3A4xL2CcyYvt
D/MWcMBGEoLSNTswwKdom4FaJpn5KThnK/T0bQcmJblJhoCtppXisbexZnCpuS0x
Zdlm2T14KJ3LABEBAAGJAjwEGAEIACYWIQQ94D0eFEp/BpNZmdyq/SOBb80tWwUC
YrVn/gIbDAUJA8JnAAAKCRCq/SOBb80tWyTBD/9AGpW6QoDF7zYjHAozH9S5RGCA
Y7E82dG/0xmFUwPprAG0BKmmgU6TiipyVGmKIXGYYYU92pMnbvXkYQMoa+WJNncN
D3fY52UeXeffTf4cFpStlzi9xgYtOLhFamzYu/4xhkjOX+xhOSXscCiFRyT8cF3B
O6c5BHU+Zj0/rGPgOyPUbx7l7B9MubB/41nNX35k08e+8T3wtWDb4XF+15HnRfva
6fblO8wgU25Orv2Rm1jnKGa9DxJ8nE40IMrqDapENtDuL+zKJsvR0+ptWvEyL56U
GtJJG5un6mXiLKuRQT0DEv4MdZRHDgDstDnqcbEiazVEbUuvhZZob6lRY2A19m1+
7zfnDxkhqCA1RCnv4fdvcPdCMMFHwLpdhjgW0aI/uwgwrvsEz5+JRlnLvdQHlPAg
q7l2fGcBSpz9U0ayyfRPjPntsNCtZl1UDxGLeciPkZhyG84zEWQbk/j52ZpRN+Ik
ALpRLa8RBFmFSmXDUmwQrmm1EmARyQXwweKU31hf8ZGbCp2lPuRYm1LuGiirXSVP
GysjRAJgW+VRpBKOzFQoUAUbReVWSaCwT8s17THzf71DdDb6CTj31jMLLYWwBpA/
i73DgobDZMIGEZZC1EKqza8eh11xfyHFzGec03tbh+lIen+5IiRtWiEWkDS9ll0G
zgS/ZdziCvdAutqnGA==
=gZWO
-----END PGP PUBLIC KEY BLOCK-----
```
Security reports are greatly appreciated and we will publicly thank you for it, although we keep your name confidential if you request it.

1
assets/emoji.json generated Normal file

File diff suppressed because one or more lines are too long

31
assets/favicon.svg Normal file
View file

@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="main_outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 640 640" style="enable-background:new 0 0 640 640;" xml:space="preserve">
<g>
<path id="teabag" style="fill:#FFFFFF" d="M395.9,484.2l-126.9-61c-12.5-6-17.9-21.2-11.8-33.8l61-126.9c6-12.5,21.2-17.9,33.8-11.8
c17.2,8.3,27.1,13,27.1,13l-0.1-109.2l16.7-0.1l0.1,117.1c0,0,57.4,24.2,83.1,40.1c3.7,2.3,10.2,6.8,12.9,14.4
c2.1,6.1,2,13.1-1,19.3l-61,126.9C423.6,484.9,408.4,490.3,395.9,484.2z"/>
<g>
<g>
<path style="fill:#609926" d="M622.7,149.8c-4.1-4.1-9.6-4-9.6-4s-117.2,6.6-177.9,8c-13.3,0.3-26.5,0.6-39.6,0.7c0,39.1,0,78.2,0,117.2
c-5.5-2.6-11.1-5.3-16.6-7.9c0-36.4-0.1-109.2-0.1-109.2c-29,0.4-89.2-2.2-89.2-2.2s-141.4-7.1-156.8-8.5
c-9.8-0.6-22.5-2.1-39,1.5c-8.7,1.8-33.5,7.4-53.8,26.9C-4.9,212.4,6.6,276.2,8,285.8c1.7,11.7,6.9,44.2,31.7,72.5
c45.8,56.1,144.4,54.8,144.4,54.8s12.1,28.9,30.6,55.5c25,33.1,50.7,58.9,75.7,62c63,0,188.9-0.1,188.9-0.1s12,0.1,28.3-10.3
c14-8.5,26.5-23.4,26.5-23.4s12.9-13.8,30.9-45.3c5.5-9.7,10.1-19.1,14.1-28c0,0,55.2-117.1,55.2-231.1
C633.2,157.9,624.7,151.8,622.7,149.8z M125.6,353.9c-25.9-8.5-36.9-18.7-36.9-18.7S69.6,321.8,60,295.4
c-16.5-44.2-1.4-71.2-1.4-71.2s8.4-22.5,38.5-30c13.8-3.7,31-3.1,31-3.1s7.1,59.4,15.7,94.2c7.2,29.2,24.8,77.7,24.8,77.7
S142.5,359.9,125.6,353.9z M425.9,461.5c0,0-6.1,14.5-19.6,15.4c-5.8,0.4-10.3-1.2-10.3-1.2s-0.3-0.1-5.3-2.1l-112.9-55
c0,0-10.9-5.7-12.8-15.6c-2.2-8.1,2.7-18.1,2.7-18.1L322,273c0,0,4.8-9.7,12.2-13c0.6-0.3,2.3-1,4.5-1.5c8.1-2.1,18,2.8,18,2.8
l110.7,53.7c0,0,12.6,5.7,15.3,16.2c1.9,7.4-0.5,14-1.8,17.2C474.6,363.8,425.9,461.5,425.9,461.5z"/>
<path style="fill:#609926" d="M326.8,380.1c-8.2,0.1-15.4,5.8-17.3,13.8c-1.9,8,2,16.3,9.1,20c7.7,4,17.5,1.8,22.7-5.4
c5.1-7.1,4.3-16.9-1.8-23.1l24-49.1c1.5,0.1,3.7,0.2,6.2-0.5c4.1-0.9,7.1-3.6,7.1-3.6c4.2,1.8,8.6,3.8,13.2,6.1
c4.8,2.4,9.3,4.9,13.4,7.3c0.9,0.5,1.8,1.1,2.8,1.9c1.6,1.3,3.4,3.1,4.7,5.5c1.9,5.5-1.9,14.9-1.9,14.9
c-2.3,7.6-18.4,40.6-18.4,40.6c-8.1-0.2-15.3,5-17.7,12.5c-2.6,8.1,1.1,17.3,8.9,21.3c7.8,4,17.4,1.7,22.5-5.3
c5-6.8,4.6-16.3-1.1-22.6c1.9-3.7,3.7-7.4,5.6-11.3c5-10.4,13.5-30.4,13.5-30.4c0.9-1.7,5.7-10.3,2.7-21.3
c-2.5-11.4-12.6-16.7-12.6-16.7c-12.2-7.9-29.2-15.2-29.2-15.2s0-4.1-1.1-7.1c-1.1-3.1-2.8-5.1-3.9-6.3c4.7-9.7,9.4-19.3,14.1-29
c-4.1-2-8.1-4-12.2-6.1c-4.8,9.8-9.7,19.7-14.5,29.5c-6.7-0.1-12.9,3.5-16.1,9.4c-3.4,6.3-2.7,14.1,1.9,19.8
C343.2,346.5,335,363.3,326.8,380.1z"/>
</g>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

1097
assets/go-licenses.json generated Normal file

File diff suppressed because one or more lines are too long

View file

@ -1,160 +1,31 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="512"
height="512"
viewBox="0 0 135.46667 135.46667"
version="1.1"
id="svg8"
sodipodi:docname="logo.svg"
inkscape:version="0.92.1 r15371"
inkscape:export-filename=""
inkscape:export-xdpi="48.000004"
inkscape:export-ydpi="48.000004">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:zoom="0.70710678"
inkscape:cx="418.13805"
inkscape:cy="177.57445"
inkscape:document-units="mm"
inkscape:current-layer="layer2"
showgrid="false"
units="px"
width="256px"
showguides="false"
inkscape:window-width="1920"
inkscape:window-height="1137"
inkscape:window-x="1912"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:pagecheckerboard="false"
inkscape:measure-start="283.373,243.952"
inkscape:measure-end="290.267,236.527">
<sodipodi:guide
position="0,0"
orientation="0,512"
id="guide3699"
inkscape:locked="false" />
<sodipodi:guide
position="135.46667,0"
orientation="-512,0"
id="guide3701"
inkscape:locked="false" />
<sodipodi:guide
position="135.46667,135.46667"
orientation="0,-512"
id="guide3703"
inkscape:locked="false" />
<sodipodi:guide
position="0,135.46667"
orientation="512,0"
id="guide3705"
inkscape:locked="false" />
</sodipodi:namedview>
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Layer 1"
inkscape:groupmode="layer"
id="layer1"
transform="translate(0,-161.53334)"
style="display:inline">
<path
style="fill:#609926;fill-opacity:1;stroke:#428f29;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none"
d="m 27.709937,195.15095 c -9.546573,-0.0272 -22.3392732,6.79805 -21.6317552,23.90397 1.105534,26.72889 25.4565952,29.20839 35.1916502,29.42301 1.068023,5.01357 12.521798,22.30563 21.001818,23.21667 h 37.15277 c 22.27763,-1.66785 38.9607,-75.75671 26.59321,-76.03825 -46.781583,2.47691 -49.995146,2.13838 -88.599758,0 -2.495053,-0.0266 -5.972321,-0.49474 -9.707935,-0.5054 z m 2.491319,9.45886 c 1.351378,13.69267 3.555849,21.70359 8.018216,33.94345 -11.382872,-1.50473 -21.069822,-5.22443 -22.851515,-19.10984 -0.950962,-7.4112 2.390428,-15.16769 14.833299,-14.83361 z"
id="path3722"
inkscape:connector-curvature="0"
sodipodi:nodetypes="sscccccsccsc" />
</g>
<g
inkscape:groupmode="layer"
id="layer2"
inkscape:label="Layer 2"
style="display:inline">
<rect
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.24757317;stroke-opacity:1"
id="rect4599"
width="34.762054"
height="34.762054"
x="87.508659"
y="18.291576"
transform="rotate(25.914715)"
ry="5.4825778" />
<path
style="display:inline;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26644793px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
d="m 79.804947,57.359056 3.241146,1.609954 V 35.255731 h -3.262698 z"
id="path4525"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</g>
<g
inkscape:groupmode="layer"
id="layer3"
inkscape:label="Layer 3"
style="display:inline">
<g
style="display:inline"
id="g4539">
<circle
transform="rotate(-19.796137)"
r="3.4745038"
cy="90.077766"
cx="49.064713"
id="path4606"
style="fill:#609926;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1" />
<circle
transform="rotate(-19.796137)"
r="3.4745038"
cy="102.1049"
cx="36.810425"
id="path4606-3"
style="fill:#609926;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1" />
<circle
transform="rotate(-19.796137)"
r="3.4745038"
cy="111.43928"
cx="46.484283"
id="path4606-1"
style="fill:#609926;fill-opacity:1;stroke:none;stroke-width:0.26458332;stroke-opacity:1" />
<rect
transform="rotate(26.024158)"
y="18.061695"
x="97.333458"
height="27.261492"
width="2.6726954"
id="rect4629-8"
style="fill:#609926;fill-opacity:1;stroke:none;stroke-width:0.27444693;stroke-opacity:1" />
<path
sodipodi:nodetypes="cc"
inkscape:connector-curvature="0"
id="path4514"
d="m 76.558096,68.116343 c 12.97589,6.395378 13.012989,4.101862 4.890858,20.907244"
style="fill:none;stroke:#609926;stroke-width:2.68000007;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
</g>
</g>
<?xml version="1.0" encoding="utf-8"?>
<svg version="1.1" id="main_outline" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px"
y="0px" viewBox="0 0 640 640" style="enable-background:new 0 0 640 640;" xml:space="preserve">
<g>
<path id="teabag" style="fill:#FFFFFF" d="M395.9,484.2l-126.9-61c-12.5-6-17.9-21.2-11.8-33.8l61-126.9c6-12.5,21.2-17.9,33.8-11.8
c17.2,8.3,27.1,13,27.1,13l-0.1-109.2l16.7-0.1l0.1,117.1c0,0,57.4,24.2,83.1,40.1c3.7,2.3,10.2,6.8,12.9,14.4
c2.1,6.1,2,13.1-1,19.3l-61,126.9C423.6,484.9,408.4,490.3,395.9,484.2z"/>
<g>
<g>
<path style="fill:#609926" d="M622.7,149.8c-4.1-4.1-9.6-4-9.6-4s-117.2,6.6-177.9,8c-13.3,0.3-26.5,0.6-39.6,0.7c0,39.1,0,78.2,0,117.2
c-5.5-2.6-11.1-5.3-16.6-7.9c0-36.4-0.1-109.2-0.1-109.2c-29,0.4-89.2-2.2-89.2-2.2s-141.4-7.1-156.8-8.5
c-9.8-0.6-22.5-2.1-39,1.5c-8.7,1.8-33.5,7.4-53.8,26.9C-4.9,212.4,6.6,276.2,8,285.8c1.7,11.7,6.9,44.2,31.7,72.5
c45.8,56.1,144.4,54.8,144.4,54.8s12.1,28.9,30.6,55.5c25,33.1,50.7,58.9,75.7,62c63,0,188.9-0.1,188.9-0.1s12,0.1,28.3-10.3
c14-8.5,26.5-23.4,26.5-23.4s12.9-13.8,30.9-45.3c5.5-9.7,10.1-19.1,14.1-28c0,0,55.2-117.1,55.2-231.1
C633.2,157.9,624.7,151.8,622.7,149.8z M125.6,353.9c-25.9-8.5-36.9-18.7-36.9-18.7S69.6,321.8,60,295.4
c-16.5-44.2-1.4-71.2-1.4-71.2s8.4-22.5,38.5-30c13.8-3.7,31-3.1,31-3.1s7.1,59.4,15.7,94.2c7.2,29.2,24.8,77.7,24.8,77.7
S142.5,359.9,125.6,353.9z M425.9,461.5c0,0-6.1,14.5-19.6,15.4c-5.8,0.4-10.3-1.2-10.3-1.2s-0.3-0.1-5.3-2.1l-112.9-55
c0,0-10.9-5.7-12.8-15.6c-2.2-8.1,2.7-18.1,2.7-18.1L322,273c0,0,4.8-9.7,12.2-13c0.6-0.3,2.3-1,4.5-1.5c8.1-2.1,18,2.8,18,2.8
l110.7,53.7c0,0,12.6,5.7,15.3,16.2c1.9,7.4-0.5,14-1.8,17.2C474.6,363.8,425.9,461.5,425.9,461.5z"/>
<path style="fill:#609926" d="M326.8,380.1c-8.2,0.1-15.4,5.8-17.3,13.8c-1.9,8,2,16.3,9.1,20c7.7,4,17.5,1.8,22.7-5.4
c5.1-7.1,4.3-16.9-1.8-23.1l24-49.1c1.5,0.1,3.7,0.2,6.2-0.5c4.1-0.9,7.1-3.6,7.1-3.6c4.2,1.8,8.6,3.8,13.2,6.1
c4.8,2.4,9.3,4.9,13.4,7.3c0.9,0.5,1.8,1.1,2.8,1.9c1.6,1.3,3.4,3.1,4.7,5.5c1.9,5.5-1.9,14.9-1.9,14.9
c-2.3,7.6-18.4,40.6-18.4,40.6c-8.1-0.2-15.3,5-17.7,12.5c-2.6,8.1,1.1,17.3,8.9,21.3c7.8,4,17.4,1.7,22.5-5.3
c5-6.8,4.6-16.3-1.1-22.6c1.9-3.7,3.7-7.4,5.6-11.3c5-10.4,13.5-30.4,13.5-30.4c0.9-1.7,5.7-10.3,2.7-21.3
c-2.5-11.4-12.6-16.7-12.6-16.7c-12.2-7.9-29.2-15.2-29.2-15.2s0-4.1-1.1-7.1c-1.1-3.1-2.8-5.1-3.9-6.3c4.7-9.7,9.4-19.3,14.1-29
c-4.1-2-8.1-4-12.2-6.1c-4.8,9.8-9.7,19.7-14.5,29.5c-6.7-0.1-12.9,3.5-16.1,9.4c-3.4,6.3-2.7,14.1,1.9,19.8
C343.2,346.5,335,363.3,326.8,380.1z"/>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 5.6 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

24
build.go Normal file
View file

@ -0,0 +1,24 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build vendor
package main
// Libraries that are included to vendor utilities used during build.
// These libraries will not be included in a normal compilation.
import (
// for embed
_ "github.com/shurcooL/vfsgen"
// for cover merge
_ "golang.org/x/tools/cover"
// for vet
_ "code.gitea.io/gitea-vet"
// for swagger
_ "github.com/go-swagger/go-swagger/cmd/swagger"
)

291
build/code-batch-process.go Normal file
View file

@ -0,0 +1,291 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build ignore
package main
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"code.gitea.io/gitea/build/codeformat"
)
// Windows has a limitation for command line arguments, the size can not exceed 32KB.
// So we have to feed the files to some tools (like gofmt) batch by batch
// We also introduce a `gitea-fmt` command, it does better import formatting than gofmt/goimports. `gitea-fmt` calls `gofmt` internally.
var optionLogVerbose bool
func logVerbose(msg string, args ...interface{}) {
if optionLogVerbose {
log.Printf(msg, args...)
}
}
func passThroughCmd(cmd string, args []string) error {
foundCmd, err := exec.LookPath(cmd)
if err != nil {
log.Fatalf("can not find cmd: %s", cmd)
}
c := exec.Cmd{
Path: foundCmd,
Args: append([]string{cmd}, args...),
Stdin: os.Stdin,
Stdout: os.Stdout,
Stderr: os.Stderr,
}
return c.Run()
}
type fileCollector struct {
dirs []string
includePatterns []*regexp.Regexp
excludePatterns []*regexp.Regexp
batchSize int
}
func newFileCollector(fileFilter string, batchSize int) (*fileCollector, error) {
co := &fileCollector{batchSize: batchSize}
if fileFilter == "go-own" {
co.dirs = []string{
"build",
"cmd",
"contrib",
"tests",
"models",
"modules",
"routers",
"services",
"tools",
}
co.includePatterns = append(co.includePatterns, regexp.MustCompile(`.*\.go$`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`.*\bbindata\.go$`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`tests/gitea-repositories-meta`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`tests/integration/migration-test`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`modules/git/tests`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`models/fixtures`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`models/migrations/fixtures`))
co.excludePatterns = append(co.excludePatterns, regexp.MustCompile(`services/gitdiff/testdata`))
}
if co.dirs == nil {
return nil, fmt.Errorf("unknown file-filter: %s", fileFilter)
}
return co, nil
}
func (fc *fileCollector) matchPatterns(path string, regexps []*regexp.Regexp) bool {
path = strings.ReplaceAll(path, "\\", "/")
for _, re := range regexps {
if re.MatchString(path) {
return true
}
}
return false
}
func (fc *fileCollector) collectFiles() (res [][]string, err error) {
var batch []string
for _, dir := range fc.dirs {
err = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
include := len(fc.includePatterns) == 0 || fc.matchPatterns(path, fc.includePatterns)
exclude := fc.matchPatterns(path, fc.excludePatterns)
process := include && !exclude
if !process {
if d.IsDir() {
if exclude {
logVerbose("exclude dir %s", path)
return filepath.SkipDir
}
// for a directory, if it is not excluded explicitly, we should walk into
return nil
}
// for a file, we skip it if it shouldn't be processed
logVerbose("skip process %s", path)
return nil
}
if d.IsDir() {
// skip dir, we don't add dirs to the file list now
return nil
}
if len(batch) >= fc.batchSize {
res = append(res, batch)
batch = nil
}
batch = append(batch, path)
return nil
})
if err != nil {
return nil, err
}
}
res = append(res, batch)
return res, nil
}
// substArgFiles expands the {file-list} to a real file list for commands
func substArgFiles(args, files []string) []string {
for i, s := range args {
if s == "{file-list}" {
newArgs := append(args[:i], files...)
newArgs = append(newArgs, args[i+1:]...)
return newArgs
}
}
return args
}
func exitWithCmdErrors(subCmd string, subArgs []string, cmdErrors []error) {
for _, err := range cmdErrors {
if err != nil {
if exitError, ok := err.(*exec.ExitError); ok {
exitCode := exitError.ExitCode()
log.Printf("run command failed (code=%d): %s %v", exitCode, subCmd, subArgs)
os.Exit(exitCode)
} else {
log.Fatalf("run command failed (err=%s) %s %v", err, subCmd, subArgs)
}
}
}
}
func parseArgs() (mainOptions map[string]string, subCmd string, subArgs []string) {
mainOptions = map[string]string{}
for i := 1; i < len(os.Args); i++ {
arg := os.Args[i]
if arg == "" {
break
}
if arg[0] == '-' {
arg = strings.TrimPrefix(arg, "-")
arg = strings.TrimPrefix(arg, "-")
fields := strings.SplitN(arg, "=", 2)
if len(fields) == 1 {
mainOptions[fields[0]] = "1"
} else {
mainOptions[fields[0]] = fields[1]
}
} else {
subCmd = arg
subArgs = os.Args[i+1:]
break
}
}
return
}
func showUsage() {
fmt.Printf(`Usage: %[1]s [options] {command} [arguments]
Options:
--verbose
--file-filter=go-own
--batch-size=100
Commands:
%[1]s gofmt ...
Arguments:
{file-list} the file list
Example:
%[1]s gofmt -s -d {file-list}
`, "file-batch-exec")
}
func getGoVersion() string {
goModFile, err := os.ReadFile("go.mod")
if err != nil {
log.Fatalf(`Faild to read "go.mod": %v`, err)
os.Exit(1)
}
goModVersionRegex := regexp.MustCompile(`go \d+\.\d+`)
goModVersionLine := goModVersionRegex.Find(goModFile)
return string(goModVersionLine[3:])
}
func newFileCollectorFromMainOptions(mainOptions map[string]string) (fc *fileCollector, err error) {
fileFilter := mainOptions["file-filter"]
if fileFilter == "" {
fileFilter = "go-own"
}
batchSize, _ := strconv.Atoi(mainOptions["batch-size"])
if batchSize == 0 {
batchSize = 100
}
return newFileCollector(fileFilter, batchSize)
}
func containsString(a []string, s string) bool {
for _, v := range a {
if v == s {
return true
}
}
return false
}
func giteaFormatGoImports(files []string, doWriteFile bool) error {
for _, file := range files {
if err := codeformat.FormatGoImports(file, doWriteFile); err != nil {
log.Printf("failed to format go imports: %s, err=%v", file, err)
return err
}
}
return nil
}
func main() {
mainOptions, subCmd, subArgs := parseArgs()
if subCmd == "" {
showUsage()
os.Exit(1)
}
optionLogVerbose = mainOptions["verbose"] != ""
fc, err := newFileCollectorFromMainOptions(mainOptions)
if err != nil {
log.Fatalf("can not create file collector: %s", err.Error())
}
fileBatches, err := fc.collectFiles()
if err != nil {
log.Fatalf("can not collect files: %s", err.Error())
}
processed := 0
var cmdErrors []error
for _, files := range fileBatches {
if len(files) == 0 {
break
}
substArgs := substArgFiles(subArgs, files)
logVerbose("batch cmd: %s %v", subCmd, substArgs)
switch subCmd {
case "gitea-fmt":
if containsString(subArgs, "-d") {
log.Print("the -d option is not supported by gitea-fmt")
}
cmdErrors = append(cmdErrors, giteaFormatGoImports(files, containsString(subArgs, "-w")))
cmdErrors = append(cmdErrors, passThroughCmd("go", append([]string{"run", os.Getenv("GOFUMPT_PACKAGE"), "-extra", "-lang", getGoVersion()}, substArgs...)))
default:
log.Fatalf("unknown cmd: %s %v", subCmd, subArgs)
}
processed += len(files)
}
logVerbose("processed %d files", processed)
exitWithCmdErrors(subCmd, subArgs, cmdErrors)
}

View file

@ -0,0 +1,195 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package codeformat
import (
"bytes"
"errors"
"io"
"os"
"sort"
"strings"
)
var importPackageGroupOrders = map[string]int{
"": 1, // internal
"code.gitea.io/gitea/": 2,
}
var errInvalidCommentBetweenImports = errors.New("comments between imported packages are invalid, please move comments to the end of the package line")
var (
importBlockBegin = []byte("\nimport (\n")
importBlockEnd = []byte("\n)")
)
type importLineParsed struct {
group string
pkg string
content string
}
func parseImportLine(line string) (*importLineParsed, error) {
il := &importLineParsed{content: line}
p1 := strings.IndexRune(line, '"')
if p1 == -1 {
return nil, errors.New("invalid import line: " + line)
}
p1++
p := strings.IndexRune(line[p1:], '"')
if p == -1 {
return nil, errors.New("invalid import line: " + line)
}
p2 := p1 + p
il.pkg = line[p1:p2]
pDot := strings.IndexRune(il.pkg, '.')
pSlash := strings.IndexRune(il.pkg, '/')
if pDot != -1 && pDot < pSlash {
il.group = "domain-package"
}
for groupName := range importPackageGroupOrders {
if groupName == "" {
continue // skip internal
}
if strings.HasPrefix(il.pkg, groupName) {
il.group = groupName
}
}
return il, nil
}
type (
importLineGroup []*importLineParsed
importLineGroupMap map[string]importLineGroup
)
func formatGoImports(contentBytes []byte) ([]byte, error) {
p1 := bytes.Index(contentBytes, importBlockBegin)
if p1 == -1 {
return nil, nil
}
p1 += len(importBlockBegin)
p := bytes.Index(contentBytes[p1:], importBlockEnd)
if p == -1 {
return nil, nil
}
p2 := p1 + p
importGroups := importLineGroupMap{}
r := bytes.NewBuffer(contentBytes[p1:p2])
eof := false
for !eof {
line, err := r.ReadString('\n')
eof = err == io.EOF
if err != nil && !eof {
return nil, err
}
line = strings.TrimSpace(line)
if line != "" {
if strings.HasPrefix(line, "//") || strings.HasPrefix(line, "/*") {
return nil, errInvalidCommentBetweenImports
}
importLine, err := parseImportLine(line)
if err != nil {
return nil, err
}
importGroups[importLine.group] = append(importGroups[importLine.group], importLine)
}
}
var groupNames []string
for groupName, importLines := range importGroups {
groupNames = append(groupNames, groupName)
sort.Slice(importLines, func(i, j int) bool {
return strings.Compare(importLines[i].pkg, importLines[j].pkg) < 0
})
}
sort.Slice(groupNames, func(i, j int) bool {
n1 := groupNames[i]
n2 := groupNames[j]
o1 := importPackageGroupOrders[n1]
o2 := importPackageGroupOrders[n2]
if o1 != 0 && o2 != 0 {
return o1 < o2
}
if o1 == 0 && o2 == 0 {
return strings.Compare(n1, n2) < 0
}
return o1 != 0
})
formattedBlock := bytes.Buffer{}
for _, groupName := range groupNames {
hasNormalImports := false
hasDummyImports := false
// non-dummy import comes first
for _, importLine := range importGroups[groupName] {
if strings.HasPrefix(importLine.content, "_") {
hasDummyImports = true
} else {
formattedBlock.WriteString("\t" + importLine.content + "\n")
hasNormalImports = true
}
}
// dummy (_ "pkg") comes later
if hasDummyImports {
if hasNormalImports {
formattedBlock.WriteString("\n")
}
for _, importLine := range importGroups[groupName] {
if strings.HasPrefix(importLine.content, "_") {
formattedBlock.WriteString("\t" + importLine.content + "\n")
}
}
}
formattedBlock.WriteString("\n")
}
formattedBlockBytes := bytes.TrimRight(formattedBlock.Bytes(), "\n")
var formattedBytes []byte
formattedBytes = append(formattedBytes, contentBytes[:p1]...)
formattedBytes = append(formattedBytes, formattedBlockBytes...)
formattedBytes = append(formattedBytes, contentBytes[p2:]...)
return formattedBytes, nil
}
// FormatGoImports format the imports by our rules (see unit tests)
func FormatGoImports(file string, doWriteFile bool) error {
f, err := os.Open(file)
if err != nil {
return err
}
var contentBytes []byte
{
defer f.Close()
contentBytes, err = io.ReadAll(f)
if err != nil {
return err
}
}
formattedBytes, err := formatGoImports(contentBytes)
if err != nil {
return err
}
if formattedBytes == nil {
return nil
}
if bytes.Equal(contentBytes, formattedBytes) {
return nil
}
if doWriteFile {
f, err = os.OpenFile(file, os.O_TRUNC|os.O_WRONLY, 0o644)
if err != nil {
return err
}
defer f.Close()
_, err = f.Write(formattedBytes)
return err
}
return err
}

View file

@ -0,0 +1,124 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package codeformat
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestFormatImportsSimple(t *testing.T) {
formatted, err := formatGoImports([]byte(`
package codeformat
import (
"github.com/stretchr/testify/assert"
"testing"
)
`))
expected := `
package codeformat
import (
"testing"
"github.com/stretchr/testify/assert"
)
`
assert.NoError(t, err)
assert.Equal(t, expected, string(formatted))
}
func TestFormatImportsGroup(t *testing.T) {
// gofmt/goimports won't group the packages, for example, they produce such code:
// "bytes"
// "image"
// (a blank line)
// "fmt"
// "image/color/palette"
// our formatter does better, and these packages are grouped into one.
formatted, err := formatGoImports([]byte(`
package test
import (
"bytes"
"fmt"
"image"
"image/color"
_ "image/gif" // for processing gif images
_ "image/jpeg" // for processing jpeg images
_ "image/png" // for processing png images
"code.gitea.io/other/package"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"xorm.io/the/package"
"github.com/issue9/identicon"
"github.com/nfnt/resize"
"github.com/oliamb/cutter"
)
`))
expected := `
package test
import (
"bytes"
"fmt"
"image"
"image/color"
_ "image/gif" // for processing gif images
_ "image/jpeg" // for processing jpeg images
_ "image/png" // for processing png images
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/other/package"
"github.com/issue9/identicon"
"github.com/nfnt/resize"
"github.com/oliamb/cutter"
"xorm.io/the/package"
)
`
assert.NoError(t, err)
assert.Equal(t, expected, string(formatted))
}
func TestFormatImportsInvalidComment(t *testing.T) {
// why we shouldn't write comments between imports: it breaks the grouping of imports
// for example:
// "pkg1"
// "pkg2"
// // a comment
// "pkgA"
// "pkgB"
// the comment splits the packages into two groups, pkg1/2 are sorted separately, pkgA/B are sorted separately
// we don't want such code, so the code should be:
// "pkg1"
// "pkg2"
// "pkgA" // a comment
// "pkgB"
_, err := formatGoImports([]byte(`
package test
import (
"image/jpeg"
// for processing gif images
"image/gif"
)
`))
assert.ErrorIs(t, err, errInvalidCommentBetweenImports)
}

92
build/generate-bindata.go Normal file
View file

@ -0,0 +1,92 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build ignore
package main
import (
"bytes"
"crypto/sha1"
"fmt"
"log"
"net/http"
"os"
"path/filepath"
"strconv"
"github.com/shurcooL/vfsgen"
)
func needsUpdate(dir, filename string) (bool, []byte) {
needRegen := false
_, err := os.Stat(filename)
if err != nil {
needRegen = true
}
oldHash, err := os.ReadFile(filename + ".hash")
if err != nil {
oldHash = []byte{}
}
hasher := sha1.New()
err = filepath.WalkDir(dir, func(path string, d os.DirEntry, err error) error {
if err != nil {
return err
}
info, err := d.Info()
if err != nil {
return err
}
_, _ = hasher.Write([]byte(d.Name()))
_, _ = hasher.Write([]byte(info.ModTime().String()))
_, _ = hasher.Write([]byte(strconv.FormatInt(info.Size(), 16)))
return nil
})
if err != nil {
return true, oldHash
}
newHash := hasher.Sum([]byte{})
if bytes.Compare(oldHash, newHash) != 0 {
return true, newHash
}
return needRegen, newHash
}
func main() {
if len(os.Args) < 4 {
log.Fatal("Insufficient number of arguments. Need: directory packageName filename")
}
dir, packageName, filename := os.Args[1], os.Args[2], os.Args[3]
var useGlobalModTime bool
if len(os.Args) == 5 {
useGlobalModTime, _ = strconv.ParseBool(os.Args[4])
}
update, newHash := needsUpdate(dir, filename)
if !update {
fmt.Printf("bindata for %s already up-to-date\n", packageName)
return
}
fmt.Printf("generating bindata for %s\n", packageName)
var fsTemplates http.FileSystem = http.Dir(dir)
err := vfsgen.Generate(fsTemplates, vfsgen.Options{
PackageName: packageName,
BuildTags: "bindata",
VariableName: "Assets",
Filename: filename,
UseGlobalModTime: useGlobalModTime,
})
if err != nil {
log.Fatalf("%v\n", err)
}
_ = os.WriteFile(filename+".hash", newHash, 0o666)
}

223
build/generate-emoji.go Normal file
View file

@ -0,0 +1,223 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Copyright 2015 Kenneth Shaw
// SPDX-License-Identifier: MIT
//go:build ignore
package main
import (
"flag"
"fmt"
"go/format"
"io"
"log"
"net/http"
"os"
"regexp"
"sort"
"strconv"
"strings"
"unicode/utf8"
"code.gitea.io/gitea/modules/json"
)
const (
gemojiURL = "https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json"
maxUnicodeVersion = 14
)
var flagOut = flag.String("o", "modules/emoji/emoji_data.go", "out")
// Gemoji is a set of emoji data.
type Gemoji []Emoji
// Emoji represents a single emoji and associated data.
type Emoji struct {
Emoji string `json:"emoji"`
Description string `json:"description,omitempty"`
Aliases []string `json:"aliases"`
UnicodeVersion string `json:"unicode_version,omitempty"`
SkinTones bool `json:"skin_tones,omitempty"`
}
// Don't include some fields in JSON
func (e Emoji) MarshalJSON() ([]byte, error) {
type emoji Emoji
x := emoji(e)
x.UnicodeVersion = ""
x.Description = ""
x.SkinTones = false
return json.Marshal(x)
}
func main() {
var err error
flag.Parse()
// generate data
buf, err := generate()
if err != nil {
log.Fatal(err)
}
// write
err = os.WriteFile(*flagOut, buf, 0o644)
if err != nil {
log.Fatal(err)
}
}
var replacer = strings.NewReplacer(
"main.Gemoji", "Gemoji",
"main.Emoji", "\n",
"}}", "},\n}",
", Description:", ", ",
", Aliases:", ", ",
", UnicodeVersion:", ", ",
", SkinTones:", ", ",
)
var emojiRE = regexp.MustCompile(`\{Emoji:"([^"]*)"`)
func generate() ([]byte, error) {
var err error
// load gemoji data
res, err := http.Get(gemojiURL)
if err != nil {
return nil, err
}
defer res.Body.Close()
// read all
body, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}
// unmarshal
var data Gemoji
err = json.Unmarshal(body, &data)
if err != nil {
return nil, err
}
skinTones := make(map[string]string)
skinTones["\U0001f3fb"] = "Light Skin Tone"
skinTones["\U0001f3fc"] = "Medium-Light Skin Tone"
skinTones["\U0001f3fd"] = "Medium Skin Tone"
skinTones["\U0001f3fe"] = "Medium-Dark Skin Tone"
skinTones["\U0001f3ff"] = "Dark Skin Tone"
var tmp Gemoji
// filter out emoji that require greater than max unicode version
for i := range data {
val, _ := strconv.ParseFloat(data[i].UnicodeVersion, 64)
if int(val) <= maxUnicodeVersion {
tmp = append(tmp, data[i])
}
}
data = tmp
sort.Slice(data, func(i, j int) bool {
return data[i].Aliases[0] < data[j].Aliases[0]
})
aliasMap := make(map[string]int, len(data))
for i, e := range data {
if e.Emoji == "" || len(e.Aliases) == 0 {
continue
}
for _, a := range e.Aliases {
if a == "" {
continue
}
aliasMap[a] = i
}
}
// gitea customizations
i, ok := aliasMap["tada"]
if ok {
data[i].Aliases = append(data[i].Aliases, "hooray")
}
i, ok = aliasMap["laughing"]
if ok {
data[i].Aliases = append(data[i].Aliases, "laugh")
}
// write a JSON file to use with tribute (write before adding skin tones since we can't support them there yet)
file, _ := json.Marshal(data)
_ = os.WriteFile("assets/emoji.json", file, 0o644)
// Add skin tones to emoji that support it
var (
s []string
newEmoji string
newDescription string
newData Emoji
)
for i := range data {
if data[i].SkinTones {
for k, v := range skinTones {
s = strings.Split(data[i].Emoji, "")
if utf8.RuneCountInString(data[i].Emoji) == 1 {
s = append(s, k)
} else {
// insert into slice after first element because all emoji that support skin tones
// have that modifier placed at this spot
s = append(s, "")
copy(s[2:], s[1:])
s[1] = k
}
newEmoji = strings.Join(s, "")
newDescription = data[i].Description + ": " + v
newAlias := data[i].Aliases[0] + "_" + strings.ReplaceAll(v, " ", "_")
newData = Emoji{newEmoji, newDescription, []string{newAlias}, "12.0", false}
data = append(data, newData)
}
}
}
sort.Slice(data, func(i, j int) bool {
return data[i].Aliases[0] < data[j].Aliases[0]
})
// add header
str := replacer.Replace(fmt.Sprintf(hdr, gemojiURL, data))
// change the format of the unicode string
str = emojiRE.ReplaceAllStringFunc(str, func(s string) string {
var err error
s, err = strconv.Unquote(s[len("{Emoji:"):])
if err != nil {
panic(err)
}
return "{" + strconv.QuoteToASCII(s)
})
// format
return format.Source([]byte(str))
}
const hdr = `
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package emoji
// Code generated by build/generate-emoji.go. DO NOT EDIT.
// Sourced from %s
var GemojiData = %#v
`

View file

@ -0,0 +1,126 @@
//go:build ignore
package main
import (
"archive/tar"
"compress/gzip"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"code.gitea.io/gitea/modules/util"
)
func main() {
var (
prefix = "gitea-gitignore"
url = "https://api.github.com/repos/github/gitignore/tarball"
githubApiToken = ""
githubUsername = ""
destination = ""
)
flag.StringVar(&destination, "dest", "options/gitignore/", "destination for the gitignores")
flag.StringVar(&githubUsername, "username", "", "github username")
flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()
file, err := os.CreateTemp(os.TempDir(), prefix)
if err != nil {
log.Fatalf("Failed to create temp file. %s", err)
}
defer util.Remove(file.Name())
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
if len(githubApiToken) > 0 && len(githubUsername) > 0 {
req.SetBasicAuth(githubUsername, githubApiToken)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
defer resp.Body.Close()
if _, err := io.Copy(file, resp.Body); err != nil {
log.Fatalf("Failed to copy archive to file. %s", err)
}
if _, err := file.Seek(0, 0); err != nil {
log.Fatalf("Failed to reset seek on archive. %s", err)
}
gz, err := gzip.NewReader(file)
if err != nil {
log.Fatalf("Failed to gunzip the archive. %s", err)
}
tr := tar.NewReader(gz)
filesToCopy := make(map[string]string, 0)
for {
hdr, err := tr.Next()
if err == io.EOF {
break
}
if err != nil {
log.Fatalf("Failed to iterate archive. %s", err)
}
if filepath.Ext(hdr.Name) != ".gitignore" {
continue
}
if hdr.Typeflag == tar.TypeSymlink {
fmt.Printf("Found symlink %s -> %s\n", hdr.Name, hdr.Linkname)
filesToCopy[strings.TrimSuffix(filepath.Base(hdr.Name), ".gitignore")] = strings.TrimSuffix(filepath.Base(hdr.Linkname), ".gitignore")
continue
}
out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".gitignore")))
if err != nil {
log.Fatalf("Failed to create new file. %s", err)
}
defer out.Close()
if _, err := io.Copy(out, tr); err != nil {
log.Fatalf("Failed to write new file. %s", err)
} else {
fmt.Printf("Written %s\n", out.Name())
}
}
for dst, src := range filesToCopy {
// Read all content of src to data
src = path.Join(destination, src)
data, err := os.ReadFile(src)
if err != nil {
log.Fatalf("Failed to read src file. %s", err)
}
// Write data to dst
dst = path.Join(destination, dst)
err = os.WriteFile(dst, data, 0o644)
if err != nil {
log.Fatalf("Failed to write new file. %s", err)
}
fmt.Printf("Written (copy of %s) %s\n", src, dst)
}
fmt.Println("Done")
}

View file

@ -0,0 +1,84 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build ignore
package main
import (
"encoding/json"
"io/fs"
"os"
goPath "path"
"path/filepath"
"regexp"
"sort"
"strings"
)
// regexp is based on go-license, excluding README and NOTICE
// https://github.com/google/go-licenses/blob/master/licenses/find.go
var licenseRe = regexp.MustCompile(`^(?i)((UN)?LICEN(S|C)E|COPYING).*$`)
type LicenseEntry struct {
Name string `json:"name"`
Path string `json:"path"`
LicenseText string `json:"licenseText"`
}
func main() {
base, out := os.Args[1], os.Args[2]
paths := []string{}
err := filepath.WalkDir(base, func(path string, entry fs.DirEntry, err error) error {
if err != nil {
return err
}
if entry.IsDir() || !licenseRe.MatchString(entry.Name()) {
return nil
}
paths = append(paths, path)
return nil
})
if err != nil {
panic(err)
}
sort.Strings(paths)
entries := []LicenseEntry{}
for _, path := range paths {
path := filepath.ToSlash(path)
licenseText, err := os.ReadFile(path)
if err != nil {
panic(err)
}
path = strings.Replace(path, base+"/", "", 1)
name := goPath.Dir(path)
// There might be a bug somewhere in go-licenses that sometimes interprets the
// root package as "." and sometimes as "code.gitea.io/gitea". Workaround by
// removing both of them for the sake of stable output.
if name == "." || name == "code.gitea.io/gitea" {
continue
}
entries = append(entries, LicenseEntry{
Name: name,
Path: path,
LicenseText: string(licenseText),
})
}
jsonBytes, err := json.MarshalIndent(entries, "", " ")
if err != nil {
panic(err)
}
err = os.WriteFile(out, jsonBytes, 0o644)
if err != nil {
panic(err)
}
}

82
build/generate-images.js Executable file
View file

@ -0,0 +1,82 @@
#!/usr/bin/env node
import imageminZopfli from 'imagemin-zopfli';
import {optimize} from 'svgo';
import {fabric} from 'fabric';
import {readFile, writeFile} from 'node:fs/promises';
function exit(err) {
if (err) console.error(err);
process.exit(err ? 1 : 0);
}
function loadSvg(svg) {
return new Promise((resolve) => {
fabric.loadSVGFromString(svg, (objects, options) => {
resolve({objects, options});
});
});
}
async function generate(svg, path, {size, bg}) {
const outputFile = new URL(path, import.meta.url);
if (String(outputFile).endsWith('.svg')) {
const {data} = optimize(svg, {
plugins: [
'preset-default',
'removeDimensions',
{
name: 'addAttributesToSVGElement',
params: {attributes: [{width: size}, {height: size}]}
},
],
});
await writeFile(outputFile, data);
return;
}
const {objects, options} = await loadSvg(svg);
const canvas = new fabric.Canvas();
canvas.setDimensions({width: size, height: size});
const ctx = canvas.getContext('2d');
ctx.scale(options.width ? (size / options.width) : 1, options.height ? (size / options.height) : 1);
if (bg) {
canvas.add(new fabric.Rect({
left: 0,
top: 0,
height: size * (1 / (size / options.height)),
width: size * (1 / (size / options.width)),
fill: 'white',
}));
}
canvas.add(fabric.util.groupSVGElements(objects, options));
canvas.renderAll();
let png = Buffer.from([]);
for await (const chunk of canvas.createPNGStream()) {
png = Buffer.concat([png, chunk]);
}
png = await imageminZopfli({more: true})(png);
await writeFile(outputFile, png);
}
async function main() {
const gitea = process.argv.slice(2).includes('gitea');
const logoSvg = await readFile(new URL('../assets/logo.svg', import.meta.url), 'utf8');
const faviconSvg = await readFile(new URL('../assets/favicon.svg', import.meta.url), 'utf8');
await Promise.all([
generate(logoSvg, '../public/img/logo.svg', {size: 32}),
generate(logoSvg, '../public/img/logo.png', {size: 512}),
generate(faviconSvg, '../public/img/favicon.svg', {size: 32}),
generate(faviconSvg, '../public/img/favicon.png', {size: 180}),
generate(logoSvg, '../public/img/avatar_default.png', {size: 200}),
generate(logoSvg, '../public/img/apple-touch-icon.png', {size: 180, bg: true}),
gitea && generate(logoSvg, '../public/img/gitea.svg', {size: 32}),
]);
}
main().then(exit).catch(exit);

122
build/generate-licenses.go Normal file
View file

@ -0,0 +1,122 @@
//go:build ignore
package main
import (
"archive/tar"
"compress/gzip"
"flag"
"fmt"
"io"
"log"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"code.gitea.io/gitea/modules/util"
)
func main() {
var (
prefix = "gitea-licenses"
url = "https://api.github.com/repos/spdx/license-list-data/tarball"
githubApiToken = ""
githubUsername = ""
destination = ""
)
flag.StringVar(&destination, "dest", "options/license/", "destination for the licenses")
flag.StringVar(&githubUsername, "username", "", "github username")
flag.StringVar(&githubApiToken, "token", "", "github api token")
flag.Parse()
file, err := os.CreateTemp(os.TempDir(), prefix)
if err != nil {
log.Fatalf("Failed to create temp file. %s", err)
}
defer util.Remove(file.Name())
if err := os.RemoveAll(destination); err != nil {
log.Fatalf("Cannot clean destination folder: %v", err)
}
if err := os.MkdirAll(destination, 0o755); err != nil {
log.Fatalf("Cannot create destination: %v", err)
}
req, err := http.NewRequest("GET", url, nil)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
if len(githubApiToken) > 0 && len(githubUsername) > 0 {
req.SetBasicAuth(githubUsername, githubApiToken)
}
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatalf("Failed to download archive. %s", err)
}
defer resp.Body.Close()
if _, err := io.Copy(file, resp.Body); err != nil {
log.Fatalf("Failed to copy archive to file. %s", err)
}
if _, err := file.Seek(0, 0); err != nil {
log.Fatalf("Failed to reset seek on archive. %s", err)
}
gz, err := gzip.NewReader(file)
if err != nil {
log.Fatalf("Failed to gunzip the archive. %s", err)
}
tr := tar.NewReader(gz)
for {
hdr, err := tr.Next()
if err == io.EOF {
break
}
if err != nil {
log.Fatalf("Failed to iterate archive. %s", err)
}
if !strings.Contains(hdr.Name, "/text/") {
continue
}
if filepath.Ext(hdr.Name) != ".txt" {
continue
}
if strings.HasPrefix(filepath.Base(hdr.Name), "README") {
continue
}
if strings.HasPrefix(filepath.Base(hdr.Name), "deprecated_") {
continue
}
out, err := os.Create(path.Join(destination, strings.TrimSuffix(filepath.Base(hdr.Name), ".txt")))
if err != nil {
log.Fatalf("Failed to create new file. %s", err)
}
defer out.Close()
if _, err := io.Copy(out, tr); err != nil {
log.Fatalf("Failed to write new file. %s", err)
} else {
fmt.Printf("Written %s\n", out.Name())
}
}
fmt.Println("Done")
}

58
build/generate-svg.js Executable file
View file

@ -0,0 +1,58 @@
#!/usr/bin/env node
import fastGlob from 'fast-glob';
import {optimize} from 'svgo';
import {parse} from 'node:path';
import {readFile, writeFile, mkdir} from 'node:fs/promises';
import {fileURLToPath} from 'node:url';
const glob = (pattern) => fastGlob.sync(pattern, {
cwd: fileURLToPath(new URL('..', import.meta.url)),
absolute: true,
});
function exit(err) {
if (err) console.error(err);
process.exit(err ? 1 : 0);
}
async function processFile(file, {prefix, fullName} = {}) {
let name;
if (fullName) {
name = fullName;
} else {
name = parse(file).name;
if (prefix) name = `${prefix}-${name}`;
if (prefix === 'octicon') name = name.replace(/-[0-9]+$/, ''); // chop of '-16' on octicons
}
const {data} = optimize(await readFile(file, 'utf8'), {
plugins: [
{name: 'preset-default'},
{name: 'removeXMLNS'},
{name: 'removeDimensions'},
{name: 'prefixIds', params: {prefix: () => name}},
{name: 'addClassesToSVGElement', params: {classNames: ['svg', name]}},
{name: 'addAttributesToSVGElement', params: {attributes: [{'width': '16'}, {'height': '16'}, {'aria-hidden': 'true'}]}},
],
});
await writeFile(fileURLToPath(new URL(`../public/img/svg/${name}.svg`, import.meta.url)), data);
}
function processFiles(pattern, opts) {
return glob(pattern).map((file) => processFile(file, opts));
}
async function main() {
try {
await mkdir(fileURLToPath(new URL('../public/img/svg', import.meta.url)), {recursive: true});
} catch {}
await Promise.all([
...processFiles('node_modules/@primer/octicons/build/svg/*-16.svg', {prefix: 'octicon'}),
...processFiles('web_src/svg/*.svg'),
...processFiles('public/img/gitea.svg', {fullName: 'gitea-gitea'}),
]);
}
main().then(exit).catch(exit);

118
build/gocovmerge.go Normal file
View file

@ -0,0 +1,118 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// Copyright (c) 2015, Wade Simmons
// SPDX-License-Identifier: MIT
// gocovmerge takes the results from multiple `go test -coverprofile` runs and
// merges them into one profile
//go:build ignore
package main
import (
"flag"
"fmt"
"io"
"log"
"os"
"sort"
"golang.org/x/tools/cover"
)
func mergeProfiles(p, merge *cover.Profile) {
if p.Mode != merge.Mode {
log.Fatalf("cannot merge profiles with different modes")
}
// Since the blocks are sorted, we can keep track of where the last block
// was inserted and only look at the blocks after that as targets for merge
startIndex := 0
for _, b := range merge.Blocks {
startIndex = mergeProfileBlock(p, b, startIndex)
}
}
func mergeProfileBlock(p *cover.Profile, pb cover.ProfileBlock, startIndex int) int {
sortFunc := func(i int) bool {
pi := p.Blocks[i+startIndex]
return pi.StartLine >= pb.StartLine && (pi.StartLine != pb.StartLine || pi.StartCol >= pb.StartCol)
}
i := 0
if sortFunc(i) != true {
i = sort.Search(len(p.Blocks)-startIndex, sortFunc)
}
i += startIndex
if i < len(p.Blocks) && p.Blocks[i].StartLine == pb.StartLine && p.Blocks[i].StartCol == pb.StartCol {
if p.Blocks[i].EndLine != pb.EndLine || p.Blocks[i].EndCol != pb.EndCol {
log.Fatalf("OVERLAP MERGE: %v %v %v", p.FileName, p.Blocks[i], pb)
}
switch p.Mode {
case "set":
p.Blocks[i].Count |= pb.Count
case "count", "atomic":
p.Blocks[i].Count += pb.Count
default:
log.Fatalf("unsupported covermode: '%s'", p.Mode)
}
} else {
if i > 0 {
pa := p.Blocks[i-1]
if pa.EndLine >= pb.EndLine && (pa.EndLine != pb.EndLine || pa.EndCol > pb.EndCol) {
log.Fatalf("OVERLAP BEFORE: %v %v %v", p.FileName, pa, pb)
}
}
if i < len(p.Blocks)-1 {
pa := p.Blocks[i+1]
if pa.StartLine <= pb.StartLine && (pa.StartLine != pb.StartLine || pa.StartCol < pb.StartCol) {
log.Fatalf("OVERLAP AFTER: %v %v %v", p.FileName, pa, pb)
}
}
p.Blocks = append(p.Blocks, cover.ProfileBlock{})
copy(p.Blocks[i+1:], p.Blocks[i:])
p.Blocks[i] = pb
}
return i + 1
}
func addProfile(profiles []*cover.Profile, p *cover.Profile) []*cover.Profile {
i := sort.Search(len(profiles), func(i int) bool { return profiles[i].FileName >= p.FileName })
if i < len(profiles) && profiles[i].FileName == p.FileName {
mergeProfiles(profiles[i], p)
} else {
profiles = append(profiles, nil)
copy(profiles[i+1:], profiles[i:])
profiles[i] = p
}
return profiles
}
func dumpProfiles(profiles []*cover.Profile, out io.Writer) {
if len(profiles) == 0 {
return
}
fmt.Fprintf(out, "mode: %s\n", profiles[0].Mode)
for _, p := range profiles {
for _, b := range p.Blocks {
fmt.Fprintf(out, "%s:%d.%d,%d.%d %d %d\n", p.FileName, b.StartLine, b.StartCol, b.EndLine, b.EndCol, b.NumStmt, b.Count)
}
}
}
func main() {
flag.Parse()
var merged []*cover.Profile
for _, file := range flag.Args() {
profiles, err := cover.ParseProfiles(file)
if err != nil {
log.Fatalf("failed to parse profile '%s': %v", file, err)
}
for _, p := range profiles {
merged = addProfile(merged, p)
}
}
dumpProfiles(merged, os.Stdout)
}

24
build/test-env-check.sh Executable file
View file

@ -0,0 +1,24 @@
#!/bin/sh
set -e
if [ ! -f ./build/test-env-check.sh ]; then
echo "${0} can only be executed in gitea source root directory"
exit 1
fi
echo "check uid ..."
# the uid of gitea defined in "https://gitea.com/gitea/test-env" is 1000
gitea_uid=$(id -u gitea)
if [ "$gitea_uid" != "1000" ]; then
echo "The uid of linux user 'gitea' is expected to be 1000, but it is $gitea_uid"
exit 1
fi
cur_uid=$(id -u)
if [ "$cur_uid" != "0" -a "$cur_uid" != "$gitea_uid" ]; then
echo "The uid of current linux user is expected to be 0 or $gitea_uid, but it is $cur_uid"
exit 1
fi

11
build/test-env-prepare.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/sh
set -e
if [ ! -f ./build/test-env-prepare.sh ]; then
echo "${0} can only be executed in gitea source root directory"
exit 1
fi
echo "change the owner of files to gitea ..."
chown -R gitea:gitea .

59
build/update-locales.sh Executable file
View file

@ -0,0 +1,59 @@
#!/bin/sh
# this script runs in alpine image which only has `sh` shell
set +e
if sed --version 2>/dev/null | grep -q GNU; then
SED_INPLACE="sed -i"
else
SED_INPLACE="sed -i ''"
fi
set -e
if [ ! -f ./options/locale/locale_en-US.ini ]; then
echo "please run this script in the root directory of the project"
exit 1
fi
mv ./options/locale/locale_en-US.ini ./options/
# the "ini" library for locale has many quirks
# * `a="xx"` gets `xx` (no quote)
# * `a=x\"y` gets `x\"y` (no unescaping)
# * `a="x\"y"` gets `"x\"y"` (no unescaping, the quotes are still there)
# * `a='x\"y'` gets `x\"y` (no unescaping, no quote)
# * `a="foo` gets `"foo` (although the quote is not closed)
# * 'a=`foo`' works like single-quote
# crowdin needs the strings to be quoted correctly and doesn't like incomplete quotes
# crowdin always outputs quoted strings if there are quotes in the strings.
# this script helps to unquote the crowdin outputs for the quirky ini library
# * find all `key="...\"..."` lines
# * remove the leading quote
# * remove the trailing quote
# * unescape the quotes
# * eg: key="...\"..." => key=..."...
$SED_INPLACE -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
s/^([-.A-Za-z0-9_]+)[ ]*=[ ]*"/\1=/
s/"$//
s/\\"/"/g
}' ./options/locale/*.ini
# * if the escaped line is incomplete like `key="...` or `key=..."`, quote it with backticks
# * eg: key="... => key=`"...`
# * eg: key=..." => key=`..."`
$SED_INPLACE -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*(".*[^"])$/\1=`\2`/' ./options/locale/*.ini
$SED_INPLACE -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*([^"].*")$/\1=`\2`/' ./options/locale/*.ini
# Remove translation under 25% of en_us
baselines=$(wc -l "./options/locale_en-US.ini" | cut -d" " -f1)
baselines=$((baselines / 4))
for filename in ./options/locale/*.ini; do
lines=$(wc -l "$filename" | cut -d" " -f1)
if [ $lines -lt $baselines ]; then
echo "Removing $filename: $lines/$baselines"
rm "$filename"
fi
done
mv ./options/locale_en-US.ini ./options/locale/

View file

@ -1,23 +1,30 @@
// Copyright 2016 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"errors"
"fmt"
"net/url"
"os"
"strings"
"text/tabwriter"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth/oauth2"
asymkey_model "code.gitea.io/gitea/models/asymkey"
auth_model "code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/models/db"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
pwd "code.gitea.io/gitea/modules/password"
"code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/util"
auth_service "code.gitea.io/gitea/services/auth"
"code.gitea.io/gitea/services/auth/source/oauth2"
"code.gitea.io/gitea/services/auth/source/smtp"
repo_service "code.gitea.io/gitea/services/repository"
"github.com/urfave/cli"
)
@ -28,74 +35,11 @@ var (
Name: "admin",
Usage: "Command line interface to perform common administrative operations",
Subcommands: []cli.Command{
subcmdCreateUser,
subcmdChangePassword,
subcmdUser,
subcmdRepoSyncReleases,
subcmdRegenerate,
subcmdAuth,
},
}
subcmdCreateUser = cli.Command{
Name: "create-user",
Usage: "Create a new user in database",
Action: runCreateUser,
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "Username. DEPRECATED: use username instead",
},
cli.StringFlag{
Name: "username",
Usage: "Username",
},
cli.StringFlag{
Name: "password",
Usage: "User password",
},
cli.StringFlag{
Name: "email",
Usage: "User email address",
},
cli.BoolFlag{
Name: "admin",
Usage: "User is an admin",
},
cli.BoolFlag{
Name: "random-password",
Usage: "Generate a random password for the user",
},
cli.BoolFlag{
Name: "must-change-password",
Usage: "Set this option to false to prevent forcing the user to change their password after initial login, (Default: true)",
},
cli.IntFlag{
Name: "random-password-length",
Usage: "Length of the random password to be generated",
Value: 12,
},
cli.BoolFlag{
Name: "access-token",
Usage: "Generate access token for the user",
},
},
}
subcmdChangePassword = cli.Command{
Name: "change-password",
Usage: "Change a user's password",
Action: runChangePassword,
Flags: []cli.Flag{
cli.StringFlag{
Name: "username,u",
Value: "",
Usage: "The user to change password for",
},
cli.StringFlag{
Name: "password,p",
Value: "",
Usage: "New password to set for user",
},
subcmdSendMail,
},
}
@ -136,6 +80,8 @@ var (
cmdAuthUpdateLdapBindDn,
cmdAuthAddLdapSimpleAuth,
cmdAuthUpdateLdapSimpleAuth,
microcmdAuthAddSMTP,
microcmdAuthUpdateSMTP,
microcmdAuthList,
microcmdAuthDelete,
},
@ -145,6 +91,32 @@ var (
Name: "list",
Usage: "List auth sources",
Action: runListAuth,
Flags: []cli.Flag{
cli.IntFlag{
Name: "min-width",
Usage: "Minimal cell width including any padding for the formatted table",
Value: 0,
},
cli.IntFlag{
Name: "tab-width",
Usage: "width of tab characters in formatted table (equivalent number of spaces)",
Value: 8,
},
cli.IntFlag{
Name: "padding",
Usage: "padding added to a cell before computing its width",
Value: 1,
},
cli.StringFlag{
Name: "pad-char",
Usage: `ASCII char used for padding if padchar == '\\t', the Writer will assume that the width of a '\\t' in the formatted output is tabwidth, and cells are left-aligned independent of align_left (for correct-looking results, tabwidth must correspond to the tab width in the viewer displaying the result)`,
Value: "\t",
},
cli.BoolFlag{
Name: "vertical-bars",
Usage: "Set to true to print vertical bars between columns",
},
},
}
idFlag = cli.Int64Flag{
@ -190,6 +162,11 @@ var (
Value: "false",
Usage: "Use custom URLs for GitLab/GitHub OAuth endpoints",
},
cli.StringFlag{
Name: "custom-tenant-id",
Value: "",
Usage: "Use custom Tenant ID for OAuth endpoints",
},
cli.StringFlag{
Name: "custom-auth-url",
Value: "",
@ -210,6 +187,54 @@ var (
Value: "",
Usage: "Use a custom Email URL (option for GitHub)",
},
cli.StringFlag{
Name: "icon-url",
Value: "",
Usage: "Custom icon URL for OAuth2 login source",
},
cli.BoolFlag{
Name: "skip-local-2fa",
Usage: "Set to true to skip local 2fa for users authenticated by this source",
},
cli.StringSliceFlag{
Name: "scopes",
Value: nil,
Usage: "Scopes to request when to authenticate against this OAuth2 source",
},
cli.StringFlag{
Name: "required-claim-name",
Value: "",
Usage: "Claim name that has to be set to allow users to login with this source",
},
cli.StringFlag{
Name: "required-claim-value",
Value: "",
Usage: "Claim value that has to be set to allow users to login with this source",
},
cli.StringFlag{
Name: "group-claim-name",
Value: "",
Usage: "Claim name providing group names for this source",
},
cli.StringFlag{
Name: "admin-group",
Value: "",
Usage: "Group Claim value for administrator users",
},
cli.StringFlag{
Name: "restricted-group",
Value: "",
Usage: "Group Claim value for restricted users",
},
cli.StringFlag{
Name: "group-team-map",
Value: "",
Usage: "JSON mapping between groups and org teams",
},
cli.BoolFlag{
Name: "group-team-map-removal",
Usage: "Activate automatic team membership removal depending on groups",
},
}
microcmdAuthUpdateOauth = cli.Command{
@ -225,137 +250,115 @@ var (
Action: runAddOauth,
Flags: oauthCLIFlags,
}
subcmdSendMail = cli.Command{
Name: "sendmail",
Usage: "Send a message to all users",
Action: runSendMail,
Flags: []cli.Flag{
cli.StringFlag{
Name: "title",
Usage: `a title of a message`,
Value: "",
},
cli.StringFlag{
Name: "content",
Usage: "a content of a message",
Value: "",
},
cli.BoolFlag{
Name: "force,f",
Usage: "A flag to bypass a confirmation step",
},
},
}
smtpCLIFlags = []cli.Flag{
cli.StringFlag{
Name: "name",
Value: "",
Usage: "Application Name",
},
cli.StringFlag{
Name: "auth-type",
Value: "PLAIN",
Usage: "SMTP Authentication Type (PLAIN/LOGIN/CRAM-MD5) default PLAIN",
},
cli.StringFlag{
Name: "host",
Value: "",
Usage: "SMTP Host",
},
cli.IntFlag{
Name: "port",
Usage: "SMTP Port",
},
cli.BoolTFlag{
Name: "force-smtps",
Usage: "SMTPS is always used on port 465. Set this to force SMTPS on other ports.",
},
cli.BoolTFlag{
Name: "skip-verify",
Usage: "Skip TLS verify.",
},
cli.StringFlag{
Name: "helo-hostname",
Value: "",
Usage: "Hostname sent with HELO. Leave blank to send current hostname",
},
cli.BoolTFlag{
Name: "disable-helo",
Usage: "Disable SMTP helo.",
},
cli.StringFlag{
Name: "allowed-domains",
Value: "",
Usage: "Leave empty to allow all domains. Separate multiple domains with a comma (',')",
},
cli.BoolTFlag{
Name: "skip-local-2fa",
Usage: "Skip 2FA to log on.",
},
cli.BoolTFlag{
Name: "active",
Usage: "This Authentication Source is Activated.",
},
}
microcmdAuthAddSMTP = cli.Command{
Name: "add-smtp",
Usage: "Add new SMTP authentication source",
Action: runAddSMTP,
Flags: smtpCLIFlags,
}
microcmdAuthUpdateSMTP = cli.Command{
Name: "update-smtp",
Usage: "Update existing SMTP authentication source",
Action: runUpdateSMTP,
Flags: append(smtpCLIFlags[:1], append([]cli.Flag{idFlag}, smtpCLIFlags[1:]...)...),
}
)
func runChangePassword(c *cli.Context) error {
if err := argsSet(c, "username", "password"); err != nil {
return err
}
func runRepoSyncReleases(_ *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(); err != nil {
return err
}
if !pwd.IsComplexEnough(c.String("password")) {
return errors.New("Password does not meet complexity requirements")
}
uname := c.String("username")
user, err := models.GetUserByName(uname)
if err != nil {
return err
}
if user.Salt, err = models.GetUserSalt(); err != nil {
return err
}
user.HashPassword(c.String("password"))
if err := models.UpdateUserCols(user, "passwd", "salt"); err != nil {
return err
}
fmt.Printf("%s's password has been successfully updated!\n", user.Name)
return nil
}
func runCreateUser(c *cli.Context) error {
if err := argsSet(c, "email"); err != nil {
return err
}
if c.IsSet("name") && c.IsSet("username") {
return errors.New("Cannot set both --name and --username flags")
}
if !c.IsSet("name") && !c.IsSet("username") {
return errors.New("One of --name or --username flags must be set")
}
if c.IsSet("password") && c.IsSet("random-password") {
return errors.New("cannot set both -random-password and -password flags")
}
var username string
if c.IsSet("username") {
username = c.String("username")
} else {
username = c.String("name")
fmt.Fprintf(os.Stderr, "--name flag is deprecated. Use --username instead.\n")
}
if err := initDB(); err != nil {
return err
}
var password string
if c.IsSet("password") {
password = c.String("password")
} else if c.IsSet("random-password") {
var err error
password, err = pwd.Generate(c.Int("random-password-length"))
if err != nil {
return err
}
fmt.Printf("generated random password is '%s'\n", password)
} else {
return errors.New("must set either password or random-password flag")
}
// always default to true
var changePassword = true
// If this is the first user being created.
// Take it as the admin and don't force a password update.
if n := models.CountUsers(); n == 0 {
changePassword = false
}
if c.IsSet("must-change-password") {
changePassword = c.Bool("must-change-password")
}
u := &models.User{
Name: username,
Email: c.String("email"),
Passwd: password,
IsActive: true,
IsAdmin: c.Bool("admin"),
MustChangePassword: changePassword,
Theme: setting.UI.DefaultTheme,
}
if err := models.CreateUser(u); err != nil {
return fmt.Errorf("CreateUser: %v", err)
}
if c.Bool("access-token") {
t := &models.AccessToken{
Name: "gitea-admin",
UID: u.ID,
}
if err := models.NewAccessToken(t); err != nil {
return err
}
fmt.Printf("Access token was successfully created... %s\n", t.Token)
}
fmt.Printf("New user '%s' has been successfully created!\n", username)
return nil
}
func runRepoSyncReleases(c *cli.Context) error {
if err := initDB(); err != nil {
if err := initDB(ctx); err != nil {
return err
}
log.Trace("Synchronizing repository releases (this may take a while)")
for page := 1; ; page++ {
repos, count, err := models.SearchRepositoryByName(&models.SearchRepoOptions{
Page: page,
PageSize: models.RepositoryListDefaultPageSize,
Private: true,
repos, count, err := repo_model.SearchRepositoryByName(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
PageSize: repo_model.RepositoryListDefaultPageSize,
Page: page,
},
Private: true,
})
if err != nil {
return fmt.Errorf("SearchRepositoryByName: %v", err)
return fmt.Errorf("SearchRepositoryByName: %w", err)
}
if len(repos) == 0 {
break
@ -363,7 +366,7 @@ func runRepoSyncReleases(c *cli.Context) error {
log.Trace("Processing next %d repos of %d", len(repos), count)
for _, repo := range repos {
log.Trace("Synchronizing repo %s with path %s", repo.FullName(), repo.RepoPath())
gitRepo, err := git.OpenRepository(repo.RepoPath())
gitRepo, err := git.OpenRepository(ctx, repo.RepoPath())
if err != nil {
log.Warn("OpenRepository: %v", err)
continue
@ -375,7 +378,7 @@ func runRepoSyncReleases(c *cli.Context) error {
}
log.Trace(" currentNumReleases is %d, running SyncReleasesWithTags", oldnum)
if err = repository.SyncReleasesWithTags(repo, gitRepo); err != nil {
if err = repo_module.SyncReleasesWithTags(repo, gitRepo); err != nil {
log.Warn(" SyncReleasesWithTags: %v", err)
gitRepo.Close()
continue
@ -398,29 +401,36 @@ func runRepoSyncReleases(c *cli.Context) error {
}
func getReleaseCount(id int64) (int64, error) {
return models.GetReleaseCountByRepoID(
return repo_model.GetReleaseCountByRepoID(
db.DefaultContext,
id,
models.FindReleasesOptions{
repo_model.FindReleasesOptions{
IncludeTags: true,
},
)
}
func runRegenerateHooks(c *cli.Context) error {
if err := initDB(); err != nil {
func runRegenerateHooks(_ *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
return models.SyncRepositoryHooks()
return repo_service.SyncRepositoryHooks(graceful.GetManager().ShutdownContext())
}
func runRegenerateKeys(c *cli.Context) error {
if err := initDB(); err != nil {
func runRegenerateKeys(_ *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
return models.RewriteAllPublicKeys()
return asymkey_model.RewriteAllPublicKeys()
}
func parseOAuth2Config(c *cli.Context) *models.OAuth2Config {
func parseOAuth2Config(c *cli.Context) *oauth2.Source {
var customURLMapping *oauth2.CustomURLMapping
if c.IsSet("use-custom-urls") {
customURLMapping = &oauth2.CustomURLMapping{
@ -428,29 +438,51 @@ func parseOAuth2Config(c *cli.Context) *models.OAuth2Config {
AuthURL: c.String("custom-auth-url"),
ProfileURL: c.String("custom-profile-url"),
EmailURL: c.String("custom-email-url"),
Tenant: c.String("custom-tenant-id"),
}
} else {
customURLMapping = nil
}
return &models.OAuth2Config{
return &oauth2.Source{
Provider: c.String("provider"),
ClientID: c.String("key"),
ClientSecret: c.String("secret"),
OpenIDConnectAutoDiscoveryURL: c.String("auto-discover-url"),
CustomURLMapping: customURLMapping,
IconURL: c.String("icon-url"),
SkipLocalTwoFA: c.Bool("skip-local-2fa"),
Scopes: c.StringSlice("scopes"),
RequiredClaimName: c.String("required-claim-name"),
RequiredClaimValue: c.String("required-claim-value"),
GroupClaimName: c.String("group-claim-name"),
AdminGroup: c.String("admin-group"),
RestrictedGroup: c.String("restricted-group"),
GroupTeamMap: c.String("group-team-map"),
GroupTeamMapRemoval: c.Bool("group-team-map-removal"),
}
}
func runAddOauth(c *cli.Context) error {
if err := initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
return models.CreateLoginSource(&models.LoginSource{
Type: models.LoginOAuth2,
Name: c.String("name"),
IsActived: true,
Cfg: parseOAuth2Config(c),
config := parseOAuth2Config(c)
if config.Provider == "openidConnect" {
discoveryURL, err := url.Parse(config.OpenIDConnectAutoDiscoveryURL)
if err != nil || (discoveryURL.Scheme != "http" && discoveryURL.Scheme != "https") {
return fmt.Errorf("invalid Auto Discovery URL: %s (this must be a valid URL starting with http:// or https://)", config.OpenIDConnectAutoDiscoveryURL)
}
}
return auth_model.CreateSource(&auth_model.Source{
Type: auth_model.OAuth2,
Name: c.String("name"),
IsActive: true,
Cfg: config,
})
}
@ -459,16 +491,19 @@ func runUpdateOauth(c *cli.Context) error {
return fmt.Errorf("--id flag is missing")
}
if err := initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
source, err := models.GetLoginSourceByID(c.Int64("id"))
source, err := auth_model.GetSourceByID(c.Int64("id"))
if err != nil {
return err
}
oAuth2Config := source.OAuth2()
oAuth2Config := source.Cfg.(*oauth2.Source)
if c.IsSet("name") {
source.Name = c.String("name")
@ -490,14 +525,46 @@ func runUpdateOauth(c *cli.Context) error {
oAuth2Config.OpenIDConnectAutoDiscoveryURL = c.String("auto-discover-url")
}
if c.IsSet("icon-url") {
oAuth2Config.IconURL = c.String("icon-url")
}
if c.IsSet("scopes") {
oAuth2Config.Scopes = c.StringSlice("scopes")
}
if c.IsSet("required-claim-name") {
oAuth2Config.RequiredClaimName = c.String("required-claim-name")
}
if c.IsSet("required-claim-value") {
oAuth2Config.RequiredClaimValue = c.String("required-claim-value")
}
if c.IsSet("group-claim-name") {
oAuth2Config.GroupClaimName = c.String("group-claim-name")
}
if c.IsSet("admin-group") {
oAuth2Config.AdminGroup = c.String("admin-group")
}
if c.IsSet("restricted-group") {
oAuth2Config.RestrictedGroup = c.String("restricted-group")
}
if c.IsSet("group-team-map") {
oAuth2Config.GroupTeamMap = c.String("group-team-map")
}
if c.IsSet("group-team-map-removal") {
oAuth2Config.GroupTeamMapRemoval = c.Bool("group-team-map-removal")
}
// update custom URL mapping
var customURLMapping = &oauth2.CustomURLMapping{}
customURLMapping := &oauth2.CustomURLMapping{}
if oAuth2Config.CustomURLMapping != nil {
customURLMapping.TokenURL = oAuth2Config.CustomURLMapping.TokenURL
customURLMapping.AuthURL = oAuth2Config.CustomURLMapping.AuthURL
customURLMapping.ProfileURL = oAuth2Config.CustomURLMapping.ProfileURL
customURLMapping.EmailURL = oAuth2Config.CustomURLMapping.EmailURL
customURLMapping.Tenant = oAuth2Config.CustomURLMapping.Tenant
}
if c.IsSet("use-custom-urls") && c.IsSet("custom-token-url") {
customURLMapping.TokenURL = c.String("custom-token-url")
@ -515,28 +582,156 @@ func runUpdateOauth(c *cli.Context) error {
customURLMapping.EmailURL = c.String("custom-email-url")
}
if c.IsSet("use-custom-urls") && c.IsSet("custom-tenant-id") {
customURLMapping.Tenant = c.String("custom-tenant-id")
}
oAuth2Config.CustomURLMapping = customURLMapping
source.Cfg = oAuth2Config
return models.UpdateSource(source)
return auth_model.UpdateSource(source)
}
func runListAuth(c *cli.Context) error {
if err := initDB(); err != nil {
func parseSMTPConfig(c *cli.Context, conf *smtp.Source) error {
if c.IsSet("auth-type") {
conf.Auth = c.String("auth-type")
validAuthTypes := []string{"PLAIN", "LOGIN", "CRAM-MD5"}
if !util.SliceContainsString(validAuthTypes, strings.ToUpper(c.String("auth-type"))) {
return errors.New("Auth must be one of PLAIN/LOGIN/CRAM-MD5")
}
conf.Auth = c.String("auth-type")
}
if c.IsSet("host") {
conf.Host = c.String("host")
}
if c.IsSet("port") {
conf.Port = c.Int("port")
}
if c.IsSet("allowed-domains") {
conf.AllowedDomains = c.String("allowed-domains")
}
if c.IsSet("force-smtps") {
conf.ForceSMTPS = c.BoolT("force-smtps")
}
if c.IsSet("skip-verify") {
conf.SkipVerify = c.BoolT("skip-verify")
}
if c.IsSet("helo-hostname") {
conf.HeloHostname = c.String("helo-hostname")
}
if c.IsSet("disable-helo") {
conf.DisableHelo = c.BoolT("disable-helo")
}
if c.IsSet("skip-local-2fa") {
conf.SkipLocalTwoFA = c.BoolT("skip-local-2fa")
}
return nil
}
func runAddSMTP(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
loginSources, err := models.LoginSources()
if !c.IsSet("name") || len(c.String("name")) == 0 {
return errors.New("name must be set")
}
if !c.IsSet("host") || len(c.String("host")) == 0 {
return errors.New("host must be set")
}
if !c.IsSet("port") {
return errors.New("port must be set")
}
active := true
if c.IsSet("active") {
active = c.BoolT("active")
}
var smtpConfig smtp.Source
if err := parseSMTPConfig(c, &smtpConfig); err != nil {
return err
}
// If not set default to PLAIN
if len(smtpConfig.Auth) == 0 {
smtpConfig.Auth = "PLAIN"
}
return auth_model.CreateSource(&auth_model.Source{
Type: auth_model.SMTP,
Name: c.String("name"),
IsActive: active,
Cfg: &smtpConfig,
})
}
func runUpdateSMTP(c *cli.Context) error {
if !c.IsSet("id") {
return fmt.Errorf("--id flag is missing")
}
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
source, err := auth_model.GetSourceByID(c.Int64("id"))
if err != nil {
return err
}
smtpConfig := source.Cfg.(*smtp.Source)
if err := parseSMTPConfig(c, smtpConfig); err != nil {
return err
}
if c.IsSet("name") {
source.Name = c.String("name")
}
if c.IsSet("active") {
source.IsActive = c.BoolT("active")
}
source.Cfg = smtpConfig
return auth_model.UpdateSource(source)
}
func runListAuth(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
authSources, err := auth_model.Sources()
if err != nil {
return err
}
flags := tabwriter.AlignRight
if c.Bool("vertical-bars") {
flags |= tabwriter.Debug
}
padChar := byte('\t')
if len(c.String("pad-char")) > 0 {
padChar = c.String("pad-char")[0]
}
// loop through each source and print
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.AlignRight)
w := tabwriter.NewWriter(os.Stdout, c.Int("min-width"), c.Int("tab-width"), c.Int("padding"), padChar, flags)
fmt.Fprintf(w, "ID\tName\tType\tEnabled\n")
for _, source := range loginSources {
fmt.Fprintf(w, "%d\t%s\t%s\t%t\n", source.ID, source.Name, models.LoginNames[source.Type], source.IsActived)
for _, source := range authSources {
fmt.Fprintf(w, "%d\t%s\t%s\t%t\n", source.ID, source.Name, source.Type.String(), source.IsActive)
}
w.Flush()
@ -548,14 +743,17 @@ func runDeleteAuth(c *cli.Context) error {
return fmt.Errorf("--id flag is missing")
}
if err := initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
source, err := models.GetLoginSourceByID(c.Int64("id"))
source, err := auth_model.GetSourceByID(c.Int64("id"))
if err != nil {
return err
}
return models.DeleteSource(source)
return auth_service.DeleteSource(source)
}

View file

@ -1,25 +1,25 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"fmt"
"strings"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/auth/ldap"
"code.gitea.io/gitea/models/auth"
"code.gitea.io/gitea/services/auth/source/ldap"
"github.com/urfave/cli"
)
type (
authService struct {
initDB func() error
createLoginSource func(loginSource *models.LoginSource) error
updateLoginSource func(loginSource *models.LoginSource) error
getLoginSourceByID func(id int64) (*models.LoginSource, error)
initDB func(ctx context.Context) error
createAuthSource func(*auth.Source) error
updateAuthSource func(*auth.Source) error
getAuthSourceByID func(id int64) (*auth.Source, error)
}
)
@ -33,6 +33,10 @@ var (
Name: "not-active",
Usage: "Deactivate the authentication source.",
},
cli.BoolFlag{
Name: "active",
Usage: "Activate the authentication source.",
},
cli.StringFlag{
Name: "security-protocol",
Usage: "Security protocol name.",
@ -61,6 +65,14 @@ var (
Name: "admin-filter",
Usage: "An LDAP filter specifying if a user should be given administrator privileges.",
},
cli.StringFlag{
Name: "restricted-filter",
Usage: "An LDAP filter specifying if a user should be given restricted status.",
},
cli.BoolFlag{
Name: "allow-deactivate-all",
Usage: "Allow empty search results to deactivate all users.",
},
cli.StringFlag{
Name: "username-attribute",
Usage: "The attribute of the users LDAP record containing the user name.",
@ -81,6 +93,14 @@ var (
Name: "public-ssh-key-attribute",
Usage: "The attribute of the users LDAP record containing the users public ssh key.",
},
cli.BoolFlag{
Name: "skip-local-2fa",
Usage: "Set to true to skip local 2fa for users authenticated by this source",
},
cli.StringFlag{
Name: "avatar-attribute",
Usage: "The attribute of the users LDAP record containing the users avatar.",
},
}
ldapBindDnCLIFlags = append(commonLdapCLIFlags,
@ -100,6 +120,10 @@ var (
Name: "synchronize-users",
Usage: "Enable user synchronization.",
},
cli.BoolFlag{
Name: "disable-synchronize-users",
Usage: "Disable user synchronization.",
},
cli.UintFlag{
Name: "page-size",
Usage: "Search page size.",
@ -151,85 +175,103 @@ var (
// newAuthService creates a service with default functions.
func newAuthService() *authService {
return &authService{
initDB: initDB,
createLoginSource: models.CreateLoginSource,
updateLoginSource: models.UpdateSource,
getLoginSourceByID: models.GetLoginSourceByID,
initDB: initDB,
createAuthSource: auth.CreateSource,
updateAuthSource: auth.UpdateSource,
getAuthSourceByID: auth.GetSourceByID,
}
}
// parseLoginSource assigns values on loginSource according to command line flags.
func parseLoginSource(c *cli.Context, loginSource *models.LoginSource) {
// parseAuthSource assigns values on authSource according to command line flags.
func parseAuthSource(c *cli.Context, authSource *auth.Source) {
if c.IsSet("name") {
loginSource.Name = c.String("name")
authSource.Name = c.String("name")
}
if c.IsSet("not-active") {
loginSource.IsActived = !c.Bool("not-active")
authSource.IsActive = !c.Bool("not-active")
}
if c.IsSet("active") {
authSource.IsActive = c.Bool("active")
}
if c.IsSet("synchronize-users") {
loginSource.IsSyncEnabled = c.Bool("synchronize-users")
authSource.IsSyncEnabled = c.Bool("synchronize-users")
}
if c.IsSet("disable-synchronize-users") {
authSource.IsSyncEnabled = !c.Bool("disable-synchronize-users")
}
}
// parseLdapConfig assigns values on config according to command line flags.
func parseLdapConfig(c *cli.Context, config *models.LDAPConfig) error {
func parseLdapConfig(c *cli.Context, config *ldap.Source) error {
if c.IsSet("name") {
config.Source.Name = c.String("name")
config.Name = c.String("name")
}
if c.IsSet("host") {
config.Source.Host = c.String("host")
config.Host = c.String("host")
}
if c.IsSet("port") {
config.Source.Port = c.Int("port")
config.Port = c.Int("port")
}
if c.IsSet("security-protocol") {
p, ok := findLdapSecurityProtocolByName(c.String("security-protocol"))
if !ok {
return fmt.Errorf("Unknown security protocol name: %s", c.String("security-protocol"))
}
config.Source.SecurityProtocol = p
config.SecurityProtocol = p
}
if c.IsSet("skip-tls-verify") {
config.Source.SkipVerify = c.Bool("skip-tls-verify")
config.SkipVerify = c.Bool("skip-tls-verify")
}
if c.IsSet("bind-dn") {
config.Source.BindDN = c.String("bind-dn")
config.BindDN = c.String("bind-dn")
}
if c.IsSet("user-dn") {
config.Source.UserDN = c.String("user-dn")
config.UserDN = c.String("user-dn")
}
if c.IsSet("bind-password") {
config.Source.BindPassword = c.String("bind-password")
config.BindPassword = c.String("bind-password")
}
if c.IsSet("user-search-base") {
config.Source.UserBase = c.String("user-search-base")
config.UserBase = c.String("user-search-base")
}
if c.IsSet("username-attribute") {
config.Source.AttributeUsername = c.String("username-attribute")
config.AttributeUsername = c.String("username-attribute")
}
if c.IsSet("firstname-attribute") {
config.Source.AttributeName = c.String("firstname-attribute")
config.AttributeName = c.String("firstname-attribute")
}
if c.IsSet("surname-attribute") {
config.Source.AttributeSurname = c.String("surname-attribute")
config.AttributeSurname = c.String("surname-attribute")
}
if c.IsSet("email-attribute") {
config.Source.AttributeMail = c.String("email-attribute")
config.AttributeMail = c.String("email-attribute")
}
if c.IsSet("attributes-in-bind") {
config.Source.AttributesInBind = c.Bool("attributes-in-bind")
config.AttributesInBind = c.Bool("attributes-in-bind")
}
if c.IsSet("public-ssh-key-attribute") {
config.Source.AttributeSSHPublicKey = c.String("public-ssh-key-attribute")
config.AttributeSSHPublicKey = c.String("public-ssh-key-attribute")
}
if c.IsSet("avatar-attribute") {
config.AttributeAvatar = c.String("avatar-attribute")
}
if c.IsSet("page-size") {
config.Source.SearchPageSize = uint32(c.Uint("page-size"))
config.SearchPageSize = uint32(c.Uint("page-size"))
}
if c.IsSet("user-filter") {
config.Source.Filter = c.String("user-filter")
config.Filter = c.String("user-filter")
}
if c.IsSet("admin-filter") {
config.Source.AdminFilter = c.String("admin-filter")
config.AdminFilter = c.String("admin-filter")
}
if c.IsSet("restricted-filter") {
config.RestrictedFilter = c.String("restricted-filter")
}
if c.IsSet("allow-deactivate-all") {
config.AllowDeactivateAll = c.Bool("allow-deactivate-all")
}
if c.IsSet("skip-local-2fa") {
config.SkipLocalTwoFA = c.Bool("skip-local-2fa")
}
return nil
}
@ -237,7 +279,7 @@ func parseLdapConfig(c *cli.Context, config *models.LDAPConfig) error {
// findLdapSecurityProtocolByName finds security protocol by its name ignoring case.
// It returns the value of the security protocol and if it was found.
func findLdapSecurityProtocolByName(name string) (ldap.SecurityProtocol, bool) {
for i, n := range models.SecurityProtocolNames {
for i, n := range ldap.SecurityProtocolNames {
if strings.EqualFold(name, n) {
return i, true
}
@ -245,23 +287,23 @@ func findLdapSecurityProtocolByName(name string) (ldap.SecurityProtocol, bool) {
return 0, false
}
// getLoginSource gets the login source by its id defined in the command line flags.
// getAuthSource gets the login source by its id defined in the command line flags.
// It returns an error if the id is not set, does not match any source or if the source is not of expected type.
func (a *authService) getLoginSource(c *cli.Context, loginType models.LoginType) (*models.LoginSource, error) {
func (a *authService) getAuthSource(c *cli.Context, authType auth.Type) (*auth.Source, error) {
if err := argsSet(c, "id"); err != nil {
return nil, err
}
loginSource, err := a.getLoginSourceByID(c.Int64("id"))
authSource, err := a.getAuthSourceByID(c.Int64("id"))
if err != nil {
return nil, err
}
if loginSource.Type != loginType {
return nil, fmt.Errorf("Invalid authentication type. expected: %s, actual: %s", models.LoginNames[loginType], models.LoginNames[loginSource.Type])
if authSource.Type != authType {
return nil, fmt.Errorf("Invalid authentication type. expected: %s, actual: %s", authType.String(), authSource.Type.String())
}
return loginSource, nil
return authSource, nil
}
// addLdapBindDn adds a new LDAP via Bind DN authentication source.
@ -270,45 +312,49 @@ func (a *authService) addLdapBindDn(c *cli.Context) error {
return err
}
if err := a.initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := a.initDB(ctx); err != nil {
return err
}
loginSource := &models.LoginSource{
Type: models.LoginLDAP,
IsActived: true, // active by default
Cfg: &models.LDAPConfig{
Source: &ldap.Source{
Enabled: true, // always true
},
authSource := &auth.Source{
Type: auth.LDAP,
IsActive: true, // active by default
Cfg: &ldap.Source{
Enabled: true, // always true
},
}
parseLoginSource(c, loginSource)
if err := parseLdapConfig(c, loginSource.LDAP()); err != nil {
parseAuthSource(c, authSource)
if err := parseLdapConfig(c, authSource.Cfg.(*ldap.Source)); err != nil {
return err
}
return a.createLoginSource(loginSource)
return a.createAuthSource(authSource)
}
// updateLdapBindDn updates a new LDAP via Bind DN authentication source.
func (a *authService) updateLdapBindDn(c *cli.Context) error {
if err := a.initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := a.initDB(ctx); err != nil {
return err
}
loginSource, err := a.getLoginSource(c, models.LoginLDAP)
authSource, err := a.getAuthSource(c, auth.LDAP)
if err != nil {
return err
}
parseLoginSource(c, loginSource)
if err := parseLdapConfig(c, loginSource.LDAP()); err != nil {
parseAuthSource(c, authSource)
if err := parseLdapConfig(c, authSource.Cfg.(*ldap.Source)); err != nil {
return err
}
return a.updateLoginSource(loginSource)
return a.updateAuthSource(authSource)
}
// addLdapSimpleAuth adds a new LDAP (simple auth) authentication source.
@ -317,43 +363,47 @@ func (a *authService) addLdapSimpleAuth(c *cli.Context) error {
return err
}
if err := a.initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := a.initDB(ctx); err != nil {
return err
}
loginSource := &models.LoginSource{
Type: models.LoginDLDAP,
IsActived: true, // active by default
Cfg: &models.LDAPConfig{
Source: &ldap.Source{
Enabled: true, // always true
},
authSource := &auth.Source{
Type: auth.DLDAP,
IsActive: true, // active by default
Cfg: &ldap.Source{
Enabled: true, // always true
},
}
parseLoginSource(c, loginSource)
if err := parseLdapConfig(c, loginSource.LDAP()); err != nil {
parseAuthSource(c, authSource)
if err := parseLdapConfig(c, authSource.Cfg.(*ldap.Source)); err != nil {
return err
}
return a.createLoginSource(loginSource)
return a.createAuthSource(authSource)
}
// updateLdapBindDn updates a new LDAP (simple auth) authentication source.
func (a *authService) updateLdapSimpleAuth(c *cli.Context) error {
if err := a.initDB(); err != nil {
ctx, cancel := installSignals()
defer cancel()
if err := a.initDB(ctx); err != nil {
return err
}
loginSource, err := a.getLoginSource(c, models.LoginDLDAP)
authSource, err := a.getAuthSource(c, auth.DLDAP)
if err != nil {
return err
}
parseLoginSource(c, loginSource)
if err := parseLdapConfig(c, loginSource.LDAP()); err != nil {
parseAuthSource(c, authSource)
if err := parseLdapConfig(c, authSource.Cfg.(*ldap.Source)); err != nil {
return err
}
return a.updateLoginSource(loginSource)
return a.updateAuthSource(authSource)
}

File diff suppressed because it is too large Load diff

21
cmd/admin_user.go Normal file
View file

@ -0,0 +1,21 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"github.com/urfave/cli"
)
var subcmdUser = cli.Command{
Name: "user",
Usage: "Modify users",
Subcommands: []cli.Command{
microcmdUserCreate,
microcmdUserList,
microcmdUserChangePassword,
microcmdUserDelete,
microcmdUserGenerateAccessToken,
microcmdUserMustChangePassword,
},
}

View file

@ -0,0 +1,76 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"errors"
"fmt"
user_model "code.gitea.io/gitea/models/user"
pwd "code.gitea.io/gitea/modules/auth/password"
"code.gitea.io/gitea/modules/setting"
"github.com/urfave/cli"
)
var microcmdUserChangePassword = cli.Command{
Name: "change-password",
Usage: "Change a user's password",
Action: runChangePassword,
Flags: []cli.Flag{
cli.StringFlag{
Name: "username,u",
Value: "",
Usage: "The user to change password for",
},
cli.StringFlag{
Name: "password,p",
Value: "",
Usage: "New password to set for user",
},
},
}
func runChangePassword(c *cli.Context) error {
if err := argsSet(c, "username", "password"); err != nil {
return err
}
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
if len(c.String("password")) < setting.MinPasswordLength {
return fmt.Errorf("Password is not long enough. Needs to be at least %d", setting.MinPasswordLength)
}
if !pwd.IsComplexEnough(c.String("password")) {
return errors.New("Password does not meet complexity requirements")
}
pwned, err := pwd.IsPwned(context.Background(), c.String("password"))
if err != nil {
return err
}
if pwned {
return errors.New("The password you chose is on a list of stolen passwords previously exposed in public data breaches. Please try again with a different password.\nFor more details, see https://haveibeenpwned.com/Passwords")
}
uname := c.String("username")
user, err := user_model.GetUserByName(ctx, uname)
if err != nil {
return err
}
if err = user.SetPassword(c.String("password")); err != nil {
return err
}
if err = user_model.UpdateUserCols(ctx, user, "passwd", "passwd_hash_algo", "salt"); err != nil {
return err
}
fmt.Printf("%s's password has been successfully updated!\n", user.Name)
return nil
}

169
cmd/admin_user_create.go Normal file
View file

@ -0,0 +1,169 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"errors"
"fmt"
"os"
auth_model "code.gitea.io/gitea/models/auth"
user_model "code.gitea.io/gitea/models/user"
pwd "code.gitea.io/gitea/modules/auth/password"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"github.com/urfave/cli"
)
var microcmdUserCreate = cli.Command{
Name: "create",
Usage: "Create a new user in database",
Action: runCreateUser,
Flags: []cli.Flag{
cli.StringFlag{
Name: "name",
Usage: "Username. DEPRECATED: use username instead",
},
cli.StringFlag{
Name: "username",
Usage: "Username",
},
cli.StringFlag{
Name: "password",
Usage: "User password",
},
cli.StringFlag{
Name: "email",
Usage: "User email address",
},
cli.BoolFlag{
Name: "admin",
Usage: "User is an admin",
},
cli.BoolFlag{
Name: "random-password",
Usage: "Generate a random password for the user",
},
cli.BoolFlag{
Name: "must-change-password",
Usage: "Set this option to false to prevent forcing the user to change their password after initial login, (Default: true)",
},
cli.IntFlag{
Name: "random-password-length",
Usage: "Length of the random password to be generated",
Value: 12,
},
cli.BoolFlag{
Name: "access-token",
Usage: "Generate access token for the user",
},
cli.BoolFlag{
Name: "restricted",
Usage: "Make a restricted user account",
},
},
}
func runCreateUser(c *cli.Context) error {
if err := argsSet(c, "email"); err != nil {
return err
}
if c.IsSet("name") && c.IsSet("username") {
return errors.New("Cannot set both --name and --username flags")
}
if !c.IsSet("name") && !c.IsSet("username") {
return errors.New("One of --name or --username flags must be set")
}
if c.IsSet("password") && c.IsSet("random-password") {
return errors.New("cannot set both -random-password and -password flags")
}
var username string
if c.IsSet("username") {
username = c.String("username")
} else {
username = c.String("name")
fmt.Fprintf(os.Stderr, "--name flag is deprecated. Use --username instead.\n")
}
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
var password string
if c.IsSet("password") {
password = c.String("password")
} else if c.IsSet("random-password") {
var err error
password, err = pwd.Generate(c.Int("random-password-length"))
if err != nil {
return err
}
fmt.Printf("generated random password is '%s'\n", password)
} else {
return errors.New("must set either password or random-password flag")
}
// always default to true
changePassword := true
// If this is the first user being created.
// Take it as the admin and don't force a password update.
if n := user_model.CountUsers(nil); n == 0 {
changePassword = false
}
if c.IsSet("must-change-password") {
changePassword = c.Bool("must-change-password")
}
restricted := util.OptionalBoolNone
if c.IsSet("restricted") {
restricted = util.OptionalBoolOf(c.Bool("restricted"))
}
// default user visibility in app.ini
visibility := setting.Service.DefaultUserVisibilityMode
u := &user_model.User{
Name: username,
Email: c.String("email"),
Passwd: password,
IsAdmin: c.Bool("admin"),
MustChangePassword: changePassword,
Visibility: visibility,
}
overwriteDefault := &user_model.CreateUserOverwriteOptions{
IsActive: util.OptionalBoolTrue,
IsRestricted: restricted,
}
if err := user_model.CreateUser(u, overwriteDefault); err != nil {
return fmt.Errorf("CreateUser: %w", err)
}
if c.Bool("access-token") {
t := &auth_model.AccessToken{
Name: "gitea-admin",
UID: u.ID,
}
if err := auth_model.NewAccessToken(t); err != nil {
return err
}
fmt.Printf("Access token was successfully created... %s\n", t.Token)
}
fmt.Printf("New user '%s' has been successfully created!\n", username)
return nil
}

78
cmd/admin_user_delete.go Normal file
View file

@ -0,0 +1,78 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"strings"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/storage"
user_service "code.gitea.io/gitea/services/user"
"github.com/urfave/cli"
)
var microcmdUserDelete = cli.Command{
Name: "delete",
Usage: "Delete specific user by id, name or email",
Flags: []cli.Flag{
cli.Int64Flag{
Name: "id",
Usage: "ID of user of the user to delete",
},
cli.StringFlag{
Name: "username,u",
Usage: "Username of the user to delete",
},
cli.StringFlag{
Name: "email,e",
Usage: "Email of the user to delete",
},
cli.BoolFlag{
Name: "purge",
Usage: "Purge user, all their repositories, organizations and comments",
},
},
Action: runDeleteUser,
}
func runDeleteUser(c *cli.Context) error {
if !c.IsSet("id") && !c.IsSet("username") && !c.IsSet("email") {
return fmt.Errorf("You must provide the id, username or email of a user to delete")
}
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
if err := storage.Init(); err != nil {
return err
}
var err error
var user *user_model.User
if c.IsSet("email") {
user, err = user_model.GetUserByEmail(ctx, c.String("email"))
} else if c.IsSet("username") {
user, err = user_model.GetUserByName(ctx, c.String("username"))
} else {
user, err = user_model.GetUserByID(ctx, c.Int64("id"))
}
if err != nil {
return err
}
if c.IsSet("username") && user.LowerName != strings.ToLower(strings.TrimSpace(c.String("username"))) {
return fmt.Errorf("The user %s who has email %s does not match the provided username %s", user.Name, c.String("email"), c.String("username"))
}
if c.IsSet("id") && user.ID != c.Int64("id") {
return fmt.Errorf("The user %s does not match the provided id %d", user.Name, c.Int64("id"))
}
return user_service.DeleteUser(ctx, user, c.Bool("purge"))
}

View file

@ -0,0 +1,80 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
auth_model "code.gitea.io/gitea/models/auth"
user_model "code.gitea.io/gitea/models/user"
"github.com/urfave/cli"
)
var microcmdUserGenerateAccessToken = cli.Command{
Name: "generate-access-token",
Usage: "Generate an access token for a specific user",
Flags: []cli.Flag{
cli.StringFlag{
Name: "username,u",
Usage: "Username",
},
cli.StringFlag{
Name: "token-name,t",
Usage: "Token name",
Value: "gitea-admin",
},
cli.BoolFlag{
Name: "raw",
Usage: "Display only the token value",
},
cli.StringFlag{
Name: "scopes",
Value: "",
Usage: "Comma separated list of scopes to apply to access token",
},
},
Action: runGenerateAccessToken,
}
func runGenerateAccessToken(c *cli.Context) error {
if !c.IsSet("username") {
return fmt.Errorf("You must provide a username to generate a token for")
}
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
user, err := user_model.GetUserByName(ctx, c.String("username"))
if err != nil {
return err
}
accessTokenScope, err := auth_model.AccessTokenScope(c.String("scopes")).Normalize()
if err != nil {
return err
}
t := &auth_model.AccessToken{
Name: c.String("token-name"),
UID: user.ID,
Scope: accessTokenScope,
}
if err := auth_model.NewAccessToken(t); err != nil {
return err
}
if c.Bool("raw") {
fmt.Printf("%s\n", t.Token)
} else {
fmt.Printf("Access token was successfully created: %s\n", t.Token)
}
return nil
}

60
cmd/admin_user_list.go Normal file
View file

@ -0,0 +1,60 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"os"
"text/tabwriter"
user_model "code.gitea.io/gitea/models/user"
"github.com/urfave/cli"
)
var microcmdUserList = cli.Command{
Name: "list",
Usage: "List users",
Action: runListUsers,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "admin",
Usage: "List only admin users",
},
},
}
func runListUsers(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if err := initDB(ctx); err != nil {
return err
}
users, err := user_model.GetAllUsers()
if err != nil {
return err
}
w := tabwriter.NewWriter(os.Stdout, 5, 0, 1, ' ', 0)
if c.IsSet("admin") {
fmt.Fprintf(w, "ID\tUsername\tEmail\tIsActive\n")
for _, u := range users {
if u.IsAdmin {
fmt.Fprintf(w, "%d\t%s\t%s\t%t\n", u.ID, u.Name, u.Email, u.IsActive)
}
}
} else {
twofa := user_model.UserList(users).GetTwoFaStatus()
fmt.Fprintf(w, "ID\tUsername\tEmail\tIsActive\tIsAdmin\t2FA\n")
for _, u := range users {
fmt.Fprintf(w, "%d\t%s\t%s\t%t\t%t\t%t\n", u.ID, u.Name, u.Email, u.IsActive, u.IsAdmin, twofa[u.ID])
}
}
w.Flush()
return nil
}

View file

@ -0,0 +1,58 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"errors"
"fmt"
user_model "code.gitea.io/gitea/models/user"
"github.com/urfave/cli"
)
var microcmdUserMustChangePassword = cli.Command{
Name: "must-change-password",
Usage: "Set the must change password flag for the provided users or all users",
Action: runMustChangePassword,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "all,A",
Usage: "All users must change password, except those explicitly excluded with --exclude",
},
cli.StringSliceFlag{
Name: "exclude,e",
Usage: "Do not change the must-change-password flag for these users",
},
cli.BoolFlag{
Name: "unset",
Usage: "Instead of setting the must-change-password flag, unset it",
},
},
}
func runMustChangePassword(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
if c.NArg() == 0 && !c.IsSet("all") {
return errors.New("either usernames or --all must be provided")
}
mustChangePassword := !c.Bool("unset")
all := c.Bool("all")
exclude := c.StringSlice("exclude")
if err := initDB(ctx); err != nil {
return err
}
n, err := user_model.SetMustChangePassword(ctx, all, mustChangePassword, c.Args(), exclude)
if err != nil {
return err
}
fmt.Printf("Updated %d users setting MustChangePassword to %t\n", n, mustChangePassword)
return nil
}

View file

@ -1,8 +1,7 @@
// Copyright 2009 The Go Authors. All rights reserved.
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
@ -180,7 +179,7 @@ func runCert(c *cli.Context) error {
}
log.Println("Written cert.pem")
keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600)
keyOut, err := os.OpenFile("key.pem", os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0o600)
if err != nil {
log.Fatalf("Failed to open key.pem for writing: %v", err)
}

View file

@ -1,16 +1,21 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
// Package cmd provides subcommands to the gitea binary - such as "web" or
// "admin".
package cmd
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
"strings"
"syscall"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
@ -25,24 +30,67 @@ func argsSet(c *cli.Context, args ...string) error {
return errors.New(a + " is not set")
}
if util.IsEmptyString(a) {
if util.IsEmptyString(c.String(a)) {
return errors.New(a + " is required")
}
}
return nil
}
func initDB() error {
return initDBDisableConsole(false)
// confirm waits for user input which confirms an action
func confirm() (bool, error) {
var response string
_, err := fmt.Scanln(&response)
if err != nil {
return false, err
}
switch strings.ToLower(response) {
case "y", "yes":
return true, nil
case "n", "no":
return false, nil
default:
return false, errors.New(response + " isn't a correct confirmation string")
}
}
func initDBDisableConsole(disableConsole bool) error {
setting.NewContext()
setting.InitDBConfig()
func initDB(ctx context.Context) error {
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
setting.LoadDBSetting()
setting.InitSQLLog(false)
setting.NewXORMLogService(disableConsole)
if err := models.SetEngine(); err != nil {
return fmt.Errorf("models.SetEngine: %v", err)
if setting.Database.Type == "" {
log.Fatal(`Database settings are missing from the configuration file: %q.
Ensure you are running in the correct environment or set the correct configuration file with -c.
If this is the intended configuration file complete the [database] section.`, setting.CustomConf)
}
if err := db.InitEngine(ctx); err != nil {
return fmt.Errorf("unable to initialize the database using the configuration in %q. Error: %w", setting.CustomConf, err)
}
return nil
}
func installSignals() (context.Context, context.CancelFunc) {
ctx, cancel := context.WithCancel(context.Background())
go func() {
// install notify
signalChannel := make(chan os.Signal, 1)
signal.Notify(
signalChannel,
syscall.SIGINT,
syscall.SIGTERM,
)
select {
case <-signalChannel:
case <-ctx.Done():
}
cancel()
signal.Reset()
}()
return ctx, cancel
}

View file

@ -1,13 +1,12 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@ -23,22 +22,25 @@ var CmdConvert = cli.Command{
}
func runConvert(ctx *cli.Context) error {
if err := initDB(); err != nil {
stdCtx, cancel := installSignals()
defer cancel()
if err := initDB(stdCtx); err != nil {
return err
}
log.Trace("AppPath: %s", setting.AppPath)
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
log.Trace("Custom path: %s", setting.CustomPath)
log.Trace("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()
log.Info("AppPath: %s", setting.AppPath)
log.Info("AppWorkPath: %s", setting.AppWorkPath)
log.Info("Custom path: %s", setting.CustomPath)
log.Info("Log path: %s", setting.Log.RootPath)
log.Info("Configuration file: %s", setting.CustomConf)
if !setting.Database.UseMySQL {
if !setting.Database.Type.IsMySQL() {
fmt.Println("This command can only be used with a MySQL database")
return nil
}
if err := models.ConvertUtf8ToUtf8mb4(); err != nil {
if err := db.ConvertUtf8ToUtf8mb4(); err != nil {
log.Fatal("Failed to convert database from utf8 to utf8mb4: %v", err)
return err
}

64
cmd/docs.go Normal file
View file

@ -0,0 +1,64 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"os"
"strings"
"github.com/urfave/cli"
)
// CmdDocs represents the available docs sub-command.
var CmdDocs = cli.Command{
Name: "docs",
Usage: "Output CLI documentation",
Description: "A command to output Gitea's CLI documentation, optionally to a file.",
Action: runDocs,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "man",
Usage: "Output man pages instead",
},
&cli.StringFlag{
Name: "output, o",
Usage: "Path to output to instead of stdout (will overwrite if exists)",
},
},
}
func runDocs(ctx *cli.Context) error {
docs, err := ctx.App.ToMarkdown()
if ctx.Bool("man") {
docs, err = ctx.App.ToMan()
}
if err != nil {
return err
}
if !ctx.Bool("man") {
// Clean up markdown. The following bug was fixed in v2, but is present in v1.
// It affects markdown output (even though the issue is referring to man pages)
// https://github.com/urfave/cli/issues/1040
firstHashtagIndex := strings.Index(docs, "#")
if firstHashtagIndex > 0 {
docs = docs[firstHashtagIndex:]
}
}
out := os.Stdout
if ctx.String("output") != "" {
fi, err := os.Create(ctx.String("output"))
if err != nil {
return err
}
defer fi.Close()
out = fi
}
_, err = fmt.Fprintln(out, docs)
return err
}

250
cmd/doctor.go Normal file
View file

@ -0,0 +1,250 @@
// Copyright 2019 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"errors"
"fmt"
golog "log"
"os"
"strings"
"text/tabwriter"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/migrations"
migrate_base "code.gitea.io/gitea/models/migrations/base"
"code.gitea.io/gitea/modules/doctor"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/urfave/cli"
"xorm.io/xorm"
)
// CmdDoctor represents the available doctor sub-command.
var CmdDoctor = cli.Command{
Name: "doctor",
Usage: "Diagnose and optionally fix problems",
Description: "A command to diagnose problems with the current Gitea instance according to the given configuration. Some problems can optionally be fixed by modifying the database or data storage.",
Action: runDoctor,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "list",
Usage: "List the available checks",
},
cli.BoolFlag{
Name: "default",
Usage: "Run the default checks (if neither --run or --all is set, this is the default behaviour)",
},
cli.StringSliceFlag{
Name: "run",
Usage: "Run the provided checks - (if --default is set, the default checks will also run)",
},
cli.BoolFlag{
Name: "all",
Usage: "Run all the available checks",
},
cli.BoolFlag{
Name: "fix",
Usage: "Automatically fix what we can",
},
cli.StringFlag{
Name: "log-file",
Usage: `Name of the log file (default: "doctor.log"). Set to "-" to output to stdout, set to "" to disable`,
},
cli.BoolFlag{
Name: "color, H",
Usage: "Use color for outputted information",
},
},
Subcommands: []cli.Command{
cmdRecreateTable,
},
}
var cmdRecreateTable = cli.Command{
Name: "recreate-table",
Usage: "Recreate tables from XORM definitions and copy the data.",
ArgsUsage: "[TABLE]... : (TABLEs to recreate - leave blank for all)",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
Usage: "Print SQL commands sent",
},
},
Description: `The database definitions Gitea uses change across versions, sometimes changing default values and leaving old unused columns.
This command will cause Xorm to recreate tables, copying over the data and deleting the old table.
You should back-up your database before doing this and ensure that your database is up-to-date first.`,
Action: runRecreateTable,
}
func runRecreateTable(ctx *cli.Context) error {
// Redirect the default golog to here
golog.SetFlags(0)
golog.SetPrefix("")
golog.SetOutput(log.NewLoggerAsWriter("INFO", log.GetLogger(log.DEFAULT)))
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
setting.LoadDBSetting()
setting.Log.EnableXORMLog = ctx.Bool("debug")
setting.Database.LogSQL = ctx.Bool("debug")
// FIXME: don't use CfgProvider directly
setting.CfgProvider.Section("log").Key("XORM").SetValue(",")
setting.InitSQLLog(!ctx.Bool("debug"))
stdCtx, cancel := installSignals()
defer cancel()
if err := db.InitEngine(stdCtx); err != nil {
fmt.Println(err)
fmt.Println("Check if you are using the right config file. You can use a --config directive to specify one.")
return nil
}
args := ctx.Args()
names := make([]string, 0, ctx.NArg())
for i := 0; i < ctx.NArg(); i++ {
names = append(names, args.Get(i))
}
beans, err := db.NamesToBean(names...)
if err != nil {
return err
}
recreateTables := migrate_base.RecreateTables(beans...)
return db.InitEngineWithMigration(stdCtx, func(x *xorm.Engine) error {
if err := migrations.EnsureUpToDate(x); err != nil {
return err
}
return recreateTables(x)
})
}
func setDoctorLogger(ctx *cli.Context) {
logFile := ctx.String("log-file")
if !ctx.IsSet("log-file") {
logFile = "doctor.log"
}
colorize := log.CanColorStdout
if ctx.IsSet("color") {
colorize = ctx.Bool("color")
}
if len(logFile) == 0 {
log.NewLogger(1000, "doctor", "console", fmt.Sprintf(`{"level":"NONE","stacktracelevel":"NONE","colorize":%t}`, colorize))
return
}
defer func() {
recovered := recover()
if recovered == nil {
return
}
err, ok := recovered.(error)
if !ok {
panic(recovered)
}
if errors.Is(err, os.ErrPermission) {
fmt.Fprintf(os.Stderr, "ERROR: Unable to write logs to provided file due to permissions error: %s\n %v\n", logFile, err)
} else {
fmt.Fprintf(os.Stderr, "ERROR: Unable to write logs to provided file: %s\n %v\n", logFile, err)
}
fmt.Fprintf(os.Stderr, "WARN: Logging will be disabled\n Use `--log-file` to configure log file location\n")
log.NewLogger(1000, "doctor", "console", fmt.Sprintf(`{"level":"NONE","stacktracelevel":"NONE","colorize":%t}`, colorize))
}()
if logFile == "-" {
log.NewLogger(1000, "doctor", "console", fmt.Sprintf(`{"level":"trace","stacktracelevel":"NONE","colorize":%t}`, colorize))
} else {
log.NewLogger(1000, "doctor", "file", fmt.Sprintf(`{"filename":%q,"level":"trace","stacktracelevel":"NONE"}`, logFile))
}
}
func runDoctor(ctx *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()
// Silence the default loggers
log.DelNamedLogger("console")
log.DelNamedLogger(log.DEFAULT)
// Now setup our own
setDoctorLogger(ctx)
colorize := log.CanColorStdout
if ctx.IsSet("color") {
colorize = ctx.Bool("color")
}
// Finally redirect the default golog to here
golog.SetFlags(0)
golog.SetPrefix("")
golog.SetOutput(log.NewLoggerAsWriter("INFO", log.GetLogger(log.DEFAULT)))
if ctx.IsSet("list") {
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0)
_, _ = w.Write([]byte("Default\tName\tTitle\n"))
for _, check := range doctor.Checks {
if check.IsDefault {
_, _ = w.Write([]byte{'*'})
}
_, _ = w.Write([]byte{'\t'})
_, _ = w.Write([]byte(check.Name))
_, _ = w.Write([]byte{'\t'})
_, _ = w.Write([]byte(check.Title))
_, _ = w.Write([]byte{'\n'})
}
return w.Flush()
}
var checks []*doctor.Check
if ctx.Bool("all") {
checks = doctor.Checks
} else if ctx.IsSet("run") {
addDefault := ctx.Bool("default")
names := ctx.StringSlice("run")
for i, name := range names {
names[i] = strings.ToLower(strings.TrimSpace(name))
}
for _, check := range doctor.Checks {
if addDefault && check.IsDefault {
checks = append(checks, check)
continue
}
for _, name := range names {
if name == check.Name {
checks = append(checks, check)
break
}
}
}
} else {
for _, check := range doctor.Checks {
if check.IsDefault {
checks = append(checks, check)
}
}
}
// Now we can set up our own logger to return information about what the doctor is doing
if err := log.NewNamedLogger("doctorouter",
0,
"console",
"console",
fmt.Sprintf(`{"level":"INFO","stacktracelevel":"NONE","colorize":%t,"flags":-1}`, colorize)); err != nil {
fmt.Println(err)
return err
}
logger := log.GetLogger("doctorouter")
defer logger.Close()
return doctor.RunChecks(stdCtx, logger, ctx.Bool("fix"), checks)
}

View file

@ -1,27 +1,100 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"io/ioutil"
"io"
"os"
"path"
"path/filepath"
"strings"
"time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
"code.gitea.io/gitea/modules/util"
"github.com/unknwon/cae/zip"
"github.com/unknwon/com"
"gitea.com/go-chi/session"
"github.com/mholt/archiver/v3"
"github.com/urfave/cli"
)
func addReader(w archiver.Writer, r io.ReadCloser, info os.FileInfo, customName string, verbose bool) error {
if verbose {
log.Info("Adding file %s", customName)
}
return w.Write(archiver.File{
FileInfo: archiver.FileInfo{
FileInfo: info,
CustomName: customName,
},
ReadCloser: r,
})
}
func addFile(w archiver.Writer, filePath, absPath string, verbose bool) error {
file, err := os.Open(absPath)
if err != nil {
return err
}
defer file.Close()
fileInfo, err := file.Stat()
if err != nil {
return err
}
return addReader(w, file, fileInfo, filePath, verbose)
}
func isSubdir(upper, lower string) (bool, error) {
if relPath, err := filepath.Rel(upper, lower); err != nil {
return false, err
} else if relPath == "." || !strings.HasPrefix(relPath, ".") {
return true, nil
}
return false, nil
}
type outputType struct {
Enum []string
Default string
selected string
}
func (o outputType) Join() string {
return strings.Join(o.Enum, ", ")
}
func (o *outputType) Set(value string) error {
for _, enum := range o.Enum {
if enum == value {
o.selected = value
return nil
}
}
return fmt.Errorf("allowed values are %s", o.Join())
}
func (o outputType) String() string {
if o.selected == "" {
return o.Default
}
return o.selected
}
var outputTypeEnum = &outputType{
Enum: []string{"zip", "tar", "tar.sz", "tar.gz", "tar.xz", "tar.bz2", "tar.br", "tar.lz4", "tar.zst"},
Default: "zip",
}
// CmdDump represents the available dump sub-command.
var CmdDump = cli.Command{
Name: "dump",
@ -33,7 +106,7 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
cli.StringFlag{
Name: "file, f",
Value: fmt.Sprintf("gitea-dump-%d.zip", time.Now().Unix()),
Usage: "Name of the dump file which will be created.",
Usage: "Name of the dump file which will be created. Supply '-' for stdout. See type for available types.",
},
cli.BoolFlag{
Name: "verbose, V",
@ -52,6 +125,35 @@ It can be used for backup and capture Gitea server image to send to maintainer`,
Name: "skip-repository, R",
Usage: "Skip the repository dumping",
},
cli.BoolFlag{
Name: "skip-log, L",
Usage: "Skip the log dumping",
},
cli.BoolFlag{
Name: "skip-custom-dir",
Usage: "Skip custom directory",
},
cli.BoolFlag{
Name: "skip-lfs-data",
Usage: "Skip LFS data",
},
cli.BoolFlag{
Name: "skip-attachment-data",
Usage: "Skip attachment data",
},
cli.BoolFlag{
Name: "skip-package-data",
Usage: "Skip package data",
},
cli.BoolFlag{
Name: "skip-index",
Usage: "Skip bleve index data",
},
cli.GenericFlag{
Name: "type",
Value: outputTypeEnum,
Usage: fmt.Sprintf("Dump output format: %s", outputTypeEnum.Join()),
},
},
}
@ -61,121 +163,257 @@ func fatal(format string, args ...interface{}) {
}
func runDump(ctx *cli.Context) error {
setting.NewContext()
setting.NewServices() // cannot access session settings otherwise
var file *os.File
fileName := ctx.String("file")
outType := ctx.String("type")
if fileName == "-" {
file = os.Stdout
err := log.DelLogger("console")
if err != nil {
fatal("Deleting default logger failed. Can not write to stdout: %v", err)
}
} else {
for _, suffix := range outputTypeEnum.Enum {
if strings.HasSuffix(fileName, "."+suffix) {
fileName = strings.TrimSuffix(fileName, "."+suffix)
break
}
}
fileName += "." + outType
}
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
err := models.SetEngine()
// make sure we are logging to the console no matter what the configuration tells us do to
// FIXME: don't use CfgProvider directly
if _, err := setting.CfgProvider.Section("log").NewKey("MODE", "console"); err != nil {
fatal("Setting logging mode to console failed: %v", err)
}
if _, err := setting.CfgProvider.Section("log.console").NewKey("STDERR", "true"); err != nil {
fatal("Setting console logger to stderr failed: %v", err)
}
if !setting.InstallLock {
log.Error("Is '%s' really the right config path?\n", setting.CustomConf)
return fmt.Errorf("gitea is not initialized")
}
setting.LoadSettings() // cannot access session settings otherwise
stdCtx, cancel := installSignals()
defer cancel()
err := db.InitEngine(stdCtx)
if err != nil {
return err
}
if err := storage.Init(); err != nil {
return err
}
if file == nil {
file, err = os.Create(fileName)
if err != nil {
fatal("Unable to open %s: %v", fileName, err)
}
}
defer file.Close()
absFileName, err := filepath.Abs(fileName)
if err != nil {
return err
}
verbose := ctx.Bool("verbose")
var iface interface{}
if fileName == "-" {
iface, err = archiver.ByExtension(fmt.Sprintf(".%s", outType))
} else {
iface, err = archiver.ByExtension(fileName)
}
if err != nil {
fatal("Unable to get archiver for extension: %v", err)
}
w, _ := iface.(archiver.Writer)
if err := w.Create(file); err != nil {
fatal("Creating archiver.Writer failed: %v", err)
}
defer w.Close()
if ctx.IsSet("skip-repository") && ctx.Bool("skip-repository") {
log.Info("Skip dumping local repositories")
} else {
log.Info("Dumping local repositories... %s", setting.RepoRootPath)
if err := addRecursiveExclude(w, "repos", setting.RepoRootPath, []string{absFileName}, verbose); err != nil {
fatal("Failed to include repositories: %v", err)
}
if ctx.IsSet("skip-lfs-data") && ctx.Bool("skip-lfs-data") {
log.Info("Skip dumping LFS data")
} else if err := storage.LFS.IterateObjects(func(objPath string, object storage.Object) error {
info, err := object.Stat()
if err != nil {
return err
}
return addReader(w, object, info, path.Join("data", "lfs", objPath), verbose)
}); err != nil {
fatal("Failed to dump LFS objects: %v", err)
}
}
tmpDir := ctx.String("tempdir")
if _, err := os.Stat(tmpDir); os.IsNotExist(err) {
fatal("Path does not exist: %s", tmpDir)
}
tmpWorkDir, err := ioutil.TempDir(tmpDir, "gitea-dump-")
dbDump, err := os.CreateTemp(tmpDir, "gitea-db.sql")
if err != nil {
fatal("Failed to create tmp work directory: %v", err)
fatal("Failed to create tmp file: %v", err)
}
log.Info("Creating tmp work dir: %s", tmpWorkDir)
// work-around #1103
if os.Getenv("TMPDIR") == "" {
os.Setenv("TMPDIR", tmpWorkDir)
}
dbDump := path.Join(tmpWorkDir, "gitea-db.sql")
fileName := ctx.String("file")
log.Info("Packing dump files...")
z, err := zip.Create(fileName)
if err != nil {
fatal("Failed to create %s: %v", fileName, err)
}
zip.Verbose = ctx.Bool("verbose")
if ctx.IsSet("skip-repository") {
log.Info("Skip dumping local repositories")
} else {
log.Info("Dumping local repositories...%s", setting.RepoRootPath)
reposDump := path.Join(tmpWorkDir, "gitea-repo.zip")
if err := zip.PackTo(setting.RepoRootPath, reposDump, true); err != nil {
fatal("Failed to dump local repositories: %v", err)
defer func() {
_ = dbDump.Close()
if err := util.Remove(dbDump.Name()); err != nil {
log.Warn("Unable to remove temporary file: %s: Error: %v", dbDump.Name(), err)
}
if err := z.AddFile("gitea-repo.zip", reposDump); err != nil {
fatal("Failed to include gitea-repo.zip: %v", err)
}
}
}()
targetDBType := ctx.String("database")
if len(targetDBType) > 0 && targetDBType != setting.Database.Type {
if len(targetDBType) > 0 && targetDBType != setting.Database.Type.String() {
log.Info("Dumping database %s => %s...", setting.Database.Type, targetDBType)
} else {
log.Info("Dumping database...")
}
if err := models.DumpDatabase(dbDump, targetDBType); err != nil {
if err := db.DumpDatabase(dbDump.Name(), targetDBType); err != nil {
fatal("Failed to dump database: %v", err)
}
if err := z.AddFile("gitea-db.sql", dbDump); err != nil {
if err := addFile(w, "gitea-db.sql", dbDump.Name(), verbose); err != nil {
fatal("Failed to include gitea-db.sql: %v", err)
}
if len(setting.CustomConf) > 0 {
log.Info("Adding custom configuration file from %s", setting.CustomConf)
if err := z.AddFile("app.ini", setting.CustomConf); err != nil {
if err := addFile(w, "app.ini", setting.CustomConf, verbose); err != nil {
fatal("Failed to include specified app.ini: %v", err)
}
}
customDir, err := os.Stat(setting.CustomPath)
if err == nil && customDir.IsDir() {
if err := z.AddDir("custom", setting.CustomPath); err != nil {
fatal("Failed to include custom: %v", err)
}
if ctx.IsSet("skip-custom-dir") && ctx.Bool("skip-custom-dir") {
log.Info("Skipping custom directory")
} else {
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
customDir, err := os.Stat(setting.CustomPath)
if err == nil && customDir.IsDir() {
if is, _ := isSubdir(setting.AppDataPath, setting.CustomPath); !is {
if err := addRecursiveExclude(w, "custom", setting.CustomPath, []string{absFileName}, verbose); err != nil {
fatal("Failed to include custom: %v", err)
}
} else {
log.Info("Custom dir %s is inside data dir %s, skipped", setting.CustomPath, setting.AppDataPath)
}
} else {
log.Info("Custom dir %s doesn't exist, skipped", setting.CustomPath)
}
}
if com.IsExist(setting.AppDataPath) {
isExist, err := util.IsExist(setting.AppDataPath)
if err != nil {
log.Error("Unable to check if %s exists. Error: %v", setting.AppDataPath, err)
}
if isExist {
log.Info("Packing data directory...%s", setting.AppDataPath)
var sessionAbsPath string
if setting.SessionConfig.Provider == "file" {
sessionAbsPath = setting.SessionConfig.ProviderConfig
var excludes []string
if setting.SessionConfig.OriginalProvider == "file" {
var opts session.Options
if err = json.Unmarshal([]byte(setting.SessionConfig.ProviderConfig), &opts); err != nil {
return err
}
excludes = append(excludes, opts.ProviderConfig)
}
if err := zipAddDirectoryExclude(z, "data", setting.AppDataPath, sessionAbsPath); err != nil {
if ctx.IsSet("skip-index") && ctx.Bool("skip-index") {
excludes = append(excludes, setting.Indexer.RepoPath)
excludes = append(excludes, setting.Indexer.IssuePath)
}
excludes = append(excludes, setting.RepoRootPath)
excludes = append(excludes, setting.LFS.Path)
excludes = append(excludes, setting.Attachment.Path)
excludes = append(excludes, setting.Packages.Path)
excludes = append(excludes, setting.Log.RootPath)
excludes = append(excludes, absFileName)
if err := addRecursiveExclude(w, "data", setting.AppDataPath, excludes, verbose); err != nil {
fatal("Failed to include data directory: %v", err)
}
}
if err := z.AddDir("log", setting.LogRootPath); err != nil {
fatal("Failed to include log: %v", err)
if ctx.IsSet("skip-attachment-data") && ctx.Bool("skip-attachment-data") {
log.Info("Skip dumping attachment data")
} else if err := storage.Attachments.IterateObjects(func(objPath string, object storage.Object) error {
info, err := object.Stat()
if err != nil {
return err
}
return addReader(w, object, info, path.Join("data", "attachments", objPath), verbose)
}); err != nil {
fatal("Failed to dump attachments: %v", err)
}
if err = z.Close(); err != nil {
_ = os.Remove(fileName)
fatal("Failed to save %s: %v", fileName, err)
if ctx.IsSet("skip-package-data") && ctx.Bool("skip-package-data") {
log.Info("Skip dumping package data")
} else if err := storage.Packages.IterateObjects(func(objPath string, object storage.Object) error {
info, err := object.Stat()
if err != nil {
return err
}
return addReader(w, object, info, path.Join("data", "packages", objPath), verbose)
}); err != nil {
fatal("Failed to dump packages: %v", err)
}
if err := os.Chmod(fileName, 0600); err != nil {
log.Info("Can't change file access permissions mask to 0600: %v", err)
// Doesn't check if LogRootPath exists before processing --skip-log intentionally,
// ensuring that it's clear the dump is skipped whether the directory's initialized
// yet or not.
if ctx.IsSet("skip-log") && ctx.Bool("skip-log") {
log.Info("Skip dumping log files")
} else {
isExist, err := util.IsExist(setting.Log.RootPath)
if err != nil {
log.Error("Unable to check if %s exists. Error: %v", setting.Log.RootPath, err)
}
if isExist {
if err := addRecursiveExclude(w, "log", setting.Log.RootPath, []string{absFileName}, verbose); err != nil {
fatal("Failed to include log: %v", err)
}
}
}
log.Info("Removing tmp work dir: %s", tmpWorkDir)
if fileName != "-" {
if err = w.Close(); err != nil {
_ = util.Remove(fileName)
fatal("Failed to save %s: %v", fileName, err)
}
if err := os.RemoveAll(tmpWorkDir); err != nil {
fatal("Failed to remove %s: %v", tmpWorkDir, err)
if err := os.Chmod(fileName, 0o600); err != nil {
log.Info("Can't change file access permissions mask to 0600: %v", err)
}
}
if fileName != "-" {
log.Info("Finish dumping in file %s", fileName)
} else {
log.Info("Finish dumping to stdout")
}
log.Info("Finish dumping in file %s", fileName)
return nil
}
// zipAddDirectoryExclude zips absPath to specified zipPath inside z excluding excludeAbsPath
func zipAddDirectoryExclude(zip *zip.ZipArchive, zipPath, absPath string, excludeAbsPath string) error {
// addRecursiveExclude zips absPath to specified insidePath inside writer excluding excludeAbsPath
func addRecursiveExclude(w archiver.Writer, insidePath, absPath string, excludeAbsPath []string, verbose bool) error {
absPath, err := filepath.Abs(absPath)
if err != nil {
return err
@ -186,25 +424,40 @@ func zipAddDirectoryExclude(zip *zip.ZipArchive, zipPath, absPath string, exclud
}
defer dir.Close()
zip.AddEmptyDir(zipPath)
files, err := dir.Readdir(0)
if err != nil {
return err
}
for _, file := range files {
currentAbsPath := path.Join(absPath, file.Name())
currentZipPath := path.Join(zipPath, file.Name())
currentInsidePath := path.Join(insidePath, file.Name())
if file.IsDir() {
if currentAbsPath != excludeAbsPath {
if err = zipAddDirectoryExclude(zip, currentZipPath, currentAbsPath, excludeAbsPath); err != nil {
if !util.SliceContainsString(excludeAbsPath, currentAbsPath) {
if err := addFile(w, currentInsidePath, currentAbsPath, false); err != nil {
return err
}
if err = addRecursiveExclude(w, currentInsidePath, currentAbsPath, excludeAbsPath, verbose); err != nil {
return err
}
}
} else {
if err = zip.AddFile(currentZipPath, currentAbsPath); err != nil {
return err
// only copy regular files and symlink regular files, skip non-regular files like socket/pipe/...
shouldAdd := file.Mode().IsRegular()
if !shouldAdd && file.Mode()&os.ModeSymlink == os.ModeSymlink {
target, err := filepath.EvalSymlinks(currentAbsPath)
if err != nil {
return err
}
targetStat, err := os.Stat(target)
if err != nil {
return err
}
shouldAdd = targetStat.Mode().IsRegular()
}
if shouldAdd {
if err = addFile(w, currentInsidePath, currentAbsPath, verbose); err != nil {
return err
}
}
}
}

191
cmd/dump_repo.go Normal file
View file

@ -0,0 +1,191 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"errors"
"fmt"
"os"
"strings"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
base "code.gitea.io/gitea/modules/migration"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/util"
"code.gitea.io/gitea/services/convert"
"code.gitea.io/gitea/services/migrations"
"github.com/urfave/cli"
)
// CmdDumpRepository represents the available dump repository sub-command.
var CmdDumpRepository = cli.Command{
Name: "dump-repo",
Usage: "Dump the repository from git/github/gitea/gitlab",
Description: "This is a command for dumping the repository data.",
Action: runDumpRepository,
Flags: []cli.Flag{
cli.StringFlag{
Name: "git_service",
Value: "",
Usage: "Git service, git, github, gitea, gitlab. If clone_addr could be recognized, this could be ignored.",
},
cli.StringFlag{
Name: "repo_dir, r",
Value: "./data",
Usage: "Repository dir path to store the data",
},
cli.StringFlag{
Name: "clone_addr",
Value: "",
Usage: "The URL will be clone, currently could be a git/github/gitea/gitlab http/https URL",
},
cli.StringFlag{
Name: "auth_username",
Value: "",
Usage: "The username to visit the clone_addr",
},
cli.StringFlag{
Name: "auth_password",
Value: "",
Usage: "The password to visit the clone_addr",
},
cli.StringFlag{
Name: "auth_token",
Value: "",
Usage: "The personal token to visit the clone_addr",
},
cli.StringFlag{
Name: "owner_name",
Value: "",
Usage: "The data will be stored on a directory with owner name if not empty",
},
cli.StringFlag{
Name: "repo_name",
Value: "",
Usage: "The data will be stored on a directory with repository name if not empty",
},
cli.StringFlag{
Name: "units",
Value: "",
Usage: `Which items will be migrated, one or more units should be separated as comma.
wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.`,
},
},
}
func runDumpRepository(ctx *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()
if err := initDB(stdCtx); err != nil {
return err
}
// migrations.GiteaLocalUploader depends on git module
if err := git.InitSimple(context.Background()); err != nil {
return err
}
log.Info("AppPath: %s", setting.AppPath)
log.Info("AppWorkPath: %s", setting.AppWorkPath)
log.Info("Custom path: %s", setting.CustomPath)
log.Info("Log path: %s", setting.Log.RootPath)
log.Info("Configuration file: %s", setting.CustomConf)
var (
serviceType structs.GitServiceType
cloneAddr = ctx.String("clone_addr")
serviceStr = ctx.String("git_service")
)
if strings.HasPrefix(strings.ToLower(cloneAddr), "https://github.com/") {
serviceStr = "github"
} else if strings.HasPrefix(strings.ToLower(cloneAddr), "https://gitlab.com/") {
serviceStr = "gitlab"
} else if strings.HasPrefix(strings.ToLower(cloneAddr), "https://gitea.com/") {
serviceStr = "gitea"
}
if serviceStr == "" {
return errors.New("git_service missed or clone_addr cannot be recognized")
}
serviceType = convert.ToGitServiceType(serviceStr)
opts := base.MigrateOptions{
GitServiceType: serviceType,
CloneAddr: cloneAddr,
AuthUsername: ctx.String("auth_username"),
AuthPassword: ctx.String("auth_password"),
AuthToken: ctx.String("auth_token"),
RepoName: ctx.String("repo_name"),
}
if len(ctx.String("units")) == 0 {
opts.Wiki = true
opts.Issues = true
opts.Milestones = true
opts.Labels = true
opts.Releases = true
opts.Comments = true
opts.PullRequests = true
opts.ReleaseAssets = true
} else {
units := strings.Split(ctx.String("units"), ",")
for _, unit := range units {
switch strings.ToLower(strings.TrimSpace(unit)) {
case "":
continue
case "wiki":
opts.Wiki = true
case "issues":
opts.Issues = true
case "milestones":
opts.Milestones = true
case "labels":
opts.Labels = true
case "releases":
opts.Releases = true
case "release_assets":
opts.ReleaseAssets = true
case "comments":
opts.Comments = true
case "pull_requests":
opts.PullRequests = true
default:
return errors.New("invalid unit: " + unit)
}
}
}
// the repo_dir will be removed if error occurs in DumpRepository
// make sure the directory doesn't exist or is empty, prevent from deleting user files
repoDir := ctx.String("repo_dir")
if exists, err := util.IsExist(repoDir); err != nil {
return fmt.Errorf("unable to stat repo_dir %q: %w", repoDir, err)
} else if exists {
if isDir, _ := util.IsDir(repoDir); !isDir {
return fmt.Errorf("repo_dir %q already exists but it's not a directory", repoDir)
}
if dir, _ := os.ReadDir(repoDir); len(dir) > 0 {
return fmt.Errorf("repo_dir %q is not empty", repoDir)
}
}
if err := migrations.DumpRepository(
context.Background(),
repoDir,
ctx.String("owner_name"),
opts,
); err != nil {
log.Fatal("Failed to dump repository: %v", err)
return err
}
log.Trace("Dump finished!!!")
return nil
}

334
cmd/embedded.go Normal file
View file

@ -0,0 +1,334 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build bindata
package cmd
import (
"errors"
"fmt"
"os"
"path/filepath"
"sort"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/options"
"code.gitea.io/gitea/modules/public"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/templates"
"code.gitea.io/gitea/modules/util"
"github.com/gobwas/glob"
"github.com/urfave/cli"
)
// Cmdembedded represents the available extract sub-command.
var (
Cmdembedded = cli.Command{
Name: "embedded",
Usage: "Extract embedded resources",
Description: "A command for extracting embedded resources, like templates and images",
Subcommands: []cli.Command{
subcmdList,
subcmdView,
subcmdExtract,
},
}
subcmdList = cli.Command{
Name: "list",
Usage: "List files matching the given pattern",
Action: runList,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "include-vendored,vendor",
Usage: "Include files under public/vendor as well",
},
},
}
subcmdView = cli.Command{
Name: "view",
Usage: "View a file matching the given pattern",
Action: runView,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "include-vendored,vendor",
Usage: "Include files under public/vendor as well",
},
},
}
subcmdExtract = cli.Command{
Name: "extract",
Usage: "Extract resources",
Action: runExtract,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "include-vendored,vendor",
Usage: "Include files under public/vendor as well",
},
cli.BoolFlag{
Name: "overwrite",
Usage: "Overwrite files if they already exist",
},
cli.BoolFlag{
Name: "rename",
Usage: "Rename files as {name}.bak if they already exist (overwrites previous .bak)",
},
cli.BoolFlag{
Name: "custom",
Usage: "Extract to the 'custom' directory as per app.ini",
},
cli.StringFlag{
Name: "destination,dest-dir",
Usage: "Extract to the specified directory",
},
},
}
sections map[string]*section
assets []asset
)
type section struct {
Path string
Names func() []string
IsDir func(string) (bool, error)
Asset func(string) ([]byte, error)
}
type asset struct {
Section *section
Name string
Path string
}
func initEmbeddedExtractor(c *cli.Context) error {
// Silence the console logger
log.DelNamedLogger("console")
log.DelNamedLogger(log.DEFAULT)
// Read configuration file
setting.InitProviderAllowEmpty()
setting.LoadCommonSettings()
pats, err := getPatterns(c.Args())
if err != nil {
return err
}
sections := make(map[string]*section, 3)
sections["public"] = &section{Path: "public", Names: public.AssetNames, IsDir: public.AssetIsDir, Asset: public.Asset}
sections["options"] = &section{Path: "options", Names: options.AssetNames, IsDir: options.AssetIsDir, Asset: options.Asset}
sections["templates"] = &section{Path: "templates", Names: templates.BuiltinAssetNames, IsDir: templates.BuiltinAssetIsDir, Asset: templates.BuiltinAsset}
for _, sec := range sections {
assets = append(assets, buildAssetList(sec, pats, c)...)
}
// Sort assets
sort.SliceStable(assets, func(i, j int) bool {
return assets[i].Path < assets[j].Path
})
return nil
}
func runList(c *cli.Context) error {
if err := runListDo(c); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return err
}
return nil
}
func runView(c *cli.Context) error {
if err := runViewDo(c); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return err
}
return nil
}
func runExtract(c *cli.Context) error {
if err := runExtractDo(c); err != nil {
fmt.Fprintf(os.Stderr, "%v\n", err)
return err
}
return nil
}
func runListDo(c *cli.Context) error {
if err := initEmbeddedExtractor(c); err != nil {
return err
}
for _, a := range assets {
fmt.Println(a.Path)
}
return nil
}
func runViewDo(c *cli.Context) error {
if err := initEmbeddedExtractor(c); err != nil {
return err
}
if len(assets) == 0 {
return fmt.Errorf("No files matched the given pattern")
} else if len(assets) > 1 {
return fmt.Errorf("Too many files matched the given pattern; try to be more specific")
}
data, err := assets[0].Section.Asset(assets[0].Name)
if err != nil {
return fmt.Errorf("%s: %w", assets[0].Path, err)
}
if _, err = os.Stdout.Write(data); err != nil {
return fmt.Errorf("%s: %w", assets[0].Path, err)
}
return nil
}
func runExtractDo(c *cli.Context) error {
if err := initEmbeddedExtractor(c); err != nil {
return err
}
if len(c.Args()) == 0 {
return fmt.Errorf("A list of pattern of files to extract is mandatory (e.g. '**' for all)")
}
destdir := "."
if c.IsSet("destination") {
destdir = c.String("destination")
} else if c.Bool("custom") {
destdir = setting.CustomPath
fmt.Println("Using app.ini at", setting.CustomConf)
}
fi, err := os.Stat(destdir)
if errors.Is(err, os.ErrNotExist) {
// In case Windows users attempt to provide a forward-slash path
wdestdir := filepath.FromSlash(destdir)
if wfi, werr := os.Stat(wdestdir); werr == nil {
destdir = wdestdir
fi = wfi
err = nil
}
}
if err != nil {
return fmt.Errorf("%s: %s", destdir, err)
} else if !fi.IsDir() {
return fmt.Errorf("%s is not a directory.", destdir)
}
fmt.Printf("Extracting to %s:\n", destdir)
overwrite := c.Bool("overwrite")
rename := c.Bool("rename")
for _, a := range assets {
if err := extractAsset(destdir, a, overwrite, rename); err != nil {
// Non-fatal error
fmt.Fprintf(os.Stderr, "%s: %v", a.Path, err)
}
}
return nil
}
func extractAsset(d string, a asset, overwrite, rename bool) error {
dest := filepath.Join(d, filepath.FromSlash(a.Path))
dir := filepath.Dir(dest)
data, err := a.Section.Asset(a.Name)
if err != nil {
return fmt.Errorf("%s: %w", a.Path, err)
}
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
return fmt.Errorf("%s: %w", dir, err)
}
perms := os.ModePerm & 0o666
fi, err := os.Lstat(dest)
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
return fmt.Errorf("%s: %w", dest, err)
}
} else if !overwrite && !rename {
fmt.Printf("%s already exists; skipped.\n", dest)
return nil
} else if !fi.Mode().IsRegular() {
return fmt.Errorf("%s already exists, but it's not a regular file", dest)
} else if rename {
if err := util.Rename(dest, dest+".bak"); err != nil {
return fmt.Errorf("Error creating backup for %s: %w", dest, err)
}
// Attempt to respect file permissions mask (even if user:group will be set anew)
perms = fi.Mode()
}
file, err := os.OpenFile(dest, os.O_WRONLY|os.O_TRUNC|os.O_CREATE, perms)
if err != nil {
return fmt.Errorf("%s: %w", dest, err)
}
defer file.Close()
if _, err = file.Write(data); err != nil {
return fmt.Errorf("%s: %w", dest, err)
}
fmt.Println(dest)
return nil
}
func buildAssetList(sec *section, globs []glob.Glob, c *cli.Context) []asset {
results := make([]asset, 0, 64)
for _, name := range sec.Names() {
if isdir, err := sec.IsDir(name); !isdir && err == nil {
if sec.Path == "public" &&
strings.HasPrefix(name, "vendor/") &&
!c.Bool("include-vendored") {
continue
}
matchName := sec.Path + "/" + name
for _, g := range globs {
if g.Match(matchName) {
results = append(results, asset{
Section: sec,
Name: name,
Path: sec.Path + "/" + name,
})
break
}
}
}
}
return results
}
func getPatterns(args []string) ([]glob.Glob, error) {
if len(args) == 0 {
args = []string{"**"}
}
pat := make([]glob.Glob, len(args))
for i := range args {
if g, err := glob.Compile(args[i], '/'); err != nil {
return nil, fmt.Errorf("'%s': Invalid glob pattern: %w", args[i], err)
} else {
pat[i] = g
}
}
return pat, nil
}

29
cmd/embedded_stub.go Normal file
View file

@ -0,0 +1,29 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
//go:build !bindata
package cmd
import (
"fmt"
"os"
"github.com/urfave/cli"
)
// Cmdembedded represents the available extract sub-command.
var (
Cmdembedded = cli.Command{
Name: "embedded",
Usage: "Extract embedded resources",
Description: "A command for extracting embedded resources, like templates and images",
Action: extractorNotImplemented,
}
)
func extractorNotImplemented(c *cli.Context) error {
err := fmt.Errorf("Sorry: the 'embedded' subcommand is not available in builds without bindata")
fmt.Fprintf(os.Stderr, "%s\n", err)
return err
}

View file

@ -1,15 +1,16 @@
// Copyright 2016 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"os"
"code.gitea.io/gitea/modules/generate"
"github.com/mattn/go-isatty"
"github.com/urfave/cli"
)
@ -59,17 +60,27 @@ func runGenerateInternalToken(c *cli.Context) error {
return err
}
fmt.Printf("%s\n", internalToken)
fmt.Printf("%s", internalToken)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Printf("\n")
}
return nil
}
func runGenerateLfsJwtSecret(c *cli.Context) error {
JWTSecretBase64, err := generate.NewJwtSecret()
JWTSecretBase64, err := generate.NewJwtSecretBase64()
if err != nil {
return err
}
fmt.Printf("%s\n", JWTSecretBase64)
fmt.Printf("%s", JWTSecretBase64)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Printf("\n")
}
return nil
}
@ -79,6 +90,11 @@ func runGenerateSecretKey(c *cli.Context) error {
return err
}
fmt.Printf("%s\n", secretKey)
fmt.Printf("%s", secretKey)
if isatty.IsTerminal(os.Stdout.Fd()) {
fmt.Printf("\n")
}
return nil
}

View file

@ -1,6 +1,5 @@
// Copyright 2017 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
@ -8,15 +7,18 @@ import (
"bufio"
"bytes"
"fmt"
"io"
"net/http"
"os"
"strconv"
"strings"
"time"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/private"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/util"
"github.com/urfave/cli"
)
@ -35,6 +37,7 @@ var (
subcmdHookPreReceive,
subcmdHookUpdate,
subcmdHookPostReceive,
subcmdHookProcReceive,
},
}
@ -43,53 +46,156 @@ var (
Usage: "Delegate pre-receive Git hook",
Description: "This command should only be called by Git",
Action: runHookPreReceive,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
subcmdHookUpdate = cli.Command{
Name: "update",
Usage: "Delegate update Git hook",
Description: "This command should only be called by Git",
Action: runHookUpdate,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
subcmdHookPostReceive = cli.Command{
Name: "post-receive",
Usage: "Delegate post-receive Git hook",
Description: "This command should only be called by Git",
Action: runHookPostReceive,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
// Note: new hook since git 2.29
subcmdHookProcReceive = cli.Command{
Name: "proc-receive",
Usage: "Delegate proc-receive Git hook",
Description: "This command should only be called by Git",
Action: runHookProcReceive,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
}
)
func runHookPreReceive(c *cli.Context) error {
if os.Getenv(models.EnvIsInternal) == "true" {
type delayWriter struct {
internal io.Writer
buf *bytes.Buffer
timer *time.Timer
}
func newDelayWriter(internal io.Writer, delay time.Duration) *delayWriter {
timer := time.NewTimer(delay)
return &delayWriter{
internal: internal,
buf: &bytes.Buffer{},
timer: timer,
}
}
func (d *delayWriter) Write(p []byte) (n int, err error) {
if d.buf != nil {
select {
case <-d.timer.C:
_, err := d.internal.Write(d.buf.Bytes())
if err != nil {
return 0, err
}
d.buf = nil
return d.internal.Write(p)
default:
return d.buf.Write(p)
}
}
return d.internal.Write(p)
}
func (d *delayWriter) WriteString(s string) (n int, err error) {
if d.buf != nil {
select {
case <-d.timer.C:
_, err := d.internal.Write(d.buf.Bytes())
if err != nil {
return 0, err
}
d.buf = nil
return d.internal.Write([]byte(s))
default:
return d.buf.WriteString(s)
}
}
return d.internal.Write([]byte(s))
}
func (d *delayWriter) Close() error {
if d == nil {
return nil
}
stopped := util.StopTimer(d.timer)
if stopped || d.buf == nil {
return nil
}
_, err := d.internal.Write(d.buf.Bytes())
d.buf = nil
return err
}
setup("hooks/pre-receive.log", false)
type nilWriter struct{}
func (n *nilWriter) Write(p []byte) (int, error) {
return len(p), nil
}
func (n *nilWriter) WriteString(s string) (int, error) {
return len(s), nil
}
func runHookPreReceive(c *cli.Context) error {
if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal {
return nil
}
ctx, cancel := installSignals()
defer cancel()
setup("hooks/pre-receive.log", c.Bool("debug"))
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
fail(`Rejecting changes as Gitea environment not set.
return fail(`Rejecting changes as Gitea environment not set.
If you are pushing over SSH you must push with a key managed by
Gitea or set your environment appropriately.`, "")
} else {
return nil
}
return nil
}
// the environment setted on serv command
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
username := os.Getenv(models.EnvRepoUsername)
reponame := os.Getenv(models.EnvRepoName)
userID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
prID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchPRID), 10, 64)
isDeployKey, _ := strconv.ParseBool(os.Getenv(models.EnvIsDeployKey))
// the environment is set by serv command
isWiki, _ := strconv.ParseBool(os.Getenv(repo_module.EnvRepoIsWiki))
username := os.Getenv(repo_module.EnvRepoUsername)
reponame := os.Getenv(repo_module.EnvRepoName)
userID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
prID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPRID), 10, 64)
deployKeyID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvDeployKeyID), 10, 64)
actionPerm, _ := strconv.ParseInt(os.Getenv(repo_module.EnvActionPerm), 10, 64)
hookOptions := private.HookOptions{
UserID: userID,
GitAlternativeObjectDirectories: os.Getenv(private.GitAlternativeObjectDirectories),
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
ProtectedBranchID: prID,
IsDeployKey: isDeployKey,
GitPushOptions: pushOptions(),
PullRequestID: prID,
DeployKeyID: deployKeyID,
ActionPerm: int(actionPerm),
}
scanner := bufio.NewScanner(os.Stdin)
@ -101,6 +207,23 @@ Gitea or set your environment appropriately.`, "")
total := 0
lastline := 0
var out io.Writer
out = &nilWriter{}
if setting.Git.VerbosePush {
if setting.Git.VerbosePushDelay > 0 {
dWriter := newDelayWriter(os.Stdout, setting.Git.VerbosePushDelay)
defer dWriter.Close()
out = dWriter
} else {
out = os.Stdout
}
}
supportProcReceive := false
if git.CheckGitVersionAtLeast("2.29") == nil {
supportProcReceive = true
}
for scanner.Scan() {
// TODO: support news feeds for wiki
if isWiki {
@ -118,41 +241,39 @@ Gitea or set your environment appropriately.`, "")
total++
lastline++
// If the ref is a branch, check if it's protected
if strings.HasPrefix(refFullName, git.BranchPrefix) {
// If the ref is a branch or tag, check if it's protected
// if supportProcReceive all ref should be checked because
// permission check was delayed
if supportProcReceive || strings.HasPrefix(refFullName, git.BranchPrefix) || strings.HasPrefix(refFullName, git.TagPrefix) {
oldCommitIDs[count] = oldCommitID
newCommitIDs[count] = newCommitID
refFullNames[count] = refFullName
count++
fmt.Fprintf(os.Stdout, "*")
os.Stdout.Sync()
fmt.Fprintf(out, "*")
if count >= hookBatchSize {
fmt.Fprintf(os.Stdout, " Checking %d branches\n", count)
os.Stdout.Sync()
fmt.Fprintf(out, " Checking %d references\n", count)
hookOptions.OldCommitIDs = oldCommitIDs
hookOptions.NewCommitIDs = newCommitIDs
hookOptions.RefFullNames = refFullNames
statusCode, msg := private.HookPreReceive(username, reponame, hookOptions)
statusCode, msg := private.HookPreReceive(ctx, username, reponame, hookOptions)
switch statusCode {
case http.StatusOK:
// no-op
case http.StatusInternalServerError:
fail("Internal Server Error", msg)
return fail("Internal Server Error", msg)
default:
fail(msg, "")
return fail(msg, "")
}
count = 0
lastline = 0
}
} else {
fmt.Fprintf(os.Stdout, ".")
os.Stdout.Sync()
fmt.Fprintf(out, ".")
}
if lastline >= hookBatchSize {
fmt.Fprintf(os.Stdout, "\n")
os.Stdout.Sync()
fmt.Fprintf(out, "\n")
lastline = 0
}
}
@ -162,25 +283,20 @@ Gitea or set your environment appropriately.`, "")
hookOptions.NewCommitIDs = newCommitIDs[:count]
hookOptions.RefFullNames = refFullNames[:count]
fmt.Fprintf(os.Stdout, " Checking %d branches\n", count)
os.Stdout.Sync()
fmt.Fprintf(out, " Checking %d references\n", count)
statusCode, msg := private.HookPreReceive(username, reponame, hookOptions)
statusCode, msg := private.HookPreReceive(ctx, username, reponame, hookOptions)
switch statusCode {
case http.StatusInternalServerError:
fail("Internal Server Error", msg)
return fail("Internal Server Error", msg)
case http.StatusForbidden:
fail(msg, "")
return fail(msg, "")
}
} else if lastline > 0 {
fmt.Fprintf(os.Stdout, "\n")
os.Stdout.Sync()
lastline = 0
fmt.Fprintf(out, "\n")
}
fmt.Fprintf(os.Stdout, "Checked %d references in total\n", total)
os.Stdout.Sync()
fmt.Fprintf(out, "Checked %d references in total\n", total)
return nil
}
@ -190,28 +306,49 @@ func runHookUpdate(c *cli.Context) error {
}
func runHookPostReceive(c *cli.Context) error {
if os.Getenv(models.EnvIsInternal) == "true" {
ctx, cancel := installSignals()
defer cancel()
setup("hooks/post-receive.log", c.Bool("debug"))
// First of all run update-server-info no matter what
if _, _, err := git.NewCommand(ctx, "update-server-info").RunStdString(nil); err != nil {
return fmt.Errorf("Failed to call 'git update-server-info': %w", err)
}
// Now if we're an internal don't do anything else
if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal {
return nil
}
setup("hooks/post-receive.log", false)
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
fail(`Rejecting changes as Gitea environment not set.
return fail(`Rejecting changes as Gitea environment not set.
If you are pushing over SSH you must push with a key managed by
Gitea or set your environment appropriately.`, "")
}
return nil
}
var out io.Writer
var dWriter *delayWriter
out = &nilWriter{}
if setting.Git.VerbosePush {
if setting.Git.VerbosePushDelay > 0 {
dWriter = newDelayWriter(os.Stdout, setting.Git.VerbosePushDelay)
defer dWriter.Close()
out = dWriter
} else {
return nil
out = os.Stdout
}
}
// the environment setted on serv command
repoUser := os.Getenv(models.EnvRepoUsername)
isWiki := (os.Getenv(models.EnvRepoIsWiki) == "true")
repoName := os.Getenv(models.EnvRepoName)
pusherID, _ := strconv.ParseInt(os.Getenv(models.EnvPusherID), 10, 64)
pusherName := os.Getenv(models.EnvPusherName)
// the environment is set by serv command
repoUser := os.Getenv(repo_module.EnvRepoUsername)
isWiki, _ := strconv.ParseBool(os.Getenv(repo_module.EnvRepoIsWiki))
repoName := os.Getenv(repo_module.EnvRepoName)
pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
pusherName := os.Getenv(repo_module.EnvPusherName)
hookOptions := private.HookOptions{
UserName: pusherName,
@ -219,6 +356,7 @@ Gitea or set your environment appropriately.`, "")
GitAlternativeObjectDirectories: os.Getenv(private.GitAlternativeObjectDirectories),
GitObjectDirectory: os.Getenv(private.GitObjectDirectory),
GitQuarantinePath: os.Getenv(private.GitQuarantinePath),
GitPushOptions: pushOptions(),
}
oldCommitIDs := make([]string, hookBatchSize)
newCommitIDs := make([]string, hookBatchSize)
@ -241,7 +379,7 @@ Gitea or set your environment appropriately.`, "")
continue
}
fmt.Fprintf(os.Stdout, ".")
fmt.Fprintf(out, ".")
oldCommitIDs[count] = string(fields[0])
newCommitIDs[count] = string(fields[1])
refFullNames[count] = string(fields[2])
@ -250,18 +388,17 @@ Gitea or set your environment appropriately.`, "")
}
count++
total++
os.Stdout.Sync()
if count >= hookBatchSize {
fmt.Fprintf(os.Stdout, " Processing %d references\n", count)
os.Stdout.Sync()
fmt.Fprintf(out, " Processing %d references\n", count)
hookOptions.OldCommitIDs = oldCommitIDs
hookOptions.NewCommitIDs = newCommitIDs
hookOptions.RefFullNames = refFullNames
resp, err := private.HookPostReceive(repoUser, repoName, hookOptions)
resp, err := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
if resp == nil {
_ = dWriter.Close()
hookPrintResults(results)
fail("Internal Server Error", err)
return fail("Internal Server Error", err)
}
wasEmpty = wasEmpty || resp.RepoWasEmpty
results = append(results, resp.Results...)
@ -272,14 +409,14 @@ Gitea or set your environment appropriately.`, "")
if count == 0 {
if wasEmpty && masterPushed {
// We need to tell the repo to reset the default branch to master
err := private.SetDefaultBranch(repoUser, repoName, "master")
err := private.SetDefaultBranch(ctx, repoUser, repoName, "master")
if err != nil {
fail("Internal Server Error", "SetDefaultBranch failed with Error: %v", err)
return fail("Internal Server Error", "SetDefaultBranch failed with Error: %v", err)
}
}
fmt.Fprintf(os.Stdout, "Processed %d references in total\n", total)
os.Stdout.Sync()
fmt.Fprintf(out, "Processed %d references in total\n", total)
_ = dWriter.Close()
hookPrintResults(results)
return nil
}
@ -288,28 +425,27 @@ Gitea or set your environment appropriately.`, "")
hookOptions.NewCommitIDs = newCommitIDs[:count]
hookOptions.RefFullNames = refFullNames[:count]
fmt.Fprintf(os.Stdout, " Processing %d references\n", count)
os.Stdout.Sync()
fmt.Fprintf(out, " Processing %d references\n", count)
resp, err := private.HookPostReceive(repoUser, repoName, hookOptions)
resp, err := private.HookPostReceive(ctx, repoUser, repoName, hookOptions)
if resp == nil {
_ = dWriter.Close()
hookPrintResults(results)
fail("Internal Server Error", err)
return fail("Internal Server Error", err)
}
wasEmpty = wasEmpty || resp.RepoWasEmpty
results = append(results, resp.Results...)
fmt.Fprintf(os.Stdout, "Processed %d references in total\n", total)
os.Stdout.Sync()
fmt.Fprintf(out, "Processed %d references in total\n", total)
if wasEmpty && masterPushed {
// We need to tell the repo to reset the default branch to master
err := private.SetDefaultBranch(repoUser, repoName, "master")
err := private.SetDefaultBranch(ctx, repoUser, repoName, "master")
if err != nil {
fail("Internal Server Error", "SetDefaultBranch failed with Error: %v", err)
return fail("Internal Server Error", "SetDefaultBranch failed with Error: %v", err)
}
}
_ = dWriter.Close()
hookPrintResults(results)
return nil
@ -333,3 +469,341 @@ func hookPrintResults(results []private.HookPostReceiveBranchResult) {
os.Stderr.Sync()
}
}
func pushOptions() map[string]string {
opts := make(map[string]string)
if pushCount, err := strconv.Atoi(os.Getenv(private.GitPushOptionCount)); err == nil {
for idx := 0; idx < pushCount; idx++ {
opt := os.Getenv(fmt.Sprintf("GIT_PUSH_OPTION_%d", idx))
kv := strings.SplitN(opt, "=", 2)
if len(kv) == 2 {
opts[kv[0]] = kv[1]
}
}
}
return opts
}
func runHookProcReceive(c *cli.Context) error {
setup("hooks/proc-receive.log", c.Bool("debug"))
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
return fail(`Rejecting changes as Gitea environment not set.
If you are pushing over SSH you must push with a key managed by
Gitea or set your environment appropriately.`, "")
}
return nil
}
ctx, cancel := installSignals()
defer cancel()
if git.CheckGitVersionAtLeast("2.29") != nil {
return fail("Internal Server Error", "git not support proc-receive.")
}
reader := bufio.NewReader(os.Stdin)
repoUser := os.Getenv(repo_module.EnvRepoUsername)
repoName := os.Getenv(repo_module.EnvRepoName)
pusherID, _ := strconv.ParseInt(os.Getenv(repo_module.EnvPusherID), 10, 64)
pusherName := os.Getenv(repo_module.EnvPusherName)
// 1. Version and features negotiation.
// S: PKT-LINE(version=1\0push-options atomic...) / PKT-LINE(version=1\n)
// S: flush-pkt
// H: PKT-LINE(version=1\0push-options...)
// H: flush-pkt
rs, err := readPktLine(reader, pktLineTypeData)
if err != nil {
return err
}
const VersionHead string = "version=1"
var (
hasPushOptions bool
response = []byte(VersionHead)
requestOptions []string
)
index := bytes.IndexByte(rs.Data, byte(0))
if index >= len(rs.Data) {
return fail("Internal Server Error", "pkt-line: format error "+fmt.Sprint(rs.Data))
}
if index < 0 {
if len(rs.Data) == 10 && rs.Data[9] == '\n' {
index = 9
} else {
return fail("Internal Server Error", "pkt-line: format error "+fmt.Sprint(rs.Data))
}
}
if string(rs.Data[0:index]) != VersionHead {
return fail("Internal Server Error", "Received unsupported version: %s", string(rs.Data[0:index]))
}
requestOptions = strings.Split(string(rs.Data[index+1:]), " ")
for _, option := range requestOptions {
if strings.HasPrefix(option, "push-options") {
response = append(response, byte(0))
response = append(response, []byte("push-options")...)
hasPushOptions = true
}
}
response = append(response, '\n')
_, err = readPktLine(reader, pktLineTypeFlush)
if err != nil {
return err
}
err = writeDataPktLine(os.Stdout, response)
if err != nil {
return err
}
err = writeFlushPktLine(os.Stdout)
if err != nil {
return err
}
// 2. receive commands from server.
// S: PKT-LINE(<old-oid> <new-oid> <ref>)
// S: ... ...
// S: flush-pkt
// # [receive push-options]
// S: PKT-LINE(push-option)
// S: ... ...
// S: flush-pkt
hookOptions := private.HookOptions{
UserName: pusherName,
UserID: pusherID,
}
hookOptions.OldCommitIDs = make([]string, 0, hookBatchSize)
hookOptions.NewCommitIDs = make([]string, 0, hookBatchSize)
hookOptions.RefFullNames = make([]string, 0, hookBatchSize)
for {
// note: pktLineTypeUnknow means pktLineTypeFlush and pktLineTypeData all allowed
rs, err = readPktLine(reader, pktLineTypeUnknow)
if err != nil {
return err
}
if rs.Type == pktLineTypeFlush {
break
}
t := strings.SplitN(string(rs.Data), " ", 3)
if len(t) != 3 {
continue
}
hookOptions.OldCommitIDs = append(hookOptions.OldCommitIDs, t[0])
hookOptions.NewCommitIDs = append(hookOptions.NewCommitIDs, t[1])
hookOptions.RefFullNames = append(hookOptions.RefFullNames, t[2])
}
hookOptions.GitPushOptions = make(map[string]string)
if hasPushOptions {
for {
rs, err = readPktLine(reader, pktLineTypeUnknow)
if err != nil {
return err
}
if rs.Type == pktLineTypeFlush {
break
}
kv := strings.SplitN(string(rs.Data), "=", 2)
if len(kv) == 2 {
hookOptions.GitPushOptions[kv[0]] = kv[1]
}
}
}
// 3. run hook
resp, err := private.HookProcReceive(ctx, repoUser, repoName, hookOptions)
if err != nil {
return fail("Internal Server Error", "run proc-receive hook failed :%v", err)
}
// 4. response result to service
// # a. OK, but has an alternate reference. The alternate reference name
// # and other status can be given in option directives.
// H: PKT-LINE(ok <ref>)
// H: PKT-LINE(option refname <refname>)
// H: PKT-LINE(option old-oid <old-oid>)
// H: PKT-LINE(option new-oid <new-oid>)
// H: PKT-LINE(option forced-update)
// H: ... ...
// H: flush-pkt
// # b. NO, I reject it.
// H: PKT-LINE(ng <ref> <reason>)
// # c. Fall through, let 'receive-pack' to execute it.
// H: PKT-LINE(ok <ref>)
// H: PKT-LINE(option fall-through)
for _, rs := range resp.Results {
if len(rs.Err) > 0 {
err = writeDataPktLine(os.Stdout, []byte("ng "+rs.OriginalRef+" "+rs.Err))
if err != nil {
return err
}
continue
}
if rs.IsNotMatched {
err = writeDataPktLine(os.Stdout, []byte("ok "+rs.OriginalRef))
if err != nil {
return err
}
err = writeDataPktLine(os.Stdout, []byte("option fall-through"))
if err != nil {
return err
}
continue
}
err = writeDataPktLine(os.Stdout, []byte("ok "+rs.OriginalRef))
if err != nil {
return err
}
err = writeDataPktLine(os.Stdout, []byte("option refname "+rs.Ref))
if err != nil {
return err
}
if rs.OldOID != git.EmptySHA {
err = writeDataPktLine(os.Stdout, []byte("option old-oid "+rs.OldOID))
if err != nil {
return err
}
}
err = writeDataPktLine(os.Stdout, []byte("option new-oid "+rs.NewOID))
if err != nil {
return err
}
if rs.IsForcePush {
err = writeDataPktLine(os.Stdout, []byte("option forced-update"))
if err != nil {
return err
}
}
}
err = writeFlushPktLine(os.Stdout)
return err
}
// git PKT-Line api
// pktLineType message type of pkt-line
type pktLineType int64
const (
// UnKnow type
pktLineTypeUnknow pktLineType = 0
// flush-pkt "0000"
pktLineTypeFlush pktLineType = iota
// data line
pktLineTypeData
)
// gitPktLine pkt-line api
type gitPktLine struct {
Type pktLineType
Length uint64
Data []byte
}
func readPktLine(in *bufio.Reader, requestType pktLineType) (*gitPktLine, error) {
var (
err error
r *gitPktLine
)
// read prefix
lengthBytes := make([]byte, 4)
for i := 0; i < 4; i++ {
lengthBytes[i], err = in.ReadByte()
if err != nil {
return nil, fail("Internal Server Error", "Pkt-Line: read stdin failed : %v", err)
}
}
r = new(gitPktLine)
r.Length, err = strconv.ParseUint(string(lengthBytes), 16, 32)
if err != nil {
return nil, fail("Internal Server Error", "Pkt-Line format is wrong :%v", err)
}
if r.Length == 0 {
if requestType == pktLineTypeData {
return nil, fail("Internal Server Error", "Pkt-Line format is wrong")
}
r.Type = pktLineTypeFlush
return r, nil
}
if r.Length <= 4 || r.Length > 65520 || requestType == pktLineTypeFlush {
return nil, fail("Internal Server Error", "Pkt-Line format is wrong")
}
r.Data = make([]byte, r.Length-4)
for i := range r.Data {
r.Data[i], err = in.ReadByte()
if err != nil {
return nil, fail("Internal Server Error", "Pkt-Line: read stdin failed : %v", err)
}
}
r.Type = pktLineTypeData
return r, nil
}
func writeFlushPktLine(out io.Writer) error {
l, err := out.Write([]byte("0000"))
if err != nil {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
if l != 4 {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
return nil
}
func writeDataPktLine(out io.Writer, data []byte) error {
hexchar := []byte("0123456789abcdef")
hex := func(n uint64) byte {
return hexchar[(n)&15]
}
length := uint64(len(data) + 4)
tmp := make([]byte, 4)
tmp[0] = hex(length >> 12)
tmp[1] = hex(length >> 8)
tmp[2] = hex(length >> 4)
tmp[3] = hex(length)
lr, err := out.Write(tmp)
if err != nil {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
if lr != 4 {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
lr, err = out.Write(data)
if err != nil {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
if int(length-4) != lr {
return fail("Internal Server Error", "Pkt-Line response failed: %v", err)
}
return nil
}

40
cmd/hook_test.go Normal file
View file

@ -0,0 +1,40 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"bufio"
"bytes"
"strings"
"testing"
"github.com/stretchr/testify/assert"
)
func TestPktLine(t *testing.T) {
// test read
s := strings.NewReader("0000")
r := bufio.NewReader(s)
result, err := readPktLine(r, pktLineTypeFlush)
assert.NoError(t, err)
assert.Equal(t, pktLineTypeFlush, result.Type)
s = strings.NewReader("0006a\n")
r = bufio.NewReader(s)
result, err = readPktLine(r, pktLineTypeData)
assert.NoError(t, err)
assert.Equal(t, pktLineTypeData, result.Type)
assert.Equal(t, []byte("a\n"), result.Data)
// test write
w := bytes.NewBuffer([]byte{})
err = writeFlushPktLine(w)
assert.NoError(t, err)
assert.Equal(t, []byte("0000"), w.Bytes())
w.Reset()
err = writeDataPktLine(w, []byte("a\nb"))
assert.NoError(t, err)
assert.Equal(t, []byte("0007a\nb"), w.Bytes())
}

View file

@ -1,6 +1,5 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
@ -62,9 +61,12 @@ func runKeys(c *cli.Context) error {
return errors.New("No key type and content provided")
}
ctx, cancel := installSignals()
defer cancel()
setup("keys.log", false)
authorizedString, err := private.AuthorizedPublicKeyByContent(content)
authorizedString, err := private.AuthorizedPublicKeyByContent(ctx, content)
if err != nil {
return err
}

55
cmd/mailer.go Normal file
View file

@ -0,0 +1,55 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"net/http"
"code.gitea.io/gitea/modules/private"
"code.gitea.io/gitea/modules/setting"
"github.com/urfave/cli"
)
func runSendMail(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
if err := argsSet(c, "title"); err != nil {
return err
}
subject := c.String("title")
confirmSkiped := c.Bool("force")
body := c.String("content")
if !confirmSkiped {
if len(body) == 0 {
fmt.Print("warning: Content is empty")
}
fmt.Print("Proceed with sending email? [Y/n] ")
isConfirmed, err := confirm()
if err != nil {
return err
} else if !isConfirmed {
fmt.Println("The mail was not sent")
return nil
}
}
status, message := private.SendEmail(ctx, subject, body, nil)
if status != http.StatusOK {
fmt.Printf("error: %s\n", message)
return nil
}
fmt.Printf("Success: %s\n", message)
return nil
}

22
cmd/main_test.go Normal file
View file

@ -0,0 +1,22 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"testing"
"code.gitea.io/gitea/models/unittest"
"code.gitea.io/gitea/modules/setting"
)
func init() {
setting.SetCustomPathAndConf("", "", "")
setting.InitProviderAndLoadCommonSettingsForTest()
}
func TestMain(m *testing.M) {
unittest.MainTest(m, &unittest.TestOptions{
GiteaRootPath: "..",
})
}

159
cmd/manager.go Normal file
View file

@ -0,0 +1,159 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"net/http"
"os"
"time"
"code.gitea.io/gitea/modules/private"
"github.com/urfave/cli"
)
var (
// CmdManager represents the manager command
CmdManager = cli.Command{
Name: "manager",
Usage: "Manage the running gitea process",
Description: "This is a command for managing the running gitea process",
Subcommands: []cli.Command{
subcmdShutdown,
subcmdRestart,
subcmdFlushQueues,
subcmdLogging,
subCmdProcesses,
},
}
subcmdShutdown = cli.Command{
Name: "shutdown",
Usage: "Gracefully shutdown the running process",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
Action: runShutdown,
}
subcmdRestart = cli.Command{
Name: "restart",
Usage: "Gracefully restart the running process - (not implemented for windows servers)",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
Action: runRestart,
}
subcmdFlushQueues = cli.Command{
Name: "flush-queues",
Usage: "Flush queues in the running process",
Action: runFlushQueues,
Flags: []cli.Flag{
cli.DurationFlag{
Name: "timeout",
Value: 60 * time.Second,
Usage: "Timeout for the flushing process",
},
cli.BoolFlag{
Name: "non-blocking",
Usage: "Set to true to not wait for flush to complete before returning",
},
cli.BoolFlag{
Name: "debug",
},
},
}
subCmdProcesses = cli.Command{
Name: "processes",
Usage: "Display running processes within the current process",
Action: runProcesses,
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
cli.BoolFlag{
Name: "flat",
Usage: "Show processes as flat table rather than as tree",
},
cli.BoolFlag{
Name: "no-system",
Usage: "Do not show system processes",
},
cli.BoolFlag{
Name: "stacktraces",
Usage: "Show stacktraces",
},
cli.BoolFlag{
Name: "json",
Usage: "Output as json",
},
cli.StringFlag{
Name: "cancel",
Usage: "Process PID to cancel. (Only available for non-system processes.)",
},
},
}
)
func runShutdown(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.Shutdown(ctx)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runRestart(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.Restart(ctx)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runFlushQueues(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.FlushQueues(ctx, c.Duration("timeout"), c.Bool("non-blocking"))
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runProcesses(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.Processes(ctx, os.Stdout, c.Bool("flat"), c.Bool("no-system"), c.Bool("stacktraces"), c.Bool("json"), c.String("cancel"))
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
return nil
}

409
cmd/manager_logging.go Normal file
View file

@ -0,0 +1,409 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"net/http"
"os"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/private"
"github.com/urfave/cli"
)
var (
defaultLoggingFlags = []cli.Flag{
cli.StringFlag{
Name: "group, g",
Usage: "Group to add logger to - will default to \"default\"",
}, cli.StringFlag{
Name: "name, n",
Usage: "Name of the new logger - will default to mode",
}, cli.StringFlag{
Name: "level, l",
Usage: "Logging level for the new logger",
}, cli.StringFlag{
Name: "stacktrace-level, L",
Usage: "Stacktrace logging level",
}, cli.StringFlag{
Name: "flags, F",
Usage: "Flags for the logger",
}, cli.StringFlag{
Name: "expression, e",
Usage: "Matching expression for the logger",
}, cli.StringFlag{
Name: "prefix, p",
Usage: "Prefix for the logger",
}, cli.BoolFlag{
Name: "color",
Usage: "Use color in the logs",
}, cli.BoolFlag{
Name: "debug",
},
}
subcmdLogging = cli.Command{
Name: "logging",
Usage: "Adjust logging commands",
Subcommands: []cli.Command{
{
Name: "pause",
Usage: "Pause logging (Gitea will buffer logs up to a certain point and will drop them after that point)",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
Action: runPauseLogging,
}, {
Name: "resume",
Usage: "Resume logging",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
Action: runResumeLogging,
}, {
Name: "release-and-reopen",
Usage: "Cause Gitea to release and re-open files used for logging",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
},
},
Action: runReleaseReopenLogging,
}, {
Name: "remove",
Usage: "Remove a logger",
ArgsUsage: "[name] Name of logger to remove",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
}, cli.StringFlag{
Name: "group, g",
Usage: "Group to add logger to - will default to \"default\"",
},
},
Action: runRemoveLogger,
}, {
Name: "add",
Usage: "Add a logger",
Subcommands: []cli.Command{
{
Name: "console",
Usage: "Add a console logger",
Flags: append(defaultLoggingFlags,
cli.BoolFlag{
Name: "stderr",
Usage: "Output console logs to stderr - only relevant for console",
}),
Action: runAddConsoleLogger,
}, {
Name: "file",
Usage: "Add a file logger",
Flags: append(defaultLoggingFlags, []cli.Flag{
cli.StringFlag{
Name: "filename, f",
Usage: "Filename for the logger - this must be set.",
}, cli.BoolTFlag{
Name: "rotate, r",
Usage: "Rotate logs",
}, cli.Int64Flag{
Name: "max-size, s",
Usage: "Maximum size in bytes before rotation",
}, cli.BoolTFlag{
Name: "daily, d",
Usage: "Rotate logs daily",
}, cli.IntFlag{
Name: "max-days, D",
Usage: "Maximum number of daily logs to keep",
}, cli.BoolTFlag{
Name: "compress, z",
Usage: "Compress rotated logs",
}, cli.IntFlag{
Name: "compression-level, Z",
Usage: "Compression level to use",
},
}...),
Action: runAddFileLogger,
}, {
Name: "conn",
Usage: "Add a net conn logger",
Flags: append(defaultLoggingFlags, []cli.Flag{
cli.BoolFlag{
Name: "reconnect-on-message, R",
Usage: "Reconnect to host for every message",
}, cli.BoolFlag{
Name: "reconnect, r",
Usage: "Reconnect to host when connection is dropped",
}, cli.StringFlag{
Name: "protocol, P",
Usage: "Set protocol to use: tcp, unix, or udp (defaults to tcp)",
}, cli.StringFlag{
Name: "address, a",
Usage: "Host address and port to connect to (defaults to :7020)",
},
}...),
Action: runAddConnLogger,
}, {
Name: "smtp",
Usage: "Add an SMTP logger",
Flags: append(defaultLoggingFlags, []cli.Flag{
cli.StringFlag{
Name: "username, u",
Usage: "Mail server username",
}, cli.StringFlag{
Name: "password, P",
Usage: "Mail server password",
}, cli.StringFlag{
Name: "host, H",
Usage: "Mail server host (defaults to: 127.0.0.1:25)",
}, cli.StringSliceFlag{
Name: "send-to, s",
Usage: "Email address(es) to send to",
}, cli.StringFlag{
Name: "subject, S",
Usage: "Subject header of sent emails",
},
}...),
Action: runAddSMTPLogger,
},
},
}, {
Name: "log-sql",
Usage: "Set LogSQL",
Flags: []cli.Flag{
cli.BoolFlag{
Name: "debug",
}, cli.BoolFlag{
Name: "off",
Usage: "Switch off SQL logging",
},
},
Action: runSetLogSQL,
},
},
}
)
func runRemoveLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
group := c.String("group")
if len(group) == 0 {
group = log.DEFAULT
}
name := c.Args().First()
ctx, cancel := installSignals()
defer cancel()
statusCode, msg := private.RemoveLogger(ctx, group, name)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runAddSMTPLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
vals := map[string]interface{}{}
mode := "smtp"
if c.IsSet("host") {
vals["host"] = c.String("host")
} else {
vals["host"] = "127.0.0.1:25"
}
if c.IsSet("username") {
vals["username"] = c.String("username")
}
if c.IsSet("password") {
vals["password"] = c.String("password")
}
if !c.IsSet("send-to") {
return fmt.Errorf("Some recipients must be provided")
}
vals["sendTos"] = c.StringSlice("send-to")
if c.IsSet("subject") {
vals["subject"] = c.String("subject")
} else {
vals["subject"] = "Diagnostic message from Gitea"
}
return commonAddLogger(c, mode, vals)
}
func runAddConnLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
vals := map[string]interface{}{}
mode := "conn"
vals["net"] = "tcp"
if c.IsSet("protocol") {
switch c.String("protocol") {
case "udp":
vals["net"] = "udp"
case "unix":
vals["net"] = "unix"
}
}
if c.IsSet("address") {
vals["address"] = c.String("address")
} else {
vals["address"] = ":7020"
}
if c.IsSet("reconnect") {
vals["reconnect"] = c.Bool("reconnect")
}
if c.IsSet("reconnect-on-message") {
vals["reconnectOnMsg"] = c.Bool("reconnect-on-message")
}
return commonAddLogger(c, mode, vals)
}
func runAddFileLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
vals := map[string]interface{}{}
mode := "file"
if c.IsSet("filename") {
vals["filename"] = c.String("filename")
} else {
return fmt.Errorf("filename must be set when creating a file logger")
}
if c.IsSet("rotate") {
vals["rotate"] = c.Bool("rotate")
}
if c.IsSet("max-size") {
vals["maxsize"] = c.Int64("max-size")
}
if c.IsSet("daily") {
vals["daily"] = c.Bool("daily")
}
if c.IsSet("max-days") {
vals["maxdays"] = c.Int("max-days")
}
if c.IsSet("compress") {
vals["compress"] = c.Bool("compress")
}
if c.IsSet("compression-level") {
vals["compressionLevel"] = c.Int("compression-level")
}
return commonAddLogger(c, mode, vals)
}
func runAddConsoleLogger(c *cli.Context) error {
setup("manager", c.Bool("debug"))
vals := map[string]interface{}{}
mode := "console"
if c.IsSet("stderr") && c.Bool("stderr") {
vals["stderr"] = c.Bool("stderr")
}
return commonAddLogger(c, mode, vals)
}
func commonAddLogger(c *cli.Context, mode string, vals map[string]interface{}) error {
if len(c.String("level")) > 0 {
vals["level"] = log.FromString(c.String("level")).String()
}
if len(c.String("stacktrace-level")) > 0 {
vals["stacktraceLevel"] = log.FromString(c.String("stacktrace-level")).String()
}
if len(c.String("expression")) > 0 {
vals["expression"] = c.String("expression")
}
if len(c.String("prefix")) > 0 {
vals["prefix"] = c.String("prefix")
}
if len(c.String("flags")) > 0 {
vals["flags"] = log.FlagsFromString(c.String("flags"))
}
if c.IsSet("color") {
vals["colorize"] = c.Bool("color")
}
group := "default"
if c.IsSet("group") {
group = c.String("group")
}
name := mode
if c.IsSet("name") {
name = c.String("name")
}
ctx, cancel := installSignals()
defer cancel()
statusCode, msg := private.AddLogger(ctx, group, name, mode, vals)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runPauseLogging(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.PauseLogging(ctx)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runResumeLogging(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.ResumeLogging(ctx)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runReleaseReopenLogging(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.ReleaseReopenLogging(ctx)
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}
func runSetLogSQL(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setup("manager", c.Bool("debug"))
statusCode, msg := private.SetLogSQL(ctx, !c.Bool("off"))
switch statusCode {
case http.StatusInternalServerError:
return fail("InternalServerError", msg)
}
fmt.Fprintln(os.Stdout, msg)
return nil
}

View file

@ -1,13 +1,12 @@
// Copyright 2018 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"code.gitea.io/gitea/models"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/migrations"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
@ -24,17 +23,20 @@ var CmdMigrate = cli.Command{
}
func runMigrate(ctx *cli.Context) error {
if err := initDB(); err != nil {
stdCtx, cancel := installSignals()
defer cancel()
if err := initDB(stdCtx); err != nil {
return err
}
log.Trace("AppPath: %s", setting.AppPath)
log.Trace("AppWorkPath: %s", setting.AppWorkPath)
log.Trace("Custom path: %s", setting.CustomPath)
log.Trace("Log path: %s", setting.LogRootPath)
setting.InitDBConfig()
log.Info("AppPath: %s", setting.AppPath)
log.Info("AppWorkPath: %s", setting.AppWorkPath)
log.Info("Custom path: %s", setting.CustomPath)
log.Info("Log path: %s", setting.Log.RootPath)
log.Info("Configuration file: %s", setting.CustomConf)
if err := models.NewEngine(context.Background(), migrations.Migrate); err != nil {
if err := db.InitEngineWithMigration(context.Background(), migrations.Migrate); err != nil {
log.Fatal("Failed to initialize ORM engine: %v", err)
return err
}

205
cmd/migrate_storage.go Normal file
View file

@ -0,0 +1,205 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"fmt"
"strings"
"code.gitea.io/gitea/models/db"
git_model "code.gitea.io/gitea/models/git"
"code.gitea.io/gitea/models/migrations"
packages_model "code.gitea.io/gitea/models/packages"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
"code.gitea.io/gitea/modules/log"
packages_module "code.gitea.io/gitea/modules/packages"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/storage"
"github.com/urfave/cli"
)
// CmdMigrateStorage represents the available migrate storage sub-command.
var CmdMigrateStorage = cli.Command{
Name: "migrate-storage",
Usage: "Migrate the storage",
Description: "Copies stored files from storage configured in app.ini to parameter-configured storage",
Action: runMigrateStorage,
Flags: []cli.Flag{
cli.StringFlag{
Name: "type, t",
Value: "",
Usage: "Type of stored files to copy. Allowed types: 'attachments', 'lfs', 'avatars', 'repo-avatars', 'repo-archivers', 'packages'",
},
cli.StringFlag{
Name: "storage, s",
Value: "",
Usage: "New storage type: local (default) or minio",
},
cli.StringFlag{
Name: "path, p",
Value: "",
Usage: "New storage placement if store is local (leave blank for default)",
},
cli.StringFlag{
Name: "minio-endpoint",
Value: "",
Usage: "Minio storage endpoint",
},
cli.StringFlag{
Name: "minio-access-key-id",
Value: "",
Usage: "Minio storage accessKeyID",
},
cli.StringFlag{
Name: "minio-secret-access-key",
Value: "",
Usage: "Minio storage secretAccessKey",
},
cli.StringFlag{
Name: "minio-bucket",
Value: "",
Usage: "Minio storage bucket",
},
cli.StringFlag{
Name: "minio-location",
Value: "",
Usage: "Minio storage location to create bucket",
},
cli.StringFlag{
Name: "minio-base-path",
Value: "",
Usage: "Minio storage basepath on the bucket",
},
cli.BoolFlag{
Name: "minio-use-ssl",
Usage: "Enable SSL for minio",
},
},
}
func migrateAttachments(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, attach *repo_model.Attachment) error {
_, err := storage.Copy(dstStorage, attach.RelativePath(), storage.Attachments, attach.RelativePath())
return err
})
}
func migrateLFS(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, mo *git_model.LFSMetaObject) error {
_, err := storage.Copy(dstStorage, mo.RelativePath(), storage.LFS, mo.RelativePath())
return err
})
}
func migrateAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, user *user_model.User) error {
_, err := storage.Copy(dstStorage, user.CustomAvatarRelativePath(), storage.Avatars, user.CustomAvatarRelativePath())
return err
})
}
func migrateRepoAvatars(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, repo *repo_model.Repository) error {
_, err := storage.Copy(dstStorage, repo.CustomAvatarRelativePath(), storage.RepoAvatars, repo.CustomAvatarRelativePath())
return err
})
}
func migrateRepoArchivers(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, archiver *repo_model.RepoArchiver) error {
p := archiver.RelativePath()
_, err := storage.Copy(dstStorage, p, storage.RepoArchives, p)
return err
})
}
func migratePackages(ctx context.Context, dstStorage storage.ObjectStorage) error {
return db.Iterate(ctx, nil, func(ctx context.Context, pb *packages_model.PackageBlob) error {
p := packages_module.KeyToRelativePath(packages_module.BlobHash256Key(pb.HashSHA256))
_, err := storage.Copy(dstStorage, p, storage.Packages, p)
return err
})
}
func runMigrateStorage(ctx *cli.Context) error {
stdCtx, cancel := installSignals()
defer cancel()
if err := initDB(stdCtx); err != nil {
return err
}
log.Info("AppPath: %s", setting.AppPath)
log.Info("AppWorkPath: %s", setting.AppWorkPath)
log.Info("Custom path: %s", setting.CustomPath)
log.Info("Log path: %s", setting.Log.RootPath)
log.Info("Configuration file: %s", setting.CustomConf)
if err := db.InitEngineWithMigration(context.Background(), migrations.Migrate); err != nil {
log.Fatal("Failed to initialize ORM engine: %v", err)
return err
}
if err := storage.Init(); err != nil {
return err
}
var dstStorage storage.ObjectStorage
var err error
switch strings.ToLower(ctx.String("storage")) {
case "":
fallthrough
case string(storage.LocalStorageType):
p := ctx.String("path")
if p == "" {
log.Fatal("Path must be given when storage is loal")
return nil
}
dstStorage, err = storage.NewLocalStorage(
stdCtx,
storage.LocalStorageConfig{
Path: p,
})
case string(storage.MinioStorageType):
dstStorage, err = storage.NewMinioStorage(
stdCtx,
storage.MinioStorageConfig{
Endpoint: ctx.String("minio-endpoint"),
AccessKeyID: ctx.String("minio-access-key-id"),
SecretAccessKey: ctx.String("minio-secret-access-key"),
Bucket: ctx.String("minio-bucket"),
Location: ctx.String("minio-location"),
BasePath: ctx.String("minio-base-path"),
UseSSL: ctx.Bool("minio-use-ssl"),
})
default:
return fmt.Errorf("unsupported storage type: %s", ctx.String("storage"))
}
if err != nil {
return err
}
migratedMethods := map[string]func(context.Context, storage.ObjectStorage) error{
"attachments": migrateAttachments,
"lfs": migrateLFS,
"avatars": migrateAvatars,
"repo-avatars": migrateRepoAvatars,
"repo-archivers": migrateRepoArchivers,
"packages": migratePackages,
}
tp := strings.ToLower(ctx.String("type"))
if m, ok := migratedMethods[tp]; ok {
if err := m(stdCtx, dstStorage); err != nil {
return err
}
log.Info("%s files have successfully been copied to the new storage.", tp)
return nil
}
return fmt.Errorf("unsupported storage: %s", ctx.String("type"))
}

View file

@ -0,0 +1,73 @@
// Copyright 2022 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"os"
"strings"
"testing"
"code.gitea.io/gitea/models/packages"
"code.gitea.io/gitea/models/unittest"
user_model "code.gitea.io/gitea/models/user"
packages_module "code.gitea.io/gitea/modules/packages"
"code.gitea.io/gitea/modules/storage"
packages_service "code.gitea.io/gitea/services/packages"
"github.com/stretchr/testify/assert"
)
func TestMigratePackages(t *testing.T) {
assert.NoError(t, unittest.PrepareTestDatabase())
creator := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
content := "package main\n\nfunc main() {\nfmt.Println(\"hi\")\n}\n"
buf, err := packages_module.CreateHashedBufferFromReader(strings.NewReader(content), 1024)
assert.NoError(t, err)
defer buf.Close()
v, f, err := packages_service.CreatePackageAndAddFile(&packages_service.PackageCreationInfo{
PackageInfo: packages_service.PackageInfo{
Owner: creator,
PackageType: packages.TypeGeneric,
Name: "test",
Version: "1.0.0",
},
Creator: creator,
SemverCompatible: true,
VersionProperties: map[string]string{},
}, &packages_service.PackageFileCreationInfo{
PackageFileInfo: packages_service.PackageFileInfo{
Filename: "a.go",
},
Creator: creator,
Data: buf,
IsLead: true,
})
assert.NoError(t, err)
assert.NotNil(t, v)
assert.NotNil(t, f)
ctx := context.Background()
p := t.TempDir()
dstStorage, err := storage.NewLocalStorage(
ctx,
storage.LocalStorageConfig{
Path: p,
})
assert.NoError(t, err)
err = migratePackages(ctx, dstStorage)
assert.NoError(t, err)
entries, err := os.ReadDir(p)
assert.NoError(t, err)
assert.EqualValues(t, 2, len(entries))
assert.EqualValues(t, "01", entries[0].Name())
assert.EqualValues(t, "tmp", entries[1].Name())
}

77
cmd/restore_repo.go Normal file
View file

@ -0,0 +1,77 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"errors"
"net/http"
"strings"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/private"
"code.gitea.io/gitea/modules/setting"
"github.com/urfave/cli"
)
// CmdRestoreRepository represents the available restore a repository sub-command.
var CmdRestoreRepository = cli.Command{
Name: "restore-repo",
Usage: "Restore the repository from disk",
Description: "This is a command for restoring the repository data.",
Action: runRestoreRepository,
Flags: []cli.Flag{
cli.StringFlag{
Name: "repo_dir, r",
Value: "./data",
Usage: "Repository dir path to restore from",
},
cli.StringFlag{
Name: "owner_name",
Value: "",
Usage: "Restore destination owner name",
},
cli.StringFlag{
Name: "repo_name",
Value: "",
Usage: "Restore destination repository name",
},
cli.StringFlag{
Name: "units",
Value: "",
Usage: `Which items will be restored, one or more units should be separated as comma.
wiki, issues, labels, releases, release_assets, milestones, pull_requests, comments are allowed. Empty means all units.`,
},
cli.BoolFlag{
Name: "validation",
Usage: "Sanity check the content of the files before trying to load them",
},
},
}
func runRestoreRepository(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
var units []string
if s := c.String("units"); s != "" {
units = strings.Split(s, ",")
}
statusCode, errStr := private.RestoreRepo(
ctx,
c.String("repo_dir"),
c.String("owner_name"),
c.String("repo_name"),
units,
c.Bool("validation"),
)
if statusCode == http.StatusOK {
return nil
}
log.Fatal("Failed to restore repository: %v", errStr)
return errors.New(errStr)
}

View file

@ -1,29 +1,37 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"encoding/json"
"context"
"fmt"
"net/http"
"net/url"
"os"
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"
"code.gitea.io/gitea/models"
asymkey_model "code.gitea.io/gitea/models/asymkey"
git_model "code.gitea.io/gitea/models/git"
"code.gitea.io/gitea/models/perm"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/json"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/pprof"
"code.gitea.io/gitea/modules/private"
"code.gitea.io/gitea/modules/process"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/services/lfs"
"github.com/dgrijalva/jwt-go"
"github.com/unknwon/com"
"github.com/golang-jwt/jwt/v4"
"github.com/kballard/go-shellquote"
"github.com/urfave/cli"
)
@ -35,7 +43,7 @@ const (
var CmdServ = cli.Command{
Name: "serv",
Usage: "This command should only be called by SSH shell",
Description: `Serv provide access auth for repositories`,
Description: "Serv provides access auth for repositories",
Action: runServ,
Flags: []cli.Flag{
cli.BoolFlag{
@ -48,45 +56,68 @@ var CmdServ = cli.Command{
}
func setup(logPath string, debug bool) {
if !debug {
_ = log.DelLogger("console")
}
setting.NewContext()
_ = log.DelLogger("console")
if debug {
setting.ProdMode = false
_ = log.NewLogger(1000, "console", "console", `{"level":"trace","stacktracelevel":"NONE","stderr":true}`)
} else {
_ = log.NewLogger(1000, "console", "console", `{"level":"fatal","stacktracelevel":"NONE","stderr":true}`)
}
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
if debug {
setting.RunMode = "dev"
}
}
func parseCmd(cmd string) (string, string) {
ss := strings.SplitN(cmd, " ", 2)
if len(ss) != 2 {
return "", ""
// Check if setting.RepoRootPath exists. It could be the case that it doesn't exist, this can happen when
// `[repository]` `ROOT` is a relative path and $GITEA_WORK_DIR isn't passed to the SSH connection.
if _, err := os.Stat(setting.RepoRootPath); err != nil {
if os.IsNotExist(err) {
_ = fail("Incorrect configuration, no repository directory.", "Directory `[repository].ROOT` %q was not found, please check if $GITEA_WORK_DIR is passed to the SSH connection or make `[repository].ROOT` an absolute value.", setting.RepoRootPath)
} else {
_ = fail("Incorrect configuration, repository directory is inaccessible", "Directory `[repository].ROOT` %q is inaccessible. err: %v", setting.RepoRootPath, err)
}
return
}
if err := git.InitSimple(context.Background()); err != nil {
_ = fail("Failed to init git", "Failed to init git, err: %v", err)
}
return ss[0], strings.Replace(ss[1], "'/", "'", 1)
}
var (
allowedCommands = map[string]models.AccessMode{
"git-upload-pack": models.AccessModeRead,
"git-upload-archive": models.AccessModeRead,
"git-receive-pack": models.AccessModeWrite,
lfsAuthenticateVerb: models.AccessModeNone,
allowedCommands = map[string]perm.AccessMode{
"git-upload-pack": perm.AccessModeRead,
"git-upload-archive": perm.AccessModeRead,
"git-receive-pack": perm.AccessModeWrite,
lfsAuthenticateVerb: perm.AccessModeNone,
}
alphaDashDotPattern = regexp.MustCompile(`[^\w-\.]`)
)
func fail(userMessage, logMessage string, args ...interface{}) {
fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
func fail(userMessage, logMessage string, args ...interface{}) error {
// There appears to be a chance to cause a zombie process and failure to read the Exit status
// if nothing is outputted on stdout.
_, _ = fmt.Fprintln(os.Stdout, "")
_, _ = fmt.Fprintln(os.Stderr, "Gitea:", userMessage)
if len(logMessage) > 0 {
if !setting.ProdMode {
fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
if !setting.IsProd {
_, _ = fmt.Fprintf(os.Stderr, logMessage+"\n", args...)
}
}
ctx, cancel := installSignals()
defer cancel()
os.Exit(1)
if len(logMessage) > 0 {
_ = private.SSHLog(ctx, true, fmt.Sprintf(logMessage+": ", args...))
}
return cli.NewExitError("", 1)
}
func runServ(c *cli.Context) error {
ctx, cancel := installSignals()
defer cancel()
// FIXME: This needs to internationalised
setup("serv.log", c.Bool("debug"))
@ -104,125 +135,149 @@ func runServ(c *cli.Context) error {
keys := strings.Split(c.Args()[0], "-")
if len(keys) != 2 || keys[0] != "key" {
fail("Key ID format error", "Invalid key argument: %s", c.Args()[0])
return fail("Key ID format error", "Invalid key argument: %s", c.Args()[0])
}
keyID, err := strconv.ParseInt(keys[1], 10, 64)
if err != nil {
return fail("Key ID format error", "Invalid key argument: %s", c.Args()[1])
}
keyID := com.StrTo(keys[1]).MustInt64()
cmd := os.Getenv("SSH_ORIGINAL_COMMAND")
if len(cmd) == 0 {
key, user, err := private.ServNoCommand(keyID)
key, user, err := private.ServNoCommand(ctx, keyID)
if err != nil {
fail("Internal error", "Failed to check provided key: %v", err)
return fail("Internal error", "Failed to check provided key: %v", err)
}
if key.Type == models.KeyTypeDeploy {
switch key.Type {
case asymkey_model.KeyTypeDeploy:
println("Hi there! You've successfully authenticated with the deploy key named " + key.Name + ", but Gitea does not provide shell access.")
} else {
case asymkey_model.KeyTypePrincipal:
println("Hi there! You've successfully authenticated with the principal " + key.Content + ", but Gitea does not provide shell access.")
default:
println("Hi there, " + user.Name + "! You've successfully authenticated with the key named " + key.Name + ", but Gitea does not provide shell access.")
}
println("If this is unexpected, please log in with password and setup Gitea under another user.")
return nil
} else if c.Bool("debug") {
log.Debug("SSH_ORIGINAL_COMMAND: %s", os.Getenv("SSH_ORIGINAL_COMMAND"))
}
verb, args := parseCmd(cmd)
words, err := shellquote.Split(cmd)
if err != nil {
return fail("Error parsing arguments", "Failed to parse arguments: %v", err)
}
if len(words) < 2 {
if git.CheckGitVersionAtLeast("2.29") == nil {
// for AGit Flow
if cmd == "ssh_info" {
fmt.Print(`{"type":"gitea","version":1}`)
return nil
}
}
return fail("Too few arguments", "Too few arguments in cmd: %s", cmd)
}
verb := words[0]
repoPath := words[1]
if repoPath[0] == '/' {
repoPath = repoPath[1:]
}
var lfsVerb string
if verb == lfsAuthenticateVerb {
if !setting.LFS.StartServer {
fail("Unknown git command", "LFS authentication request over SSH denied, LFS support is disabled")
return fail("Unknown git command", "LFS authentication request over SSH denied, LFS support is disabled")
}
argsSplit := strings.Split(args, " ")
if len(argsSplit) >= 2 {
args = strings.TrimSpace(argsSplit[0])
lfsVerb = strings.TrimSpace(argsSplit[1])
if len(words) > 2 {
lfsVerb = words[2]
}
}
repoPath := strings.ToLower(strings.Trim(args, "'"))
// LowerCase and trim the repoPath as that's how they are stored.
repoPath = strings.ToLower(strings.TrimSpace(repoPath))
rr := strings.SplitN(repoPath, "/", 2)
if len(rr) != 2 {
fail("Invalid repository path", "Invalid repository path: %v", args)
return fail("Invalid repository path", "Invalid repository path: %v", repoPath)
}
username := strings.ToLower(rr[0])
reponame := strings.ToLower(strings.TrimSuffix(rr[1], ".git"))
if setting.EnablePprof || c.Bool("enable-pprof") {
if alphaDashDotPattern.MatchString(reponame) {
return fail("Invalid repo name", "Invalid repo name: %s", reponame)
}
if c.Bool("enable-pprof") {
if err := os.MkdirAll(setting.PprofDataPath, os.ModePerm); err != nil {
fail("Error while trying to create PPROF_DATA_PATH", "Error while trying to create PPROF_DATA_PATH: %v", err)
return fail("Error while trying to create PPROF_DATA_PATH", "Error while trying to create PPROF_DATA_PATH: %v", err)
}
stopCPUProfiler, err := pprof.DumpCPUProfileForUsername(setting.PprofDataPath, username)
if err != nil {
fail("Internal Server Error", "Unable to start CPU profile: %v", err)
return fail("Internal Server Error", "Unable to start CPU profile: %v", err)
}
defer func() {
stopCPUProfiler()
err := pprof.DumpMemProfileForUsername(setting.PprofDataPath, username)
if err != nil {
fail("Internal Server Error", "Unable to dump Mem Profile: %v", err)
_ = fail("Internal Server Error", "Unable to dump Mem Profile: %v", err)
}
}()
}
requestedMode, has := allowedCommands[verb]
if !has {
fail("Unknown git command", "Unknown git command %s", verb)
return fail("Unknown git command", "Unknown git command %s", verb)
}
if verb == lfsAuthenticateVerb {
if lfsVerb == "upload" {
requestedMode = models.AccessModeWrite
requestedMode = perm.AccessModeWrite
} else if lfsVerb == "download" {
requestedMode = models.AccessModeRead
requestedMode = perm.AccessModeRead
} else {
fail("Unknown LFS verb", "Unknown lfs verb %s", lfsVerb)
return fail("Unknown LFS verb", "Unknown lfs verb %s", lfsVerb)
}
}
results, err := private.ServCommand(keyID, username, reponame, requestedMode, verb, lfsVerb)
results, err := private.ServCommand(ctx, keyID, username, reponame, requestedMode, verb, lfsVerb)
if err != nil {
if private.IsErrServCommand(err) {
errServCommand := err.(private.ErrServCommand)
if errServCommand.StatusCode != http.StatusInternalServerError {
fail("Unauthorized", "%s", errServCommand.Error())
} else {
fail("Internal Server Error", "%s", errServCommand.Error())
return fail("Unauthorized", "%s", errServCommand.Error())
}
return fail("Internal Server Error", "%s", errServCommand.Error())
}
fail("Internal Server Error", "%s", err.Error())
return fail("Internal Server Error", "%s", err.Error())
}
os.Setenv(models.EnvRepoIsWiki, strconv.FormatBool(results.IsWiki))
os.Setenv(models.EnvRepoName, results.RepoName)
os.Setenv(models.EnvRepoUsername, results.OwnerName)
os.Setenv(models.EnvPusherName, results.UserName)
os.Setenv(models.EnvPusherID, strconv.FormatInt(results.UserID, 10))
os.Setenv(models.ProtectedBranchRepoID, strconv.FormatInt(results.RepoID, 10))
os.Setenv(models.ProtectedBranchPRID, fmt.Sprintf("%d", 0))
os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
//LFS token authentication
// LFS token authentication
if verb == lfsAuthenticateVerb {
url := fmt.Sprintf("%s%s/%s.git/info/lfs", setting.AppURL, url.PathEscape(results.OwnerName), url.PathEscape(results.RepoName))
now := time.Now()
claims := jwt.MapClaims{
"repo": results.RepoID,
"op": lfsVerb,
"exp": now.Add(setting.LFS.HTTPAuthExpiry).Unix(),
"nbf": now.Unix(),
"user": results.UserID,
claims := lfs.Claims{
RegisteredClaims: jwt.RegisteredClaims{
ExpiresAt: jwt.NewNumericDate(now.Add(setting.LFS.HTTPAuthExpiry)),
NotBefore: jwt.NewNumericDate(now),
},
RepoID: results.RepoID,
Op: lfsVerb,
UserID: results.UserID,
}
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
// Sign and get the complete encoded token as a string using the secret
tokenString, err := token.SignedString(setting.LFS.JWTSecretBytes)
if err != nil {
fail("Internal error", "Failed to sign JWT token: %v", err)
return fail("Internal error", "Failed to sign JWT token: %v", err)
}
tokenAuthentication := &models.LFSTokenResponse{
tokenAuthentication := &git_model.LFSTokenResponse{
Header: make(map[string]string),
Href: url,
}
@ -231,36 +286,59 @@ func runServ(c *cli.Context) error {
enc := json.NewEncoder(os.Stdout)
err = enc.Encode(tokenAuthentication)
if err != nil {
fail("Internal error", "Failed to encode LFS json response: %v", err)
return fail("Internal error", "Failed to encode LFS json response: %v", err)
}
return nil
}
// Special handle for Windows.
if setting.IsWindows {
verb = strings.Replace(verb, "-", " ", 1)
}
var gitcmd *exec.Cmd
verbs := strings.Split(verb, " ")
if len(verbs) == 2 {
gitcmd = exec.Command(verbs[0], verbs[1], repoPath)
} else {
gitcmd = exec.Command(verb, repoPath)
gitBinPath := filepath.Dir(git.GitExecutable) // e.g. /usr/bin
gitBinVerb := filepath.Join(gitBinPath, verb) // e.g. /usr/bin/git-upload-pack
if _, err := os.Stat(gitBinVerb); err != nil {
// if the command "git-upload-pack" doesn't exist, try to split "git-upload-pack" to use the sub-command with git
// ps: Windows only has "git.exe" in the bin path, so Windows always uses this way
verbFields := strings.SplitN(verb, "-", 2)
if len(verbFields) == 2 {
// use git binary with the sub-command part: "C:\...\bin\git.exe", "upload-pack", ...
gitcmd = exec.CommandContext(ctx, git.GitExecutable, verbFields[1], repoPath)
}
}
if gitcmd == nil {
// by default, use the verb (it has been checked above by allowedCommands)
gitcmd = exec.CommandContext(ctx, gitBinVerb, repoPath)
}
process.SetSysProcAttribute(gitcmd)
gitcmd.Dir = setting.RepoRootPath
gitcmd.Stdout = os.Stdout
gitcmd.Stdin = os.Stdin
gitcmd.Stderr = os.Stderr
gitcmd.Env = append(gitcmd.Env, os.Environ()...)
gitcmd.Env = append(gitcmd.Env,
repo_module.EnvRepoIsWiki+"="+strconv.FormatBool(results.IsWiki),
repo_module.EnvRepoName+"="+results.RepoName,
repo_module.EnvRepoUsername+"="+results.OwnerName,
repo_module.EnvPusherName+"="+results.UserName,
repo_module.EnvPusherEmail+"="+results.UserEmail,
repo_module.EnvPusherID+"="+strconv.FormatInt(results.UserID, 10),
repo_module.EnvRepoID+"="+strconv.FormatInt(results.RepoID, 10),
repo_module.EnvPRID+"="+fmt.Sprintf("%d", 0),
repo_module.EnvDeployKeyID+"="+fmt.Sprintf("%d", results.DeployKeyID),
repo_module.EnvKeyID+"="+fmt.Sprintf("%d", results.KeyID),
repo_module.EnvAppURL+"="+setting.AppURL,
)
// to avoid breaking, here only use the minimal environment variables for the "gitea serv" command.
// it could be re-considered whether to use the same git.CommonGitCmdEnvs() as "git" command later.
gitcmd.Env = append(gitcmd.Env, git.CommonCmdServEnvs()...)
if err = gitcmd.Run(); err != nil {
fail("Internal error", "Failed to execute git command: %v", err)
return fail("Internal error", "Failed to execute git command: %v", err)
}
// Update user key activity.
if results.KeyID > 0 {
if err = private.UpdatePublicKeyInRepo(results.KeyID, results.RepoID); err != nil {
fail("Internal error", "UpdatePublicKeyInRepo: %v", err)
if err = private.UpdatePublicKeyInRepo(ctx, results.KeyID, results.RepoID); err != nil {
return fail("Internal error", "UpdatePublicKeyInRepo: %v", err)
}
}

View file

@ -1,27 +1,27 @@
// Copyright 2014 The Gogs Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"context"
"fmt"
"net"
"net/http"
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
"os"
"strings"
_ "net/http/pprof" // Used for debugging if enabled and a web server is running
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/routers"
"code.gitea.io/gitea/routers/routes"
"code.gitea.io/gitea/routers/install"
context2 "github.com/gorilla/context"
"github.com/unknwon/com"
"github.com/felixge/fgprof"
"github.com/urfave/cli"
"golang.org/x/crypto/acme/autocert"
ini "gopkg.in/ini.v1"
)
@ -38,15 +38,31 @@ and it takes care of all the other things for you`,
Value: "3000",
Usage: "Temporary port number to prevent conflict",
},
cli.StringFlag{
Name: "install-port",
Value: "3000",
Usage: "Temporary port number to run the install page on to prevent conflict",
},
cli.StringFlag{
Name: "pid, P",
Value: "/var/run/gitea.pid",
Value: setting.PIDFile,
Usage: "Custom pid file path",
},
cli.BoolFlag{
Name: "quiet, q",
Usage: "Only display Fatal logging errors until logging is set-up",
},
cli.BoolFlag{
Name: "verbose",
Usage: "Set initial logging to TRACE level until logging is properly set-up",
},
},
}
func runHTTPRedirector() {
_, _, finished := process.GetManager().AddTypedContext(graceful.GetManager().HammerContext(), "Web: HTTP Redirector", process.SystemProcessType, true)
defer finished()
source := fmt.Sprintf("%s:%s", setting.HTTPAddr, setting.PortToRedirect)
dest := strings.TrimSuffix(setting.AppURL, "/")
log.Info("Redirecting: %s to %s", source, dest)
@ -59,44 +75,26 @@ func runHTTPRedirector() {
http.Redirect(w, r, target, http.StatusTemporaryRedirect)
})
var err = runHTTP("tcp", source, context2.ClearHandler(handler))
err := runHTTP("tcp", source, "HTTP Redirector", handler, setting.RedirectorUseProxyProtocol)
if err != nil {
log.Fatal("Failed to start port redirection: %v", err)
}
}
func runLetsEncrypt(listenAddr, domain, directory, email string, m http.Handler) error {
certManager := autocert.Manager{
Prompt: autocert.AcceptTOS,
HostPolicy: autocert.HostWhitelist(domain),
Cache: autocert.DirCache(directory),
Email: email,
func runWeb(ctx *cli.Context) error {
if ctx.Bool("verbose") {
_ = log.DelLogger("console")
log.NewLogger(0, "console", "console", fmt.Sprintf(`{"level": "trace", "colorize": %t, "stacktraceLevel": "none"}`, log.CanColorStdout))
} else if ctx.Bool("quiet") {
_ = log.DelLogger("console")
log.NewLogger(0, "console", "console", fmt.Sprintf(`{"level": "fatal", "colorize": %t, "stacktraceLevel": "none"}`, log.CanColorStdout))
}
go func() {
log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
// all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
var err = runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, certManager.HTTPHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)))
if err != nil {
log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
defer func() {
if panicked := recover(); panicked != nil {
log.Fatal("PANIC: %v\n%s", panicked, log.Stack(2))
}
}()
return runHTTPSWithTLSConfig("tcp", listenAddr, certManager.TLSConfig(), context2.ClearHandler(m))
}
func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" && r.Method != "HEAD" {
http.Error(w, "Use HTTPS", http.StatusBadRequest)
return
}
// Remove the trailing slash at the end of setting.AppURL, the request
// URI always contains a leading slash, which would result in a double
// slash
target := strings.TrimRight(setting.AppURL, "/") + r.URL.RequestURI()
http.Redirect(w, r, target, http.StatusFound)
}
func runWeb(ctx *cli.Context) error {
managerCtx, cancel := context.WithCancel(context.Background())
graceful.InitManager(managerCtx)
defer cancel()
@ -109,103 +107,167 @@ func runWeb(ctx *cli.Context) error {
// Set pid file setting
if ctx.IsSet("pid") {
setting.CustomPID = ctx.String("pid")
setting.PIDFile = ctx.String("pid")
setting.WritePIDFile = true
}
// Perform global initialization
routers.GlobalInit(graceful.GetManager().HammerContext())
// Set up Macaron
m := routes.NewMacaron()
routes.RegisterRoutes(m)
// Flag for port number in case first time run conflict.
if ctx.IsSet("port") {
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, ctx.String("port"), 1)
setting.HTTPPort = ctx.String("port")
switch setting.Protocol {
case setting.UnixSocket:
case setting.FCGI:
case setting.FCGIUnix:
// Perform pre-initialization
needsInstall := install.PreloadSettings(graceful.GetManager().HammerContext())
if needsInstall {
// Flag for port number in case first time run conflict
if ctx.IsSet("port") {
if err := setPort(ctx.String("port")); err != nil {
return err
}
}
if ctx.IsSet("install-port") {
if err := setPort(ctx.String("install-port")); err != nil {
return err
}
}
installCtx, cancel := context.WithCancel(graceful.GetManager().HammerContext())
c := install.Routes(installCtx)
err := listen(c, false)
cancel()
if err != nil {
log.Critical("Unable to open listener for installer. Is Gitea already running?")
graceful.GetManager().DoGracefulShutdown()
}
select {
case <-graceful.GetManager().IsShutdown():
<-graceful.GetManager().Done()
log.Info("PID: %d Gitea Web Finished", os.Getpid())
log.Close()
return err
default:
// Save LOCAL_ROOT_URL if port changed
cfg := ini.Empty()
if com.IsFile(setting.CustomConf) {
// Keeps custom settings if there is already something.
if err := cfg.Append(setting.CustomConf); err != nil {
return fmt.Errorf("Failed to load custom conf '%s': %v", setting.CustomConf, err)
}
}
}
} else {
NoInstallListener()
}
defaultLocalURL := string(setting.Protocol) + "://"
if setting.HTTPAddr == "0.0.0.0" {
defaultLocalURL += "localhost"
} else {
defaultLocalURL += setting.HTTPAddr
}
defaultLocalURL += ":" + setting.HTTPPort + "/"
if setting.EnablePprof {
go func() {
http.DefaultServeMux.Handle("/debug/fgprof", fgprof.Handler())
_, _, finished := process.GetManager().AddTypedContext(context.Background(), "Web: PProf Server", process.SystemProcessType, true)
// The pprof server is for debug purpose only, it shouldn't be exposed on public network. At the moment it's not worth to introduce a configurable option for it.
log.Info("Starting pprof server on localhost:6060")
log.Info("Stopped pprof server: %v", http.ListenAndServe("localhost:6060", nil))
finished()
}()
}
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
log.Info("Global init")
// Perform global initialization
setting.InitProviderFromExistingFile()
setting.LoadCommonSettings()
routers.GlobalInitInstalled(graceful.GetManager().HammerContext())
if err := cfg.SaveTo(setting.CustomConf); err != nil {
return fmt.Errorf("Error saving generated JWT Secret to custom config: %v", err)
}
// We check that AppDataPath exists here (it should have been created during installation)
// We can't check it in `GlobalInitInstalled`, because some integration tests
// use cmd -> GlobalInitInstalled, but the AppDataPath doesn't exist during those tests.
if _, err := os.Stat(setting.AppDataPath); err != nil {
log.Fatal("Can not find APP_DATA_PATH '%s'", setting.AppDataPath)
}
// Override the provided port number within the configuration
if ctx.IsSet("port") {
if err := setPort(ctx.String("port")); err != nil {
return err
}
}
listenAddr := setting.HTTPAddr
if setting.Protocol != setting.UnixSocket && setting.Protocol != setting.FCGIUnix {
listenAddr += ":" + setting.HTTPPort
// Set up Chi routes
c := routers.NormalRoutes(graceful.GetManager().HammerContext())
err := listen(c, true)
<-graceful.GetManager().Done()
log.Info("PID: %d Gitea Web Finished", os.Getpid())
log.Close()
return err
}
func setPort(port string) error {
setting.AppURL = strings.Replace(setting.AppURL, setting.HTTPPort, port, 1)
setting.HTTPPort = port
switch setting.Protocol {
case setting.HTTPUnix:
case setting.FCGI:
case setting.FCGIUnix:
default:
defaultLocalURL := string(setting.Protocol) + "://"
if setting.HTTPAddr == "0.0.0.0" {
defaultLocalURL += "localhost"
} else {
defaultLocalURL += setting.HTTPAddr
}
defaultLocalURL += ":" + setting.HTTPPort + "/"
// Save LOCAL_ROOT_URL if port changed
setting.CreateOrAppendToCustomConf("server.LOCAL_ROOT_URL", func(cfg *ini.File) {
cfg.Section("server").Key("LOCAL_ROOT_URL").SetValue(defaultLocalURL)
})
}
return nil
}
func listen(m http.Handler, handleRedirector bool) error {
listenAddr := setting.HTTPAddr
if setting.Protocol != setting.HTTPUnix && setting.Protocol != setting.FCGIUnix {
listenAddr = net.JoinHostPort(listenAddr, setting.HTTPPort)
}
_, _, finished := process.GetManager().AddTypedContext(graceful.GetManager().HammerContext(), "Web: Gitea Server", process.SystemProcessType, true)
defer finished()
log.Info("Listen: %v://%s%s", setting.Protocol, listenAddr, setting.AppSubURL)
// This can be useful for users, many users do wrong to their config and get strange behaviors behind a reverse-proxy.
// A user may fix the configuration mistake when he sees this log.
// And this is also very helpful to maintainers to provide help to users to resolve their configuration problems.
log.Info("AppURL(ROOT_URL): %s", setting.AppURL)
if setting.LFS.StartServer {
log.Info("LFS server enabled")
}
if setting.EnablePprof {
go func() {
log.Info("Starting pprof server on localhost:6060")
log.Info("%v", http.ListenAndServe("localhost:6060", nil))
}()
}
var err error
switch setting.Protocol {
case setting.HTTP:
NoHTTPRedirector()
err = runHTTP("tcp", listenAddr, context2.ClearHandler(m))
case setting.HTTPS:
if setting.EnableLetsEncrypt {
err = runLetsEncrypt(listenAddr, setting.Domain, setting.LetsEncryptDirectory, setting.LetsEncryptEmail, context2.ClearHandler(m))
break
}
if setting.RedirectOtherPort {
go runHTTPRedirector()
} else {
if handleRedirector {
NoHTTPRedirector()
}
err = runHTTPS("tcp", listenAddr, setting.CertFile, setting.KeyFile, context2.ClearHandler(m))
err = runHTTP("tcp", listenAddr, "Web", m, setting.UseProxyProtocol)
case setting.HTTPS:
if setting.EnableAcme {
err = runACME(listenAddr, m)
break
}
if handleRedirector {
if setting.RedirectOtherPort {
go runHTTPRedirector()
} else {
NoHTTPRedirector()
}
}
err = runHTTPS("tcp", listenAddr, "Web", setting.CertFile, setting.KeyFile, m, setting.UseProxyProtocol, setting.ProxyProtocolTLSBridging)
case setting.FCGI:
NoHTTPRedirector()
err = runFCGI("tcp", listenAddr, context2.ClearHandler(m))
case setting.UnixSocket:
NoHTTPRedirector()
err = runHTTP("unix", listenAddr, context2.ClearHandler(m))
if handleRedirector {
NoHTTPRedirector()
}
err = runFCGI("tcp", listenAddr, "FCGI Web", m, setting.UseProxyProtocol)
case setting.HTTPUnix:
if handleRedirector {
NoHTTPRedirector()
}
err = runHTTP("unix", listenAddr, "Web", m, setting.UseProxyProtocol)
case setting.FCGIUnix:
NoHTTPRedirector()
err = runFCGI("unix", listenAddr, context2.ClearHandler(m))
if handleRedirector {
NoHTTPRedirector()
}
err = runFCGI("unix", listenAddr, "Web", m, setting.UseProxyProtocol)
default:
log.Fatal("Invalid protocol: %s", setting.Protocol)
}
if err != nil {
log.Critical("Failed to start server: %v", err)
}
log.Info("HTTP Listener: %s Closed", listenAddr)
<-graceful.GetManager().Done()
log.Info("PID: %d Gitea Web Finished", os.Getpid())
log.Close()
return nil
return err
}

135
cmd/web_acme.go Normal file
View file

@ -0,0 +1,135 @@
// Copyright 2020 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"crypto/x509"
"encoding/pem"
"fmt"
"net/http"
"os"
"strconv"
"strings"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/process"
"code.gitea.io/gitea/modules/setting"
"github.com/caddyserver/certmagic"
)
func getCARoot(path string) (*x509.CertPool, error) {
r, err := os.ReadFile(path)
if err != nil {
return nil, err
}
block, _ := pem.Decode(r)
if block == nil {
return nil, fmt.Errorf("no PEM found in the file %s", path)
}
caRoot, err := x509.ParseCertificate(block.Bytes)
if err != nil {
return nil, err
}
certPool := x509.NewCertPool()
certPool.AddCert(caRoot)
return certPool, nil
}
func runACME(listenAddr string, m http.Handler) error {
// If HTTP Challenge enabled, needs to be serving on port 80. For TLSALPN needs 443.
// Due to docker port mapping this can't be checked programmatically
// TODO: these are placeholders until we add options for each in settings with appropriate warning
enableHTTPChallenge := true
enableTLSALPNChallenge := true
altHTTPPort := 0
altTLSALPNPort := 0
if p, err := strconv.Atoi(setting.PortToRedirect); err == nil {
altHTTPPort = p
}
if p, err := strconv.Atoi(setting.HTTPPort); err == nil {
altTLSALPNPort = p
}
magic := certmagic.NewDefault()
magic.Storage = &certmagic.FileStorage{Path: setting.AcmeLiveDirectory}
// Try to use private CA root if provided, otherwise defaults to system's trust
var certPool *x509.CertPool
if setting.AcmeCARoot != "" {
var err error
certPool, err = getCARoot(setting.AcmeCARoot)
if err != nil {
log.Warn("Failed to parse CA Root certificate, using default CA trust: %v", err)
}
}
myACME := certmagic.NewACMEIssuer(magic, certmagic.ACMEIssuer{
CA: setting.AcmeURL,
TrustedRoots: certPool,
Email: setting.AcmeEmail,
Agreed: setting.AcmeTOS,
DisableHTTPChallenge: !enableHTTPChallenge,
DisableTLSALPNChallenge: !enableTLSALPNChallenge,
ListenHost: setting.HTTPAddr,
AltTLSALPNPort: altTLSALPNPort,
AltHTTPPort: altHTTPPort,
})
magic.Issuers = []certmagic.Issuer{myACME}
// this obtains certificates or renews them if necessary
err := magic.ManageSync(graceful.GetManager().HammerContext(), []string{setting.Domain})
if err != nil {
return err
}
tlsConfig := magic.TLSConfig()
tlsConfig.NextProtos = append(tlsConfig.NextProtos, "h2")
if version := toTLSVersion(setting.SSLMinimumVersion); version != 0 {
tlsConfig.MinVersion = version
}
if version := toTLSVersion(setting.SSLMaximumVersion); version != 0 {
tlsConfig.MaxVersion = version
}
// Set curve preferences
if curves := toCurvePreferences(setting.SSLCurvePreferences); len(curves) > 0 {
tlsConfig.CurvePreferences = curves
}
// Set cipher suites
if ciphers := toTLSCiphers(setting.SSLCipherSuites); len(ciphers) > 0 {
tlsConfig.CipherSuites = ciphers
}
if enableHTTPChallenge {
go func() {
_, _, finished := process.GetManager().AddTypedContext(graceful.GetManager().HammerContext(), "Web: ACME HTTP challenge server", process.SystemProcessType, true)
defer finished()
log.Info("Running Let's Encrypt handler on %s", setting.HTTPAddr+":"+setting.PortToRedirect)
// all traffic coming into HTTP will be redirect to HTTPS automatically (LE HTTP-01 validation happens here)
err := runHTTP("tcp", setting.HTTPAddr+":"+setting.PortToRedirect, "Let's Encrypt HTTP Challenge", myACME.HTTPChallengeHandler(http.HandlerFunc(runLetsEncryptFallbackHandler)), setting.RedirectorUseProxyProtocol)
if err != nil {
log.Fatal("Failed to start the Let's Encrypt handler on port %s: %v", setting.PortToRedirect, err)
}
}()
}
return runHTTPSWithTLSConfig("tcp", listenAddr, "Web", tlsConfig, m, setting.UseProxyProtocol, setting.ProxyProtocolTLSBridging)
}
func runLetsEncryptFallbackHandler(w http.ResponseWriter, r *http.Request) {
if r.Method != "GET" && r.Method != "HEAD" {
http.Error(w, "Use HTTPS", http.StatusBadRequest)
return
}
// Remove the trailing slash at the end of setting.AppURL, the request
// URI always contains a leading slash, which would result in a double
// slash
target := strings.TrimSuffix(setting.AppURL, "/") + r.URL.RequestURI()
http.Redirect(w, r, target, http.StatusTemporaryRedirect)
}

View file

@ -1,29 +1,21 @@
// Copyright 2016 The Gitea Authors. All rights reserved.
// Use of this source code is governed by a MIT-style
// license that can be found in the LICENSE file.
// SPDX-License-Identifier: MIT
package cmd
import (
"crypto/tls"
"net"
"net/http"
"net/http/fcgi"
"strings"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
)
func runHTTP(network, listenAddr string, m http.Handler) error {
return graceful.HTTPListenAndServe(network, listenAddr, m)
}
func runHTTPS(network, listenAddr, certFile, keyFile string, m http.Handler) error {
return graceful.HTTPListenAndServeTLS(network, listenAddr, certFile, keyFile, m)
}
func runHTTPSWithTLSConfig(network, listenAddr string, tlsConfig *tls.Config, m http.Handler) error {
return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, tlsConfig, m)
func runHTTP(network, listenAddr, name string, m http.Handler, useProxyProtocol bool) error {
return graceful.HTTPListenAndServe(network, listenAddr, name, m, useProxyProtocol)
}
// NoHTTPRedirector tells our cleanup routine that we will not be using a fallback http redirector
@ -37,13 +29,24 @@ func NoMainListener() {
graceful.GetManager().InformCleanup()
}
func runFCGI(network, listenAddr string, m http.Handler) error {
// NoInstallListener tells our cleanup routine that we will not be using a possibly provided listener
// for our install HTTP/HTTPS service
func NoInstallListener() {
graceful.GetManager().InformCleanup()
}
func runFCGI(network, listenAddr, name string, m http.Handler, useProxyProtocol bool) error {
// This needs to handle stdin as fcgi point
fcgiServer := graceful.NewServer(network, listenAddr)
fcgiServer := graceful.NewServer(network, listenAddr, name)
err := fcgiServer.ListenAndServe(func(listener net.Listener) error {
return fcgi.Serve(listener, m)
})
return fcgi.Serve(listener, http.HandlerFunc(func(resp http.ResponseWriter, req *http.Request) {
if setting.AppSubURL != "" {
req.URL.Path = strings.TrimPrefix(req.URL.Path, setting.AppSubURL)
}
m.ServeHTTP(resp, req)
}))
}, useProxyProtocol)
if err != nil {
log.Fatal("Failed to start FCGI main server: %v", err)
}

191
cmd/web_https.go Normal file
View file

@ -0,0 +1,191 @@
// Copyright 2021 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"crypto/tls"
"net/http"
"os"
"strings"
"code.gitea.io/gitea/modules/graceful"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/setting"
"github.com/klauspost/cpuid/v2"
)
var tlsVersionStringMap = map[string]uint16{
"": tls.VersionTLS12, // Default to tls.VersionTLS12
"tlsv1.0": tls.VersionTLS10,
"tlsv1.1": tls.VersionTLS11,
"tlsv1.2": tls.VersionTLS12,
"tlsv1.3": tls.VersionTLS13,
}
func toTLSVersion(version string) uint16 {
tlsVersion, ok := tlsVersionStringMap[strings.TrimSpace(strings.ToLower(version))]
if !ok {
log.Warn("Unknown tls version: %s", version)
return 0
}
return tlsVersion
}
var curveStringMap = map[string]tls.CurveID{
"x25519": tls.X25519,
"p256": tls.CurveP256,
"p384": tls.CurveP384,
"p521": tls.CurveP521,
}
func toCurvePreferences(preferences []string) []tls.CurveID {
ids := make([]tls.CurveID, 0, len(preferences))
for _, pref := range preferences {
id, ok := curveStringMap[strings.TrimSpace(strings.ToLower(pref))]
if !ok {
log.Warn("Unknown curve: %s", pref)
}
if id != 0 {
ids = append(ids, id)
}
}
return ids
}
var cipherStringMap = map[string]uint16{
"rsa_with_rc4_128_sha": tls.TLS_RSA_WITH_RC4_128_SHA,
"rsa_with_3des_ede_cbc_sha": tls.TLS_RSA_WITH_3DES_EDE_CBC_SHA,
"rsa_with_aes_128_cbc_sha": tls.TLS_RSA_WITH_AES_128_CBC_SHA,
"rsa_with_aes_256_cbc_sha": tls.TLS_RSA_WITH_AES_256_CBC_SHA,
"rsa_with_aes_128_cbc_sha256": tls.TLS_RSA_WITH_AES_128_CBC_SHA256,
"rsa_with_aes_128_gcm_sha256": tls.TLS_RSA_WITH_AES_128_GCM_SHA256,
"rsa_with_aes_256_gcm_sha384": tls.TLS_RSA_WITH_AES_256_GCM_SHA384,
"ecdhe_ecdsa_with_rc4_128_sha": tls.TLS_ECDHE_ECDSA_WITH_RC4_128_SHA,
"ecdhe_ecdsa_with_aes_128_cbc_sha": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA,
"ecdhe_ecdsa_with_aes_256_cbc_sha": tls.TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA,
"ecdhe_rsa_with_rc4_128_sha": tls.TLS_ECDHE_RSA_WITH_RC4_128_SHA,
"ecdhe_rsa_with_3des_ede_cbc_sha": tls.TLS_ECDHE_RSA_WITH_3DES_EDE_CBC_SHA,
"ecdhe_rsa_with_aes_128_cbc_sha": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
"ecdhe_rsa_with_aes_256_cbc_sha": tls.TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
"ecdhe_ecdsa_with_aes_128_cbc_sha256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256,
"ecdhe_rsa_with_aes_128_cbc_sha256": tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
"ecdhe_rsa_with_aes_128_gcm_sha256": tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
"ecdhe_ecdsa_with_aes_128_gcm_sha256": tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
"ecdhe_rsa_with_aes_256_gcm_sha384": tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
"ecdhe_ecdsa_with_aes_256_gcm_sha384": tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
"ecdhe_rsa_with_chacha20_poly1305_sha256": tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256,
"ecdhe_ecdsa_with_chacha20_poly1305_sha256": tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256,
"ecdhe_rsa_with_chacha20_poly1305": tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
"ecdhe_ecdsa_with_chacha20_poly1305": tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
"aes_128_gcm_sha256": tls.TLS_AES_128_GCM_SHA256,
"aes_256_gcm_sha384": tls.TLS_AES_256_GCM_SHA384,
"chacha20_poly1305_sha256": tls.TLS_CHACHA20_POLY1305_SHA256,
}
func toTLSCiphers(cipherStrings []string) []uint16 {
ciphers := make([]uint16, 0, len(cipherStrings))
for _, cipherString := range cipherStrings {
cipher, ok := cipherStringMap[strings.TrimSpace(strings.ToLower(cipherString))]
if !ok {
log.Warn("Unknown cipher: %s", cipherString)
}
if cipher != 0 {
ciphers = append(ciphers, cipher)
}
}
return ciphers
}
// defaultCiphers uses hardware support to check if AES is specifically
// supported by the CPU.
//
// If AES is supported AES ciphers will be preferred over ChaCha based ciphers
// (This code is directly inspired by the certmagic code.)
func defaultCiphers() []uint16 {
if cpuid.CPU.Supports(cpuid.AESNI) {
return defaultCiphersAESfirst
}
return defaultCiphersChaChaFirst
}
var (
defaultCiphersAES = []uint16{
tls.TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,
tls.TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,
tls.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,
}
defaultCiphersChaCha = []uint16{
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,
}
defaultCiphersAESfirst = append(defaultCiphersAES, defaultCiphersChaCha...)
defaultCiphersChaChaFirst = append(defaultCiphersChaCha, defaultCiphersAES...)
)
// runHTTPS listens on the provided network address and then calls
// Serve to handle requests on incoming TLS connections.
//
// Filenames containing a certificate and matching private key for the server must
// be provided. If the certificate is signed by a certificate authority, the
// certFile should be the concatenation of the server's certificate followed by the
// CA's certificate.
func runHTTPS(network, listenAddr, name, certFile, keyFile string, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error {
tlsConfig := &tls.Config{}
if tlsConfig.NextProtos == nil {
tlsConfig.NextProtos = []string{"h2", "http/1.1"}
}
if version := toTLSVersion(setting.SSLMinimumVersion); version != 0 {
tlsConfig.MinVersion = version
}
if version := toTLSVersion(setting.SSLMaximumVersion); version != 0 {
tlsConfig.MaxVersion = version
}
// Set curve preferences
tlsConfig.CurvePreferences = []tls.CurveID{
tls.X25519,
tls.CurveP256,
}
if curves := toCurvePreferences(setting.SSLCurvePreferences); len(curves) > 0 {
tlsConfig.CurvePreferences = curves
}
// Set cipher suites
tlsConfig.CipherSuites = defaultCiphers()
if ciphers := toTLSCiphers(setting.SSLCipherSuites); len(ciphers) > 0 {
tlsConfig.CipherSuites = ciphers
}
tlsConfig.Certificates = make([]tls.Certificate, 1)
certPEMBlock, err := os.ReadFile(certFile)
if err != nil {
log.Error("Failed to load https cert file %s for %s:%s: %v", certFile, network, listenAddr, err)
return err
}
keyPEMBlock, err := os.ReadFile(keyFile)
if err != nil {
log.Error("Failed to load https key file %s for %s:%s: %v", keyFile, network, listenAddr, err)
return err
}
tlsConfig.Certificates[0], err = tls.X509KeyPair(certPEMBlock, keyPEMBlock)
if err != nil {
log.Error("Failed to create certificate from cert file %s and key file %s for %s:%s: %v", certFile, keyFile, network, listenAddr, err)
return err
}
return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging)
}
func runHTTPSWithTLSConfig(network, listenAddr, name string, tlsConfig *tls.Config, m http.Handler, useProxyProtocol, proxyProtocolTLSBridging bool) error {
return graceful.HTTPListenAndServeTLSConfig(network, listenAddr, name, tlsConfig, m, useProxyProtocol, proxyProtocolTLSBridging)
}

View file

@ -0,0 +1,17 @@
Bash and Zsh completion
=======================
From within the gitea root run:
```bash
source contrib/autocompletion/bash_autocomplete
```
or for zsh run:
```bash
source contrib/autocompletion/zsh_autocomplete
```
These scripts will check if gitea is on the path and if so add autocompletion for `gitea`. Or if not autocompletion will work for `./gitea`.
If gitea has been installed as a different program pass in the `PROG` environment variable to set the correct program name.

View file

@ -0,0 +1,30 @@
#! /bin/bash
# Heavily inspired by https://github.com/urfave/cli
_cli_bash_autocomplete() {
if [[ "${COMP_WORDS[0]}" != "source" ]]; then
local cur opts base
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
if [[ "$cur" == "-"* ]]; then
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} ${cur} --generate-bash-completion )
else
opts=$( ${COMP_WORDS[@]:0:$COMP_CWORD} --generate-bash-completion )
fi
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
}
if [ -z "$PROG" ] && [ ! "$(command -v gitea &> /dev/null)" ] ; then
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete gitea
elif [ -z "$PROG" ]; then
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete ./gitea
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PWD/gitea"
else
complete -o bashdefault -o default -o nospace -F _cli_bash_autocomplete "$PROG"
unset PROG
fi

View file

@ -0,0 +1,30 @@
#compdef ${PROG:=gitea}
# Heavily inspired by https://github.com/urfave/cli
_cli_zsh_autocomplete() {
local -a opts
local cur
cur=${words[-1]}
if [[ "$cur" == "-"* ]]; then
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} ${cur} --generate-bash-completion)}")
else
opts=("${(@f)$(_CLI_ZSH_AUTOCOMPLETE_HACK=1 ${words[@]:0:#words[@]-1} --generate-bash-completion)}")
fi
if [[ "${opts[1]}" != "" ]]; then
_describe 'values' opts
else
_files
fi
return
}
if [ -z $PROG ] ; then
compdef _cli_zsh_autocomplete gitea
else
compdef _cli_zsh_autocomplete $(basename $PROG)
fi

41
contrib/backport/README Normal file
View file

@ -0,0 +1,41 @@
`backport`
==========
`backport` is a command to help create backports of PRs. It backports a
provided PR from main on to a released version.
It will create a backport branch, cherry-pick the PR's merge commit, adjust
the commit message and then push this back up to your fork's remote.
The default version will read from `docs/config.yml`. You can override this
using the option `--version`.
The upstream branches will be fetched, using the remote `origin`. This can
be overrided using `--upstream`, and fetching can be avoided using
`--no-fetch`.
By default the branch created will be called `backport-$PR-$VERSION`. You
can override this using the option `--backport-branch`. This branch will
be created from `--release-branch` which is `release/$(VERSION)`
by default and will be pulled from `$(UPSTREAM)`.
The merge-commit as determined by the github API will be used as the SHA to
cherry-pick. You can override this using `--cherry-pick`.
The commit message will be amended to add the `Backport` header.
`--no-amend-message` can be set to stop this from happening.
If cherry-pick is successful the backported branch will be pushed up to your
fork using your remote. These will be determined using `git remote -v`. You
can set your fork name using `--fork-user` and your remote name using
`--remote`. You can avoid pushing using `--no-push`.
If the push is successful, `xdg-open` will be called to open a backport url.
You can stop this using `--no-xdg-open`.
Installation
============
```bash
go install contrib/backport/backport.go
```

Some files were not shown because too many files have changed in this diff Show more