]> source.dussan.org Git - gitea.git/log
gitea.git
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>
2 years agoPrevent start panic due to missing DotEscape function
Andrew Thornton [Wed, 23 Mar 2022 16:08:27 +0000 (16:08 +0000)]
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>
2 years agoFix compare link in active feeds for new branch (#19149)
a1012112796 [Wed, 23 Mar 2022 13:40:12 +0000 (21:40 +0800)]
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>
2 years agoRedirect .wiki/* ui link to /wiki (#18831)
a1012112796 [Wed, 23 Mar 2022 13:29:18 +0000 (21:29 +0800)]
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>
2 years agoTry to prevent autolinking of displaynames by email readers (#19169)
zeripath [Wed, 23 Mar 2022 12:34:20 +0000 (12:34 +0000)]
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>
2 years agoUpdate HTTP status codes to modern codes (#18063)
KN4CK3R [Wed, 23 Mar 2022 04:54:07 +0000 (05:54 +0100)]
Update HTTP status codes to modern codes (#18063)

* 2xx/3xx/4xx/5xx -> http.Status...
* http.StatusFound -> http.StatusTemporaryRedirect
* http.StatusMovedPermanently -> http.StatusPermanentRedirect

2 years agoRemove the Go version in UI, add a link on Gitea Version to show config details ...
wxiaoguang [Wed, 23 Mar 2022 01:15:54 +0000 (09:15 +0800)]
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.

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Wed, 23 Mar 2022 00:24:20 +0000 (00:24 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoClean paths when looking in Storage (#19124)
zeripath [Tue, 22 Mar 2022 21:02:26 +0000 (21:02 +0000)]
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>
2 years agoUse the new/choose link for New Issue on project page (#19172)
zeripath [Tue, 22 Mar 2022 19:54:24 +0000 (19:54 +0000)]
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>
2 years agoEnsure that setting.LocalURL always has a trailing slash (#19171)
zeripath [Tue, 22 Mar 2022 16:59:57 +0000 (16:59 +0000)]
Ensure that setting.LocalURL always has a trailing slash (#19171)

Fix #19166

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoUse `ctx` instead of `db.DefaultContext` in some packages(routers/services/modules...
wxiaoguang [Tue, 22 Mar 2022 15:22:54 +0000 (23:22 +0800)]
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

2 years agoFix the bug: deploy key with write access can not push (#19010)
wxiaoguang [Tue, 22 Mar 2022 09:29:07 +0000 (17:29 +0800)]
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.

2 years agoRenamed ctx.User to ctx.Doer. (#19161)
KN4CK3R [Tue, 22 Mar 2022 07:03:22 +0000 (08:03 +0100)]
Renamed ctx.User to ctx.Doer. (#19161)

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2 years ago[docs] Enhance container selection in docker dump (#14292)
Robin [Tue, 22 Mar 2022 05:50:31 +0000 (06:50 +0100)]
[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.

2 years agoCleanup protected branches when deleting users & teams (#19158)
Norwin [Tue, 22 Mar 2022 01:09:45 +0000 (02:09 +0100)]
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>
2 years agoReorder issue templates and automatically add labels (#18875)
delvh [Mon, 21 Mar 2022 12:00:25 +0000 (13:00 +0100)]
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>
2 years agoUse IterateBufferSize whilst querying repositories during adoption check (#19140)
zeripath [Mon, 21 Mar 2022 08:09:42 +0000 (08:09 +0000)]
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>
2 years agoAdd 1.18 (#19151)
Sasha Melentyev [Mon, 21 Mar 2022 03:22:34 +0000 (06:22 +0300)]
Add 1.18 (#19151)

Co-authored-by: 6543 <6543@obermui.de>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 21 Mar 2022 00:24:03 +0000 (00:24 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoFix NPE `/repos/issues/search` when not signed in (#19154)
Gusted [Sun, 20 Mar 2022 21:04:51 +0000 (21:04 +0000)]
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

2 years ago[skip ci] Updated licenses and gitignores
GiteaBot [Sun, 20 Mar 2022 00:24:18 +0000 (00:24 +0000)]
[skip ci] Updated licenses and gitignores

2 years agoUse custom favicon when viewing static files if it exists (#19130)
Abheek Dhawan [Sat, 19 Mar 2022 19:53:31 +0000 (14:53 -0500)]
Use custom favicon when viewing static files if it exists (#19130)

Redirect `/favicon.ico` to `/assets/img/favicon.png`.

Fix #19109

2 years agonot send notification emails to inactive users (part 2) (#19142)
zeripath [Sat, 19 Mar 2022 16:20:03 +0000 (16:20 +0000)]
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>
2 years agoMake migrations SKIP_TLS_VERIFY apply to git too (#19132)
zeripath [Sat, 19 Mar 2022 14:16:38 +0000 (14:16 +0000)]
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>
2 years agoDo not send notification emails to inactive users (#19131)
zeripath [Sat, 19 Mar 2022 12:45:44 +0000 (12:45 +0000)]
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>
2 years agoremove not needed (#19128)
6543 [Fri, 18 Mar 2022 19:17:57 +0000 (20:17 +0100)]
remove not needed (#19128)

2 years agoAdd warning to set SENDMAIL_ARGS to -- (#19102)
zeripath [Fri, 18 Mar 2022 14:19:02 +0000 (14:19 +0000)]
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>
2 years agoDo not send activation email if manual confirm is set (#19119)
zeripath [Fri, 18 Mar 2022 09:57:07 +0000 (09:57 +0000)]
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>
2 years agoUpdate tool dependencies (#19120)
silverwind [Fri, 18 Mar 2022 02:17:56 +0000 (03:17 +0100)]
Update tool dependencies (#19120)

- Use tag over hash for all tool dependencies
- Update them to latest released versions

2 years agoDelete related notifications on issue deletion too (#18953)
Otto Richter (fnetX) [Thu, 17 Mar 2022 22:04:09 +0000 (23:04 +0100)]
Delete related notifications on issue deletion too (#18953)

* use .Decr for issue comment counting

* Remove notification on issue removal

2 years agonit fix (#19116)
6543 [Thu, 17 Mar 2022 18:04:36 +0000 (19:04 +0100)]
nit fix (#19116)

2 years agoStore the foreign ID of issues during migration (#18446)
Aravinth Manivannan [Thu, 17 Mar 2022 17:08:35 +0000 (22:38 +0530)]
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>
2 years agoRemove italics for `due_date_not_set` (#19113)
MeIchthys [Thu, 17 Mar 2022 15:43:10 +0000 (11:43 -0400)]
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`.

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

2 years agoFixed log path in fail2ban documentation (#19103)
Fredrik Ekre [Wed, 16 Mar 2022 16:39:13 +0000 (17:39 +0100)]
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.

2 years agorm .sample hooks which aren't used (#19101)
techknowlogick [Wed, 16 Mar 2022 10:33:07 +0000 (06:33 -0400)]
rm .sample hooks which aren't used (#19101)

2 years agouse go1.18 to build gitea (#19099)
techknowlogick [Wed, 16 Mar 2022 04:08:31 +0000 (00:08 -0400)]
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

2 years agoUse `go run` for tool dependencies, require go 1.17 (#18874)
silverwind [Wed, 16 Mar 2022 02:50:26 +0000 (03:50 +0100)]
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>
2 years agoUpdate golang.org/x/crypto (#19097)
Gusted [Wed, 16 Mar 2022 01:59:53 +0000 (01:59 +0000)]
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:
- https://github.com/golang/crypto/commit/5d542ad81a58c89581d596f49d0ba5d435481bcf
- & https://github.com/golang/crypto/commit/3147a52a75dda54ac3a611ef8978640d85188a2a

* Update Kex Algorithms

- Use standardized name for curve22519-sha256. https://github.com/golang/crypto/commit/9b076918e3c7e908b2bdea932f272a9979f2488a
- Prefer SHA256 version over SHA1 version. https://github.com/golang/crypto/commit/e4b3678e5f38521e67eba223ddd1902ceb3a303c

2 years agoHandle email address not exist. (#19089)
KN4CK3R [Tue, 15 Mar 2022 09:18:39 +0000 (10:18 +0100)]
Handle email address not exist. (#19089)

2 years agoFrontport Changelogs (#19088)
6543 [Mon, 14 Mar 2022 22:18:01 +0000 (23:18 +0100)]
Frontport Changelogs (#19088)

* Frontport Changelogs

* bump version in docs

2 years agoRestrict email address validation (#17688)
Lunny Xiao [Mon, 14 Mar 2022 17:39:54 +0000 (01:39 +0800)]
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.

2 years agoFix lfs bug (#19072)
Lunny Xiao [Mon, 14 Mar 2022 15:18:27 +0000 (23:18 +0800)]
Fix lfs bug (#19072)

* Fix lfs bug

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 14 Mar 2022 00:11:34 +0000 (00:11 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoFix documentation and #19065 (#19067)
mscherer [Sun, 13 Mar 2022 17:30:58 +0000 (18:30 +0100)]
Fix documentation and #19065 (#19067)

2 years agoRSS/Atom support for Repos (#19055)
6543 [Sun, 13 Mar 2022 16:40:47 +0000 (17:40 +0100)]
RSS/Atom support for Repos (#19055)

* support for repos
* refactor
* advertise the feeds via meta tags
* allow feed suffix and feed header
* optimize performance

2 years ago[skip ci] Updated licenses and gitignores
GiteaBot [Sun, 13 Mar 2022 00:11:52 +0000 (00:11 +0000)]
[skip ci] Updated licenses and gitignores

2 years agoFeeds: render markdown to html (#19058)
Norwin [Sat, 12 Mar 2022 22:05:12 +0000 (23:05 +0100)]
Feeds: render markdown to html (#19058)

* feeds: render markdown to html

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Sat, 12 Mar 2022 00:11:48 +0000 (00:11 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoPrevent 500 when there is an error during new auth source post (#19041)
zeripath [Thu, 10 Mar 2022 22:40:43 +0000 (22:40 +0000)]
Prevent 500 when there is an error during new auth source post (#19041)

Fix #19036

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoUpdate the webauthn_credential_id_sequence in Postgres (#19048)
zeripath [Thu, 10 Mar 2022 22:04:55 +0000 (22:04 +0000)]
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>
2 years agoIf rendering has failed due to a net.OpError stop rendering (attempt 2) (#19049)
zeripath [Thu, 10 Mar 2022 20:23:15 +0000 (20:23 +0000)]
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>
2 years agouse xorm builder for models.getReviewers() (#19033)
6543 [Thu, 10 Mar 2022 18:12:10 +0000 (19:12 +0100)]
use xorm builder for models.getReviewers() (#19033)

* xorm builder

* dedup code

2 years agoRSS/Atom support for Orgs (#17714)
6543 [Thu, 10 Mar 2022 14:54:51 +0000 (15:54 +0100)]
RSS/Atom support for Orgs (#17714)

part of #569

2 years agoFix flag validation (#19046)
Norwin [Thu, 10 Mar 2022 10:11:26 +0000 (11:11 +0100)]
Fix flag validation (#19046)

Regression from #5785

2 years agoImprove SyncMirrors logging (#19045)
zeripath [Thu, 10 Mar 2022 10:09:48 +0000 (10:09 +0000)]
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>
2 years agofix pam authorization (#19040)
zeripath [Thu, 10 Mar 2022 02:00:05 +0000 (02:00 +0000)]
fix pam authorization (#19040)

https://huntr.dev/bounties/8d221f92-b2b1-4878-bc31-66ff272e5ceb/

Co-authored-by: ysf <34326+ysf@users.noreply.github.com>
2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Thu, 10 Mar 2022 00:11:57 +0000 (00:11 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoUpgrading binding package (#19034)
Lunny Xiao [Wed, 9 Mar 2022 18:06:58 +0000 (02:06 +0800)]
Upgrading binding package (#19034)

Fix #18855

2 years agoEnsure isSSH is set whenever DISABLE_HTTP_GIT is set (#19028)
wxiaoguang [Wed, 9 Mar 2022 04:42:29 +0000 (12:42 +0800)]
Ensure isSSH is set whenever DISABLE_HTTP_GIT is set (#19028)

When DISABLE_HTTP_GIT is set we should always show the SSH button

2 years agoAdd button for issue deletion (#19032)
Otto Richter (fnetX) [Wed, 9 Mar 2022 00:38:11 +0000 (01:38 +0100)]
Add button for issue deletion (#19032)

Co-authored-by: Norwin <noerw@users.noreply.github.com>
Co-authored-by: 6543 <6543@obermui.de>
2 years agoFix script compatiable with OpenWrt (#19000)
YISH [Tue, 8 Mar 2022 22:58:14 +0000 (06:58 +0800)]
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>
2 years agoAllow users to self-request a PR review (#19030)
Norwin [Tue, 8 Mar 2022 21:48:47 +0000 (22:48 +0100)]
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>
2 years agoFix wrong scopes caused by empty scope input (#19029)
wxiaoguang [Tue, 8 Mar 2022 18:56:40 +0000 (02:56 +0800)]
Fix wrong scopes caused by empty scope input (#19029)

2 years agoFeature: show issue assignee on project board (#15232)
Roger Luo [Tue, 8 Mar 2022 16:42:28 +0000 (00:42 +0800)]
Feature: show issue assignee on project board (#15232)

* Show assignees in project boards.

2 years agobump go deps (#19021)
techknowlogick [Tue, 8 Mar 2022 11:15:30 +0000 (06:15 -0500)]
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>
2 years agoDon't show context cancelled errors in attribute reader (#19006)
zeripath [Tue, 8 Mar 2022 08:30:14 +0000 (08:30 +0000)]
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>
2 years agoSet `rel="nofollow noindex"` on new issue links (#19023)
zeripath [Mon, 7 Mar 2022 22:08:05 +0000 (22:08 +0000)]
Set `rel="nofollow noindex"` on new issue links (#19023)

Fix #19018

Signed-off-by: Andrew Thornton <art27@cantab.net>
2 years agoupdate to correct stable version
techknowlogick [Mon, 7 Mar 2022 07:03:06 +0000 (02:03 -0500)]
update to correct stable version

2 years ago[skip ci] Updated translations via Crowdin
GiteaBot [Mon, 7 Mar 2022 00:11:49 +0000 (00:11 +0000)]
[skip ci] Updated translations via Crowdin

2 years agoAdd Index to comment for migrations and mirroring (#18806)
singuliere [Sun, 6 Mar 2022 19:00:41 +0000 (20:00 +0100)]
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>
2 years agoSupport ignore all santize for external renderer (#18984)
Lunny Xiao [Sun, 6 Mar 2022 08:41:54 +0000 (16:41 +0800)]
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>
2 years agoFix EasyMDE error when input Enter (#19004)
wxiaoguang [Sat, 5 Mar 2022 17:53:34 +0000 (01:53 +0800)]
Fix EasyMDE error when input Enter (#19004)

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years agoFix update hint bug (#18996)
Lunny Xiao [Fri, 4 Mar 2022 20:59:29 +0000 (04:59 +0800)]
Fix update hint bug (#18996)

2 years agoFix the editor height in review box (#19003)
wxiaoguang [Fri, 4 Mar 2022 20:57:26 +0000 (04:57 +0800)]
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">