From 61dd1fb38ed49c6b131462667ee1d0878414fa61 Mon Sep 17 00:00:00 2001 From: Vadim Markovtsev Date: Tue, 26 Feb 2019 20:33:10 +0100 Subject: [PATCH] Do not handle merges in --devs Signed-off-by: Vadim Markovtsev --- leaves/devs.go | 5 +++++ leaves/devs_test.go | 27 ++++++++++++++++++++++++--- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/leaves/devs.go b/leaves/devs.go index d2574c81..d85221d7 100644 --- a/leaves/devs.go +++ b/leaves/devs.go @@ -158,6 +158,11 @@ func (devs *DevsAnalysis) Consume(deps map[string]interface{}) (map[string]inter devsDay[author] = dd } dd.Commits++ + if deps[core.DependencyIsMerge].(bool) { + // we ignore merge commit diffs + // TODO(vmarkovtsev): handle them + return nil, nil + } cache := deps[items.DependencyBlobCache].(map[plumbing.Hash]*items.CachedBlob) fileDiffs := deps[items.DependencyFileDiff].(map[string]items.FileDiffData) langs := deps[items.DependencyLanguages].(map[plumbing.Hash]string) diff --git a/leaves/devs_test.go b/leaves/devs_test.go index d5ba661f..6be01c59 100644 --- a/leaves/devs_test.go +++ b/leaves/devs_test.go @@ -156,6 +156,23 @@ func TestDevsConsumeFinalize(t *testing.T) { assert.Equal(t, dev.Languages["Go"].Removed, 9) assert.Equal(t, dev.Languages["Go"].Changed, 67) + deps[core.DependencyIsMerge] = true + result, err = devs.Consume(deps) + assert.Nil(t, result) + assert.Nil(t, err) + assert.Len(t, devs.days, 1) + day = devs.days[0] + assert.Len(t, day, 1) + dev = day[0] + assert.Equal(t, dev.Commits, 2) + assert.Equal(t, dev.Added, 847) + assert.Equal(t, dev.Removed, 9) + assert.Equal(t, dev.Changed, 67) + assert.Equal(t, dev.Languages["Go"].Added, 847) + assert.Equal(t, dev.Languages["Go"].Removed, 9) + assert.Equal(t, dev.Languages["Go"].Changed, 67) + + deps[core.DependencyIsMerge] = false deps[identity.DependencyAuthor] = 1 result, err = devs.Consume(deps) assert.Nil(t, result) @@ -165,7 +182,11 @@ func TestDevsConsumeFinalize(t *testing.T) { assert.Len(t, day, 2) for i := 0; i < 2; i++ { dev = day[i] - assert.Equal(t, dev.Commits, 1) + if i == 0 { + assert.Equal(t, dev.Commits, 2) + } else { + assert.Equal(t, dev.Commits, 1) + } assert.Equal(t, dev.Added, 847) assert.Equal(t, dev.Removed, 9) assert.Equal(t, dev.Changed, 67) @@ -181,7 +202,7 @@ func TestDevsConsumeFinalize(t *testing.T) { day = devs.days[0] assert.Len(t, day, 2) dev = day[0] - assert.Equal(t, dev.Commits, 1) + assert.Equal(t, dev.Commits, 2) assert.Equal(t, dev.Added, 847) assert.Equal(t, dev.Removed, 9) assert.Equal(t, dev.Changed, 67) @@ -205,7 +226,7 @@ func TestDevsConsumeFinalize(t *testing.T) { day = devs.days[0] assert.Len(t, day, 2) dev = day[0] - assert.Equal(t, dev.Commits, 1) + assert.Equal(t, dev.Commits, 2) assert.Equal(t, dev.Added, 847) assert.Equal(t, dev.Removed, 9) assert.Equal(t, dev.Changed, 67)