summaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* Only migrate the first 255 chars of a Github issue title (#28902) (#28912)Giteabot2024-01-241-1/+2
| | | | | | | Backport #28902 by @JakobDev Fixes #28846 Co-authored-by: JakobDev <jakobdev@gmx.de>
* Fix `DeleteCollaboration` transaction behaviour (#28886) (#28889)Giteabot2024-01-221-2/+5
| | | | | | | | | | | | | Backport #28886 by @KN4CK3R The method can't be called with an outer transaction because if the user is not a collaborator the outer transaction will be rolled back even if the inner transaction uses the no-error path. `has == 0` leads to `return nil` which cancels the transaction. A standalone call of this method does nothing but if used with an outer transaction, that will be canceled. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix schedule not trigger bug because matching full ref name with short ref ↵Giteabot2024-01-221-12/+16
| | | | | | | | | | | name (#28874) (#28888) Backport #28874 by @lunny Fix #28533 Caused by #28691 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix reverting a merge commit failing (#28794) (#28825)Mihir Joshi2024-01-217-8/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport https://github.com/go-gitea/gitea/pull/28794 Fixes #22236 --- Error occurring currently while trying to revert commit using read-tree -m approach: > 2022/12/26 16:04:43 ...rvices/pull/patch.go:240:AttemptThreeWayMerge() [E] [63a9c61a] Unable to run read-tree -m! Error: exit status 128 - fatal: this operation must be run in a work tree > - fatal: this operation must be run in a work tree We need to clone a non-bare repository for `git read-tree -m` to work. https://github.com/go-gitea/gitea/commit/bb371aee6ecf5e570cdf7b5f7f0d6f47a607a325 adds support to create a non-bare cloned temporary upload repository. After cloning a non-bare temporary upload repository, we [set default index](https://github.com/go-gitea/gitea/blob/main/services/repository/files/cherry_pick.go#L37) (`git read-tree HEAD`). This operation ends up resetting the git index file (see investigation details below), due to which, we need to call `git update-index --refresh` afterward. Here's the diff of the index file before and after we execute SetDefaultIndex: https://www.diffchecker.com/hyOP3eJy/ Notice the **ctime**, **mtime** are set to 0 after SetDefaultIndex. You can reproduce the same behavior using these steps: ```bash $ git clone https://try.gitea.io/me-heer/test.git -s -b main $ cd test $ git read-tree HEAD $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 error: Entry '1' not uptodate. Cannot merge. ``` After which, we can fix like this: ```bash $ git update-index --refresh $ git read-tree -m 1f085d7ed8 1f085d7ed8 9933caed00 ```
* Rework markup link rendering (#26745) (#28803)KN4CK3R2024-01-162-6/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #26745 Fixes #26548 This PR refactors the rendering of markup links. The old code uses `strings.Replace` to change some urls while the new code uses more context to decide which link should be generated. The added tests should ensure the same output for the old and new behaviour (besides the bug). We may need to refactor the rendering a bit more to make it clear how the different helper methods render the input string. There are lots of options (resolve links / images / mentions / git hashes / emojis / ...) but you don't really know what helper uses which options. For example, we currently support images in the user description which should not be allowed I think: <details> <summary>Profile</summary> https://try.gitea.io/KN4CK3R ![grafik](https://github.com/go-gitea/gitea/assets/1666336/109ae422-496d-4200-b52e-b3a528f553e5) </details>
* Forbid removing the last admin user (#28337) (#28793)Giteabot2024-01-161-1/+6
| | | | | | Backport #28337 by @yp05327 Co-authored-by: yp05327 <576951401@qq.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Fix schedule tasks bugs (#28691) (#28780)Lunny Xiao2024-01-145-22/+131
| | | | | | | | | | | | | | Fix #28157 Backport #28691 This PR fix the possible bugs about actions schedule. - Move `UpdateRepositoryUnit` and `SetRepoDefaultBranch` from models to service layer - Remove schedules plan from database and cancel waiting & running schedules tasks in this repository when actions unit has been disabled or global disabled. - Remove schedules plan from database and cancel waiting & running schedules tasks in this repository when default branch changed.
* Fix `convert.ToTeams` on empty input (#28426) (#28767)Giteabot2024-01-122-26/+26
| | | | | | | | | Backport #28426 by @KN4CK3R Fixes #28420 Don't return `nil` if the input was empty. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Concatenate error in `checkIfPRContentChanged` (#28731) (#28737)Giteabot2024-01-091-0/+4
| | | | | | | | | | | | Backport #28731 by @earl-warren - If there's a error with the Git command in `checkIfPRContentChanged` the stderr wasn't concatendated to the error, which results in still not knowing why an error happend. - Adds concatenation for stderr to the returned error. - Ref: https://codeberg.org/forgejo/forgejo/issues/2077 Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Fix alpine package files are not rebuilt (#28638) (#28665)Giteabot2023-12-311-0/+5
| | | | | | | | | Backport #28638 by @lng2020 I noticed the `BuildAllRepositoryFiles` function under the Alpine folder is unused and I thought it was a bug. But I'm not sure about this. Was it on purpose? Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* fix empty ref for cron workflow runs (#28640) (#28647)Giteabot2023-12-291-2/+3
| | | | | | | | | | Backport #28640 by @denyskon Fix #27678 Please see https://github.com/go-gitea/gitea/issues/27678#issuecomment-1871445853 for details. Co-authored-by: Denys Konovalov <kontakt@denyskon.de>
* Remove unnecessary syncbranchToDB with tests (#28624) (#28629)Lunny Xiao2023-12-291-20/+9
| | | | | | | | | | Replace #28625 Backport #28624 by lunny #28361 introduced `syncBranchToDB` in `CreateNewBranchFromCommit`. This PR will revert the change because it's unnecessary. Every push will already be checked by `syncBranchToDB`. This PR also created a test to ensure it's right.
* Use known issue IID to generate new PR index number when migrating from ↵Giteabot2023-12-272-11/+45
| | | | | | | | | GitLab (#28616) (#28618) Backport #28616 by wxiaoguang Fix #13884 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add option to disable ambiguous unicode characters detection (#28454) (#28499)wxiaoguang2023-12-182-6/+6
| | | | | | | | Backport #28454 (the only conflict is caused by some comments) * Close #24483 * Close #28123 * Close #23682 * Close #23149
* Fix possible nil pointer access (#28428) (#28440)Giteabot2023-12-124-28/+14
| | | | | | | | Backport #28428 by @KN4CK3R There could be a nil pointer exception if the file is not found because that specific error is suppressed but not handled. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Deprecate query string auth tokens (#28390) (#28430)Giteabot2023-12-121-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #28390 by @jackHay22 ## Changes - Add deprecation warning to `Token` and `AccessToken` authentication methods in swagger. - Add deprecation warning header to API response. Example: ``` HTTP/1.1 200 OK ... Warning: token and access_token API authentication is deprecated ... ``` - Add setting `DISABLE_QUERY_AUTH_TOKEN` to reject query string auth tokens entirely. Default is `false` ## Next steps - `DISABLE_QUERY_AUTH_TOKEN` should be true in a subsequent release and the methods should be removed in swagger - `DISABLE_QUERY_AUTH_TOKEN` should be removed and the implementation of the auth methods in question should be removed ## Open questions - Should there be further changes to the swagger documentation? Deprecation is not yet supported for security definitions (coming in [OpenAPI Spec version 3.2.0](https://github.com/OAI/OpenAPI-Specification/issues/2506)) - Should the API router logger sanitize urls that use `token` or `access_token`? (This is obviously an insufficient solution on its own) Co-authored-by: Jack Hay <jack@allspice.io> Co-authored-by: delvh <dev.lh@web.de>
* Recover from panic in cron task (#28409) (#28425)Giteabot2023-12-121-5/+7
| | | | | | | | | | | | | | | | | Backport #28409 by @earl-warren - Currently there's code to recover gracefully from panics that happen within the execution of cron tasks. However this recover code wasn't being run, because `RunWithShutdownContext` also contains code to recover from any panic and then gracefully shutdown Forgejo. Because `RunWithShutdownContext` registers that code as last, that would get run first which in this case is not behavior that we want. - Move the recover code to inside the function, so that is run first before `RunWithShutdownContext`'s recover code (which is now a noop). Fixes: https://codeberg.org/forgejo/forgejo/issues/1910 Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Also sync DB branches on push if necessary (#28361) (#28403)Lunny Xiao2023-12-112-32/+72
| | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #28056 Backport #28361 This PR will check whether the repo has zero branch when pushing a branch. If that, it means this repository hasn't been synced. The reason caused that is after user upgrade from v1.20 -> v1.21, he just push branches without visit the repository user interface. Because all repositories routers will check whether a branches sync is necessary but push has not such check. For every repository, it has two states, synced or not synced. If there is zero branch for a repository, then it will be assumed as non-sync state. Otherwise, it's synced state. So if we think it's synced, we just need to update branch/insert new branch. Otherwise do a full sync. So that, for every push, there will be almost no extra load added. It's high performance than yours. For the implementation, we in fact will try to update the branch first, if updated success with affect records > 0, then all are done. Because that means the branch has been in the database. If no record is affected, that means the branch does not exist in database. So there are two possibilities. One is this is a new branch, then we just need to insert the record. Another is the branches haven't been synced, then we need to sync all the branches into database.
* Fix migration panic due to an empty review comment diff (#28334) (#28362)Giteabot2023-12-051-1/+1
| | | | | | | | | | | | | | | | | | | | | Backport #28334 by @lng2020 Fix #28328 ``` func (p *PullRequestComment) GetDiffHunk() string { if p == nil || p.DiffHunk == nil { return "" } return *p.DiffHunk } ``` This function in the package `go-github` may return an empty diff. When it's empty, the following code will panic because it access `ss[1]` https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/services/migrations/gitea_uploader.go#L861-L867 https://github.com/go-gitea/gitea/blob/ec1feedbf582b05b6a5e8c59fb2457f25d053ba2/modules/git/diff.go#L97-L101 Co-authored-by: Nanguan Lin <70063547+lng2020@users.noreply.github.com>
* Fix RPM/Debian signature key creation (#28352) (#28353)Giteabot2023-12-052-4/+3
| | | | | | | | | | | Backport #28352 by @KN4CK3R Fixes #28324 The name parameter can't contain some characters (https://github.com/keybase/go-crypto/blob/master/openpgp/keys.go#L680) but is optional. Therefore just use an empty string. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix missing issue search index update when changing status (#28325) (#28330)Giteabot2023-12-031-0/+22
| | | | | | | | | Backport #28325 by @brechtvl Changing an issue status, assignee, labels or milestone without also adding a comment would not update the index, resulting in wrong search results. Co-authored-by: Brecht Van Lommel <brecht@blender.org>
* Fix required error for token name (#28267) (#28284)Giteabot2023-11-291-1/+1
| | | | | | | | | | | | Backport #28267 by @earl-warren - Say to the binding middleware which locale should be used for the required error. - Resolves https://codeberg.org/forgejo/forgejo/issues/1683 (cherry picked from commit 5a2d7966127b5639332038e9925d858ab54fc360) Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Fix comment permissions (#28213) (#28216)Lunny Xiao2023-11-252-15/+5
| | | | | | | backport #28213 This PR will fix some missed checks for private repositories' data on web routes and API routes.
* Fix Matrix and MSTeams nil dereference (#28089) (#28105)Giteabot2023-11-1711-6/+155
| | | | | | | | | | | Backport #28089 by @KN4CK3R Fixes #28088 Fixes #28094 Added missing tests. Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Unify two factor check (#27915) (#27929)Giteabot2023-11-061-2/+22
| | | | | | | | | | | | Backport #27915 by @KN4CK3R Fixes #27819 We have support for two factor logins with the normal web login and with basic auth. For basic auth the two factor check was implemented at three different places and you need to know that this check is necessary. This PR moves the check into the basic auth itself. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Remove action runners on user deletion (#27902) (#27908)Giteabot2023-11-051-0/+2
| | | | | | | | | | | | | Backport #27902 by @earl-warren - On user deletion, delete action runners that the user has created. - Add a database consistency check to remove action runners that have nonexistent belonging owner. - Resolves https://codeberg.org/forgejo/forgejo/issues/1720 (cherry picked from commit 009ca7223dab054f7f760b7ccae69e745eebfabb) Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz>
* Fix DownloadFunc when migrating releases (#27887) (#27890)Giteabot2023-11-032-6/+9
| | | | | | | | | | | | | Backport #27887 by @Zettat123 We should not use `asset.ID` in DownloadFunc because DownloadFunc is a closure. https://github.com/go-gitea/gitea/blob/1bf5527eac6b947010c8faf408f6747de2a2384f/services/migrations/gitea_downloader.go#L284-L295 A similar bug when migrating from GitHub has been fixed in #14703. This PR fixes the bug when migrating from Gitea and GitLab. Co-authored-by: Zettat123 <zettat123@gmail.com>
* Delete repos of org when purge delete user (#27273) (#27728)65432023-11-017-40/+67
| | | | | | | | | Fixes https://codeberg.org/forgejo/forgejo/issues/1514 Backports #27273 --------- Co-authored-by: JakobDev <jakobdev@gmx.de>
* Clean up template locale usage (#27856) (#27857)wxiaoguang2023-10-316-46/+15
| | | | | | | Backport #27856 The only conflict is `ThemeName` in `500.tmpl`, it has been resolved manually by keeping using old `{{.SignedUser.Theme}}{{else}}{{DefaultTheme}}`
* Fix package webhook (#27839) (#27855)Giteabot2023-10-3112-1/+92
| | | | | | | | Backport #27839 by @lunny Fix #23742 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Close all hashed buffers (#27787) (#27790)Giteabot2023-10-253-0/+18
| | | | | | | | Backport #27787 by @KN4CK3R Add missing `.Close()` calls. The current code does not delete the temporary files if the data grows over 32mb. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Do not force creation of _cargo-index repo on publish (#27266) (#27765)Giteabot2023-10-242-5/+11
| | | | | | | | | | | | | | | | | | | | | | | Backport #27266 by @merlleu Hello there, Cargo Index over HTTP is now prefered over git for package updates: we should not force users who do not need the GIT repo to have the repo created/updated on each publish (it can still be created in the packages settings). The current behavior when publishing is to check if the repo exist and create it on the fly if not, then update it's content. Cargo HTTP Index does not rely on the repo itself so this will be useless for everyone not using the git protocol for cargo registry. This PR only disable the creation on the fly of the repo when publishing a crate. This is linked to #26844 (error 500 when trying to publish a crate if user is missing write access to the repo) because it's now optional. Co-authored-by: merlleu <r.langdorph@gmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix incorrect ctx usage in defer function (#27740) (#27741)wxiaoguang2023-10-221-2/+2
|
* Add doctor dbconsistency fix to delete repos with no owner (#27290) (#27693)65432023-10-221-6/+9
| | | Backport #27290
* Always delete existing scheduled action tasks (#27662) (#27688)Giteabot2023-10-191-11/+8
| | | | | | | Backport #27662 by @KN4CK3R Fixes #27650 Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Support allowed hosts for webhook to work with proxy (#27655) (#27675)Giteabot2023-10-182-18/+58
| | | | | | | | | | | | | | | | | | | | | Backport #27655 by @wolfogre When `webhook.PROXY_URL` has been set, the old code will check if the proxy host is in `ALLOWED_HOST_LIST` or reject requests through the proxy. It requires users to add the proxy host to `ALLOWED_HOST_LIST`. However, it actually allows all requests to any port on the host, when the proxy host is probably an internal address. But things may be even worse. `ALLOWED_HOST_LIST` doesn't really work when requests are sent to the allowed proxy, and the proxy could forward them to any hosts. This PR fixes it by: - If the proxy has been set, always allow connectioins to the host and port. - Check `ALLOWED_HOST_LIST` before forwarding. Co-authored-by: Jason Song <i@wolfogre.com>
* Fix poster is not loaded in get default merge message (#27657) (#27666)Giteabot2023-10-171-0/+3
| | | | | Backport #27657 by @lunny Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Improve retrying index issues (#27554) (#27634)Giteabot2023-10-162-9/+9
| | | | | | | Backport #27554 by @wolfogre Fix #27540 Co-authored-by: Jason Song <i@wolfogre.com>
* Fix data-race bug when accessing task.LastRun (#27584) (#27586)Giteabot2023-10-111-2/+1
| | | | | Backport #27584 by @wxiaoguang Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* show manual cron run's last time (#27544) (#27577)Giteabot2023-10-112-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | Backport #27544 by @earl-warren - Currently in the cron tasks, the 'Previous Time' only displays the previous time of when the cron library executes the function, but not any of the manual executions of the task. - Store the last run's time in memory in the Task struct and use that, when that time is later than time that the cron library has executed this task. - This ensures that if an instance admin manually starts a task, there's feedback that this task is/has been run, because the task might be run that quick, that the status icon already has been changed to an checkmark, - Tasks that are executed at startup now reflect this as well, as the time of the execution of that task on startup is now being shown as 'Previous Time'. - Added integration tests for the API part, which is easier to test because querying the HTML table of cron tasks is non-trivial. - Resolves https://codeberg.org/forgejo/forgejo/issues/949 (cherry picked from commit fd34fdac1408ece6b7d9fe6a76501ed9a45d06fa) Co-authored-by: Earl Warren <109468362+earl-warren@users.noreply.github.com> Co-authored-by: Gusted <postmaster@gusted.xyz> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: silverwind <me@silverwind.io>
* Fix attachment download bug (#27486) (#27571)Giteabot2023-10-116-21/+21
| | | | | | | | | | | Backport #27486 by @lunny Fix #27204 This PR allows `/<username>/<reponame>/attachments/<uuid>` access with personal access token and also changed attachments API download url to it so it can be download correctly. Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Avoid run change title process when the title is same (#27467) (#27558)yp053272023-10-101-0/+4
| | | Backport #27467 manually.
* Make Actions tasks/jobs timeouts configurable by the user (#27400) (#27402)Giteabot2023-10-031-9/+4
| | | | | | | | | | | | | | | | | | | | | Backport #27400 by @fantognazza With this PR we added the possibility to configure the Actions timeouts values for killing tasks/jobs. Particularly this enhancement is closely related to the `act_runner` configuration reported below: ``` # The timeout for a job to be finished. # Please note that the Gitea instance also has a timeout (3h by default) for the job. # So the job could be stopped by the Gitea instance if it's timeout is shorter than this. timeout: 3h ``` --- Setting the corresponding key in the INI configuration file, it is possible to let jobs run for more than 3 hours. Signed-off-by: Francesco Antognazza <francesco.antognazza@gmail.com>
* Allow get release download files and lfs files with oauth2 token format ↵Giteabot2023-10-011-1/+3
| | | | | | | | | | (#26430) (#27379) Backport #26430 by @lunny Fix #26165 Fix #25257 Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* More `db.DefaultContext` refactor (#27265) (#27347)Giteabot2023-09-2915-43/+43
| | | | | | | | | | | Backport #27265 by @JakobDev Part of #27065 This PR touches functions used in templates. As templates are not static typed, errors are harder to find, but I hope I catch it all. I think some tests from other persons do not hurt. Co-authored-by: JakobDev <jakobdev@gmx.de>
* Fix Bug in Issue Config when only contact links are set (#26521) (#27334)Giteabot2023-09-281-1/+1
| | | | | | | | | | | | | | | | Backport #26521 by @JakobDev Blank Issues should be enabled if they are not explicit disabled through the `blank_issues_enabled` field of the Issue Config. The Implementation has currently a Bug: If you create a Issue Config file with only `contact_links` and without a `blank_issues_enabled` field, `blank_issues_enabled` is set to false by default. The fix is only one line, but I decided to also improve the tests to make sure there are no other problems with the Implementation. This is a bugfix, so it should be backported to 1.20. Co-authored-by: JakobDev <jakobdev@gmx.de>
* Another round of `db.DefaultContext` refactor (#27103) (#27262)Giteabot2023-09-2525-104/+113
| | | | | | | | Backport #27103 by @JakobDev Part of #27065 Co-authored-by: JakobDev <jakobdev@gmx.de> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Fix PushEvent NullPointerException jenkinsci/github-plugin (#27203) (#27251)Giteabot2023-09-251-0/+1
| | | | | | | Backport #27203 by @Nabapadma-sarker Fixes #27202 Co-authored-by: Nabapadma-sarker <nabapadmacse1991@gmail.com>
* Fix release URL in webhooks (#27182) (#27185)Giteabot2023-09-219-9/+9
| | | | | | | | | | | | Backport #27182 by @jolheiser Resolves #27180 `URL` points to the API URL, `HTMLURL` points to the web page. Notably, however, for PRs they are the same URL. I switched them to use HTMLURL to match the rest of the codebase terminology. Co-authored-by: John Olheiser <john.olheiser@gmail.com>
* Fix successful return value for `SyncAndGetUserSpecificDiff` (#27152)v1.21.0-rc0delvh2023-09-201-1/+1
| | | | A function should not return an error when it is successful. Otherwise, things like https://discord.com/channels/322538954119184384/322538954119184384/1153705341620600833 happen…