From 18aea4bfe89b83c5e2d6d55daa68efa6180655cc Mon Sep 17 00:00:00 2001 From: Henning Perl Date: Sun, 28 Dec 2014 23:07:33 +0100 Subject: Add git_diff_get_stats() This commit adds git_diff_get_stats() as well as functions to query the stats for insertions, deletions, and changed files. --- diff_test.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'diff_test.go') diff --git a/diff_test.go b/diff_test.go index 7c54f4e..fc6fed9 100644 --- a/diff_test.go +++ b/diff_test.go @@ -148,6 +148,20 @@ func TestDiffTreeToTree(t *testing.T) { if want1, want2 := "x1/README", "y1/README"; !strings.Contains(patches[0], want1) || !strings.Contains(patches[0], want2) { t.Errorf("Diff patch doesn't contain %q or %q\n\n%s", want1, want2, patches[0]) + + } + + stats, err := diff.Stats() + checkFatal(t, err) + + if stats.Insertions() != 1 { + t.Fatal("Incorrect number of insertions in diff") + } + if stats.Deletions() != 1 { + t.Fatal("Incorrect number of deletions in diff") + } + if stats.FilesChanged() != 1 { + t.Fatal("Incorrect number of changed files in diff") } errTest := errors.New("test error") -- cgit v1.2.3