aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/github')
-rw-r--r--bridge/github/export.go14
-rw-r--r--bridge/github/export_test.go7
-rw-r--r--bridge/github/import.go22
3 files changed, 22 insertions, 21 deletions
diff --git a/bridge/github/export.go b/bridge/github/export.go
index 447e4342..675ed039 100644
--- a/bridge/github/export.go
+++ b/bridge/github/export.go
@@ -318,7 +318,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
return
}
- out <- core.NewExportComment(op.Id())
+ out <- core.NewExportComment(b.Id())
// cache comment id
ge.cachedOperationIDs[op.Id()] = id
@@ -334,7 +334,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
return
}
- out <- core.NewExportCommentEdition(op.Id())
+ out <- core.NewExportCommentEdition(b.Id())
id = bugGithubID
url = bugGithubURL
@@ -354,7 +354,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
return
}
- out <- core.NewExportCommentEdition(op.Id())
+ out <- core.NewExportCommentEdition(b.Id())
// use comment id/url instead of issue id/url
id = eid
@@ -368,7 +368,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
return
}
- out <- core.NewExportStatusChange(op.Id())
+ out <- core.NewExportStatusChange(b.Id())
id = bugGithubID
url = bugGithubURL
@@ -380,7 +380,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
return
}
- out <- core.NewExportTitleEdition(op.Id())
+ out <- core.NewExportTitleEdition(b.Id())
id = bugGithubID
url = bugGithubURL
@@ -392,7 +392,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
return
}
- out <- core.NewExportLabelChange(op.Id())
+ out <- core.NewExportLabelChange(b.Id())
id = bugGithubID
url = bugGithubURL
@@ -659,7 +659,7 @@ func (ge *githubExporter) createGithubIssue(ctx context.Context, gc *rateLimitHa
return issue.ID, issue.URL, nil
}
-// add a comment to an issue and return it ID
+// add a comment to an issue and return its ID
func (ge *githubExporter) addCommentGithubIssue(ctx context.Context, gc *rateLimitHandlerClient, subjectID string, body string) (string, string, error) {
m := &addCommentToIssueMutation{}
input := githubv4.AddCommentInput{
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index de2d3f34..2ebe9622 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -41,7 +41,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
@@ -71,11 +71,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/github/import.go b/bridge/github/import.go
index 5b2bf54b..7ccac3fb 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -274,7 +274,7 @@ func (gi *githubImporter) ensureTimelineItem(ctx context.Context, repo *cache.Re
return err
}
- gi.out <- core.NewImportLabelChange(op.Id())
+ gi.out <- core.NewImportLabelChange(b.Id(), op.Id())
return nil
case "UnlabeledEvent":
@@ -304,7 +304,7 @@ func (gi *githubImporter) ensureTimelineItem(ctx context.Context, repo *cache.Re
return err
}
- gi.out <- core.NewImportLabelChange(op.Id())
+ gi.out <- core.NewImportLabelChange(b.Id(), op.Id())
return nil
case "ClosedEvent":
@@ -330,7 +330,7 @@ func (gi *githubImporter) ensureTimelineItem(ctx context.Context, repo *cache.Re
return err
}
- gi.out <- core.NewImportStatusChange(op.Id())
+ gi.out <- core.NewImportStatusChange(b.Id(), op.Id())
return nil
case "ReopenedEvent":
@@ -356,7 +356,7 @@ func (gi *githubImporter) ensureTimelineItem(ctx context.Context, repo *cache.Re
return err
}
- gi.out <- core.NewImportStatusChange(op.Id())
+ gi.out <- core.NewImportStatusChange(b.Id(), op.Id())
return nil
case "RenamedTitleEvent":
@@ -392,7 +392,7 @@ func (gi *githubImporter) ensureTimelineItem(ctx context.Context, repo *cache.Re
return err
}
- gi.out <- core.NewImportTitleEdition(op.Id())
+ gi.out <- core.NewImportTitleEdition(b.Id(), op.Id())
return nil
}
@@ -425,11 +425,13 @@ func (gi *githubImporter) ensureCommentEdit(ctx context.Context, repo *cache.Rep
return nil
}
+ commentId := entity.CombineIds(b.Id(), target)
+
// comment edition
- op, err := b.EditCommentRaw(
+ _, err = b.EditCommentRaw(
editor,
edit.CreatedAt.Unix(),
- entity.CombineIds(b.Id(), target),
+ commentId,
text.Cleanup(string(*edit.Diff)),
map[string]string{
metaKeyGithubId: parseId(edit.Id),
@@ -440,7 +442,7 @@ func (gi *githubImporter) ensureCommentEdit(ctx context.Context, repo *cache.Rep
return err
}
- gi.out <- core.NewImportCommentEdition(op.Id())
+ gi.out <- core.NewImportCommentEdition(b.Id(), commentId)
return nil
}
@@ -469,7 +471,7 @@ func (gi *githubImporter) ensureComment(ctx context.Context, repo *cache.RepoCac
}
// add comment operation
- op, err := b.AddCommentRaw(
+ commentId, _, err := b.AddCommentRaw(
author,
comment.CreatedAt.Unix(),
text.Cleanup(textInput),
@@ -483,7 +485,7 @@ func (gi *githubImporter) ensureComment(ctx context.Context, repo *cache.RepoCac
return err
}
- gi.out <- core.NewImportComment(op.Id())
+ gi.out <- core.NewImportComment(b.Id(), commentId)
return nil
}