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

Method parseDiffHeader

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

* Parse the diff header, meaning everything from the * start of the diff output to the end of the line beginning * with +++ * * Example diff header: * * diff --git a/app/src/lib/diff-parser.ts b/app/src/lib/diff-parser.ts * index e1d4871..3bd3ee0 100644 * --- a/app/src/

()

Source from the content-addressed store, hash-verified

172 * found (which is a valid state).
173 */
174 private parseDiffHeader(): IDiffHeaderInfo | null {
175 // TODO: There's information in here that we might want to
176 // capture, such as mode changes
177 while (this.nextLine()) {
178 if (this.lineStartsWith('Binary files ') && this.lineEndsWith('differ')) {
179 return { isBinary: true }
180 }
181
182 if (this.lineStartsWith('+++')) {
183 return { isBinary: false }
184 }
185 }
186
187 // It's not an error to not find the +++ line, see the
188 // 'parses diff of empty file' test in diff-parser-tests.ts
189 return null
190 }
191
192 /**
193 * Attempts to convert a RegExp capture group into a number.

Callers 1

parseMethod · 0.95

Calls 3

nextLineMethod · 0.95
lineStartsWithMethod · 0.95
lineEndsWithMethod · 0.95

Tested by

no test coverage detected