Conversation
…ncatenation - Extract duplicate sanitization logic from sanitizeBranchNameForPatch and sanitizeRepoSlugForPatch into a shared private sanitizeForFilename helper that accepts a fallback parameter - Fix multi-part string concatenation on error message to use a single template literal instead of three concatenated fragments Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Mar 7, 2026
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.
Summary
Simplification of recently modified
generate_git_patch.cjs(changed in #19963 which merged 2026-03-07).Files Simplified
actions/setup/js/generate_git_patch.cjs— extracted duplicate sanitization logic and fixed string concatenationImprovements Made
1. Eliminated Duplicate Sanitization Logic
sanitizeBranchNameForPatchandsanitizeRepoSlugForPatchshared an identical four-step.replace()chain, differing only in their fallback value for empty/null input. Extracted into a privatesanitizeForFilename(value, fallback)helper:2. Fixed String Concatenation
Replaced a three-fragment string concatenation with a single template literal:
Changes Based On
Recent changes from #19963 - fix: pass git auth via environment variables instead of writing to .git/config
Testing
sanitizeBranchNameForPatch/sanitizeRepoSlugForPatchassertions passmake lint-cjs)make fmt-cjs)Review Focus
Please verify:
sanitizeForFilenameis not exported (it's a private implementation detail)References: §22805044981