You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by zh...@apache.org on 2022/12/27 02:20:19 UTC

[incubator-devlake] branch main updated: fix(gitex): fix csv (#4030)

This is an automated email from the ASF dual-hosted git repository.

zhangliang2022 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git


The following commit(s) were added to refs/heads/main by this push:
     new a47a28231 fix(gitex): fix csv (#4030)
a47a28231 is described below

commit a47a282319117601b5b0936974802005c2e24655
Author: Warren Chen <yi...@merico.dev>
AuthorDate: Tue Dec 27 10:20:15 2022 +0800

    fix(gitex): fix csv (#4030)
---
 plugins/gitextractor/main.go        | 12 +++++++-----
 plugins/gitextractor/parser/repo.go |  1 -
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/plugins/gitextractor/main.go b/plugins/gitextractor/main.go
index b1fba1ddc..65408d85f 100644
--- a/plugins/gitextractor/main.go
+++ b/plugins/gitextractor/main.go
@@ -57,6 +57,11 @@ func main() {
 	if *id == "" {
 		panic("id is missing")
 	}
+	db, err := runner.NewGormDb(cfg, log)
+	if err != nil {
+		panic(err)
+	}
+	basicRes := rootImpl.NewDefaultBasicRes(cfg, log, dalgorm.NewDalgorm(db))
 	if *output != "" {
 		storage, err = store.NewCsvStore(*output)
 		if err != nil {
@@ -67,12 +72,9 @@ func main() {
 	} else {
 		panic("either specify `-output` or `-db` argument as destination")
 	}
-	db, err := runner.NewGormDb(cfg, log)
-	if err != nil {
-		panic(err)
+	if storage == nil {
+		storage = store.NewDatabase(basicRes, *url)
 	}
-	basicRes := rootImpl.NewDefaultBasicRes(cfg, log, dalgorm.NewDalgorm(db))
-	storage = store.NewDatabase(basicRes, *url)
 	defer storage.Close()
 	ctx := context.Background()
 	subTaskCtx := helper.NewStandaloneSubTaskContext(
diff --git a/plugins/gitextractor/parser/repo.go b/plugins/gitextractor/parser/repo.go
index 0c1700416..6e1d9026f 100644
--- a/plugins/gitextractor/parser/repo.go
+++ b/plugins/gitextractor/parser/repo.go
@@ -218,7 +218,6 @@ func (r *GitRepo) CollectCommits(subtaskCtx core.SubTaskContext) errors.Error {
 	if err != nil {
 		return err
 	}
-	// TODO: this defeat the csv mode!
 	db := subtaskCtx.GetDal()
 	components := make([]code.Component, 0)
 	err = db.All(&components, dal.From(components), dal.Where("repo_id= ?", r.id))