diff options
author | Michael Muré <batolettre@gmail.com> | 2022-11-15 12:25:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-15 12:25:48 +0100 |
commit | 9b393b487308da156c5988bb7c2d2747f7b7f8aa (patch) | |
tree | 8cf4307bf48f016e0f8728c311bcc53ce38432e3 /bridge/jira | |
parent | 55a2e8e4485fe63fbda759540958c7190dfeb85c (diff) | |
parent | 3c6ebc2bfd50b72ff786a2cfd3bbdeb15b478dd3 (diff) | |
download | git-bug-9b393b487308da156c5988bb7c2d2747f7b7f8aa.tar.gz |
Merge pull request #913 from MichaelMure/comment-id-fix
core: bubble up the comment ID when created, or edited the first comment
Diffstat (limited to 'bridge/jira')
-rw-r--r-- | bridge/jira/export.go | 14 | ||||
-rw-r--r-- | bridge/jira/import.go | 24 |
2 files changed, 20 insertions, 18 deletions
diff --git a/bridge/jira/export.go b/bridge/jira/export.go index 763d6a1c..8587a55d 100644 --- a/bridge/jira/export.go +++ b/bridge/jira/export.go @@ -315,7 +315,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch if err != nil { out <- core.NewExportError( fmt.Errorf("missing operation author credentials for user %.8s", - author.Id().String()), op.Id()) + author.Id().String()), b.Id()) continue } @@ -330,7 +330,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch return err } id = comment.ID - out <- core.NewExportComment(op.Id()) + out <- core.NewExportComment(b.Id()) // cache comment id je.cachedOperationIDs[op.Id()] = id @@ -345,7 +345,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch out <- core.NewExportError(err, b.Id()) return err } - out <- core.NewExportCommentEdition(op.Id()) + out <- core.NewExportCommentEdition(b.Id()) id = bugJiraID } else { // Otherwise it's an edit to an actual comment. A comment cannot be @@ -363,7 +363,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch out <- core.NewExportError(err, b.Id()) return err } - out <- core.NewExportCommentEdition(op.Id()) + out <- core.NewExportCommentEdition(b.Id()) // JIRA doesn't track all comment edits, they will only tell us about // the most recent one. We must invent a consistent id for the operation // so we use the comment ID plus the timestamp of the update, as @@ -384,7 +384,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch // update. In this case, just don't export the operation. continue } - out <- core.NewExportStatusChange(op.Id()) + out <- core.NewExportStatusChange(b.Id()) id = bugJiraID } else { out <- core.NewExportError(fmt.Errorf( @@ -398,7 +398,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch out <- core.NewExportError(err, b.Id()) return err } - out <- core.NewExportTitleEdition(op.Id()) + out <- core.NewExportTitleEdition(b.Id()) id = bugJiraID case *bug.LabelChangeOperation: @@ -409,7 +409,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch out <- core.NewExportError(err, b.Id()) return err } - out <- core.NewExportLabelChange(op.Id()) + out <- core.NewExportLabelChange(b.Id()) id = bugJiraID default: diff --git a/bridge/jira/import.go b/bridge/jira/import.go index 8043acf4..ff9fbb7a 100644 --- a/bridge/jira/import.go +++ b/bridge/jira/import.go @@ -286,7 +286,7 @@ func (ji *jiraImporter) ensureComment(repo *cache.RepoCache, b *cache.BugCache, } // add comment operation - op, err := b.AddCommentRaw( + commentId, op, err := b.AddCommentRaw( author, item.Created.Unix(), cleanText, @@ -299,7 +299,7 @@ func (ji *jiraImporter) ensureComment(repo *cache.RepoCache, b *cache.BugCache, return err } - ji.out <- core.NewImportComment(op.Id()) + ji.out <- core.NewImportComment(b.Id(), commentId) targetOpID = op.Id() } @@ -329,11 +329,13 @@ func (ji *jiraImporter) ensureComment(repo *cache.RepoCache, b *cache.BugCache, return err } + commentId := entity.CombineIds(b.Id(), targetOpID) + // comment edition - op, err := b.EditCommentRaw( + _, err = b.EditCommentRaw( editor, item.Updated.Unix(), - entity.CombineIds(b.Id(), targetOpID), + commentId, text.Cleanup(item.Body), map[string]string{ metaKeyJiraId: derivedID, @@ -344,7 +346,7 @@ func (ji *jiraImporter) ensureComment(repo *cache.RepoCache, b *cache.BugCache, return err } - ji.out <- core.NewImportCommentEdition(op.Id()) + ji.out <- core.NewImportCommentEdition(b.Id(), commentId) return nil } @@ -510,7 +512,7 @@ func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, e return err } - ji.out <- core.NewImportLabelChange(op.Id()) + ji.out <- core.NewImportLabelChange(b.Id(), op.Id()) case "status": statusStr, hasMap := statusMap[item.To] @@ -528,7 +530,7 @@ func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, e if err != nil { return err } - ji.out <- core.NewImportStatusChange(op.Id()) + ji.out <- core.NewImportStatusChange(b.Id(), op.Id()) case common.ClosedStatus.String(): op, err := b.CloseRaw( @@ -542,7 +544,7 @@ func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, e if err != nil { return err } - ji.out <- core.NewImportStatusChange(op.Id()) + ji.out <- core.NewImportStatusChange(b.Id(), op.Id()) } } else { ji.out <- core.NewImportError( @@ -567,12 +569,12 @@ func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, e return err } - ji.out <- core.NewImportTitleEdition(op.Id()) + ji.out <- core.NewImportTitleEdition(b.Id(), op.Id()) case "description": // NOTE(josh): JIRA calls it "description", which sounds more like the // title but it's actually the body - op, err := b.EditCreateCommentRaw( + commentId, _, err := b.EditCreateCommentRaw( author, entry.Created.Unix(), text.Cleanup(item.ToString), @@ -585,7 +587,7 @@ func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, e return err } - ji.out <- core.NewImportCommentEdition(op.Id()) + ji.out <- core.NewImportCommentEdition(b.Id(), commentId) default: ji.out <- core.NewImportWarning( |