ソースを参照

Fix --burndown-people with external identities

Closes #216

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 6 年 前
コミット
1995126426
3 ファイル変更9 行追加5 行削除
  1. 2 2
      internal/plumbing/identity/identity.go
  2. 6 2
      leaves/burndown.go
  3. 1 1
      leaves/burndown_test.go

+ 2 - 2
internal/plumbing/identity/identity.go

@@ -25,8 +25,8 @@ type Detector struct {
 
 const (
 	// AuthorMissing is the internal author index which denotes any unmatched identities
-	// (Detector.Consume()).
-	AuthorMissing = (1 << 18) - 1
+	// (Detector.Consume()). It may *not* be (1 << 18) - 1, see BurndownAnalysis.packPersonWithDay().
+	AuthorMissing = (1 << 18) - 2
 	// AuthorMissingName is the string name which corresponds to AuthorMissing.
 	AuthorMissingName = "<unmatched>"
 

+ 6 - 2
leaves/burndown.go

@@ -161,7 +161,7 @@ const (
 	DefaultBurndownGranularity = 30
 	// authorSelf is the internal author index which is used in BurndownAnalysis.Finalize() to
 	// format the author overwrites matrix.
-	authorSelf = (1 << (32 - burndown.TreeMaxBinPower)) - 2
+	authorSelf = identity.AuthorMissing - 1
 )
 
 type sparseHistory = map[int]map[int]int64
@@ -1004,8 +1004,12 @@ func (analyser *BurndownAnalysis) packPersonWithDay(person int, day int) int {
 	}
 	result := day & burndown.TreeMergeMark
 	result |= person << burndown.TreeMaxBinPower
-	// This effectively means max (16383 - 1) days (>44 years) and (131072 - 2) devs.
+	// This effectively means max (16383 - 1) days (>44 years) and (262143 - 3) devs.
 	// One day less because burndown.TreeMergeMark = ((1 << 14) - 1) is a special day.
+	// Three devs less because:
+	// - math.MaxUint32 is the special rbtree value with day == TreeMergeMark (-1)
+	// - identity.AuthorMissing (-2)
+	// - authorSelf (-3)
 	return result
 }
 

+ 1 - 1
leaves/burndown_test.go

@@ -416,7 +416,7 @@ func TestBurndownConsumeMergeAuthorMissing(t *testing.T) {
 	// check that we survive merge + missing author
 	bd := BurndownAnalysis{PeopleNumber: 1}
 	assert.Nil(t, bd.Initialize(test.Repository))
-	deps[identity.DependencyAuthor] = 1
+	deps[identity.DependencyAuthor] = 0
 	deps[core.DependencyIsMerge] = false
 	_, err = bd.Consume(deps)
 	assert.Nil(t, err)