diff options
author | Michael Muré <batolettre@gmail.com> | 2020-03-28 17:11:16 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-28 17:11:16 +0100 |
commit | 58abc6b0a35b679ac0c34579ff1cb53c8fa71af4 (patch) | |
tree | a2a9556a580d21f1850c06eeb591a44acc0d2373 | |
parent | 5491d12873732d05d2f08cfe784985eee6e41a20 (diff) | |
parent | a8666bfeb8255c2a0a9eed55ba143d65237febbf (diff) | |
download | git-bug-58abc6b0a35b679ac0c34579ff1cb53c8fa71af4.tar.gz |
Merge pull request #358 from MichaelMure/gitlab-tests
gitlab: fix issues import url
-rw-r--r-- | bridge/github/import.go | 5 | ||||
-rw-r--r-- | bridge/gitlab/import.go | 7 | ||||
-rw-r--r-- | bridge/gitlab/import_test.go | 8 | ||||
-rw-r--r-- | bridge/jira/import.go | 12 | ||||
-rw-r--r-- | bridge/jira/jira.go | 1 | ||||
-rw-r--r-- | bridge/launchpad/import.go | 5 |
6 files changed, 30 insertions, 8 deletions
diff --git a/bridge/github/import.go b/bridge/github/import.go index a74c49c5..78e93436 100644 --- a/bridge/github/import.go +++ b/bridge/github/import.go @@ -108,7 +108,10 @@ func (gi *githubImporter) ensureIssue(repo *cache.RepoCache, issue issueTimeline } // resolve bug - b, err := repo.ResolveBugCreateMetadata(metaKeyGithubUrl, issue.Url.String()) + b, err := repo.ResolveBugMatcher(func(excerpt *cache.BugExcerpt) bool { + return excerpt.CreateMetadata[core.MetaKeyOrigin] == target && + excerpt.CreateMetadata[metaKeyGithubId] == parseId(issue.Id) + }) if err != nil && err != bug.ErrBugNotExist { return nil, err } diff --git a/bridge/gitlab/import.go b/bridge/gitlab/import.go index 5ed5f0e3..0a47a783 100644 --- a/bridge/gitlab/import.go +++ b/bridge/gitlab/import.go @@ -123,7 +123,12 @@ func (gi *gitlabImporter) ensureIssue(repo *cache.RepoCache, issue *gitlab.Issue } // resolve bug - b, err := repo.ResolveBugCreateMetadata(metaKeyGitlabUrl, issue.WebURL) + b, err := repo.ResolveBugMatcher(func(excerpt *cache.BugExcerpt) bool { + return excerpt.CreateMetadata[core.MetaKeyOrigin] == target && + excerpt.CreateMetadata[metaKeyGitlabId] == parseID(issue.IID) && + excerpt.CreateMetadata[metaKeyGitlabBaseUrl] == gi.conf[confKeyProjectID] && + excerpt.CreateMetadata[metaKeyGitlabProject] == gi.conf[confKeyGitlabBaseUrl] + }) if err == nil { return b, nil } diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go index f916d20c..42a37cda 100644 --- a/bridge/gitlab/import_test.go +++ b/bridge/gitlab/import_test.go @@ -29,7 +29,7 @@ func TestImport(t *testing.T) { }{ { name: "simple issue", - url: "https://gitlab.com/git-bug/test/issues/1", + url: "https://gitlab.com/git-bug/test/-/issues/1", bug: &bug.Snapshot{ Operations: []bug.Operation{ bug.NewCreateOp(author, 0, "simple issue", "initial comment", nil), @@ -40,7 +40,7 @@ func TestImport(t *testing.T) { }, { name: "empty issue", - url: "https://gitlab.com/git-bug/test/issues/2", + url: "https://gitlab.com/git-bug/test/-/issues/2", bug: &bug.Snapshot{ Operations: []bug.Operation{ bug.NewCreateOp(author, 0, "empty issue", "", nil), @@ -49,7 +49,7 @@ func TestImport(t *testing.T) { }, { name: "complex issue", - url: "https://gitlab.com/git-bug/test/issues/3", + url: "https://gitlab.com/git-bug/test/-/issues/3", bug: &bug.Snapshot{ Operations: []bug.Operation{ bug.NewCreateOp(author, 0, "complex issue", "initial comment", nil), @@ -66,7 +66,7 @@ func TestImport(t *testing.T) { }, { name: "editions", - url: "https://gitlab.com/git-bug/test/issues/4", + url: "https://gitlab.com/git-bug/test/-/issues/4", bug: &bug.Snapshot{ Operations: []bug.Operation{ bug.NewCreateOp(author, 0, "editions", "initial comment edited", nil), diff --git a/bridge/jira/import.go b/bridge/jira/import.go index 3d6d5414..b66b0fa3 100644 --- a/bridge/jira/import.go +++ b/bridge/jira/import.go @@ -216,7 +216,16 @@ func (ji *jiraImporter) ensureIssue(repo *cache.RepoCache, issue Issue) (*cache. return nil, err } - b, err := repo.ResolveBugCreateMetadata(metaKeyJiraId, issue.ID) + b, err := repo.ResolveBugMatcher(func(excerpt *cache.BugExcerpt) bool { + if _, ok := excerpt.CreateMetadata[metaKeyJiraBaseUrl]; ok && + excerpt.CreateMetadata[metaKeyJiraBaseUrl] != ji.conf[confKeyBaseUrl] { + return false + } + + return excerpt.CreateMetadata[core.MetaKeyOrigin] == target && + excerpt.CreateMetadata[metaKeyJiraId] == issue.ID && + excerpt.CreateMetadata[metaKeyJiraProject] == ji.conf[confKeyProject] + }) if err != nil && err != bug.ErrBugNotExist { return nil, err } @@ -241,6 +250,7 @@ func (ji *jiraImporter) ensureIssue(repo *cache.RepoCache, issue Issue) (*cache. metaKeyJiraId: issue.ID, metaKeyJiraKey: issue.Key, metaKeyJiraProject: ji.conf[confKeyProject], + metaKeyJiraBaseUrl: ji.conf[confKeyBaseUrl], }) if err != nil { return nil, err diff --git a/bridge/jira/jira.go b/bridge/jira/jira.go index 066c6597..6423843c 100644 --- a/bridge/jira/jira.go +++ b/bridge/jira/jira.go @@ -20,6 +20,7 @@ const ( metaKeyJiraKey = "jira-key" metaKeyJiraUser = "jira-user" metaKeyJiraProject = "jira-project" + metaKeyJiraBaseUrl = "jira-base-url" metaKeyJiraExportTime = "jira-export-time" metaKeyJiraLogin = "jira-login" diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go index 3b6d7fe0..7f528c7d 100644 --- a/bridge/launchpad/import.go +++ b/bridge/launchpad/import.go @@ -62,7 +62,10 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach return default: lpBugID := fmt.Sprintf("%d", lpBug.ID) - b, err := repo.ResolveBugCreateMetadata(metaKeyLaunchpadID, lpBugID) + b, err := repo.ResolveBugMatcher(func(excerpt *cache.BugExcerpt) bool { + return excerpt.CreateMetadata[core.MetaKeyOrigin] == target && + excerpt.CreateMetadata[metaKeyLaunchpadID] == lpBugID + }) if err != nil && err != bug.ErrBugNotExist { out <- core.NewImportError(err, entity.Id(lpBugID)) return |