(repo *cache.RepoCache, issue *gitlab.Issue)
| 101 | } |
| 102 | |
| 103 | func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue) (*cache.BugCache, error) { |
| 104 | // ensure issue author |
| 105 | author, err := gi.ensurePerson(repo, issue.Author.ID) |
| 106 | if err != nil { |
| 107 | return nil, err |
| 108 | } |
| 109 | |
| 110 | // resolve bug |
| 111 | b, err := repo.Bugs().ResolveMatcher(func(excerpt *cache.BugExcerpt) bool { |
| 112 | return excerpt.CreateMetadata[core.MetaKeyOrigin] == target && |
| 113 | excerpt.CreateMetadata[metaKeyGitlabId] == fmt.Sprintf("%d", issue.IID) && |
| 114 | excerpt.CreateMetadata[metaKeyGitlabBaseUrl] == gi.conf[confKeyGitlabBaseUrl] && |
| 115 | excerpt.CreateMetadata[metaKeyGitlabProject] == gi.conf[confKeyProjectID] |
| 116 | }) |
| 117 | if err == nil { |
| 118 | return b, nil |
| 119 | } |
| 120 | if !entity.IsErrNotFound(err) { |
| 121 | return nil, err |
| 122 | } |
| 123 | |
| 124 | // if bug was never imported, create bug |
| 125 | b, _, err = repo.Bugs().NewRaw( |
| 126 | author, |
| 127 | issue.CreatedAt.Unix(), |
| 128 | text.CleanupOneLine(issue.Title), |
| 129 | text.Cleanup(issue.Description), |
| 130 | nil, |
| 131 | map[string]string{ |
| 132 | core.MetaKeyOrigin: target, |
| 133 | metaKeyGitlabId: fmt.Sprintf("%d", issue.IID), |
| 134 | metaKeyGitlabUrl: issue.WebURL, |
| 135 | metaKeyGitlabProject: gi.conf[confKeyProjectID], |
| 136 | metaKeyGitlabBaseUrl: gi.conf[confKeyGitlabBaseUrl], |
| 137 | }, |
| 138 | ) |
| 139 | |
| 140 | if err != nil { |
| 141 | return nil, err |
| 142 | } |
| 143 | |
| 144 | // importing a new bug |
| 145 | gi.out <- core.NewImportBug(b.Id()) |
| 146 | |
| 147 | return b, nil |
| 148 | } |
| 149 | |
| 150 | func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCache, issue *gitlab.Issue, event Event) error { |
| 151 | id, errResolve := b.ResolveOperationWithMetadata(metaKeyGitlabId, event.ID()) |
no test coverage detected