Refactor: move part of updating protected branch logic to service layer#33742
Merged
Conversation
Contributor
There was a problem hiding this comment.
PR Overview
This PR refactors the protected branch update logic by moving part of it to the service layer, centralizing functionality and reducing redundancy. Key changes include:
- Introducing a new service function (CreateOrUpdateProtectedBranch) in services/pull/protected_branch.go to encapsulate the update and PR recheck logic.
- Updating the web and API route handlers to call the new service function instead of duplicating the branch-check logic.
- Removing redundant inline recheck logic and cleaning up obsolete comments.
Reviewed Changes
| File | Description |
|---|---|
| services/pull/protected_branch.go | New service function for creating or updating protected branches. |
| routers/web/repo/setting/protected_branch.go | Updated to use the new service function for protected branch updates. |
| routers/api/v1/repo/branch.go | Removed duplicate branch-check logic in favor of the new service. |
| services/forms/repo_form.go | Removed extraneous ASCII art comments. |
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (1)
services/pull/protected_branch.go:22
- [nitpick] Consider renaming 'isPlainRule' to 'isRegularRule' for improved clarity on the branch rule type.
isPlainRule := !git_model.IsRuleNameSpecial(protectBranch.RuleName)
wxiaoguang
approved these changes
Mar 4, 2025
hiifong
approved these changes
Mar 5, 2025
zjjhot
added a commit
to zjjhot/gitea
that referenced
this pull request
Mar 6, 2025
* giteaofficial/main: [skip ci] Updated translations via Crowdin Refactor: move part of updating protected branch logic to service layer (go-gitea#33742) Update changelog for v1.23.5 (go-gitea#33797) Email option to embed images as base64 instead of link (go-gitea#32061) Update TypeScript types (go-gitea#33799) Disable vet=off again (go-gitea#33794)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.