aboutsummaryrefslogtreecommitdiffstats
path: root/bridge
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2022-08-01 17:16:45 +0200
committerGitHub <noreply@github.com>2022-08-01 17:16:45 +0200
commitcd52872475f1b39f3fb6546606c1e78afb6c08e3 (patch)
tree9f04b1e1ee362e210e74aaa324d950058ed14bf2 /bridge
parent2ade8fb1d570ddcb4aedc9386af46d208b129daa (diff)
parent56966fec5562c3a0e23340d0fbe754626c3beb64 (diff)
downloadgit-bug-cd52872475f1b39f3fb6546606c1e78afb6c08e3.tar.gz
Merge pull request #835 from MichaelMure/op-base
entity/dag: proper base operation for simplified implementation
Diffstat (limited to 'bridge')
-rw-r--r--bridge/github/export.go3
-rw-r--r--bridge/github/export_test.go4
-rw-r--r--bridge/github/import_test.go19
-rw-r--r--bridge/gitlab/export.go3
-rw-r--r--bridge/gitlab/export_test.go7
-rw-r--r--bridge/gitlab/import_test.go9
-rw-r--r--bridge/jira/export.go3
-rw-r--r--bridge/jira/import.go3
8 files changed, 29 insertions, 22 deletions
diff --git a/bridge/github/export.go b/bridge/github/export.go
index 35d456c2..5164fcab 100644
--- a/bridge/github/export.go
+++ b/bridge/github/export.go
@@ -20,6 +20,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/identity"
)
@@ -288,7 +289,7 @@ func (ge *githubExporter) exportBug(ctx context.Context, b *cache.BugCache, out
for _, op := range snapshot.Operations[1:] {
// ignore SetMetadata operations
- if _, ok := op.(*bug.SetMetadataOperation); ok {
+ if _, ok := op.(dag.OperationDoesntChangeSnapshot); ok {
continue
}
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index 94664853..93cc47c0 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -15,8 +15,8 @@ import (
"github.com/MichaelMure/git-bug/bridge/core"
"github.com/MichaelMure/git-bug/bridge/core/auth"
- "github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/interrupt"
)
@@ -245,7 +245,7 @@ func TestGithubPushPull(t *testing.T) {
// verify operation have correct metadata
for _, op := range tt.bug.Snapshot().Operations {
// Check if the originals operations (*not* SetMetadata) are tagged properly
- if _, ok := op.(*bug.SetMetadataOperation); !ok {
+ if _, ok := op.(dag.OperationDoesntChangeSnapshot); !ok {
_, haveIDMetadata := op.GetMetadata(metaKeyGithubId)
require.True(t, haveIDMetadata)
diff --git a/bridge/github/import_test.go b/bridge/github/import_test.go
index df4989a4..f1c863ac 100644
--- a/bridge/github/import_test.go
+++ b/bridge/github/import_test.go
@@ -13,6 +13,7 @@ import (
"github.com/MichaelMure/git-bug/bridge/core/auth"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/interrupt"
@@ -44,7 +45,7 @@ func TestGithubImporter(t *testing.T) {
name: "simple issue",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/1",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "simple issue", "initial comment", nil),
bug.NewAddCommentOp(author, 0, "first comment", nil),
bug.NewAddCommentOp(author, 0, "second comment", nil),
@@ -55,7 +56,7 @@ func TestGithubImporter(t *testing.T) {
name: "empty issue",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/2",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "empty issue", "", nil),
},
},
@@ -64,7 +65,7 @@ func TestGithubImporter(t *testing.T) {
name: "complex issue",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/3",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "complex issue", "initial comment", nil),
bug.NewLabelChangeOperation(author, 0, []bug.Label{"bug"}, []bug.Label{}),
bug.NewLabelChangeOperation(author, 0, []bug.Label{"duplicate"}, []bug.Label{}),
@@ -81,7 +82,7 @@ func TestGithubImporter(t *testing.T) {
name: "editions",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/4",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "editions", "initial comment edited", nil),
bug.NewEditCommentOp(author, 0, "", "erased then edited again", nil),
bug.NewAddCommentOp(author, 0, "first comment", nil),
@@ -93,7 +94,7 @@ func TestGithubImporter(t *testing.T) {
name: "comment deletion",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/5",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "comment deletion", "", nil),
},
},
@@ -102,7 +103,7 @@ func TestGithubImporter(t *testing.T) {
name: "edition deletion",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/6",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "edition deletion", "initial comment", nil),
bug.NewEditCommentOp(author, 0, "", "initial comment edited again", nil),
bug.NewAddCommentOp(author, 0, "first comment", nil),
@@ -114,7 +115,7 @@ func TestGithubImporter(t *testing.T) {
name: "hidden comment",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/7",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "hidden comment", "initial comment", nil),
bug.NewAddCommentOp(author, 0, "first comment", nil),
},
@@ -124,7 +125,7 @@ func TestGithubImporter(t *testing.T) {
name: "transfered issue",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/8",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "transfered issue", "", nil),
},
},
@@ -133,7 +134,7 @@ func TestGithubImporter(t *testing.T) {
name: "unicode control characters",
url: "https://github.com/MichaelMure/git-bug-test-github-bridge/issues/10",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "unicode control characters", "u0000: \nu0001: \nu0002: \nu0003: \nu0004: \nu0005: \nu0006: \nu0007: \nu0008: \nu0009: \t\nu0010: \nu0011: \nu0012: \nu0013: \nu0014: \nu0015: \nu0016: \nu0017: \nu0018: \nu0019:", nil),
},
},
diff --git a/bridge/gitlab/export.go b/bridge/gitlab/export.go
index e6587eba..bb83662e 100644
--- a/bridge/gitlab/export.go
+++ b/bridge/gitlab/export.go
@@ -15,6 +15,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/identity"
)
@@ -256,7 +257,7 @@ func (ge *gitlabExporter) exportBug(ctx context.Context, b *cache.BugCache, out
labelSet := make(map[string]struct{})
for _, op := range snapshot.Operations[1:] {
// ignore SetMetadata operations
- if _, ok := op.(*bug.SetMetadataOperation); ok {
+ if _, ok := op.(dag.OperationDoesntChangeSnapshot); ok {
continue
}
diff --git a/bridge/gitlab/export_test.go b/bridge/gitlab/export_test.go
index cca4c6ca..b48254e6 100644
--- a/bridge/gitlab/export_test.go
+++ b/bridge/gitlab/export_test.go
@@ -11,11 +11,12 @@ import (
"github.com/xanzy/go-gitlab"
+ "github.com/MichaelMure/git-bug/entity/dag"
+
"github.com/stretchr/testify/require"
"github.com/MichaelMure/git-bug/bridge/core"
"github.com/MichaelMure/git-bug/bridge/core/auth"
- "github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/interrupt"
@@ -247,7 +248,7 @@ func TestGitlabPushPull(t *testing.T) {
// verify operation have correct metadata
for _, op := range tt.bug.Snapshot().Operations {
// Check if the originals operations (*not* SetMetadata) are tagged properly
- if _, ok := op.(*bug.SetMetadataOperation); !ok {
+ if _, ok := op.(dag.OperationDoesntChangeSnapshot); !ok {
_, haveIDMetadata := op.GetMetadata(metaKeyGitlabId)
require.True(t, haveIDMetadata)
@@ -272,7 +273,7 @@ func TestGitlabPushPull(t *testing.T) {
require.True(t, ok)
require.Equal(t, issueOrigin, target)
- //TODO: maybe more tests to ensure bug final state
+ // TODO: maybe more tests to ensure bug final state
})
}
}
diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go
index 676e8749..a4a9ce15 100644
--- a/bridge/gitlab/import_test.go
+++ b/bridge/gitlab/import_test.go
@@ -13,6 +13,7 @@ import (
"github.com/MichaelMure/git-bug/bridge/core/auth"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/interrupt"
@@ -49,7 +50,7 @@ func TestGitlabImport(t *testing.T) {
name: "simple issue",
url: "https://gitlab.com/git-bug/test/-/issues/1",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "simple issue", "initial comment", nil),
bug.NewAddCommentOp(author, 0, "first comment", nil),
bug.NewAddCommentOp(author, 0, "second comment", nil),
@@ -60,7 +61,7 @@ func TestGitlabImport(t *testing.T) {
name: "empty issue",
url: "https://gitlab.com/git-bug/test/-/issues/2",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "empty issue", "", nil),
},
},
@@ -69,7 +70,7 @@ func TestGitlabImport(t *testing.T) {
name: "complex issue",
url: "https://gitlab.com/git-bug/test/-/issues/3",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "complex issue", "initial comment", nil),
bug.NewAddCommentOp(author, 0, "### header\n\n**bold**\n\n_italic_\n\n> with quote\n\n`inline code`\n\n```\nmultiline code\n```\n\n- bulleted\n- list\n\n1. numbered\n1. list\n\n- [ ] task\n- [x] list\n\n@MichaelMure mention\n\n#2 reference issue\n#3 auto-reference issue", nil),
bug.NewSetTitleOp(author, 0, "complex issue edited", "complex issue"),
@@ -86,7 +87,7 @@ func TestGitlabImport(t *testing.T) {
name: "editions",
url: "https://gitlab.com/git-bug/test/-/issues/4",
bug: &bug.Snapshot{
- Operations: []bug.Operation{
+ Operations: []dag.Operation{
bug.NewCreateOp(author, 0, "editions", "initial comment edited", nil),
bug.NewAddCommentOp(author, 0, "first comment edited", nil),
},
diff --git a/bridge/jira/export.go b/bridge/jira/export.go
index e5c19074..0cadf754 100644
--- a/bridge/jira/export.go
+++ b/bridge/jira/export.go
@@ -15,6 +15,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/identity"
)
@@ -297,7 +298,7 @@ func (je *jiraExporter) exportBug(ctx context.Context, b *cache.BugCache, out ch
for _, op := range snapshot.Operations[1:] {
// ignore SetMetadata operations
- if _, ok := op.(*bug.SetMetadataOperation); ok {
+ if _, ok := op.(dag.OperationDoesntChangeSnapshot); ok {
continue
}
diff --git a/bridge/jira/import.go b/bridge/jira/import.go
index d601febb..572c393e 100644
--- a/bridge/jira/import.go
+++ b/bridge/jira/import.go
@@ -14,6 +14,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/cache"
"github.com/MichaelMure/git-bug/entity"
+ "github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/util/text"
)
@@ -377,7 +378,7 @@ func labelSetsMatch(jiraSet []string, gitbugSet []bug.Label) bool {
// Create a bug.Operation (or a series of operations) from a JIRA changelog
// entry
-func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, entry ChangeLogEntry, potentialOp bug.Operation) error {
+func (ji *jiraImporter) ensureChange(repo *cache.RepoCache, b *cache.BugCache, entry ChangeLogEntry, potentialOp dag.Operation) error {
// If we have an operation which is already mapped to the entire changelog
// entry then that means this changelog entry was induced by an export