summaryrefslogtreecommitdiffstats
path: root/modules
Commit message (Collapse)AuthorAgeFilesLines
* Remove DataRaceCheck (#29258)wxiaoguang2024-02-191-14/+0
| | | | | Since #26254, it started using `{{ctx.Locale.Tr ...}}` Now the `ctx` seems stable enough, so the check could be removed.
* Use general token signing secret (#29205)wxiaoguang2024-02-185-20/+76
| | | Use a clearly defined "signing secret" for token signing.
* Improve TrHTML and add more tests (#29228)wxiaoguang2024-02-182-3/+71
| | | | | Follow #29165. Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Implement some action notifier functions (#29173)yp053272024-02-182-4/+8
| | | | | | | | | | | Fix #29166 Add support for the following activity types of `pull_request` - assigned - unassigned - review_requested - review_request_removed - milestoned - demilestoned
* Refactor more code in templates (#29236)wxiaoguang2024-02-183-1/+23
| | | | | | | | Follow #29165. * Introduce JSONTemplate to help to render JSON templates * Introduce JSEscapeSafe for templates. Now only use `{{ ... | JSEscape}}` instead of `{{ ... | JSEscape | Safe}}` * Simplify "UserLocationMapURL" useage
* Refactor JWT secret generating & decoding code (#29172)wxiaoguang2024-02-166-43/+53
| | | | | | | | Old code is not consistent for generating & decoding the JWT secrets. Now, the callers only need to use 2 consistent functions: NewJwtSecretWithBase64 and DecodeJwtSecretBase64 And remove a non-common function Base64FixedDecode from util.go
* Refactor locale&string&template related code (#29165)wxiaoguang2024-02-1420-133/+203
| | | | | | Clarify when "string" should be used (and be escaped), and when "template.HTML" should be used (no need to escape) And help PRs like #29059 , to render the error messages correctly.
* bump to use go 1.22 (#29119)techknowlogick2024-02-142-8/+8
|
* Refactor git version functions and check compatibility (#29155)wxiaoguang2024-02-142-30/+70
| | | | | | | | | | | | Introduce a new function checkGitVersionCompatibility, when the git version can't be used by Gitea, tell the end users to downgrade or upgrade. The refactored functions are related to make the code easier to test. And simplify the comments for "safe.directory" --------- Co-authored-by: delvh <dev.lh@web.de>
* Add merge style `fast-forward-only` (#28954)Chris Copeland2024-02-123-3/+10
| | | | | | | | | With this option, it is possible to require a linear commit history with the following benefits over the next best option `Rebase+fast-forward`: The original commits continue existing, with the original signatures continuing to stay valid instead of being rewritten, there is no merge commit, and reverting commits becomes easier. Closes #24906
* Add alert blocks in markdown (#29121)Yarden Shoham2024-02-103-24/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Follows https://github.com/go-gitea/gitea/pull/21711 - Closes https://github.com/go-gitea/gitea/issues/28316 Implement GitHub's alert blocks markdown feature Docs: - https://docs.github.com/en/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts - https://github.com/orgs/community/discussions/16925 ### Before ![image](https://github.com/go-gitea/gitea/assets/20454870/14f7b02a-5de5-4fd0-8437-a055dadb31f2) ### After ![image](https://github.com/go-gitea/gitea/assets/20454870/ed06a869-e545-42f1-bf25-4ba20b1be196) ## :warning: BREAKING :warning: The old syntax no longer works How to migrate: If you used ```md > **Note** My note ``` Switch to ```md > [!NOTE] > My note ``` --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
* Disallow duplicate storage paths (#26484)Lunny Xiao2024-02-097-20/+42
| | | | Replace #26380
* Refactor parseSignatureFromCommitLine (#29054)wxiaoguang2024-02-098-149/+104
| | | | | | | | | | | | Replace #28849. Thanks to @yp05327 for the looking into the problem. Fix #28840 The old behavior of newSignatureFromCommitline is not right. The new parseSignatureFromCommitLine: 1. never fails 2. only accept one format (if there is any other, it could be easily added) And add some tests.
* Remove unnecessary parameter (#29092)Lunny Xiao2024-02-082-9/+3
| | | | The parameter extraConfigs has never been used anywhere. This PR just removed it. It can be taken back once it's needed.
* Improve user experience for outdated comments (#29050)wxiaoguang2024-02-081-2/+13
| | | | | | | | | | Try to improve #28949 1. Make `ctx.Data["ShowOutdatedComments"] = true` by default: it brings consistent user experience, and sometimes the "outdated (source changed)" comments are still valuable. 2. Show a friendly message if the comment won't show, then the end users won't fell that "the comment disappears" (it is the special case when `ShowOutdatedComments = false`)
* fix: Elasticsearch: Request Entity Too Large #28117 (#29062)dark-angel2024-02-071-5/+11
| | | | | | | | | | | | | | | | Fix for gitea putting everything into one request without batching and sending it to Elasticsearch for indexing as issued in #28117 This issue occured in large repositories while Gitea tries to index the code using ElasticSearch. I've applied necessary changes that takes batch length from below config (app.ini) ``` [queue.code_indexer] BATCH_LENGTH=<length_int> ``` and batches all requests to Elasticsearch in chunks as configured in the above config
* Fix orgmode link resolving (#29024)wxiaoguang2024-02-072-39/+41
| | | | | Fix #28974 Add some new tests and fix some legacy unclear tests.
* Propagate install_if and provider_priority to APKINDEX (#28899)Sergey Bugaev2024-02-051-10/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolves https://github.com/go-gitea/gitea/issues/28704 Example of an entry in the generated `APKINDEX` file: ``` C:Q1xCO3H9LTTEbhKt9G1alSC87I56c= P:hello V:2.12-r1 A:x86_64 T:The GNU Hello program produces a familiar, friendly greeting U:https://www.gnu.org/software/hello/ L:GPL-3.0-or-later S:15403 I:36864 o:hello m: t:1705934118 D:so:libc.musl-x86_64.so.1 p:cmd:hello=2.12-r1 i:foobar=1.0 !baz k:42 ``` the `i:` and `k:` entries are new. --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Show whether a PR is WIP inside popups (#28975)Bram Hagens2024-02-041-2/+3
| | | | | | | | | | | | | | | | | | Fixes https://codeberg.org/forgejo/forgejo/issues/2257 Draft status of a PR is currently not exposed by the API. This PR adds a 'draft' field to pull requests in the API, which is used to correctly set the PR color/icon in a ContextPopup. --- Before: ![image](https://github.com/go-gitea/gitea/assets/5541521/72cbd30e-1175-4338-aa97-ac99c46c5118) After: ![image](https://github.com/go-gitea/gitea/assets/5541521/111c9eba-460e-4d57-bcca-23a151c3a4f1)
* Unify user update methods (#28733)KN4CK3R2024-02-046-69/+162
| | | | | | | | | | | Fixes #28660 Fixes an admin api bug related to `user.LoginSource` Fixed `/user/emails` response not identical to GitHub api This PR unifies the user update methods. The goal is to keep the logic only at one place (having audit logs in mind). For example, do the password checks only in one method not everywhere a password is updated. After that PR is merged, the user creation should be next.
* Update tool dependencies (#29030)silverwind2024-02-022-2/+0
|
* Fix default avatar image size in PR diff page (#28971)yp053272024-02-021-1/+1
| | | | | Fix #28941 ps: didn't test. The repo is too big to migrate.
* Fix an actions schedule bug (#28942)Zettat1232024-01-311-0/+35
| | | | | | | | | In #28691, schedule plans will be deleted when a repo's actions unit is disabled. But when the unit is enabled, the schedule plans won't be created again. This PR fixes the bug. The schedule plans will be created again when the actions unit is re-enabled
* Also match weakly validated ETags (#28957)cchangwen2024-01-291-1/+1
| | | | | | | | | https://stackoverflow.com/questions/51973120/where-does-the-w-in-an-etag-appear-from https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag# --------- Co-authored-by: delvh <dev.lh@web.de>
* Fix bug for generated repository object format (#28969)Lunny Xiao2024-01-281-16/+15
| | | | A repository generated from a template repository should have the same git ObjectFormat.
* Fix inconsistent naming of OAuth 2.0 `ENABLE` setting (#28951)wackbyte2024-01-281-6/+13
| | | | | | | | | | | | Renames it to `ENABLED` to be consistent with other settings and deprecates it. I believe this change is necessary because other setting groups such as `attachment`, `cors`, `mailer`, etc. have an `ENABLED` setting, but `oauth2` is the only one with an `ENABLE` setting, which could cause confusion for users. This is no longer a breaking change because `ENABLE` has been set as deprecated and as an alias to `ENABLED`.
* Simplify how git repositories are opened (#28937)Lunny Xiao2024-01-2716-125/+219
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Purpose This is a refactor toward building an abstraction over managing git repositories. Afterwards, it does not matter anymore if they are stored on the local disk or somewhere remote. ## What this PR changes We used `git.OpenRepository` everywhere previously. Now, we should split them into two distinct functions: Firstly, there are temporary repositories which do not change: ```go git.OpenRepository(ctx, diskPath) ``` Gitea managed repositories having a record in the database in the `repository` table are moved into the new package `gitrepo`: ```go gitrepo.OpenRepository(ctx, repo_model.Repo) ``` Why is `repo_model.Repository` the second parameter instead of file path? Because then we can easily adapt our repository storage strategy. The repositories can be stored locally, however, they could just as well be stored on a remote server. ## Further changes in other PRs - A Git Command wrapper on package `gitrepo` could be created. i.e. `NewCommand(ctx, repo_model.Repository, commands...)`. `git.RunOpts{Dir: repo.RepoPath()}`, the directory should be empty before invoking this method and it can be filled in the function only. #28940 - Remove the `RepoPath()`/`WikiPath()` functions to reduce the possibility of mistakes. --------- Co-authored-by: delvh <dev.lh@web.de>
* Preserve BOM in web editor (#28935)silverwind2024-01-274-122/+58
| | | | | | | | | | | | | | | | | | | The `ToUTF8*` functions were stripping BOM, while BOM is actually valid in UTF8, so the stripping must be optional depending on use case. This does: - Add a options struct to all `ToUTF8*` functions, that by default will strip BOM to preserve existing behaviour - Remove `ToUTF8` function, it was dead code - Rename `ToUTF8WithErr` to `ToUTF8` - Preserve BOM in Monaco Editor - Remove a unnecessary newline in the textarea value. Browsers did ignore it, it seems but it's better not to rely on this behaviour. Fixes: https://github.com/go-gitea/gitea/issues/28743 Related: https://github.com/go-gitea/gitea/issues/6716 which seems to have once introduced a mechanism that strips and re-adds the BOM, but from what I can tell, this mechanism was removed at some point after that PR.
* Strip `/` from relative links (#28932)KN4CK3R2024-01-272-4/+32
| | | | | | | Fixes #28915 Restores the old behaviour: https://github.com/go-gitea/gitea/pull/26745/files#diff-d78a9d361b1fddc12218e4dd42f42d39d6be1fda184041e06bb6fb30f0d94c59L96
* Don't remove all mirror repository's releases when mirroring (#28817)Lunny Xiao2024-01-262-6/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix #22066 # Purpose This PR fix the releases will be deleted when mirror repository sync the tags. # The problem In the previous implementation of #19125. All releases record in databases of one mirror repository will be deleted before sync. Ref: https://github.com/go-gitea/gitea/pull/19125/files#diff-2aa04998a791c30e5a02b49a97c07fcd93d50e8b31640ce2ddb1afeebf605d02R481 # The Pros This PR introduced a new method which will load all releases from databases and all tags on git data into memory. And detect which tags needs to be inserted, which tags need to be updated or deleted. Only tags releases(IsTag=true) which are not included in git data will be deleted, only tags which sha1 changed will be updated. So it will not delete any real releases include drafts. # The Cons The drawback is the memory usage will be higher than before if there are many tags on this repository. This PR defined a special release struct to reduce columns loaded from database to memory.
* Use new RPM constants (#28931)KN4CK3R2024-01-251-1/+1
| | | https://github.com/sassoftware/go-rpmutils/pull/24 got merged.
* Check for sha256 support to use --object-format flag (#28928)John Olheiser2024-01-251-1/+3
| | | | | | | | | | | | This should fix https://github.com/go-gitea/gitea/issues/28927 Technically older versions of Git would support this flag as well, but per https://github.com/go-gitea/gitea/pull/28466 that's the version where using it (object-format=sha256) left "experimental" state. `sha1` is (currently) the default, so older clients should be unaffected in either case. Signed-off-by: jolheiser <john.olheiser@gmail.com>
* Respect branch info for relative links (#28909)KN4CK3R2024-01-252-2/+4
| | | | | Fix #28904 Co-authored-by: Giteabot <teabot@gitea.io>
* Allow to sync tags from admin dashboard (#28045)JakobDev2024-01-241-0/+16
| | | | | | | | | Inspired by #28043 This PR adds a option to the Admin Dashboard to sync all tags to the database. ![grafik](https://github.com/go-gitea/gitea/assets/15185051/26ac51ef-82a4-4fd9-a6a6-5aefec612ff6)
* Update go dependencies and fix go-git (#28893)wxiaoguang2024-01-232-3/+12
| | | | | More details are in the comment of repo_base_gogit.go And ref: https://github.com/go-git/go-git/issues/1006
* Fix sort bug on repository issues list (#28897)Lunny Xiao2024-01-231-2/+2
| | | Fix #28896
* Prevent anonymous container access if `RequireSignInView` is enabled (#28877)KN4CK3R2024-01-211-1/+1
| | | | | Fixes #28875 If `RequireSignInView` is enabled, the ghost user has no access rights.
* Fix incorrect PostgreSQL connection string for Unix sockets (#28865)sdvcrx2024-01-202-2/+10
| | | Fix #28864
* Move doctor package from modules to services (#28856)Lunny Xiao2024-01-2017-2386/+0
|
* Add support for sha256 repositories (#23894)Adam Majer2024-01-1972-38/+572
| | | | | | | | | | | | | | | | Currently only SHA1 repositories are supported by Gitea. This adds support for alternate SHA256 with the additional aim of easier support for additional hash types in the future. Fixes: #13794 Limited by: https://github.com/go-git/go-git/issues/899 Depend on: #28138 <img width="776" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/5448c9a7-608e-4341-a149-5dd0069c9447"> --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: 6543 <6543@obermui.de>
* Fix some RPM registry flaws (#28782)KN4CK3R2024-01-193-6/+12
| | | | | | | | | | | | | | | | | | | Related #26984 (https://github.com/go-gitea/gitea/pull/26984#issuecomment-1889588912) Fix admin cleanup message. Fix models `Get` not respecting default values. Rebuild RPM repository files after cleanup. Do not add RPM group to package version name. Force stable sorting of Alpine/Debian/RPM repository data. Fix missing deferred `Close`. Add tests for multiple RPM groups. Removed non-cached `ReplaceAllStringRegex`. If there are multiple groups available, it's stated in the package installation screen: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/8f132760-882c-4ab8-9678-77e47dfc4415)
* Fix archive creating LFS hooks and breaking pull requests (#28848)Brecht Van Lommel2024-01-191-0/+5
| | | | | | | | | | | | | | | | | | | | | | When LFS hooks are present in gitea-repositories, operations like git push for creating a pull request fail. These repositories are not meant to include LFS files or git push them, that is handled separately. And so they should not have LFS hooks. Installing git-lfs on some systems (like Debian Linux) will automatically set up /etc/gitconfig to create LFS hooks in repositories. For most git commands in Gitea this is not a problem, either because they run on a temporary clone or the git command does not create LFS hooks. But one case where this happens is git archive for creating repository archives. To fix that, add a GIT_CONFIG_NOSYSTEM=1 to disable using the system configuration for that command. According to a comment, GIT_CONFIG_NOSYSTEM is not used for all git commands because the system configuration can be intentionally set up for Gitea to use. Resolves #19810, #21148
* Return `responseText` instead of string in some functions (#28836)yp053272024-01-195-27/+15
| | | | Follow https://github.com/go-gitea/gitea/pull/28796#issuecomment-1891727591
* Remove duplicated checkinit on git module (#28824)Lunny Xiao2024-01-171-4/+0
| | | | `checkInit` has been invoked in `InitSimple`. So it's unnecessary to invoke it twice in `InitFull`.
* Retarget depending pulls when the parent branch is deleted (#28686)Viktor Kuzmin2024-01-171-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes you need to work on a feature which depends on another (unmerged) feature. In this case, you may create a PR based on that feature instead of the main branch. Currently, such PRs will be closed without the possibility to reopen in case the parent feature is merged and its branch is deleted. Automatic target branch change make life a lot easier in such cases. Github and Bitbucket behave in such way. Example: $PR_1$: main <- feature1 $PR_2$: feature1 <- feature2 Currently, merging $PR_1$ and deleting its branch leads to $PR_2$ being closed without the possibility to reopen. This is both annoying and loses the review history when you open a new PR. With this change, $PR_2$ will change its target branch to main ($PR_2$: main <- feature2) after $PR_1$ has been merged and its branch has been deleted. This behavior is enabled by default but can be disabled. For security reasons, this target branch change will not be executed when merging PRs targeting another repo. Fixes #27062 Fixes #18408 --------- Co-authored-by: Denys Konovalov <kontakt@denyskon.de> Co-authored-by: delvh <dev.lh@web.de>
* Use refname:strip-2 instead of refname:short when syncing tags (#28797)Lunny Xiao2024-01-163-13/+15
| | | | | | | | | Fix #28694 Generally, `refname:short` should be equal to `refname:lstrip=2` except `core.warnAmbiguousRefs is used to select the strict abbreviation mode.` ref: https://git-scm.com/docs/git-for-each-ref#Documentation/git-for-each-ref.txt-refname
* Caller should check the ResponseExtra.HasError() first to see whether the ↵wxiaoguang2024-01-154-3/+4
| | | | | | request fails (#28796) `resp != nil` doesn't mean the request really succeeded. Add a comment for requestJSONResp to clarify the behavior.
* Rework markup link rendering (#26745)KN4CK3R2024-01-1513-240/+745
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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> --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Fix nil pointer panic when exec some gitea cli command (#28791)yp053272024-01-153-0/+9
| | | | | | | | | panic: ![image](https://github.com/go-gitea/gitea/assets/18380374/7fcde2ad-1d42-4b60-b120-3b60a8926e8e) After: ![image](https://github.com/go-gitea/gitea/assets/18380374/49d9f0ca-e590-4a35-8ca2-1317d1b7c939)
* Add branch protection setting for ignoring stale approvals (#28498)Jimmy Praet2024-01-151-0/+3
| | | | | | | | | | | | | | | | | | | | | | Fixes #27114. * In Gitea 1.12 (#9532), a "dismiss stale approvals" branch protection setting was introduced, for ignoring stale reviews when verifying the approval count of a pull request. * In Gitea 1.14 (#12674), the "dismiss review" feature was added. * This caused confusion with users (#25858), as "dismiss" now means 2 different things. * In Gitea 1.20 (#25882), the behavior of the "dismiss stale approvals" branch protection was modified to actually dismiss the stale review. For some users this new behavior of dismissing the stale reviews is not desirable. So this PR reintroduces the old behavior as a new "ignore stale approvals" branch protection setting. --------- Co-authored-by: delvh <dev.lh@web.de>