diff options
author | Michael Muré <batolettre@gmail.com> | 2021-05-03 11:45:15 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-08-22 13:25:26 +0200 |
commit | 45b04351d8d02e53b3401b0ee23f7cbe750b63cd (patch) | |
tree | 59d203ef6c0f6a497b7074cd5617c8869cac3b14 /bridge/gitlab | |
parent | 43026fc53669d462a60feec7d22aec090959be72 (diff) | |
download | git-bug-45b04351d8d02e53b3401b0ee23f7cbe750b63cd.tar.gz |
bug: have a type for combined ids, fix https://github.com/MichaelMure/git-bug/issues/653
Diffstat (limited to 'bridge/gitlab')
-rw-r--r-- | bridge/gitlab/export_test.go | 7 | ||||
-rw-r--r-- | bridge/gitlab/import.go | 13 |
2 files changed, 11 insertions, 9 deletions
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, ) |