refactor: reduce complexity of execute_impl in create_pull_request.rs#1609
Merged
jamesadevine merged 1 commit intoJul 22, 2026
Conversation
Extract six focused helpers from the 883-line execute_impl method: - handle_no_changes: no-changes branch with symlink suffix logic - validate_and_build_labels: agent label validation + merge with operator labels - push_new_branch: ADO push + TOCTOU branch-collision retry - build_push_payload: pure function building the ADO push JSON body - random_branch_suffix: encapsulates rand usage - rename_branch_suffix: replaces inline rfind/format pattern used in two places execute_impl shrinks from 883 lines to 718 lines. Each extracted function has a single clear responsibility and is individually testable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
jamesadevine
marked this pull request as ready for review
July 22, 2026 20:54
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
execute_implinsrc/safe_outputs/create_pull_request.rshad grown to 883 lines — a massive single method handling every phase of PR creation inline:IfNoChangesdispatchserde_json::json!block)The function was readable locally but too long to hold in working memory, and the duplicated branch-suffix logic was a DRY violation.
What was changed
Six focused helpers extracted from
execute_impl:handle_no_changesIfNoChangesvariantvalidate_and_build_labelspush_new_branchbuild_push_payloadrandom_branch_suffixrand::rng().random()rename_branch_suffixrfind('-')/format!patternPushBranchParamsstruct introduced to satisfy Clippy'stoo_many_argumentslint onpush_new_branch.Before / After
execute_implonly)Verification
cargo build— cleancargo test— all tests passcargo clippy --all-targets --all-features— 1 pre-existing warning incommon.rs(unrelated), no new warningsWarning
Firewall blocked 1 domain
The following domain was blocked by the firewall during workflow execution:
spsprodeus21.vssps.visualstudio.comSee Network Configuration for more information.