]> source.dussan.org Git - gitea.git/log
gitea.git
2 years agoDetect dark theme via css variable (#17800)
ThetaDev [Thu, 25 Nov 2021 07:14:48 +0000 (08:14 +0100)]
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.

2 years agoAllow forks to org if you can create repos (#17783)
qwerty287 [Thu, 25 Nov 2021 05:03:03 +0000 (06:03 +0100)]
Allow forks to org if you can create repos (#17783)

2 years agoUse correct user on releases (#17806)
Gusted [Thu, 25 Nov 2021 04:17:16 +0000 (04:17 +0000)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 25 Nov 2021 00:25:19 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoCreate menus for organization pages (#17802)
Lunny Xiao [Wed, 24 Nov 2021 16:12:54 +0000 (00:12 +0800)]
Create menus for organization pages (#17802)

* Create menus for organization pages

* Fix frontend lint

* Fix frontend lint

2 years agoPreserve color when inverting emojis (#17797)
silverwind [Wed, 24 Nov 2021 12:42:03 +0000 (04:42 -0800)]
Preserve color when inverting emojis (#17797)

Fixes: https://github.com/go-gitea/gitea/issues/17795
2 years agoMove user related model into models/user (#17781)
Lunny Xiao [Wed, 24 Nov 2021 09:49:20 +0000 (17:49 +0800)]
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

2 years agoUse `*PushUpdateOptions` as receiver (#17724)
Gusted [Wed, 24 Nov 2021 09:08:13 +0000 (09:08 +0000)]
Use `*PushUpdateOptions` as receiver (#17724)

2 years agoMove repofiles from modules/repofiles to services/repository/files (#17774)
Lunny Xiao [Wed, 24 Nov 2021 07:56:24 +0000 (15:56 +0800)]
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>
2 years agoFix visibility of org avatars (#17789)
qwerty287 [Wed, 24 Nov 2021 03:51:08 +0000 (04:51 +0100)]
Fix visibility of org avatars (#17789)

* Fix visibility of org avatar

* more clear syntax

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoUse correct Sender on webhook change title (#17791)
Gusted [Wed, 24 Nov 2021 02:47:03 +0000 (02:47 +0000)]
Use correct Sender on webhook change title (#17791)

As title, thanks to @mscherer for pointing out the incorrect code.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 24 Nov 2021 00:25:19 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoUse new OneDev /milestones endpoint (#17782)
KN4CK3R [Tue, 23 Nov 2021 19:28:06 +0000 (20:28 +0100)]
Use new OneDev /milestones endpoint (#17782)

OneDev changed the API which fails every build at the moment.

2 years agoFix keys test (#17776)
techknowlogick [Tue, 23 Nov 2021 08:12:02 +0000 (03:12 -0500)]
Fix keys test (#17776)

2 years agoAdd `PULL_LIMIT` and `PUSH_LIMIT` to cron.update_mirror task (#17568)
zeripath [Tue, 23 Nov 2021 03:09:35 +0000 (03:09 +0000)]
Add `PULL_LIMIT` and `PUSH_LIMIT` to cron.update_mirror task (#17568)

2 years agoImprove ellipsis buttons (#17773)
silverwind [Tue, 23 Nov 2021 02:44:38 +0000 (03:44 +0100)]
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>
2 years agoHarden authorized keys a bit more (#17772)
mscherer [Tue, 23 Nov 2021 02:44:26 +0000 (03:44 +0100)]
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>
2 years agoAdd copy Commit ID button in commits list (#17759)
velengel [Tue, 23 Nov 2021 02:44:10 +0000 (11:44 +0900)]
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>
2 years agoAdd documentation for backend development (#17512)
Lunny Xiao [Tue, 23 Nov 2021 02:10:18 +0000 (10:10 +0800)]
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

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 23 Nov 2021 00:31:08 +0000 (00:31 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoMore pleasantly handle broken or missing git repositories (#17747)
zeripath [Mon, 22 Nov 2021 22:32:16 +0000 (22:32 +0000)]
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>
2 years agoRemove unnecessary attributes of User struct (#17745)
Lunny Xiao [Mon, 22 Nov 2021 15:21:55 +0000 (23:21 +0800)]
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

2 years agoSupport pagination of organizations on user settings pages (#16083)
Lunny Xiao [Mon, 22 Nov 2021 13:51:45 +0000 (21:51 +0800)]
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

2 years agoMake `bind` error more readable (#17750)
Gusted [Mon, 22 Nov 2021 13:05:29 +0000 (13:05 +0000)]
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

2 years agoImprovements to content history (#17746)
Jimmy Praet [Mon, 22 Nov 2021 12:20:16 +0000 (13:20 +0100)]
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

2 years agoFix project board bug and improve documents (#17753)
wxiaoguang [Mon, 22 Nov 2021 11:40:17 +0000 (19:40 +0800)]
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)

2 years agoFix navbar on project view (#17749)
Gusted [Mon, 22 Nov 2021 10:57:05 +0000 (10:57 +0000)]
Fix navbar on project view (#17749)

- Shows that the project nav item is active when you're viewing a project.

2 years agoExclude from watching tests (#17744)
Gusted [Mon, 22 Nov 2021 10:17:21 +0000 (10:17 +0000)]
Exclude from watching tests (#17744)

2 years agoAdd user settings key/value DB table (#16834)
techknowlogick [Mon, 22 Nov 2021 09:47:23 +0000 (04:47 -0500)]
Add user settings key/value DB table (#16834)

2 years agoAdd new JS linter rules (#17699)
silverwind [Mon, 22 Nov 2021 08:19:01 +0000 (09:19 +0100)]
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>
2 years agoUse `f` variant to parse formatting (#17751)
Gusted [Mon, 22 Nov 2021 06:18:31 +0000 (06:18 +0000)]
Use `f` variant to parse formatting (#17751)

As title.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 22 Nov 2021 00:24:56 +0000 (00:24 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAllow Loading of Diffs that are too large (#17739)
zeripath [Sun, 21 Nov 2021 16:51:08 +0000 (16:51 +0000)]
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>
2 years agoRemove NewSession method from db.Engine interface (#17577)
Lunny Xiao [Sun, 21 Nov 2021 15:41:00 +0000 (23:41 +0800)]
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

2 years agoFix close issue but time watcher still running (#17643)
Lunny Xiao [Sun, 21 Nov 2021 09:11:48 +0000 (17:11 +0800)]
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

2 years ago[skip ci] Updated licenses and gitignores
GiteaBot [Sun, 21 Nov 2021 00:25:17 +0000 (00:25 +0000)]
[skip ci] Updated licenses and gitignores

2 years agoReset locale on login (#17734)
zeripath [Sat, 20 Nov 2021 21:32:37 +0000 (21:32 +0000)]
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>
2 years agoExtract constant names out for the ReverseProxy and Basic authentication methods...
zeripath [Sat, 20 Nov 2021 15:33:18 +0000 (15:33 +0000)]
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>
2 years agoEnable show more files in diff for git <2.31 (#17733)
zeripath [Sat, 20 Nov 2021 13:50:00 +0000 (13:50 +0000)]
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>
2 years agoMake a.add-code-comment click handler an event handler (#17737)
zeripath [Sat, 20 Nov 2021 12:12:59 +0000 (12:12 +0000)]
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>
2 years agoUse `hostmatcher` to replace `matchlist`, improve security (#17605)
wxiaoguang [Sat, 20 Nov 2021 09:34:05 +0000 (17:34 +0800)]
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.

2 years agoMake SSL cipher suite configurable (#17440)
zeripath [Sat, 20 Nov 2021 06:12:43 +0000 (06:12 +0000)]
Make SSL cipher suite configurable (#17440)

2 years agoFix correct usage of teams (#17732)
Gusted [Sat, 20 Nov 2021 03:13:24 +0000 (03:13 +0000)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Sat, 20 Nov 2021 00:25:08 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoBetter builtin avatar generator (#17707)
wxiaoguang [Fri, 19 Nov 2021 17:10:41 +0000 (01:10 +0800)]
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

2 years agoAdd settings to allow different SMTP envelope from address (#17479)
zeripath [Fri, 19 Nov 2021 15:35:20 +0000 (15:35 +0000)]
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>
2 years agoAllow Token API calls be authorized using the reverse-proxy header (#15119)
Paweł Bogusławski [Fri, 19 Nov 2021 14:54:44 +0000 (15:54 +0100)]
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

2 years agoMove attachment into models/repo/ (#17650)
Lunny Xiao [Fri, 19 Nov 2021 13:39:57 +0000 (21:39 +0800)]
Move attachment into models/repo/ (#17650)

* Move attachment into models/repo/

* Fix test

* Fix bug

2 years agoUse a standalone struct name for Organization (#17632)
Lunny Xiao [Fri, 19 Nov 2021 11:41:40 +0000 (19:41 +0800)]
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>
2 years agoPrevent double sanitize (#16386)
KN4CK3R [Fri, 19 Nov 2021 10:46:47 +0000 (11:46 +0100)]
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.

2 years agoAdded comment for changing issue ref (#17672)
Gusted [Fri, 19 Nov 2021 09:54:31 +0000 (09:54 +0000)]
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.

2 years agoRemove unused `user` paramater (#17723)
Gusted [Fri, 19 Nov 2021 08:37:13 +0000 (08:37 +0000)]
Remove unused `user` paramater (#17723)

As title

2 years agoPrepare and check test env during CI (#17725)
wxiaoguang [Fri, 19 Nov 2021 05:58:34 +0000 (13:58 +0800)]
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

2 years agoFix bug when project board get open issue number (#17703)
Lunny Xiao [Fri, 19 Nov 2021 04:00:18 +0000 (12:00 +0800)]
Fix bug when project board get open issue number (#17703)

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years agoperf: sent `data-path` once for each file (#17657)
Gusted [Fri, 19 Nov 2021 02:28:27 +0000 (02:28 +0000)]
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%)

2 years agoPrevent deadlock in TestPersistableChannelQueue (#17717)
zeripath [Fri, 19 Nov 2021 01:13:25 +0000 (01:13 +0000)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 19 Nov 2021 00:25:46 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoMove user/org deletion to services (#17673)
KN4CK3R [Thu, 18 Nov 2021 17:42:27 +0000 (18:42 +0100)]
Move user/org deletion to services (#17673)

2 years agoRefactor repo-legacy.js, remove messy global variables. Fix errors. (#17646)
wxiaoguang [Thu, 18 Nov 2021 16:45:00 +0000 (00:45 +0800)]
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

2 years agoFix Migrate Description (#17692)
99rgosse [Thu, 18 Nov 2021 15:28:10 +0000 (16:28 +0100)]
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>
2 years agoAdd pagination to fork list (#17639)
Gusted [Thu, 18 Nov 2021 14:45:56 +0000 (14:45 +0000)]
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.

2 years agoFix possible panic (#17694)
Gusted [Thu, 18 Nov 2021 13:25:56 +0000 (13:25 +0000)]
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.

2 years agoSimplify code for wrting SHA to name-rev (#17696)
Gusted [Thu, 18 Nov 2021 09:50:22 +0000 (09:50 +0000)]
Simplify code for wrting SHA to name-rev (#17696)

2 years agoPrevent NPE due to missing repo in regression in #17551 (#17697)
zeripath [Thu, 18 Nov 2021 08:18:12 +0000 (08:18 +0000)]
Prevent NPE due to missing repo in regression in #17551 (#17697)

2 years agoMove task from modules to services (#17680)
Lunny Xiao [Thu, 18 Nov 2021 06:47:57 +0000 (14:47 +0800)]
Move task from modules to services (#17680)

2 years agoMove user functions into user.go (#17659)
Lunny Xiao [Thu, 18 Nov 2021 05:58:42 +0000 (13:58 +0800)]
Move user functions into user.go (#17659)

* Move user functions into user.go

* Fix test

2 years agoCleanup and use global style on popups (#17674)
silverwind [Thu, 18 Nov 2021 03:26:50 +0000 (04:26 +0100)]
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>
2 years agoRemove unnecessary variable assignments (#17695)
Gusted [Thu, 18 Nov 2021 01:33:06 +0000 (01:33 +0000)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 18 Nov 2021 00:25:14 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoFixed commit count. (#17698)
KN4CK3R [Wed, 17 Nov 2021 23:50:17 +0000 (00:50 +0100)]
Fixed commit count. (#17698)

Added "Tag" label.
Unified branch, tag and commit name.

2 years agoAdd .gitattribute assisted language detection to blame, diff and render (#17590)
zeripath [Wed, 17 Nov 2021 20:37:00 +0000 (20:37 +0000)]
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>
2 years agoReturn 400 but not 500 when request archive with wrong format (#17691)
Lunny Xiao [Wed, 17 Nov 2021 19:47:35 +0000 (03:47 +0800)]
Return 400 but not 500 when request archive with wrong format (#17691)

2 years agoSanitize user-input on file name (#17666)
Gusted [Wed, 17 Nov 2021 18:08:25 +0000 (18:08 +0000)]
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>
2 years agoMove some functions into services/repository (#17677)
Lunny Xiao [Wed, 17 Nov 2021 15:17:31 +0000 (23:17 +0800)]
Move some functions into services/repository (#17677)

2 years agoA better go code formatter, and now `make fmt` can run in Windows (#17684)
wxiaoguang [Wed, 17 Nov 2021 12:34:35 +0000 (20:34 +0800)]
A better go code formatter, and now `make fmt` can run in Windows (#17684)

* go build / format tools
* re-format imports

2 years agoFix bug when read mysql database max lifetime (#17682)
Lunny Xiao [Wed, 17 Nov 2021 10:59:23 +0000 (18:59 +0800)]
Fix bug when read mysql database max lifetime (#17682)

2 years agoMove user follow and openid into models/user/ (#17613)
Lunny Xiao [Wed, 17 Nov 2021 09:58:31 +0000 (17:58 +0800)]
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

2 years agoEnable bidichk (#17610)
Gusted [Wed, 17 Nov 2021 08:47:28 +0000 (08:47 +0000)]
Enable bidichk (#17610)

- https://github.com/breml/bidichk

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 6543 <6543@obermui.de>
2 years agofix migrations documents (#17679)
Lunny Xiao [Wed, 17 Nov 2021 07:17:37 +0000 (15:17 +0800)]
fix migrations documents (#17679)

Co-authored-by: techknowlogick <techknowlogick@gitea.io>
2 years agoUpdate golangci-lint in Makefile (#17647)
Gusted [Wed, 17 Nov 2021 05:41:01 +0000 (05:41 +0000)]
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>
2 years agoSet unit test timeout to 20 minutes (#17664)
Lunny Xiao [Wed, 17 Nov 2021 02:54:05 +0000 (10:54 +0800)]
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>
2 years agoUpdate for reverse proxying static resources (#17670)
rstular [Wed, 17 Nov 2021 02:53:15 +0000 (03:53 +0100)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 17 Nov 2021 00:25:11 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAllow admins to change user avatars (#17661)
qwerty287 [Tue, 16 Nov 2021 19:13:13 +0000 (20:13 +0100)]
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>
2 years agoMultiple Escaping Improvements (#17551)
zeripath [Tue, 16 Nov 2021 18:18:25 +0000 (18:18 +0000)]
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>
2 years agoMove migrations into services and base into modules/migration (#17663)
Lunny Xiao [Tue, 16 Nov 2021 15:25:33 +0000 (23:25 +0800)]
Move migrations into services and base into modules/migration (#17663)

* Move migrtions into services and base into modules/migration

* Fix imports

* Fix lint

2 years agoMove some functions into services/repository (#17660)
Lunny Xiao [Tue, 16 Nov 2021 13:30:11 +0000 (21:30 +0800)]
Move some functions into services/repository (#17660)

2 years agoRemove superfluous argument (#17667)
Gusted [Tue, 16 Nov 2021 11:36:03 +0000 (11:36 +0000)]
Remove superfluous argument (#17667)

As title.

2 years agoDecouple unit test, remove intermediate `unittestbridge` package (#17662)
wxiaoguang [Tue, 16 Nov 2021 08:53:21 +0000 (16:53 +0800)]
Decouple unit test, remove intermediate `unittestbridge` package (#17662)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoAdd copy button to markdown code blocks (#17638)
silverwind [Tue, 16 Nov 2021 08:16:05 +0000 (09:16 +0100)]
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>
2 years agoMigrating wiki don't require token, so we should move it out of the require form...
Lunny Xiao [Tue, 16 Nov 2021 06:17:21 +0000 (14:17 +0800)]
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

2 years agoFix GitBucket icon (#17644)
silverwind [Tue, 16 Nov 2021 04:24:22 +0000 (05:24 +0100)]
Fix GitBucket icon (#17644)

Partial fix for https://github.com/go-gitea/gitea/issues/17642.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years agoFix database deadlock when update issue labels (#17649)
wxiaoguang [Tue, 16 Nov 2021 02:21:13 +0000 (10:21 +0800)]
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.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 16 Nov 2021 00:25:21 +0000 (00:25 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoChanged migration text. (#17654)
KN4CK3R [Mon, 15 Nov 2021 23:12:09 +0000 (00:12 +0100)]
Changed migration text. (#17654)

2 years agoFix nil checking on typed interface (#17598)
Gusted [Mon, 15 Nov 2021 13:16:11 +0000 (13:16 +0000)]
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>
2 years agoRemove unnecassary calls to `filepath.Join` (#17608)
Gusted [Mon, 15 Nov 2021 06:02:53 +0000 (06:02 +0000)]
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>
2 years agoAdd download button for file viewer (#17640)
Gusted [Mon, 15 Nov 2021 01:05:12 +0000 (01:05 +0000)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 15 Nov 2021 00:24:54 +0000 (00:24 +0000)]
[skip ci] Updated translations via Crowdin

2 years agofix typo (#17614)
缘生 [Sun, 14 Nov 2021 22:32:48 +0000 (06:32 +0800)]
fix typo (#17614)