]> source.dussan.org Git - gitea.git/log
gitea.git
2 years agoDisallow selecting the text of buttons (#19330)
delvh [Thu, 14 Apr 2022 08:57:19 +0000 (10:57 +0200)]
Disallow selecting the text of buttons (#19330)

Introduce a CSS class `.unselectable`

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 13 Apr 2022 00:10:15 +0000 (00:10 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoNote where frontend files are located in docs (#19379)
ktprograms [Tue, 12 Apr 2022 20:36:24 +0000 (04:36 +0800)]
Note where frontend files are located in docs (#19379)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoDocument 409 error returned by repos/migrate api (#19376)
Chongyi Zheng [Tue, 12 Apr 2022 08:13:07 +0000 (04:13 -0400)]
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>
2 years agoFix middleware function's placements for some `/user/...` (#19377)
Gusted [Tue, 12 Apr 2022 02:02:58 +0000 (04:02 +0200)]
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.

2 years agoFix panic in teams API when requesting members (#19360)
delvh [Mon, 11 Apr 2022 12:49:49 +0000 (14:49 +0200)]
Fix panic in teams API when requesting members (#19360)

2 years agoAdd logic to switch between source/rendered on Markdown (#19356)
Gusted [Sun, 10 Apr 2022 15:01:35 +0000 (17:01 +0200)]
Add logic to switch between source/rendered on Markdown (#19356)

Adds a button to switch between the source blob and the rendered markdown.

2 years agoFixed registry host value. (#19363)
KN4CK3R [Sun, 10 Apr 2022 11:57:36 +0000 (13:57 +0200)]
Fixed registry host value. (#19363)

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Sun, 10 Apr 2022 00:10:15 +0000 (00:10 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAllow package linking to private repository (#19348)
KN4CK3R [Sat, 9 Apr 2022 15:57:37 +0000 (17:57 +0200)]
Allow package linking to private repository (#19348)

* Display private repos too.

* lint

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoUse "main" as default branch name (#19354)
wxiaoguang [Sat, 9 Apr 2022 04:26:48 +0000 (12:26 +0800)]
Use "main" as default branch name (#19354)

* Use "main" as default branch name

* fix test code

2 years agoMove milestone to models/issues/ (#19278)
Lunny Xiao [Fri, 8 Apr 2022 09:11:15 +0000 (17:11 +0800)]
Move milestone to models/issues/ (#19278)

* Move milestone to models/issues/

* Fix lint

* Fix test

* Fix lint

* Fix lint

2 years agoRefactor CSRF protection modules, make sure CSRF tokens can be up-to-date. (#19337)
wxiaoguang [Fri, 8 Apr 2022 05:21:05 +0000 (13:21 +0800)]
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.

2 years agoRemove dependent on session auth for api/v1 routers (#19321)
Lunny Xiao [Fri, 8 Apr 2022 04:22:10 +0000 (12:22 +0800)]
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

2 years agoAPI: Search Issues, dont show 500 if filter result in empty list (#19244)
6543 [Fri, 8 Apr 2022 02:39:03 +0000 (04:39 +0200)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 8 Apr 2022 00:17:39 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoNever use /api/v1 from Gitea UI Pages (#19318)
Lunny Xiao [Thu, 7 Apr 2022 18:59:56 +0000 (02:59 +0800)]
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

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 7 Apr 2022 00:17:35 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoShow ssh command directly in template instead of i18n translation (#19335)
原俊杰 [Wed, 6 Apr 2022 11:35:04 +0000 (19:35 +0800)]
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>
2 years agoPackage registry changes (#19305)
KN4CK3R [Wed, 6 Apr 2022 01:32:09 +0000 (03:32 +0200)]
Package registry changes (#19305)

* removed debug logs
* fixed SELECT
* removed unneeded error type
* use common SearchVersions method
* remove empty container upload versions
* return err

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 6 Apr 2022 00:17:36 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAdd `ENABLE_SSH_LOG` to debugging problems (#19316)
Gusted [Tue, 5 Apr 2022 20:41:56 +0000 (22:41 +0200)]
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`

2 years agoWarn on SSH connection for incorrect configuration (#19317)
Gusted [Tue, 5 Apr 2022 20:28:10 +0000 (22:28 +0200)]
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>
2 years agoescape fake link
techknowlogick [Tue, 5 Apr 2022 17:30:07 +0000 (13:30 -0400)]
escape fake link

2 years agoAllow custom redirect for landing page (#19324)
techknowlogick [Tue, 5 Apr 2022 16:16:01 +0000 (12:16 -0400)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Tue, 5 Apr 2022 00:17:38 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 4 Apr 2022 00:17:51 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoFix links to packages documentation (#19315)
Steven [Sun, 3 Apr 2022 16:22:01 +0000 (18:22 +0200)]
Fix links to packages documentation (#19315)

2 years agoRemove legacy unmaintained packages, refactor to support change default locale (...
wxiaoguang [Sun, 3 Apr 2022 09:46:48 +0000 (17:46 +0800)]
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.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Sun, 3 Apr 2022 00:17:41 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoPrevent intermittent NPE in queue tests (#19301)
zeripath [Sat, 2 Apr 2022 07:59:04 +0000 (08:59 +0100)]
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>
2 years agoUpgrade xorm/builder from v0.3.9 to v0.3.10 (#19296)
Lunny Xiao [Fri, 1 Apr 2022 20:14:14 +0000 (04:14 +0800)]
Upgrade xorm/builder from v0.3.9 to v0.3.10 (#19296)

xorm/builder v0.3.10 add support to EXISTS and NOT EXISTS.

2 years agoAn attempt to sync a non-mirror repo must give 400 (Bad Request) (#19300)
Peter Gardfjäll [Fri, 1 Apr 2022 18:29:57 +0000 (20:29 +0200)]
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>
2 years agoRemove legacy `unknwon/com` package (#19298)
wxiaoguang [Fri, 1 Apr 2022 16:34:57 +0000 (00:34 +0800)]
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`

2 years agoImprove package registry docs (#19273)
Norwin [Fri, 1 Apr 2022 15:31:40 +0000 (17:31 +0200)]
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>
2 years agoA pull-mirror repo should be marked as such on creation (#19295)
Peter Gardfjäll [Fri, 1 Apr 2022 14:14:36 +0000 (16:14 +0200)]
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.

2 years agoRefactor legacy `unknwon/com` package, improve golangci lint (#19284)
wxiaoguang [Fri, 1 Apr 2022 08:47:50 +0000 (16:47 +0800)]
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).

2 years agoSkip frontend ROOT_URL check on installation page, remove unnecessary global var...
wxiaoguang [Fri, 1 Apr 2022 08:00:26 +0000 (16:00 +0800)]
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

2 years agoFix broken of team create (#19288)
Lunny Xiao [Fri, 1 Apr 2022 06:05:31 +0000 (14:05 +0800)]
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>
2 years agoRemove `git.Command.Run` and `git.Command.RunInDir*` (#19280)
wxiaoguang [Fri, 1 Apr 2022 02:55:30 +0000 (10:55 +0800)]
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})`

2 years agoPerformance improvement for add team user when org has more than 1000 repositories...
Lunny Xiao [Fri, 1 Apr 2022 01:53:18 +0000 (09:53 +0800)]
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

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 1 Apr 2022 00:17:38 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoUpdate JS dependencies (#19281)
silverwind [Fri, 1 Apr 2022 00:15:46 +0000 (02:15 +0200)]
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

2 years agoFix container download counter (#19287)
KN4CK3R [Thu, 31 Mar 2022 23:08:32 +0000 (01:08 +0200)]
Fix container download counter (#19287)

* Increment counter on manifest download.

* Refactor GetPackageFileStream method.

2 years agogo.mod: update kevinburke/ssh_config to v1.2.0 (#19286)
Kevin Burke [Thu, 31 Mar 2022 22:05:57 +0000 (15:05 -0700)]
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.

2 years agoFix global packages enabled avaiable (#19276)
Lunny Xiao [Thu, 31 Mar 2022 17:31:53 +0000 (01:31 +0800)]
Fix global packages enabled avaiable (#19276)

Fix #19275

2 years agoAdd Goroutine stack inspector to admin/monitor (#19207)
zeripath [Thu, 31 Mar 2022 17:01:43 +0000 (18:01 +0100)]
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>
2 years agoMove checks for pulls before merge into own function (#19271)
6543 [Thu, 31 Mar 2022 14:53:08 +0000 (16:53 +0200)]
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 ...

2 years agoRestore user autoregistration with email addresses (#19261)
zeripath [Thu, 31 Mar 2022 13:20:25 +0000 (14:20 +0100)]
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>
2 years agoImprove sync performance for pull-mirrors (#19125)
Peter Gardfjäll [Thu, 31 Mar 2022 12:30:40 +0000 (14:30 +0200)]
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.

2 years agoRefactor `git.Command.Run*`, introduce `RunWithContextString` and `RunWithContextByte...
wxiaoguang [Thu, 31 Mar 2022 11:56:22 +0000 (19:56 +0800)]
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`

2 years agoMove reaction to models/issues/ (#19264)
Lunny Xiao [Thu, 31 Mar 2022 09:20:39 +0000 (17:20 +0800)]
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>
2 years agoUpdate reserved usernames list (#18438)
Gusted [Thu, 31 Mar 2022 04:02:13 +0000 (06:02 +0200)]
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.

2 years agoConfigure OpenSSH log level via Environment in Docker (#19274)
Gusted [Thu, 31 Mar 2022 03:15:36 +0000 (05:15 +0200)]
Configure OpenSSH log level via Environment in Docker (#19274)

Introduce a new environment variable: SSH_LOG_LEVEL

2 years agoUse a more general (and faster) method to sanitize URLs with credentials (#19239)
wxiaoguang [Thu, 31 Mar 2022 02:25:40 +0000 (10:25 +0800)]
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

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 31 Mar 2022 00:18:20 +0000 (00:18 +0000)]
[skip ci] Updated translations via Crowdin

2 years agofix link to package registry docs (#19268)
Norwin [Wed, 30 Mar 2022 19:17:05 +0000 (21:17 +0200)]
fix link to package registry docs (#19268)

2 years agoAdd Redis Sentinel Authentication Support (#19213)
Justin Sievenpiper [Wed, 30 Mar 2022 19:12:02 +0000 (12:12 -0700)]
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.

2 years agoAdd Package Registry (#16510)
KN4CK3R [Wed, 30 Mar 2022 08:42:47 +0000 (10:42 +0200)]
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>
2 years agoShow messages for users if the ROOT_URL is wrong, show JavaScript errors (#18971)
wxiaoguang [Wed, 30 Mar 2022 05:52:24 +0000 (13:52 +0800)]
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.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 30 Mar 2022 00:17:38 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoMake git.OpenRepository accept Context (#19260)
6543 [Tue, 29 Mar 2022 19:13:41 +0000 (21:13 +0200)]
Make git.OpenRepository accept Context (#19260)

* OpenRepositoryCtx -> OpenRepository
* OpenRepository -> openRepositoryWithDefaultContext, only for internal usage

2 years agoUse full output of git show-ref --tags to get tags for PushUpdateAddTag (#19235)
zeripath [Tue, 29 Mar 2022 17:12:33 +0000 (18:12 +0100)]
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>
2 years agoWhen conflicts have been previously detected ensure that they can be resolved (#19247)
zeripath [Tue, 29 Mar 2022 16:42:34 +0000 (17:42 +0100)]
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>
2 years agoMore commit info from API (#19252)
John Olheiser [Tue, 29 Mar 2022 15:47:44 +0000 (10:47 -0500)]
More commit info from API (#19252)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoMove some issue methods as functions (#19255)
Lunny Xiao [Tue, 29 Mar 2022 14:57:33 +0000 (22:57 +0800)]
Move some issue methods as functions (#19255)

* Move some issue methods as functions

* Fix bug

2 years agoMove project files into models/project sub package (#17704)
Lunny Xiao [Tue, 29 Mar 2022 14:16:31 +0000 (22:16 +0800)]
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>
2 years agoGranular webhook events in editHook (#19251)
John Olheiser [Tue, 29 Mar 2022 11:55:00 +0000 (06:55 -0500)]
Granular webhook events in editHook (#19251)

Signed-off-by: jolheiser <john.olheiser@gmail.com>
2 years agoProvide configuration to allow camo-media proxying (#12802)
zeripath [Tue, 29 Mar 2022 08:27:37 +0000 (09:27 +0100)]
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>
2 years agoMove init repository related functions to modules (#19159)
Lunny Xiao [Tue, 29 Mar 2022 07:23:45 +0000 (15:23 +0800)]
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>
2 years agoMove organization related structs into sub package (#18518)
Lunny Xiao [Tue, 29 Mar 2022 06:29:02 +0000 (14:29 +0800)]
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>
2 years agoRefactor repo clone button and repo clone links, fix JS error on empty repo page...
wxiaoguang [Tue, 29 Mar 2022 03:21:30 +0000 (11:21 +0800)]
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`

2 years agoShow last cron messages on monitor page (#19223)
zeripath [Tue, 29 Mar 2022 01:31:07 +0000 (02:31 +0100)]
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>
2 years agoAllow API to create file on empty repo (#19224)
zeripath [Mon, 28 Mar 2022 19:48:41 +0000 (20:48 +0100)]
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>
2 years agoUse goproxy.io instead of goproxy.cn (#19242)
Lunny Xiao [Mon, 28 Mar 2022 17:01:07 +0000 (01:01 +0800)]
Use goproxy.io instead of goproxy.cn (#19242)

2 years agoNew cron task: delete old system notices (#19219)
Pilou [Mon, 28 Mar 2022 12:54:59 +0000 (14:54 +0200)]
New cron task: delete old system notices (#19219)

Add a new cron task which deletes the old system notices.

2 years agoLet web and API routes have different auth methods group (#19168)
Lunny Xiao [Mon, 28 Mar 2022 04:46:28 +0000 (12:46 +0800)]
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>
2 years agoOnly send webhook events to active system webhooks and only deliver to active hooks...
zeripath [Mon, 28 Mar 2022 03:17:21 +0000 (04:17 +0100)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 28 Mar 2022 00:17:27 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoPrevent intermittent failures in RepoIndexerTest (2) (#19229)
zeripath [Sun, 27 Mar 2022 21:54:51 +0000 (22:54 +0100)]
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>
2 years agoFix `contrib/upgrade.sh` (#19222)
Norwin [Sun, 27 Mar 2022 17:48:08 +0000 (19:48 +0200)]
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

2 years agoTouch mirrors on even on fail to update (#19217)
zeripath [Sun, 27 Mar 2022 14:40:17 +0000 (15:40 +0100)]
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>
2 years agoHide sensitive content on admin panel progress monitor (#19218)
Lunny Xiao [Sun, 27 Mar 2022 11:54:09 +0000 (19:54 +0800)]
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>
2 years agoDo not include global arguments in process manager (#19226)
zeripath [Sun, 27 Mar 2022 09:09:56 +0000 (10:09 +0100)]
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>
2 years agoPrevent intermittent failures in RepoIndexerTest (#19225)
zeripath [Sun, 27 Mar 2022 07:05:01 +0000 (08:05 +0100)]
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>
2 years agoSet the default branch for repositories generated from templates (#19136)
Abheek Dhawan [Sun, 27 Mar 2022 02:56:28 +0000 (21:56 -0500)]
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>
2 years ago[skip ci] Updated licenses and gitignores
GiteaBot [Sun, 27 Mar 2022 00:17:35 +0000 (00:17 +0000)]
[skip ci] Updated licenses and gitignores

2 years agoMake cron task no notice on success (#19221)
zeripath [Sat, 26 Mar 2022 21:13:04 +0000 (21:13 +0000)]
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.

 ## :warning: BREAKING :warning:

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>
2 years agoAdd auto logging of goroutine pid label (#19212)
zeripath [Sat, 26 Mar 2022 20:04:36 +0000 (20:04 +0000)]
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>
2 years agoCheck go and nodejs version by go.mod and package.json (#19197)
gesangtome [Sat, 26 Mar 2022 10:39:31 +0000 (18:39 +0800)]
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>
2 years agoAdd `ContextUser` to http request context (#18798)
KN4CK3R [Sat, 26 Mar 2022 09:04:22 +0000 (10:04 +0100)]
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.

2 years agoSet OpenGraph title to DisplayName in profile pages (#19206)
Nulo [Fri, 25 Mar 2022 18:15:13 +0000 (18:15 +0000)]
Set OpenGraph title to DisplayName in profile pages (#19206)

Co-authored-by: Lauris BH <lauris@nix.lv>
2 years agoAdd pprof labels in processes and for lifecycles (#19202)
zeripath [Fri, 25 Mar 2022 12:47:12 +0000 (12:47 +0000)]
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>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Fri, 25 Mar 2022 00:17:35 +0000 (00:17 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoBump goldmark to v1.4.11 (#19201)
Robert Kaussow [Thu, 24 Mar 2022 15:47:37 +0000 (16:47 +0100)]
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>
2 years agoBump minimist from 1.2.5 to 1.2.6 (#19194)
dependabot[bot] [Thu, 24 Mar 2022 04:29:55 +0000 (00:29 -0400)]
Bump minimist from 1.2.5 to 1.2.6 (#19194)

2 years agoChangelog for 1.16.5 (#19189) (#19192)
6543 [Thu, 24 Mar 2022 02:04:12 +0000 (03:04 +0100)]
Changelog for 1.16.5 (#19189) (#19192)

* Changelog for 1.16.5 (#19189)

* bump version

2 years agoFix showing issues in your repositories (#18916)
Gusted [Wed, 23 Mar 2022 22:57:09 +0000 (23:57 +0100)]
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

2 years agoUpdate issue_no_dependencies description (#19112)
MeIchthys [Wed, 23 Mar 2022 16:46:50 +0000 (12:46 -0400)]
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>
2 years agoPrevent redirect to Host (2) (#19175)
zeripath [Wed, 23 Mar 2022 16:12:36 +0000 (16:12 +0000)]
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>