MCPcopy Index your code
hub / github.com/desktop/desktop / parseLinePrefix

Method parseLinePrefix

app/src/lib/diff-parser.ts:267–276  ·  view source on GitHub ↗

* Convenience function which lets us leverage the type system to * prove exhaustive checks in parseHunk. * * Takes an arbitrary string and checks to see if the first character * of that string is one of the allowed prefix characters for diff * lines (ie lines in between hunk headers).

(c: string | null)

Source from the content-addressed store, hash-verified

265 * lines (ie lines in between hunk headers).
266 */
267 private parseLinePrefix(c: string | null): DiffLinePrefix | null {
268 // Since we know that DiffLinePrefixChars and the DiffLinePrefix type
269 // include the same characters we can tell the type system that we
270 // now know that c[0] is one of the characters in the DifflinePrefix set
271 if (c && c.length && (DiffLinePrefixChars as Set<string>).has(c[0])) {
272 return c[0] as DiffLinePrefix
273 }
274
275 return null
276 }
277
278 /**
279 * Parses a hunk, including its header or throws an error if the diff doesn't

Callers 1

parseHunkMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected