diff options
author | Michael Muré <batolettre@gmail.com> | 2022-11-13 12:31:38 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-11-13 12:31:38 +0100 |
commit | 3c6ebc2bfd50b72ff786a2cfd3bbdeb15b478dd3 (patch) | |
tree | 8cf4307bf48f016e0f8728c311bcc53ce38432e3 /bridge/gitlab | |
parent | 55a2e8e4485fe63fbda759540958c7190dfeb85c (diff) | |
download | git-bug-3c6ebc2bfd50b72ff786a2cfd3bbdeb15b478dd3.tar.gz |
core: bubble up the comment ID when created, or edited the first comment
Diffstat (limited to 'bridge/gitlab')
-rw-r--r-- | bridge/gitlab/export.go | 16 | ||||
-rw-r--r-- | bridge/gitlab/export_test.go | 7 | ||||
-rw-r--r-- | bridge/gitlab/import.go | 16 |
3 files changed, 19 insertions, 20 deletions
diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go index 04972455..83465428 100644 --- a/bridge/gitlab/export.go +++ b/bridge/gitlab/export.go @@ -288,7 +288,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out return } - out <- core.NewExportComment(op.Id()) + out <- core.NewExportComment(b.Id()) idString = strconv.Itoa(id) // cache comment id @@ -307,7 +307,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out return } - out <- core.NewExportCommentEdition(op.Id()) + out <- core.NewExportCommentEdition(b.Id()) id = bugGitlabID } else { @@ -315,13 +315,13 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out // case comment edition operation: we need to edit the Gitlab comment commentID, ok := ge.cachedOperationIDs[targetId] if !ok { - out <- core.NewExportError(fmt.Errorf("unexpected error: comment id not found"), op.Target) + out <- core.NewExportError(fmt.Errorf("unexpected error: comment id not found"), b.Id()) return } commentIDint, err := strconv.Atoi(commentID) if err != nil { - out <- core.NewExportError(fmt.Errorf("unexpected comment id format"), op.Target) + out <- core.NewExportError(fmt.Errorf("unexpected comment id format"), b.Id()) return } @@ -331,7 +331,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out return } - out <- core.NewExportCommentEdition(op.Id()) + out <- core.NewExportCommentEdition(b.Id()) id = commentIDint } @@ -342,7 +342,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out return } - out <- core.NewExportStatusChange(op.Id()) + out <- core.NewExportStatusChange(b.Id()) id = bugGitlabID case *bug.SetTitleOperation: @@ -352,7 +352,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out return } - out <- core.NewExportTitleEdition(op.Id()) + out <- core.NewExportTitleEdition(b.Id()) id = bugGitlabID case *bug.LabelChangeOperation: @@ -378,7 +378,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out return } - out <- core.NewExportLabelChange(op.Id()) + out <- core.NewExportLabelChange(b.Id()) id = bugGitlabID default: panic("unhandled operation type case") diff --git a/bridge/gitlab/export_test.go b/bridge/gitlab/export_test.go index e9f3ae75..47d5a9b1 100644 --- a/bridge/gitlab/export_test.go +++ b/bridge/gitlab/export_test.go @@ -44,7 +44,7 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase { bugWithComments, _, err := repo.NewBug("bug with comments", "new bug") require.NoError(t, err) - _, err = bugWithComments.AddComment("new comment") + _, _, err = bugWithComments.AddComment("new comment") require.NoError(t, err) // bug with label changes @@ -68,11 +68,10 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase { entity.CombineIds(bugWithCommentEditions.Id(), createOp.Id()), "first comment edited") require.NoError(t, err) - commentOp, err := bugWithCommentEditions.AddComment("first comment") + commentId, _, err := bugWithCommentEditions.AddComment("first comment") require.NoError(t, err) - _, err = bugWithCommentEditions.EditComment( - entity.CombineIds(bugWithCommentEditions.Id(), commentOp.Id()), "first comment edited") + _, err = bugWithCommentEditions.EditComment(commentId, "first comment edited") require.NoError(t, err) // bug status changed diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go index cf6b5ca6..c7909c8f 100644 --- a/bridge/gitlab/import.go +++ b/bridge/gitlab/import.go @@ -178,7 +178,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa return err } - gi.out <- core.NewImportStatusChange(op.Id()) + gi.out <- core.NewImportStatusChange(b.Id(), op.Id()) case EventReopened: if errResolve == nil { @@ -196,7 +196,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa return err } - gi.out <- core.NewImportStatusChange(op.Id()) + gi.out <- core.NewImportStatusChange(b.Id(), op.Id()) case EventDescriptionChanged: firstComment := b.Snapshot().Comments[0] @@ -219,7 +219,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa return err } - gi.out <- core.NewImportTitleEdition(op.Id()) + gi.out <- core.NewImportTitleEdition(b.Id(), op.Id()) } case EventComment: @@ -229,7 +229,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa if errResolve == cache.ErrNoMatchingOp { // add comment operation - op, err := b.AddCommentRaw( + commentId, _, err := b.AddCommentRaw( author, event.CreatedAt().Unix(), cleanText, @@ -241,7 +241,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa if err != nil { return err } - gi.out <- core.NewImportComment(op.Id()) + gi.out <- core.NewImportComment(b.Id(), commentId) return nil } @@ -256,7 +256,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa // compare local bug comment with the new event body if comment.Message != cleanText { // comment edition - op, err := b.EditCommentRaw( + _, err := b.EditCommentRaw( author, event.(NoteEvent).UpdatedAt.Unix(), comment.CombinedId(), @@ -267,7 +267,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa if err != nil { return err } - gi.out <- core.NewImportCommentEdition(op.Id()) + gi.out <- core.NewImportCommentEdition(b.Id(), comment.CombinedId()) } return nil @@ -290,7 +290,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa return err } - gi.out <- core.NewImportTitleEdition(op.Id()) + gi.out <- core.NewImportTitleEdition(b.Id(), op.Id()) case EventAddLabel: _, err = b.ForceChangeLabelsRaw( |