MCPcopy Create free account
hub / github.com/github/gh-aw / countUniquePatchFiles

Function countUniquePatchFiles

actions/setup/js/create_pull_request.cjs:451–467  ·  view source on GitHub ↗

* Counts the number of unique file paths touched by a git patch. * * `git format-patch` emits one `diff --git` header per (commit, file), so the * same file modified across multiple commits will appear multiple times. The * file-count safety limit counts unique files (i.e. how many distinct file

(patchContent)

Source from the content-addressed store, hash-verified

449 * @returns {number} Number of unique file paths referenced in the patch
450 */
451function countUniquePatchFiles(patchContent) {
452 if (!patchContent || !patchContent.trim()) {
453 return 0;
454 }
455 const files = new Set();
456 const entries = extractDiffGitHeaderEntries(patchContent);
457 let unparseableIdx = 0;
458 for (const entry of entries) {
459 const path = entry.newPath || entry.oldPath;
460 if (path) {
461 files.add(path);
462 } else {
463 files.add(`__unparseable_header_${entry.headerIndex}_${unparseableIdx++}`);
464 }
465 }
466 return files.size;
467}
468
469/**
470 * Enforces maximum limits on pull request parameters to prevent resource exhaustion attacks.

Callers 4

enforcePullRequestLimitsFunction · 0.85
mainFunction · 0.85

Calls 2

addMethod · 0.45

Tested by

no test coverage detected