refactor: reduce complexity of execute_impl in create_pr.rs#361
Conversation
Extract five focused helper functions from the 992-line execute_impl: - check_for_conflict_markers: deduplicates the git-grep conflict scan that was copy-pasted in both the git-apply and git-am fallback paths - apply_patch_with_exclusions: the git-apply --3way path (excluded-files) - apply_patch_without_exclusions: the git-am --3way + git-apply fallback path - apply_patch_to_worktree: thin dispatcher selecting the right strategy - set_pr_completion_options: sets delete-source-branch / squash-merge / auto-complete on the newly created PR - add_reviewers_to_pr: resolves and attaches each configured reviewer execute_impl shrinks from 992 lines to 789 lines (-203 lines). The extracted functions are independently documented and testable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
/rust-review |
|
✅ Rust PR Reviewer completed successfully! |
🔍 Rust PR ReviewSummary: Looks good — clean, faithful refactor. One minor observability regression worth noting. Findings
|
|
@copilot implement suggestion |
…_completion_options Agent-Logs-Url: https://github.com/githubnext/ado-aw/sessions/1c554779-676a-488c-b5b4-fcf961e2c542 Co-authored-by: jamesadevine <4742697+jamesadevine@users.noreply.github.com>
What was complex
execute_implinsrc/safeoutputs/create_pr.rswas 992 lines — a single async method that handled the entire PR creation pipeline: input validation, ADO config extraction, patch security checks, git worktree setup, patch application (two strategies), change collection, ADO push with collision retry, PR creation, label/work-item wiring, completion options, and reviewer assignment.Two specific problems stood out:
git grep -l -E '^(<<<<<<<\s|>>>>>>>\s)') was copy-pasted in both thegit applypath and thegit amfallback path.What changed
Five focused helper functions extracted, all placed alongside the existing standalone helpers below the
implblock:check_for_conflict_markersapply_patch_with_exclusionsgit apply --3waypath (used whenexcluded-filesare set)apply_patch_without_exclusionsgit am --3way+git applyfallback pathapply_patch_to_worktreeResult<bool, ExecutionResult>set_pr_completion_optionsadd_reviewers_to_prThe call sites in
execute_implbecome:Before / After
execute_impllinescheck_for_conflict_markers)Verification
cargo build— ✅ cleancargo test— ✅ all tests passcargo clippy --all-targets --all-features— ✅ no new warnings