MCPcopy Create free account
hub / github.com/ds300/patch-package / parseHunkHeaderLine

Function parseHunkHeaderLine

src/patch/parse.ts:14–32  ·  view source on GitHub ↗
(headerLine: string)

Source from the content-addressed store, hash-verified

12}
13
14export const parseHunkHeaderLine = (headerLine: string): HunkHeader => {
15 const match = headerLine
16 .trim()
17 .match(/^@@ -(\d+)(,(\d+))? \+(\d+)(,(\d+))? @@.*/)
18 if (!match) {
19 throw new Error(`Bad header line: '${headerLine}'`)
20 }
21
22 return {
23 original: {
24 start: Math.max(Number(match[1]), 1),
25 length: Number(match[3] || 1),
26 },
27 patched: {
28 start: Math.max(Number(match[4]), 1),
29 length: Number(match[6] || 1),
30 },
31 }
32}
33
34export const NON_EXECUTABLE_FILE_MODE = 0o644
35export const EXECUTABLE_FILE_MODE = 0o755

Callers 1

emptyHunkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…