This is an automated email from the ASF dual-hosted git repository. abeizn pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/incubator-devlake.git
commit 95b9759852dd8aa2909d3188d9c20279e51b284f Author: abeizn <[email protected]> AuthorDate: Thu Jun 23 16:45:45 2022 +0800 fix: jira record not found --- plugins/github/tasks/commit_stats_collector.go | 8 ++++---- plugins/github/tasks/commit_stats_extractor.go | 3 ++- plugins/refdiff/tasks/refdiff_task_data.go | 3 ++- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/plugins/github/tasks/commit_stats_collector.go b/plugins/github/tasks/commit_stats_collector.go index b5b46b9d..50716fbe 100644 --- a/plugins/github/tasks/commit_stats_collector.go +++ b/plugins/github/tasks/commit_stats_collector.go @@ -20,16 +20,16 @@ package tasks import ( "encoding/json" "fmt" + "gorm.io/gorm" "io/ioutil" "net/http" "net/url" "reflect" - "github.com/apache/incubator-devlake/plugins/core/dal" - "github.com/apache/incubator-devlake/plugins/helper" - "github.com/apache/incubator-devlake/plugins/core" + "github.com/apache/incubator-devlake/plugins/core/dal" "github.com/apache/incubator-devlake/plugins/github/models" + "github.com/apache/incubator-devlake/plugins/helper" ) const RAW_COMMIT_STATS_TABLE = "github_api_commit_stats" @@ -54,7 +54,7 @@ func CollectApiCommitStats(taskCtx core.SubTaskContext) error { dal.Orderby("committed_date DESC"), dal.Limit(1), ) - if err != nil { + if err != nil && err != gorm.ErrRecordNotFound { return fmt.Errorf("failed to get latest github commit record: %w", err) } diff --git a/plugins/github/tasks/commit_stats_extractor.go b/plugins/github/tasks/commit_stats_extractor.go index 48a20c5a..87b88892 100644 --- a/plugins/github/tasks/commit_stats_extractor.go +++ b/plugins/github/tasks/commit_stats_extractor.go @@ -21,6 +21,7 @@ import ( "encoding/json" "github.com/apache/incubator-devlake/plugins/core/dal" + "gorm.io/gorm" "github.com/apache/incubator-devlake/plugins/core" "github.com/apache/incubator-devlake/plugins/github/models" @@ -83,7 +84,7 @@ func ExtractApiCommitStats(taskCtx core.SubTaskContext) error { db := taskCtx.GetDal() commit := &models.GithubCommit{} err = db.First(commit, dal.Where("sha = ?", body.Sha), dal.Limit(1)) - if err != nil { + if err != nil && err != gorm.ErrRecordNotFound { return nil, err } diff --git a/plugins/refdiff/tasks/refdiff_task_data.go b/plugins/refdiff/tasks/refdiff_task_data.go index 8e0c9fec..0d5747a8 100644 --- a/plugins/refdiff/tasks/refdiff_task_data.go +++ b/plugins/refdiff/tasks/refdiff_task_data.go @@ -19,6 +19,7 @@ package tasks import ( "fmt" + "gorm.io/gorm" "regexp" "sort" "strings" @@ -203,7 +204,7 @@ func CalculateCommitPairs(db dal.Dal, repoId string, pairs []RefPair, rs Refs) ( } ref.Id = fmt.Sprintf("%s:%s", repoId, refName) err := db.First(ref) - if err != nil { + if err != nil && err != gorm.ErrRecordNotFound { return "", fmt.Errorf("faild to load Ref info for repoId:%s, refName:%s", repoId, refName) } return ref.CommitSha, nil
