aboutsummaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* Use strict protocol check when redirect (#29642)wxiaoguang2024-03-072-1/+48
|
* Add download URL for executable files (#28260)Earl Warren2024-03-061-1/+1
| | | | | | Consider executable files as a valid case when returning a DownloadURL for them. They are just regular files with the difference being the executable permission bit being set. Co-authored-by: Gusted <postmaster@gusted.xyz>
* Cache repository default branch commit status to reduce query on commit ↵Lunny Xiao2024-03-062-48/+135
| | | | | | | | | | | | | status table (#29444) After repository commit status has been introduced on dashaboard, the most top SQL comes from `GetLatestCommitStatusForPairs`. This PR adds a cache for the repository's default branch's latest combined commit status. When a new commit status updated, the cache will be marked as invalid. <img width="998" alt="image" src="https://github.com/go-gitea/gitea/assets/81045/76759de7-3a83-4d54-8571-278f5422aed3">
* Sync branches to DB immediately when handle git hook calling (#29493)Jason Song2024-03-062-44/+82
| | | | | | | | | | | Unlike other async processing in the queue, we should sync branches to the DB immediately when handling git hook calling. If it fails, users can see the error message in the output of the git command. It can avoid potential inconsistency issues, and help #29494. --------- Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Make wiki default branch name changable (#29603)wxiaoguang2024-03-065-57/+123
| | | | | | | | | Fix #29000 Fix #28685 Fix #18568 Related: #27497 And by the way fix #24036, add a Cancel button there (one line)
* A small refactor for agit implementation (#29614)Lunny Xiao2024-03-061-40/+33
| | | | | | | | This PR made the code simpler, reduced unnecessary database queries and fixed some warnning for the errors.New . --------- Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Add ac claim for old docker/build-push-action@v3 / current buildx gha cache ↵ChristopherHX2024-03-052-0/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#29584) Also resolves a warning for current releases ``` | ##[group]GitHub Actions runtime token ACs | ##[warning]Cannot parse GitHub Actions Runtime Token ACs: "undefined" is not valid JSON | ##[endgroup] ====> | ##[group]GitHub Actions runtime token ACs | ##[endgroup] ``` \* this is an error in v3 References in the docker org: - https://github.com/docker/build-push-action/blob/831ca179d3cf91cf0c90ca465a408fa61e2129a2/src/main.ts#L24 - https://github.com/docker/actions-toolkit/blob/7d8b4dc6694df35a06fae786427672ce27a8c18d/src/github.ts#L61 No known official action of GitHub makes use of this claim. Current releases throw an error when configure to use actions cache ``` | ERROR: failed to solve: failed to configure gha cache exporter: invalid token without access controls | ##[error]buildx failed with: ERROR: failed to solve: failed to configure gha cache exporter: invalid token without access controls ```
* Skip email domain check when admins edit user emails (#29609)Zettat1232024-03-052-6/+21
| | | | | | Follow #29522 Administrators should be able to set a user's email address even if the email address is not in `EMAIL_DOMAIN_ALLOWLIST`
* Add empty repo check in `DetectAndHandleSchedules` (#29606)yp053272024-03-051-0/+4
| | | ![image](https://github.com/go-gitea/gitea/assets/18380374/e6081301-bd3e-4cf6-ba4e-e574348dffb4)
* Make "/user/login" page redirect if the current user has signed in (#29583)wxiaoguang2024-03-051-1/+2
| | | | Fix #29582 and maybe more. Maybe fix #29116
* Add missing database transaction for new issue (#29490)Lunny Xiao2024-03-041-7/+16
| | | | When creating an issue, inserting issue, assign users and set project should be in the same transaction.
* Move some asymkey functions to service layer (#28894)Lunny Xiao2024-03-0411-17/+281
| | | | After the moving, all models will not depend on `util.Rename` so that I can do next step refactoring.
* Add user blocking (#29028)KN4CK3R2024-03-0419-38/+723
| | | | | | | | | | | | | | | | | | | | | | Fixes #17453 This PR adds the abbility to block a user from a personal account or organization to restrict how the blocked user can interact with the blocker. The docs explain what's the consequence of blocking a user. Screenshots: ![grafik](https://github.com/go-gitea/gitea/assets/1666336/4ed884f3-e06a-4862-afd3-3b8aa2488dc6) ![grafik](https://github.com/go-gitea/gitea/assets/1666336/ae6d4981-f252-4f50-a429-04f0f9f1cdf1) ![grafik](https://github.com/go-gitea/gitea/assets/1666336/ca153599-5b0f-4b4a-90fe-18bdfd6f0b6b) --------- Co-authored-by: Lauris BH <lauris@nix.lv>
* Enable/disable owner and repo projects independently (#28805)Denys Konovalov2024-03-042-1/+6
| | | | | | | | | | | | | | | Part of #23318 Add menu in repo settings to allow for repo admin to decide not just if projects are enabled or disabled per repo, but also which kind of projects (repo-level/owner-level) are enabled. If repo projects disabled, don't show the projects tab. ![grafik](https://github.com/go-gitea/gitea/assets/47871822/b9b43fb4-824b-47f9-b8e2-12004313647c) --------- Co-authored-by: delvh <dev.lh@web.de>
* Add an trailing slash to dashboard links (#29555)wxiaoguang2024-03-041-1/+3
| | | Fix #29533, and add some tests for "base/paginate.tmpl"
* Fix workflow trigger event IssueChangeXXX bug (#29559)yp053272024-03-031-2/+14
| | | | | | Bugs from #29308 Follow #29467 partly fix #29558
* Add option to set language in admin user view (#28449)65432024-03-021-0/+1
| | | | | | | | | | | ![image](https://github.com/go-gitea/gitea/assets/24977596/be7e3f92-af3f-4628-b4ed-abf6439687f3) `/admin/users/<UserID>/edit` ![image](https://github.com/go-gitea/gitea/assets/24977596/906af0dd-cceb-4ed9-9cd9-32c71ae1bf71) `/admin/users/<UserID>` --- *Sponsored by Kithara Software GmbH*
* Fix incorrect relative/absolute URL usages (#29531)wxiaoguang2024-03-021-1/+1
| | | | Add two "HTMLURL" methods for PackageDescriptor. And rename "FullWebLink" to "VersionWebLink"
* Add support for API blob upload of release attachments (#29507)KN4CK3R2024-03-021-3/+3
| | | | | | | | | | | | Fixes #29502 Our endpoint is not Github compatible. https://docs.github.com/en/rest/releases/assets?apiVersion=2022-11-28#upload-a-release-asset --------- Co-authored-by: Giteabot <teabot@gitea.io>
* remove util.OptionalBool and related functions (#29513)65432024-03-0211-30/+29
| | | | | | and migrate affected code _last refactoring bits to replace **util.OptionalBool** with **optional.Option[bool]**_
* Make PR form use toast to show error message (#29545)wxiaoguang2024-03-021-4/+5
| | | ![image](https://github.com/go-gitea/gitea/assets/2114189/b7a14ed6-db89-4f21-a590-66cd33307233)
* Fix incorrect diff expander for deletion of last lines in a file (#29501)silverwind2024-03-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes: https://github.com/go-gitea/gitea/issues/29498 I don't quite understand this code, but this change does seem to fix the issue and I tested a number of diffs with it and saw no issue. The function gets such value if last line is an addition: ``` LastLeftIdx: (int) 0, LastRightIdx: (int) 47, LeftIdx: (int) 47, RightIdx: (int) 48, ``` If it's a deletion, it gets: ``` LastLeftIdx: (int) 47, LastRightIdx: (int) 0, LeftIdx: (int) 48, RightIdx: (int) 47, ``` So I think it's correct to make this check respect both left and right side.
* Use a predictiable fork URL to allow forking repositories without providing ↵wxiaoguang2024-03-011-20/+0
| | | | | | | | | | a repo ID (#29519) Close #29512 The "fork" URL: * Before: `/repo/fork/{RepoID}` * After: `/{OwnerName}/{RepoName}/fork`
* Move migration functions to services layer (#29497)Lunny Xiao2024-03-012-1/+265
|
* Fix workflow trigger event bugs (#29467)Zettat1232024-02-281-1/+7
| | | | | | 1. Fix incorrect `HookEventType` for issue-related events in `IssueChangeAssignee` 2. Add `case "types"` in the `switch` block in `matchPullRequestEvent` to avoid warning logs
* Move generate from module to service (#29465)Lunny Xiao2024-02-285-5/+542
|
* The job should always run when `if` is `always()` (#29464)Zettat1232024-02-282-1/+76
| | | | | | | | | | | | | | | Fix #27906 According to GitHub's [documentation](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idneeds), a job should always run when its `if` is `always()` > If you would like a job to run even if a job it is dependent on did not succeed, use the `always()` conditional expression in `jobs.<job_id>.if`. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Let ctx.FormOptionalBool() return optional.Option[bool] (#29461)65432024-02-282-7/+7
| | | | just some refactoring bits towards replacing **util.OptionalBool** with **optional.Option[bool]**
* Move context from modules to services (#29440)Lunny Xiao2024-02-2755-37/+4489
| | | | | | | | | | | | | | | Since `modules/context` has to depend on `models` and many other packages, it should be moved from `modules/context` to `services/context` according to design principles. There is no logic code change on this PR, only move packages. - Move `code.gitea.io/gitea/modules/context` to `code.gitea.io/gitea/services/context` - Move `code.gitea.io/gitea/modules/contexttest` to `code.gitea.io/gitea/services/contexttest` because of depending on context - Move `code.gitea.io/gitea/modules/upload` to `code.gitea.io/gitea/services/context/upload` because of depending on context
* Ignore empty repo for CreateRepository in action notifier (#29416)yp053272024-02-261-0/+3
| | | Fix #29415
* Include resource state events in Gitlab downloads (#29382)Sebastian Brückner2024-02-262-0/+60
| | | | | | | | | | | Some specific events on Gitlab issues and merge requests are stored separately from comments as "resource state events". With this change, all relevant resource state events are downloaded during issue and merge request migration, and converted to comments. This PR also updates the template used to render comments to add support for migrated comments of these types. ref: https://docs.gitlab.com/ee/api/resource_state_events.html
* Integrate alpine `noarch` packages into other architectures index (#29137)KN4CK3R2024-02-251-8/+48
| | | | | | | | | | | | Fixes #26691 Revert #24972 The alpine package manager expects `noarch` packages in the index of other architectures too. --------- Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Use `crypto/sha256` (#29386)KN4CK3R2024-02-253-4/+3
| | | | | | | | Go 1.21 improved the performance of `crypto/sha256`. It's now similar to `minio/sha256-simd`, so we should just use the standard libs. https://go.dev/doc/go1.21#crypto/sha256 https://go-review.googlesource.com/c/go/+/408795 https://github.com/multiformats/go-multihash/pull/173
* Add attachment support for code review comments (#29220)Jimmy Praet2024-02-253-2/+7
| | | | | | | Fixes #27960, #24411, #12183 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Refactor git attributes (#29356)KN4CK3R2024-02-242-35/+19
|
* Allow non-admin users to delete review requests (#29057)Zettat1232024-02-241-57/+88
| | | | | | | | Fix #14459 The following users can add/remove review requests of a PR - the poster of the PR - the owner or collaborators of the repository - members with read permission on the pull requests unit
* Properly migrate target branch change GitLab comment (#29340)Sebastian Brückner2024-02-243-4/+35
| | | | | | | | | | | | | | | | | | GitLab generates "system notes" whenever an event happens within the platform. Unlike Gitea, those events are stored and retrieved as text comments with no semantic details. The only way to tell whether a comment was generated in this manner is the `system` flag on the note type. This PR adds detection for a new specific kind of event: Changing the target branch of a PR. When detected, it is downloaded using Gitea's type for this event, and eventually uploaded into Gitea in the expected format, i.e. with no text content in the comment. This PR also updates the template used to render comments to add support for migrated comments of this type. ref: https://gitlab.com/gitlab-org/gitlab/-/blob/11bd6dc826e0bea2832324a1d7356949a9398884/app/services/system_notes/merge_requests_service.rb#L102
* Use the database object format name but not read from git repoisitory ↵Lunny Xiao2024-02-2410-27/+24
| | | | | | | | | | | | | everytime and fix possible migration wrong objectformat when migrating a sha256 repository (#29294) Now we can get object format name from git command line or from the database repository table. Assume the column is right, we don't need to read from git command line every time. This also fixed a possible bug that the object format is wrong when migrating a sha256 repository from external. <img width="658" alt="image" src="https://github.com/go-gitea/gitea/assets/81045/6e9a9dcf-13bf-4267-928b-6bf2c2560423">
* Revert "Support SAML authentication (#25165)" (#29358)65432024-02-2412-586/+12
| | | | | | | | | | This reverts #25165 (5bb8d1924d77c675467694de26697b876d709a17), as there was a chance some important reviews got missed. so after reverting this patch it will be resubmitted for reviewing again https://github.com/go-gitea/gitea/pull/25165#issuecomment-1960670242 temporary Open #5512 again
* Implement code frequency graph (#29191)Şahin Akkaya2024-02-231-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ### Overview This is the implementation of Code Frequency page. This feature was mentioned on these issues: #18262, #7392. It adds another tab to Activity page called Code Frequency. Code Frequency tab shows additions and deletions over time since the repository existed. Before: <img width="1296" alt="image" src="https://github.com/go-gitea/gitea/assets/32161460/2603504f-aee7-4929-a8c4-fb3412a7a0f6"> After: <img width="1296" alt="image" src="https://github.com/go-gitea/gitea/assets/32161460/58c03721-729f-4536-a663-9f337f240963"> --- #### Features - See additions deletions over time since repository existed - Click on "Additions" or "Deletions" legend to show only one type of contribution - Use the same cache from Contributors page so that the loading of data will be fast once it is cached by visiting either one of the pages --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Fix tarball/zipball download bug (#29342)Zettat1232024-02-232-1/+6
| | | | | | | Fix #29249 ~~Use the `/repos/{owner}/{repo}/archive/{archive}` API to download.~~ Apply #26430 to archive download URLs.
* Start to migrate from `util.OptionalBool` to `optional.Option[bool]` (#29329)65432024-02-238-16/+18
| | | just create transition helper and migrate two structs
* Support SAML authentication (#25165)techknowlogick2024-02-2312-12/+586
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Closes https://github.com/go-gitea/gitea/issues/5512 This PR adds basic SAML support - Adds SAML 2.0 as an auth source - Adds SAML configuration documentation - Adds integration test: - Use bare-bones SAML IdP to test protocol flow and test account is linked successfully (only runs on Postgres by default) - Adds documentation for configuring and running SAML integration test locally Future PRs: - Support group mapping - Support auto-registration (account linking) Co-Authored-By: @jackHay22 --------- Co-authored-by: jackHay22 <jack@allspice.io> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: morphelinho <morphelinho@users.noreply.github.com> Co-authored-by: Zettat123 <zettat123@gmail.com> Co-authored-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: silverwind <me@silverwind.io>
* Improve the `issue_comment` workflow trigger event (#29277)Zettat1232024-02-222-27/+80
| | | | | | | | | | | | | | | | | Fix #29175 Replace #29207 This PR makes some improvements to the `issue_comment` workflow trigger event. 1. Fix the bug that pull requests cannot trigger `issue_comment` workflows 2. Previously the `issue_comment` event only supported the `created` activity type. This PR adds support for the missing `edited` and `deleted` activity types. 3. Some events (including `issue_comment`, `issues`, etc. ) only trigger workflows that belong to the workflow file on the default branch. This PR introduces the `IsDefaultBranchWorkflow` function to check for these events.
* Properly migrate automatic merge GitLab comments (#27873)Sebastian Brückner2024-02-223-24/+93
| | | | | | | | | | | | | | | | | | | | | | | | GitLab generates "system notes" whenever an event happens within the platform. Unlike Gitea, those events are stored and retrieved as text comments with no semantic details. The only way to tell whether a comment was generated in this manner is the `system` flag on the note type. This PR adds detection for two specific kinds of events: Scheduling and un-scheduling of automatic merges on a PR. When detected, they are downloaded using Gitea's type for these events, and eventually uploaded into Gitea in the expected format, i.e. with no text content in the comment. This PR also updates the template used to render comments to add support for migrated comments of these two types. ref: https://gitlab.com/gitlab-org/gitlab/-/blob/11bd6dc826e0bea2832324a1d7356949a9398884/app/services/system_notes/merge_requests_service.rb#L6-L17 --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* small cache when get user id on interation (#29296)Lunny Xiao2024-02-221-5/+5
|
* Fix content size does not match error when uploading lfs file (#29259)vincent2024-02-191-1/+5
| | | | | | | | | | | | | | | | | | | | ![image](https://github.com/go-gitea/gitea/assets/38434877/cd726b4d-4771-4547-8aee-ae4e4b56b1d1) When we update an lfs file by API `api/v1/repos/{owner}/{repo}/contents/{filepath}`, there will show an error ```json { "message": "Put \"http://localhost:9000/gitea/lfs/38/92/05904d6c7bb83fc676513911226f2be25bf1465616bb9b29587100ab1414\": readfrom tcp [::1]:57300->[::1]:9000: content size does not match", "url": "http://localhost:3000/api/swagger" } ``` The reason of this error is https://github.com/go-gitea/gitea/blob/main/services/repository/files/update.go, in this file, the `file.ContentReader` been used twice. So when use `file.ContentReader` in the second time, the `i` of this Reader has been updated to the length of the content. it will return 0 and an `io.EOF` error when we try to read cotent from this Reader.
* Fix c/p error in inline documentation (#29148)Johan Van de Wauw2024-02-191-1/+1
| | | | | | | Fix small copy/paste error in inline documentation --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Show commit status for releases (#29149)KN4CK3R2024-02-191-0/+3
| | | | | Fixes #29082 ![grafik](https://github.com/go-gitea/gitea/assets/1666336/bb2ccde1-ee99-459d-9e74-0fb8ea79e8b3)
* Disallow merge when required checked are missing (#29143)Markus Amshove2024-02-191-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | fixes #21892 This PR disallows merging a PR when not all commit status contexts configured in the branch protection are met. Previously, the PR was happy to merge when one commit status was successful and the other contexts weren't reported. Any feedback is welcome, first time Go :-) I'm also not sure if the changes in the template break something else Given the following branch protection: ![branch_protection](https://github.com/go-gitea/gitea/assets/2401875/f871b4e4-138b-435a-b496-f9ad432e3dec) This was shown before the change: ![before](https://github.com/go-gitea/gitea/assets/2401875/60424ff0-ee09-4fa0-856e-64e6e3fb0612) With the change, it is now shown as this: ![after](https://github.com/go-gitea/gitea/assets/2401875/4e464142-efb1-4889-8166-eb3be26c8f3d) --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>