Skip to content

Commit

Permalink
Do not handle merges in --devs
Browse files Browse the repository at this point in the history
Signed-off-by: Vadim Markovtsev <[email protected]>
  • Loading branch information
vmarkovtsev committed Feb 26, 2019
1 parent 0a3e606 commit 61dd1fb
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
5 changes: 5 additions & 0 deletions leaves/devs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
27 changes: 24 additions & 3 deletions leaves/devs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit 61dd1fb

Please sign in to comment.