MCPcopy Index your code
hub / github.com/bigcode-project/jupytercoder / parseIndex

Function parseIndex

src/diff.js:564–606  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

562 i = 0;
563
564 function parseIndex() {
565 var index = {};
566 list.push(index); // Parse diff metadata
567
568 while (i < diffstr.length) {
569 var line = diffstr[i]; // File header found, end parsing diff metadata
570
571 if (/^(\-\-\-|\+\+\+|@@)\s/.test(line)) {
572 break;
573 } // Diff index
574
575
576 var header = /^(?:Index:|diff(?: -r \w+)+)\s+(.+?)\s*$/.exec(line);
577
578 if (header) {
579 index.index = header[1];
580 }
581
582 i++;
583 } // Parse file headers if they are defined. Unified diff requires them, but
584 // there's no technical issues to have an isolated hunk without file header
585
586
587 parseFileHeader(index);
588 parseFileHeader(index); // Parse hunks
589
590 index.hunks = [];
591
592 while (i < diffstr.length) {
593 var _line = diffstr[i];
594
595 if (/^(Index:|diff|\-\-\-|\+\+\+)\s/.test(_line)) {
596 break;
597 } else if (/^@@/.test(_line)) {
598 index.hunks.push(parseHunk());
599 } else if (_line && options.strict) {
600 // Ignore unexpected content unless in strict mode
601 throw new Error('Unknown line ' + (i + 1) + ' ' + JSON.stringify(_line));
602 } else {
603 i++;
604 }
605 }
606 } // Parses the --- and +++ headers, if none are found, no lines
607 // are consumed.
608
609

Callers 1

parsePatchFunction · 0.85

Calls 2

parseFileHeaderFunction · 0.85
parseHunkFunction · 0.85

Tested by

no test coverage detected