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/07/11 07:18:01 UTC
[incubator-devlake] branch main updated: fix: github record not found and jira connection failed (#2463)
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 69dd8fcc fix: github record not found and jira connection failed (#2463)
69dd8fcc is described below
commit 69dd8fcc04c5e37bf95d1b57ec69d08a93d4ae6a
Author: abeizn <10...@users.noreply.github.com>
AuthorDate: Mon Jul 11 15:17:57 2022 +0800
fix: github record not found and jira connection failed (#2463)
* fix: github record not found
* fix: jira connection failed
* fix: jira connection failed
---
plugins/github/tasks/comment_extractor.go | 3 +-
.../jira/models/migrationscripts/init_schema.go | 71 +++++++++++-----------
2 files changed, 39 insertions(+), 35 deletions(-)
diff --git a/plugins/github/tasks/comment_extractor.go b/plugins/github/tasks/comment_extractor.go
index 4ef82c18..d2e919b3 100644
--- a/plugins/github/tasks/comment_extractor.go
+++ b/plugins/github/tasks/comment_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"
@@ -84,7 +85,7 @@ func ExtractApiComments(taskCtx core.SubTaskContext) error {
if issue.GithubId == 0 {
pr := &models.GithubPullRequest{}
err = taskCtx.GetDal().First(pr, dal.Where("connection_id = ? and number = ? and repo_id = ?", data.Options.ConnectionId, issueINumber, data.Repo.GithubId))
- if err != nil {
+ if err != nil && err != gorm.ErrRecordNotFound {
return nil, err
}
githubPrComment := &models.GithubPullRequestComment{
diff --git a/plugins/jira/models/migrationscripts/init_schema.go b/plugins/jira/models/migrationscripts/init_schema.go
index 5af83d2a..77461180 100644
--- a/plugins/jira/models/migrationscripts/init_schema.go
+++ b/plugins/jira/models/migrationscripts/init_schema.go
@@ -107,49 +107,52 @@ func (*InitSchemas) Up(ctx context.Context, db *gorm.DB) error {
db.Create(&conn)
}
}
- } else if m.HasTable(&archived.JiraConnectionV10{}) {
- var jiraConns []archived.JiraConnectionV10
- result = db.Find(&jiraConns)
+ }
+ } else if m.HasTable(&archived.JiraConnectionV10{}) {
+ var jiraConns []archived.JiraConnectionV10
+ result = db.Find(&jiraConns)
+
+ if result.Error == nil {
+ err := db.Migrator().DropTable(&archived.JiraConnectionV10{})
+ if err != nil {
+ return err
+ }
+ err = db.Migrator().AutoMigrate(&archived.JiraConnection{})
+ if err != nil {
+ return err
+ }
- if result.Error == nil {
- err := db.Migrator().DropTable(&archived.JiraConnectionV10{})
+ for _, v := range jiraConns {
+ conn := &archived.JiraConnection{}
+ conn.ID = v.ID
+ conn.Name = v.Name
+ conn.Endpoint = v.Endpoint
+ conn.Proxy = v.Proxy
+ conn.RateLimit = v.RateLimit
+
+ c := config.GetConfig()
+ encKey := c.GetString("ENCODE_KEY")
+ auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
if err != nil {
return err
}
- err = db.Migrator().AutoMigrate(&archived.JiraConnection{})
+ pk, err := base64.StdEncoding.DecodeString(auth)
if err != nil {
return err
}
-
- for _, v := range jiraConns {
- conn := &archived.JiraConnection{}
- conn.ID = v.ID
- conn.Name = v.Name
- conn.Endpoint = v.Endpoint
- conn.Proxy = v.Proxy
- conn.RateLimit = v.RateLimit
-
- c := config.GetConfig()
- encKey := c.GetString("ENCODE_KEY")
- auth, err := core.Decrypt(encKey, v.BasicAuthEncoded)
- if err != nil {
- return err
- }
- pk, err := base64.StdEncoding.DecodeString(auth)
- if err != nil {
- return err
- }
- originInfo := strings.Split(string(pk), ":")
- if len(originInfo) == 2 {
- conn.Username = originInfo[0]
- conn.Password = originInfo[1]
- // create
- db.Create(&conn)
- }
+ originInfo := strings.Split(string(pk), ":")
+ if len(originInfo) == 2 {
+ conn.Username = originInfo[0]
+ conn.Password = originInfo[1]
+ // create
+ db.Create(&conn)
}
}
- } else {
- return result.Error
+ }
+ } else {
+ err := db.Migrator().AutoMigrate(&archived.JiraConnection{})
+ if err != nil {
+ return err
}
}