aboutsummaryrefslogtreecommitdiffstats
path: root/services
Commit message (Collapse)AuthorAgeFilesLines
* More refactoring of `db.DefaultContext` (#27083)JakobDev2023-09-1515-64/+66
| | | Next step of #27065
* Reduce usage of `db.DefaultContext` (#27073)JakobDev2023-09-1416-41/+49
| | | | | | | | | | | | | | Part of #27065 This reduces the usage of `db.DefaultContext`. I think I've got enough files for the first PR. When this is merged, I will continue working on this. Considering how many files this PR affect, I hope it won't take to long to merge, so I don't end up in the merge conflict hell. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Replace 'userxx' with 'orgxx' in all test files when the user type is org ↵Nanguan Lin2023-09-142-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#27052) Currently 'userxx' and 'orgxx' are both used as username in test files when the user type is org, which is confusing. This PR replaces all 'userxx' with 'orgxx' when the user type is org(`user.type==1`). Some non-trivial changes 1. Rename `user3` dir to `org3` in `tests/git-repositories-meta` 2. Change `end` in `issue reference` because 'org3' is one char shorter than 'user3' ![ksnip_20230913-112819](https://github.com/go-gitea/gitea/assets/70063547/442988c5-4cf4-49b8-aa01-4dd6bf0ca954) 3. Change the search result number of `user/repo2` because `user3/repo21` can't be searched now ![ksnip_20230913-112931](https://github.com/go-gitea/gitea/assets/70063547/d9ebeba4-479f-4110-9a85-825efbc981fd) 4. Change the first org name getting from API because the result is ordered by alphabet asc and now `org 17` is before `org25` ![JW8U7NIO(J$H _YCRB36H)T](https://github.com/go-gitea/gitea/assets/70063547/f55a685c-cf24-40e5-a87f-3a2327319548) ![)KFD411O4I8RB5ZOH7E0 Z3](https://github.com/go-gitea/gitea/assets/70063547/a0dc3299-249c-46f6-91cb-d15d4ee88dd5) Other modifications are just find all and replace all. Unit tests with SQLite are all passed. --------- Co-authored-by: caicandong <1290147055@qq.com>
* Load reviewer before sending notification (#27063)sebastian-sauer2023-09-131-0/+3
| | | | | | | | The [template](https://github.com/go-gitea/gitea/blob/main/templates/mail/issue/default.tmpl#L51) uses the Reviewer.Name property - this was not loaded. Fixes #27035
* Update status and code index after changing the default branch (#27018)Nanguan Lin2023-09-134-0/+22
| | | | | | | | | | | Fix #26723 Add `ChangeDefaultBranch` to the `notifier` interface and implement it in `indexerNotifier`. So when changing the default branch, `indexerNotifier` sends a message to the `indexer queue` to update the index. --------- Co-authored-by: techknowlogick <matti@mdranta.net>
* Extract auth middleware from service (#27028)KN4CK3R2023-09-121-255/+0
| | | | | | Related #27027 Extract the router logic from `services/auth/middleware.go` into `routers/web` <-> `routers/common` <-> `routers/api`.
* Move some functions to service layer (#26969)Lunny Xiao2023-09-085-9/+105
|
* Add a new column schedule_id for action_run to track (#26975)Lunny Xiao2023-09-081-13/+1
| | | | | | | | Fix #26971 And the UI now will display it's scheduled but not triggered by a push. <img width="954" alt="图片" src="https://github.com/go-gitea/gitea/assets/81045/d211845c-457e-4c3e-af1f-a0d654d3f365">
* move repository deletion to service layer (#26948)Lunny Xiao2023-09-0824-19/+513
| | | Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Team invite url fix when registration disabled (#26950)Jack Hay2023-09-071-2/+2
| | | | | This is a follow-on to https://github.com/go-gitea/gitea/pull/26550 and fixes the case where the team invite links to the registration page if it is disabled in settings.
* Fix schedule actions still running even if workflow disalbed (#26939)Lunny Xiao2023-09-071-0/+10
| | | Fix #26782
* Move createrepository from module to service layer (#26927)Lunny Xiao2023-09-067-9/+473
| | | | Repository creation depends on many models, so moving it to service layer is better.
* Artifacts retention and auto clean up (#26131)FuXiaoHei2023-09-062-0/+60
| | | | | | | | | | | | | | Currently, Artifact does not have an expiration and automatic cleanup mechanism, and this feature needs to be added. It contains the following key points: - [x] add global artifact retention days option in config file. Default value is 90 days. - [x] add cron task to clean up expired artifacts. It should run once a day. - [x] support custom retention period from `retention-days: 5` in `upload-artifact@v3`. - [x] artifacts link in actions view should be non-clickable text when expired.
* Fix the display of org level badges (#26504)yp053272023-09-061-0/+1
| | | | | | | | | | | Follow #24654 #22705 #24232 In some pages we still have missing badges, for example: ![image](https://github.com/go-gitea/gitea/assets/18380374/f57fae6d-95ad-4996-8881-160c9cd27768) ![image](https://github.com/go-gitea/gitea/assets/18380374/11e86d43-b715-4d14-bdf0-51bf8b5c7b01) ![image](https://github.com/go-gitea/gitea/assets/18380374/61c514e7-d8f6-4c93-a61f-60604619e3a7)
* Move notification interface to services layer (#26915)Lunny Xiao2023-09-0538-306/+945
| | | Extract from #22266
* Improve LDAP group config documentation, fixes #21159 (#21227)Sven Seeberg2023-09-051-4/+5
| | | | Improve the wording of the LDAP group attributes documentation and expand the examples.
* Remove `Named` interface (#26913)KN4CK3R2023-09-058-21/+4
| | | | `Named` is implemented by every `Method` and future implementations should implement the method too.
* Refactor secrets modification logic (#26873)KN4CK3R2023-09-052-0/+108
| | | | - Share code between web and api - Add some tests
* Move feed notification service layer (#26908)Lunny Xiao2023-09-053-2/+514
| | | Extract from #22266
* Move ui notification to service layer (#26907)Lunny Xiao2023-09-051-0/+262
| | | Extract from #22266
* Move indexer notification to service layer (#26906)Lunny Xiao2023-09-052-0/+143
| | | Extract from #22266
* Move mail notification logic to service layer (#26905)Lunny Xiao2023-09-052-0/+206
| | | Extract from #22266
* Use Go 1.21 and update dependencies (#26878)wxiaoguang2023-09-031-3/+1
| | | | | | To make sure Gitea's next release's lifecycle could have active Golang support. And min/max are builtin now.
* Move web/api context related testing function into a separate package (#26859)wxiaoguang2023-09-016-64/+64
| | | | | | | | | Just like `models/unittest`, the testing helper functions should be in a separate package: `contexttest` And complete the TODO: > // TODO: move this function to other packages, because it depends on "models" package
* Update team invitation email link (#26550)Jack Hay2023-08-312-2/+21
| | | | | Co-authored-by: Kyle D <kdumontnu@gmail.com> Co-authored-by: Jonathan Tran <jonnytran@gmail.com>
* Sync tags when adopting repos (#26816)Zettat1232023-08-311-0/+4
| | | | | | | | | | Fixes #26138 Sync the tags into database when adopting repos --------- Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: KN4CK3R <admin@oldschoolhack.me>
* Check blocklist for emails when adding them to account (#26812)techknowlogick2023-08-301-26/+3
|
* Use `Set[Type]` instead of `map[Type]bool/struct{}`. (#26804)KN4CK3R2023-08-302-6/+7
|
* Fix some slice append usages (#26778)Chongyi Zheng2023-08-291-3/+3
| | | Co-authored-by: delvh <dev.lh@web.de>
* Reduce some allocations in type conversion (#26772)Chongyi Zheng2023-08-292-3/+3
|
* Add auth-required to config.json for Cargo http registry (#26729)merlleu2023-08-281-6/+9
| | | | | | | | | | | | | | | | | | | | | | | Cargo registry-auth feature requires config.json to have a property auth-required set to true in order to send token to all registry requests. This is ok for git index because you can manually edit the config.json file to add the auth-required, but when using sparse (setting index url to "sparse+https://git.example.com/api/packages/{owner}/cargo/"), the config.json is dynamically rendered, and does not reflect changes to the config.json file in the repo. I see two approaches: - Serve the real config.json file when fetching the config.json on the cargo service. - Automatically detect if the registry requires authorization. (This is what I implemented in this PR). What the PR does: - When a cargo index repository is created, on the config.json, set auth-required to wether or not the repository is private. - When the cargo/config.json endpoint is called, set auth-required to wether or not the request was authorized using an API token.
* Fix bug for ctx usage (#26762)Lunny Xiao2023-08-281-2/+2
| | | | | Regression from #26158 Fix #26684
* Move `modules/mirror` to `services` (#26737)Chongyi Zheng2023-08-274-11/+124
| | | | | To solve the cyclic imports in a better way Closes #20261
* Make web context initialize correctly for different cases (#26726)wxiaoguang2023-08-251-1/+2
| | | | | | | The web context (modules/context.Context) is quite complex, it's difficult for the callers to initialize correctly. This PR introduces a `NewWebContext` function, to make sure the web context have the same behavior for different cases.
* add Upload URL to release API (#26663)Earl Warren2023-08-242-0/+29
| | | | | | | | | | | | - Resolves https://codeberg.org/forgejo/forgejo/issues/580 - Return a `upload_field` to any release API response, which points to the API URL for uploading new assets. - Adds unit test. - Adds integration testing to verify URL is returned correctly and that upload endpoint actually works --------- Co-authored-by: Gusted <postmaster@gusted.xyz>
* chore(actions): support cron schedule task (#26655)Lunny Xiao2023-08-243-4/+253
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace #22751 1. only support the default branch in the repository setting. 2. autoload schedule data from the schedule table after starting the service. 3. support specific syntax like `@yearly`, `@monthly`, `@weekly`, `@daily`, `@hourly` ## How to use See the [GitHub Actions document](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#schedule) for getting more detailed information. ```yaml on: schedule: - cron: '30 5 * * 1,3' - cron: '30 5 * * 2,4' jobs: test_schedule: runs-on: ubuntu-latest steps: - name: Not on Monday or Wednesday if: github.event.schedule != '30 5 * * 1,3' run: echo "This step will be skipped on Monday and Wednesday" - name: Every time run: echo "This step will always run" ``` Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com> --------- Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com> Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
* Modify the content format of the Feishu webhook (#25106)谈笑风生间2023-08-244-15/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | close https://github.com/go-gitea/gitea/issues/24368 ## what my pull request does Since the official documentation states that custom bots do not support hyperlink functionality, simply adding it without making some formatting changes would result in an unappealing output. Therefore, I have modified the formatting of the output. Currently, it is only used for Feishu. --- [docs](https://open.feishu.cn/document/uAjLw4CM/ukTMukTMukTM/im-v1/message/create_json#%E8%B6%85%E9%93%BE%E6%8E%A5%E4%BD%BF%E7%94%A8%E8%AF%B4%E6%98%8E) <img width="641" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/360e1c81-ab64-4ef6-851e-aa450d6e85a4"> - Issue <img width="423" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/519f6fae-81ab-4ec8-89b8-f6a73ff93783"> - Issue Comment <img width="548" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/749c0d1c-3657-431e-b787-8bf4c23cce83"> - Assign <img width="431" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/066f99e5-eabb-455d-91fb-a8359cc26dc7"> <img width="457" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/c6c10f99-db83-46ef-a775-4c91979fa68f"> - Merge <img width="408" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/e627bf43-5954-45aa-acf6-261ee046802f"> - PullRequest <img width="425" alt="image" src="https://github.com/go-gitea/gitea/assets/75628309/72cfa714-d3fa-4fb9-abdd-e8508d756056">
* feat: implement organization secret creation API (#26566)Bo-Yi Wu2023-08-221-0/+18
| | | | | | | | | | | | | - Add a new `CreateSecretOption` struct for creating secrets - Implement a `CreateOrgSecret` function to create a secret in an organization - Add a new route in `api.go` to handle the creation of organization secrets - Update the Swagger template to include the new `CreateOrgSecret` API endpoint --------- Signed-off-by: appleboy <appleboy.tw@gmail.com>
* Add `branch_filter` to hooks API endpoints (#26599)Yarden Shoham2023-08-211-0/+1
| | | | | | | | | | | | | | | | | | We now include the branch filler in the response. - Closes #26591 # Before ![image](https://github.com/go-gitea/gitea/assets/20454870/73933940-c1a7-4573-abae-f340b63028b2) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/3b3c4a85-0f7c-48c7-8617-def7a66c671d) --------- Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: Giteabot <teabot@gitea.io>
* Add link to job details and tooltip to commit status in repo list in ↵yp053272023-08-211-2/+3
| | | | | | | | | | | dashboard (#26326) Tooltip: ![image](https://github.com/go-gitea/gitea/assets/18380374/237cb545-7844-424b-b995-1008eaaaedec) Link to the target job: ![image](https://github.com/go-gitea/gitea/assets/18380374/0c11a97f-6517-47f2-8773-f381488c084e)
* Support rebuilding issue indexer manually (#26546)Jason Song2023-08-171-0/+12
| | | | | | | | | | | Provide a way to rebuild issue indexer manually. So if the indexer get outdated because of some bugs like #26539, we can rebuild it. <img width="1104" alt="image" src="https://github.com/go-gitea/gitea/assets/9418365/ac242e29-6f04-47ca-b3d0-801a796448d3"> Co-authored-by: Giteabot <teabot@gitea.io>
* Sync repo's IsEmpty status correctly (#26517)wxiaoguang2023-08-171-1/+3
| | | Close #26509
* Use `object-fit: contain` for oauth2 custom icons (#26493)wxiaoguang2023-08-141-1/+1
|
* add disable workflow feature (#26413)a10121127962023-08-141-0/+7
| | | | | | | | | | | | | | | | As title, that's simmilar with github. ![image](https://github.com/go-gitea/gitea/assets/25342410/9e8b2444-63e0-4e87-80da-730c1e4d09d6) ![image](https://github.com/go-gitea/gitea/assets/25342410/6c3a3345-3ba7-48c9-9acd-3e621632491b) --------- Signed-off-by: a1012112796 <1012112796@qq.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Jason Song <i@wolfogre.com>
* Handle base64 decoding correctly to avoid panic (#26483)wxiaoguang2023-08-141-10/+1
| | | Fix the panic if the "base64 secret" is too long.
* Allow to archive labels (#26478)puni98692023-08-142-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ## Archived labels This adds the structure to allow for archived labels. Archived labels are, just like closed milestones or projects, a medium to hide information without deleting it. It is especially useful if there are outdated labels that should no longer be used without deleting the label entirely. ## Changes 1. UI and API have been equipped with the support to mark a label as archived 2. The time when a label has been archived will be stored in the DB ## Outsourced for the future There's no special handling for archived labels at the moment. This will be done in the future. ## Screenshots ![image](https://github.com/go-gitea/gitea/assets/80308335/208f95cd-42e4-4ed7-9a1f-cd2050a645d4) ![image](https://github.com/go-gitea/gitea/assets/80308335/746428e0-40bb-45b3-b992-85602feb371d) Part of https://github.com/go-gitea/gitea/issues/25237 --------- Co-authored-by: delvh <dev.lh@web.de> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
* Add ThreadID parameter for Telegram webhooks (#25996)Earl Warren2023-08-132-0/+2
| | | | | | Telegram has recently implemented threads (channels) for group chats. Co-authored-by: neveraskedtoexist <matikot415@gmail.com>
* Fix stderr usages (#26477)wxiaoguang2023-08-131-3/+3
|
* Add transaction when creating pull request created dirty data (#26259)Lunny Xiao2023-08-104-74/+106
| | | | | | | | | | | | Fix #26129 Replace #26258 This PR will introduce a transaction on creating pull request so that if some step failed, it will rollback totally. And there will be no dirty pull request exist. --------- Co-authored-by: Giteabot <teabot@gitea.io>
* Add pull request review request webhook event (#26401)Yarden Shoham2023-08-091-0/+4
| | | | | | | | | | | | | | | | | | | | Add webhook events for pull request review requests - Fixes #26371 - Added support for the "Pull request review requested" and "Pull request review request removed" webhook events. - Updated the `getPullRequestPayloadInfo` function in `general.go` to handle these new webhook events. # Before ![image](https://github.com/go-gitea/gitea/assets/20454870/bd942971-fb1d-40f3-8961-46638e3588fa) # After ![image](https://github.com/go-gitea/gitea/assets/20454870/216e9c7d-0a4d-49f9-8492-2d14c88bbf4e) Signed-off-by: Yarden Shoham <git@yardenshoham.com> Co-authored-by: Giteabot <teabot@gitea.io>