You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devlake.apache.org by wa...@apache.org on 2022/07/13 12:43:43 UTC
[incubator-devlake] branch main updated: feat: extract author info from commit
This is an automated email from the ASF dual-hosted git repository.
warren 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 e8eea41b feat: extract author info from commit
e8eea41b is described below
commit e8eea41b69df0ac5e13fa147981bc43d7976fc05
Author: zhangliang <li...@merico.dev>
AuthorDate: Wed Jul 13 00:32:44 2022 +0800
feat: extract author info from commit
---
plugins/gitextractor/store/database.go | 21 ++++++++++++++++++---
1 file changed, 18 insertions(+), 3 deletions(-)
diff --git a/plugins/gitextractor/store/database.go b/plugins/gitextractor/store/database.go
index b050da94..becb5264 100644
--- a/plugins/gitextractor/store/database.go
+++ b/plugins/gitextractor/store/database.go
@@ -21,7 +21,9 @@ import (
"fmt"
"reflect"
+ "github.com/apache/incubator-devlake/models/domainlayer"
"github.com/apache/incubator-devlake/models/domainlayer/code"
+ "github.com/apache/incubator-devlake/models/domainlayer/crossdomain"
"github.com/apache/incubator-devlake/plugins/core"
"github.com/apache/incubator-devlake/plugins/helper"
)
@@ -29,7 +31,6 @@ import (
const BathSize = 100
type Database struct {
- //db *gorm.DB
driver *helper.BatchSaveDivider
}
@@ -53,11 +54,25 @@ func (d *Database) RepoCommits(repoCommit *code.RepoCommit) error {
}
func (d *Database) Commits(commit *code.Commit) error {
- batch, err := d.driver.ForType(reflect.TypeOf(commit))
+ account := &crossdomain.Account{
+ DomainEntity: domainlayer.DomainEntity{Id: commit.AuthorEmail},
+ Email: commit.AuthorEmail,
+ FullName: commit.AuthorName,
+ UserName: commit.AuthorName,
+ }
+ accountBatch, err := d.driver.ForType(reflect.TypeOf(account))
+ if err != nil {
+ return err
+ }
+ err = accountBatch.Add(account)
+ if err != nil {
+ return err
+ }
+ commitBatch, err := d.driver.ForType(reflect.TypeOf(commit))
if err != nil {
return err
}
- return batch.Add(commit)
+ return commitBatch.Add(commit)
}
func (d *Database) Refs(ref *code.Ref) error {