浏览代码

Handle panics inside Pipeline.Run() better

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 6 年之前
父节点
当前提交
24177530e6
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 10 0
      internal/core/pipeline.go
  2. 0 1
      leaves/burndown.go

+ 10 - 0
internal/core/pipeline.go

@@ -681,6 +681,15 @@ func (pipeline *Pipeline) Initialize(facts map[string]interface{}) error {
 // There is always a "nil" record with CommonAnalysisResult.
 func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]interface{}, error) {
 	startRunTime := time.Now()
+	cleanReturn := false
+	defer func() {
+		if !cleanReturn {
+			remotes, _ := pipeline.repository.Remotes()
+			if len(remotes) > 0 {
+				log.Printf("Failed to run the pipeline on %s", remotes[0].Config().URLs)
+			}
+		}
+	}()
 	onProgress := pipeline.OnProgress
 	if onProgress == nil {
 		onProgress = func(int, int) {}
@@ -838,6 +847,7 @@ func (pipeline *Pipeline) Run(commits []*object.Commit) (map[LeafPipelineItem]in
 		RunTime:        time.Since(startRunTime),
 		RunTimePerItem: runTimePerItem,
 	}
+	cleanReturn = true
 	return result, nil
 }
 

+ 0 - 1
leaves/burndown.go

@@ -1132,7 +1132,6 @@ func (analyser *BurndownAnalysis) handleInsertion(
 	name := change.To.Name
 	file, exists := analyser.files[name]
 	if exists {
-		log.Println("\n", analyser, "error")
 		return fmt.Errorf("file %s already exists", name)
 	}
 	var hash plumbing.Hash