aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/gitlab/import.go
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/gitlab/import.go')
-rw-r--r--bridge/gitlab/import.go43
1 files changed, 21 insertions, 22 deletions
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go
index e2015773..92e9952e 100644
--- a/bridge/gitlab/import.go
+++ b/bridge/gitlab/import.go
@@ -73,8 +73,10 @@ func (gi *gitlabImporter) ImportAll(ctx context.Context, repo *cache.RepoCache,
}
}
- // commit bug state
- if err := b.CommitAsNeeded(); err != nil {
+ if !b.NeedCommit() {
+ out <- core.NewImportNothing(b.Id(), "no imported operation")
+ } else if err := b.Commit(); err != nil {
+ // commit bug state
err := fmt.Errorf("bug commit: %v", err)
out <- core.NewImportError(err, "")
return
@@ -97,9 +99,8 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
}
// resolve bug
- b, err := repo.ResolveBugCreateMetadata(keyGitlabUrl, issue.WebURL)
+ b, err := repo.ResolveBugCreateMetadata(metaKeyGitlabUrl, issue.WebURL)
if err == nil {
- gi.out <- core.NewImportNothing("", "bug already imported")
return b, nil
}
if err != bug.ErrBugNotExist {
@@ -120,10 +121,10 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
cleanText,
nil,
map[string]string{
- core.KeyOrigin: target,
- keyGitlabId: parseID(issue.IID),
- keyGitlabUrl: issue.WebURL,
- keyGitlabProject: gi.conf[keyProjectID],
+ core.MetaKeyOrigin: target,
+ metaKeyGitlabId: parseID(issue.IID),
+ metaKeyGitlabUrl: issue.WebURL,
+ metaKeyGitlabProject: gi.conf[keyProjectID],
},
)
@@ -140,7 +141,7 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, note *gitlab.Note) error {
gitlabID := parseID(note.ID)
- id, errResolve := b.ResolveOperationWithMetadata(keyGitlabId, gitlabID)
+ id, errResolve := b.ResolveOperationWithMetadata(metaKeyGitlabId, gitlabID)
if errResolve != nil && errResolve != cache.ErrNoMatchingOp {
return errResolve
}
@@ -162,7 +163,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
author,
note.CreatedAt.Unix(),
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -180,7 +181,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
author,
note.CreatedAt.Unix(),
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -204,7 +205,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
firstComment.Id(),
issue.Description,
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -230,7 +231,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
cleanText,
nil,
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -278,7 +279,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
note.CreatedAt.Unix(),
body,
map[string]string{
- keyGitlabId: gitlabID,
+ metaKeyGitlabId: gitlabID,
},
)
if err != nil {
@@ -299,8 +300,6 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
NOTE_MENTIONED_IN_ISSUE,
NOTE_MENTIONED_IN_MERGE_REQUEST:
- reason := fmt.Sprintf("unsupported note type: %s", noteType.String())
- gi.out <- core.NewImportNothing("", reason)
return nil
default:
@@ -311,7 +310,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n
}
func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCache, labelEvent *gitlab.LabelEvent) error {
- _, err := b.ResolveOperationWithMetadata(keyGitlabId, parseID(labelEvent.ID))
+ _, err := b.ResolveOperationWithMetadata(metaKeyGitlabId, parseID(labelEvent.ID))
if err != cache.ErrNoMatchingOp {
return err
}
@@ -330,7 +329,7 @@ func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCa
[]string{labelEvent.Label.Name},
nil,
map[string]string{
- keyGitlabId: parseID(labelEvent.ID),
+ metaKeyGitlabId: parseID(labelEvent.ID),
},
)
@@ -341,7 +340,7 @@ func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCa
nil,
[]string{labelEvent.Label.Name},
map[string]string{
- keyGitlabId: parseID(labelEvent.ID),
+ metaKeyGitlabId: parseID(labelEvent.ID),
},
)
@@ -354,7 +353,7 @@ func (gi *gitlabImporter) ensureLabelEvent(repo *cache.RepoCache, b *cache.BugCa
func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.IdentityCache, error) {
// Look first in the cache
- i, err := repo.ResolveIdentityImmutableMetadata(keyGitlabId, strconv.Itoa(id))
+ i, err := repo.ResolveIdentityImmutableMetadata(metaKeyGitlabId, strconv.Itoa(id))
if err == nil {
return i, nil
}
@@ -376,8 +375,8 @@ func (gi *gitlabImporter) ensurePerson(repo *cache.RepoCache, id int) (*cache.Id
user.AvatarURL,
map[string]string{
// because Gitlab
- keyGitlabId: strconv.Itoa(id),
- keyGitlabLogin: user.Username,
+ metaKeyGitlabId: strconv.Itoa(id),
+ metaKeyGitlabLogin: user.Username,
},
)
if err != nil {