diff options
author | Michael Muré <batolettre@gmail.com> | 2019-08-05 23:27:05 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-05 23:27:05 +0100 |
commit | 2c3034a0abe13eb6b07d8dd13041e7be4adc6f93 (patch) | |
tree | 65b6e753200104ff69906e9e553d01ea88dd8b2b | |
parent | 00402f1cece6270d5caccee04f0ccbb6dbe87004 (diff) | |
parent | e678e81bc70638a1217b3c657fcdf7e270c3e222 (diff) | |
download | git-bug-2c3034a0abe13eb6b07d8dd13041e7be4adc6f93.tar.gz |
Merge pull request #189 from A-Hilaly/bridge-gitlab-fix
bridge: fix gitlab bridge when running multiple imports.
-rw-r--r-- | bridge/gitlab/import.go | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go index e9426016..dbedfda8 100644 --- a/bridge/gitlab/import.go +++ b/bridge/gitlab/import.go @@ -132,6 +132,11 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, note *gitlab.Note) error { id := parseID(note.ID) + hash, errResolve := b.ResolveOperationWithMetadata(keyGitlabId, id) + if errResolve != nil && errResolve != cache.ErrNoMatchingOp { + return errResolve + } + // ensure issue author author, err := gi.ensurePerson(repo, note.Author.ID) if err != nil { @@ -141,6 +146,10 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n noteType, body := GetNoteType(note) switch noteType { case NOTE_CLOSED: + if errResolve == nil { + return nil + } + _, err = b.CloseRaw( author, note.CreatedAt.Unix(), @@ -151,6 +160,10 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n return err case NOTE_REOPENED: + if errResolve == nil { + return nil + } + _, err = b.OpenRaw( author, note.CreatedAt.Unix(), @@ -167,8 +180,7 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n // since gitlab doesn't provide the issue history // we should check for "changed the description" notes and compare issue texts // TODO: Check only one time and ignore next 'description change' within one issue - if issue.Description != firstComment.Message { - + if errResolve == cache.ErrNoMatchingOp && issue.Description != firstComment.Message { // comment edition _, err = b.EditCommentRaw( author, @@ -184,11 +196,6 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n } case NOTE_COMMENT: - hash, errResolve := b.ResolveOperationWithMetadata(keyGitlabId, id) - if errResolve != cache.ErrNoMatchingOp { - return errResolve - } - cleanText, err := text.Cleanup(body) if err != nil { return err @@ -237,6 +244,10 @@ func (gi *gitlabImporter) ensureNote(repo *cache.RepoCache, b *cache.BugCache, n case NOTE_TITLE_CHANGED: // title change events are given new notes + if errResolve == nil { + return nil + } + _, err = b.SetTitleRaw( author, note.CreatedAt.Unix(), |