| ... | @@ -518,6 +518,8 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { | ... | @@ -518,6 +518,8 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { |
| 518 | }, | 518 | }, |
| 519 | .action = std.meta.stringToEnum(TreeDiff.Action, action_s).?, | 519 | .action = std.meta.stringToEnum(TreeDiff.Action, action_s).?, |
| 520 | .sub_path = kter.rest(), | 520 | .sub_path = kter.rest(), |
| | 521 | .adds = 0, |
| | 522 | .subs = 0, |
| 521 | }); | 523 | }); |
| 522 | } | 524 | } |
| 523 | | 525 | |
| ... | @@ -581,18 +583,24 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { | ... | @@ -581,18 +583,24 @@ pub fn parseTreeDiff(alloc: std.mem.Allocator, input: string) !TreeDiff { |
| 581 | while (lineiter.next()) |lin| { | 583 | while (lineiter.next()) |lin| { |
| 582 | if (std.mem.startsWith(u8, lin, "diff --git")) { | 584 | if (std.mem.startsWith(u8, lin, "diff --git")) { |
| 583 | const end_index = lineiter.index.? - lin.len - 2; | 585 | const end_index = lineiter.index.? - lin.len - 2; |
| | 586 | const content = input[start_index..end_index]; |
| | 587 | overview.items[diffs.items.len].adds = @intCast(std.mem.count(u8, content, "\n+")); |
| | 588 | overview.items[diffs.items.len].subs = @intCast(std.mem.count(u8, content, "\n-")); |
| 584 | try diffs.append(.{ | 589 | try diffs.append(.{ |
| 585 | .before_path = before_path, | 590 | .before_path = before_path, |
| 586 | .after_path = after_path, | 591 | .after_path = after_path, |
| 587 | .content = input[start_index..end_index], | 592 | .content = content, |
| 588 | }); | 593 | }); |
| 589 | continue :blk; | 594 | continue :blk; |
| 590 | } | 595 | } |
| 591 | } | 596 | } |
| | 597 | const content = input[start_index..]; |
| | 598 | overview.items[diffs.items.len].adds = @intCast(std.mem.count(u8, content, "\n+")); |
| | 599 | overview.items[diffs.items.len].subs = @intCast(std.mem.count(u8, content, "\n-")); |
| 592 | try diffs.append(.{ | 600 | try diffs.append(.{ |
| 593 | .before_path = before_path, | 601 | .before_path = before_path, |
| 594 | .after_path = after_path, | 602 | .after_path = after_path, |
| 595 | .content = input[start_index..], | 603 | .content = content, |
| 596 | }); | 604 | }); |
| 597 | break :blk; | 605 | break :blk; |
| 598 | } | 606 | } |
| ... | @@ -612,6 +620,8 @@ pub const TreeDiff = struct { | ... | @@ -612,6 +620,8 @@ pub const TreeDiff = struct { |
| 612 | after: State, | 620 | after: State, |
| 613 | action: Action, | 621 | action: Action, |
| 614 | sub_path: string, | 622 | sub_path: string, |
| | 623 | adds: u16, |
| | 624 | subs: u16, |
| 615 | }; | 625 | }; |
| 616 | | 626 | |
| 617 | pub const State = struct { | 627 | pub const State = struct { |