aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'bridge')
-rw-r--r--bridge/github/export_test.go7
-rw-r--r--bridge/github/import.go3
-rw-r--r--bridge/gitlab/export_test.go7
-rw-r--r--bridge/gitlab/import.go13
-rw-r--r--bridge/jira/import.go5
5 files changed, 20 insertions, 15 deletions
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index 93cc47c0..de2d3f34 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -16,6 +16,7 @@ import (
"github.com/MichaelMure/git-bug/bridge/core"
"github.com/MichaelMure/git-bug/bridge/core/auth"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/interrupt"
@@ -66,13 +67,15 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase {
bugWithCommentEditions, createOp, err := repo.NewBug("bug with comments editions", "new bug")
require.NoError(t, err)
- _, err = bugWithCommentEditions.EditComment(createOp.Id(), "first comment edited")
+ _, err = bugWithCommentEditions.EditComment(
+ entity.CombineIds(bugWithCommentEditions.Id(), createOp.Id()), "first comment edited")
require.NoError(t, err)
commentOp, err := bugWithCommentEditions.AddComment("first comment")
require.NoError(t, err)
- _, err = bugWithCommentEditions.EditComment(commentOp.Id(), "first comment edited")
+ _, err = bugWithCommentEditions.EditComment(
+ entity.CombineIds(bugWithCommentEditions.Id(), commentOp.Id()), "first comment edited")
require.NoError(t, err)
// bug status changed
diff --git a/bridge/github/import.go b/bridge/github/import.go
index 722bf256..5b2bf54b 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -405,6 +405,7 @@ func (gi *githubImporter) ensureCommentEdit(ctx context.Context, repo *cache.Rep
if err != nil {
return err
}
+ // check if the comment edition already exist
_, err = b.ResolveOperationWithMetadata(metaKeyGithubId, parseId(edit.Id))
if err == nil {
return nil
@@ -428,7 +429,7 @@ func (gi *githubImporter) ensureCommentEdit(ctx context.Context, repo *cache.Rep
op, err := b.EditCommentRaw(
editor,
edit.CreatedAt.Unix(),
- target,
+ entity.CombineIds(b.Id(), target),
text.Cleanup(string(*edit.Diff)),
map[string]string{
metaKeyGithubId: parseId(edit.Id),
diff --git a/bridge/gitlab/export_test.go b/bridge/gitlab/export_test.go
index b48254e6..e9f3ae75 100644
--- a/bridge/gitlab/export_test.go
+++ b/bridge/gitlab/export_test.go
@@ -11,6 +11,7 @@ import (
"github.com/xanzy/go-gitlab"
+ "github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/entity/dag"
"github.com/stretchr/testify/require"
@@ -63,13 +64,15 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase {
bugWithCommentEditions, createOp, err := repo.NewBug("bug with comments editions", "new bug")
require.NoError(t, err)
- _, err = bugWithCommentEditions.EditComment(createOp.Id(), "first comment edited")
+ _, err = bugWithCommentEditions.EditComment(
+ entity.CombineIds(bugWithCommentEditions.Id(), createOp.Id()), "first comment edited")
require.NoError(t, err)
commentOp, err := bugWithCommentEditions.AddComment("first comment")
require.NoError(t, err)
- _, err = bugWithCommentEditions.EditComment(commentOp.Id(), "first comment edited")
+ _, err = bugWithCommentEditions.EditComment(
+ entity.CombineIds(bugWithCommentEditions.Id(), commentOp.Id()), "first comment edited")
require.NoError(t, err)
// bug status changed
diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go
index 8228c4a0..cf6b5ca6 100644
--- a/bridge/gitlab/import.go
+++ b/bridge/gitlab/import.go
@@ -55,7 +55,6 @@ func (gi *gitlabImporter) Init(_ context.Context, repo *cache.RepoCache, conf co
// ImportAll iterate over all the configured repository issues (notes) and ensure the creation
// of the missing issues / comments / label events / title changes ...
func (gi *gitlabImporter) ImportAll(ctx context.Context, repo *cache.RepoCache, since time.Time) (<-chan core.ImportResult, error) {
-
out := make(chan core.ImportResult)
gi.out = out
@@ -150,7 +149,6 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue
}
func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCache, issue *gitlab.Issue, event Event) error {
-
id, errResolve := b.ResolveOperationWithMetadata(metaKeyGitlabId, event.ID())
if errResolve != nil && errResolve != cache.ErrNoMatchingOp {
return errResolve
@@ -205,13 +203,14 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa
// 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 errResolve == cache.ErrNoMatchingOp && issue.Description != firstComment.Message {
+ cleanedDesc := text.Cleanup(issue.Description)
+ if errResolve == cache.ErrNoMatchingOp && cleanedDesc != firstComment.Message {
// comment edition
op, err := b.EditCommentRaw(
author,
event.(NoteEvent).UpdatedAt.Unix(),
- firstComment.Id(),
- text.Cleanup(issue.Description),
+ firstComment.CombinedId(),
+ cleanedDesc,
map[string]string{
metaKeyGitlabId: event.ID(),
},
@@ -249,7 +248,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa
// if comment was already exported
// search for last comment update
- comment, err := b.Snapshot().SearchComment(id)
+ comment, err := b.Snapshot().SearchCommentByOpId(id)
if err != nil {
return err
}
@@ -260,7 +259,7 @@ func (gi *gitlabImporter) ensureIssueEvent(repo *cache.RepoCache, b *cache.BugCa
op, err := b.EditCommentRaw(
author,
event.(NoteEvent).UpdatedAt.Unix(),
- comment.Id(),
+ comment.CombinedId(),
cleanText,
nil,
)
diff --git a/bridge/jira/import.go b/bridge/jira/import.go
index c297abcf..8043acf4 100644
--- a/bridge/jira/import.go
+++ b/bridge/jira/import.go
@@ -270,8 +270,7 @@ func (ji *jiraImporter) ensureComment(repo *cache.RepoCache, b *cache.BugCache,
return err
}
- targetOpID, err := b.ResolveOperationWithMetadata(
- metaKeyJiraId, item.ID)
+ targetOpID, err := b.ResolveOperationWithMetadata(metaKeyJiraId, item.ID)
if err != nil && err != cache.ErrNoMatchingOp {
return err
}
@@ -334,7 +333,7 @@ func (ji *jiraImporter) ensureComment(repo *cache.RepoCache, b *cache.BugCache,
op, err := b.EditCommentRaw(
editor,
item.Updated.Unix(),
- targetOpID,
+ entity.CombineIds(b.Id(), targetOpID),
text.Cleanup(item.Body),
map[string]string{
metaKeyJiraId: derivedID,