Repository navigation
refactor: reduce complexity of execute_impl in create_branch.rs - #2328
Draft
github-actions[bot] wants to merge 1 commit into
Draft
github-actions[bot] wants to merge 1 commit into
github-actions[bot] wants to merge 1 commit into
Conversation
…ranch.rs Extract 6 helper functions from the 160-line execute_impl in CreateBranchResult::execute_impl (flagged by clippy::too_many_lines at 160/100): - check_branch_pattern: validate branch-pattern regex config - check_allowed_repository: validate allowed-repositories policy - check_allowed_source_branch: validate allowed-source-branches policy - resolve_source_sha: resolve source_commit or source_branch to a SHA - qualified_ref_name: normalize branch_name to refs/heads/... form - submit_branch_creation: POST the ref update and interpret the Azure DevOps response (including per-ref errors) execute_impl itself shrank to a ~45-line orchestrator that calls these helpers in sequence. No behavior change. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What was complex
CreateBranchResult::execute_implinsrc/safe_outputs/create_branch.rswas flagged byclippy::too_many_linesat 160/100 lines. It mixed four distinct concerns inline:What changed
Extracted 6 single-purpose helper functions, each handling one concern:
check_branch_pattern— validates the branch name against the configuredbranch-patternregexcheck_allowed_repository— validates the repository alias againstallowed-repositoriescheck_allowed_source_branch— validates the source branch againstallowed-source-branchesresolve_source_sha— resolvessource_commit(if given) or looks upsource_branchvia the refs APIqualified_ref_name— normalizes a branch name to itsrefs/heads/...formsubmit_branch_creation— POSTs the ref-creation request and interprets the HTTP/per-ref responseexecute_implitself shrank to a ~45-line orchestrator that calls these helpers in sequence. No public API signatures or observable behavior changed.Before/after complexity
clippy::too_many_linesValidation
cargo test --bin ado-aw create_branch— 17/17 passedcargo test --bin ado-aw— 3408 passed, 0 failed, 1 ignored (full suite, no regressions)cargo clippy --all-targets --all-features— no new warnings (only pre-existing, unrelatedasync_traitdouble_must_usewarnings tracked separately in open PR fix(clippy): bump async-trait to 0.1.92 to clear double_must_use lint #2296)too_many_lineslint scoped to this file:execute_implno longer appears in the violations listWarning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comTo allow these domains, add them to the
network.allowedlist in your workflow frontmatter:See Network Configuration for more information.