Преглед на файлове

Fix the commit index bug

Vadim Markovtsev преди 6 години
родител
ревизия
22c1b913d0
променени са 2 файла, в които са добавени 8 реда и са изтрити 6 реда
  1. 7 5
      internal/core/pipeline.go
  2. 1 1
      leaves/burndown.go

+ 7 - 5
internal/core/pipeline.go

@@ -558,6 +558,7 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 	rootClone := cloneItems(pipeline.items, 1)[0]
 	var newestTime int64
 
+	commitIndex := 0
 	for index, step := range plan {
 		onProgress(index + 1, progressSteps)
 		firstItem := step.Items[0]
@@ -565,13 +566,13 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 		case runActionCommit:
 			state := map[string]interface{}{
 				DependencyCommit: step.Commit,
-				DependencyIndex: index,
+				DependencyIndex: commitIndex,
 			}
 			for _, item := range branches[firstItem] {
 				update, err := item.Consume(state)
 				if err != nil {
-					log.Printf("%s failed on commit #%d %s\n",
-						item.Name(), index + 1, step.Commit.Hash.String())
+					log.Printf("%s failed on commit #%d (%d) %s\n",
+						item.Name(), commitIndex + 1, index + 1, step.Commit.Hash.String())
 					return nil, err
 				}
 				for _, key := range item.Provides() {
@@ -582,10 +583,11 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 					state[key] = val
 				}
 			}
-			commitTime := step.Commit.Author.When.Unix()
+			commitTime := step.Commit.Committer.When.Unix()
 			if commitTime > newestTime {
 				newestTime = commitTime
 			}
+			commitIndex++
 		case runActionFork:
 			for i, clone := range cloneItems(branches[firstItem], len(step.Items)-1) {
 				branches[step.Items[i+1]] = clone
@@ -615,7 +617,7 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 	}
 	onProgress(progressSteps, progressSteps)
 	result[nil] = &CommonAnalysisResult{
-		BeginTime:     plan[0].Commit.Author.When.Unix(),
+		BeginTime:     plan[0].Commit.Committer.When.Unix(),
 		EndTime:       newestTime,
 		CommitsNumber: len(commits),
 		RunTime:       time.Since(startRunTime),

+ 1 - 1
leaves/burndown.go

@@ -21,7 +21,7 @@ import (
 	items "gopkg.in/src-d/hercules.v4/internal/plumbing"
 	"gopkg.in/src-d/hercules.v4/internal/plumbing/identity"
 	"gopkg.in/src-d/hercules.v4/yaml"
-	)
+)
 
 // BurndownAnalysis allows to gather the line burndown statistics for a Git repository.
 // It is a LeafPipelineItem.