(taskCtx plugin.SubTaskContext)
| 32 | ) |
| 33 | |
| 34 | func ConvertBugCommit(taskCtx plugin.SubTaskContext) errors.Error { |
| 35 | rawDataSubTaskArgs, data := CreateRawDataSubTaskArgs(taskCtx, RAW_BUG_COMMIT_TABLE) |
| 36 | logger := taskCtx.GetLogger() |
| 37 | db := taskCtx.GetDal() |
| 38 | logger.Info("convert workspace: %d", data.Options.WorkspaceId) |
| 39 | clauses := []dal.Clause{ |
| 40 | dal.From(&models.TapdBugCommit{}), |
| 41 | dal.Where("connection_id = ? AND workspace_id = ?", data.Options.ConnectionId, data.Options.WorkspaceId), |
| 42 | } |
| 43 | cursor, err := db.Cursor(clauses...) |
| 44 | if err != nil { |
| 45 | return err |
| 46 | } |
| 47 | defer cursor.Close() |
| 48 | issueIdGen := didgen.NewDomainIdGenerator(&models.TapdBug{}) |
| 49 | converter, err := helper.NewDataConverter(helper.DataConverterArgs{ |
| 50 | RawDataSubTaskArgs: *rawDataSubTaskArgs, |
| 51 | InputRowType: reflect.TypeOf(models.TapdBugCommit{}), |
| 52 | Input: cursor, |
| 53 | Convert: func(inputRow interface{}) ([]interface{}, errors.Error) { |
| 54 | toolL := inputRow.(*models.TapdBugCommit) |
| 55 | results := make([]interface{}, 0, 2) |
| 56 | issueCommit := &crossdomain.IssueCommit{ |
| 57 | IssueId: issueIdGen.Generate(data.Options.ConnectionId, toolL.BugId), |
| 58 | CommitSha: toolL.CommitId, |
| 59 | } |
| 60 | results = append(results, issueCommit) |
| 61 | if toolL.WebURL != `` { |
| 62 | u, err := errors.Convert01(url.Parse(toolL.WebURL)) |
| 63 | if err != nil { |
| 64 | return nil, err |
| 65 | } |
| 66 | repoUrl := toolL.WebURL |
| 67 | if !strings.HasSuffix(repoUrl, `.git`) { |
| 68 | repoUrl = repoUrl + `.git` |
| 69 | } |
| 70 | issueRepoCommit := &crossdomain.IssueRepoCommit{ |
| 71 | IssueId: issueIdGen.Generate(data.Options.ConnectionId, toolL.BugId), |
| 72 | RepoUrl: repoUrl, |
| 73 | CommitSha: toolL.CommitId, |
| 74 | Host: u.Hostname(), |
| 75 | Namespace: getRepoNamespaceFromUrlPath(u.Path), |
| 76 | RepoName: getRepoNameFromUrlPath(u.Path), |
| 77 | } |
| 78 | results = append(results, issueRepoCommit) |
| 79 | } |
| 80 | |
| 81 | return results, nil |
| 82 | }, |
| 83 | }) |
| 84 | if err != nil { |
| 85 | return err |
| 86 | } |
| 87 | |
| 88 | return converter.Execute() |
| 89 | } |
| 90 | |
| 91 | var ConvertBugCommitMeta = plugin.SubTaskMeta{ |
nothing calls this directly
no test coverage detected