Skip to content

Commit

Permalink
Update parse-git-patch, remove workarounds
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrisbin committed Nov 19, 2024
1 parent 7bd3f0e commit 60d5914
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 26 deletions.
2 changes: 1 addition & 1 deletion run/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"@actions/github": "^6.0.0",
"@types/temp": "^0.9.4",
"action-docs": "^2.5.1",
"parse-git-patch": "^1.2.2",
"parse-git-patch": "^2.0.0",
"temp": "^0.9.4"
},
"devDependencies": {
Expand Down
22 changes: 1 addition & 21 deletions run/src/patch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export function parsePatches(str: string): ParsedPatchType[] {
return;
}

const parsed = parsePatch(patchLines.join("\n"));
const parsed = parseGitPatch(patchLines.join("\n"));

if (!parsed) {
return;
Expand All @@ -51,23 +51,3 @@ export function parsePatches(str: string): ParsedPatchType[] {

return patches;
}

function parsePatch(str: string): ParsedPatchType | null {
// https://github.com/dherault/parse-git-patch/issues/17
const p = parseGitPatch(str) as ParsedPatchType | null;

if (p) {
fixLineNumbers(p);
}

return p;
}

// https://github.com/dherault/parse-git-patch/issues/16
function fixLineNumbers(patch: ParsedPatchType): void {
patch.files.forEach((file) => {
file.modifiedLines.forEach((mod) => {
mod.lineNumber = mod.lineNumber - 1;
});
});
}
8 changes: 4 additions & 4 deletions run/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2776,10 +2776,10 @@ parent-module@^1.0.0:
dependencies:
callsites "^3.0.0"

parse-git-patch@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/parse-git-patch/-/parse-git-patch-1.2.2.tgz#b1e184d030e95091470c2e929974bb587c85d523"
integrity sha512-Ap5/BFHSgLK+ouuofWPEFCpP5TG6MAfFLtES7Rbe8JBAXtXdFr87rwPoCn8/t3pzTKWxHgNjtiiXjEME1GRgYg==
parse-git-patch@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/parse-git-patch/-/parse-git-patch-2.0.0.tgz#8d63c01daeb795e6447f8ed5b37681558598680b"
integrity sha512-dG79wuJ/fezufoTJyCHxrzjrsmB1NGEIE9x1/c+9TPYAqSZvdB6KJqJO8W487BB6uq5HVT+SmjE0C8VbcV16eA==

parse-json@^5.2.0:
version "5.2.0"
Expand Down

0 comments on commit 60d5914

Please sign in to comment.