Skip to content

Refactor: move part of updating protected branch logic to service layer #33742

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 5, 2025

Conversation

lunny
Copy link
Member

@lunny lunny commented Feb 27, 2025

No description provided.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Feb 27, 2025
@github-actions github-actions bot added modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code labels Feb 27, 2025
@lunny lunny requested a review from Copilot February 27, 2025 18:00
@lunny lunny added the type/refactoring Existing code has been cleaned up. There should be no new functionality. label Feb 27, 2025
@lunny lunny added this to the 1.24.0 milestone Feb 27, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 4, 2025
@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 5, 2025
@lunny lunny enabled auto-merge (squash) March 5, 2025 18:48
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Mar 5, 2025
@lunny lunny merged commit 0453177 into go-gitea:main Mar 5, 2025
26 checks passed
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label 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)
@lunny lunny deleted the lunny/merge_update_protected_branch branch March 14, 2025 02:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. modifies/api This PR adds API routes or modifies them modifies/go Pull requests that update Go code type/refactoring Existing code has been cleaned up. There should be no new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants