From 49285b03c9f255e5205e585e30ff61c87cb548ad Mon Sep 17 00:00:00 2001 From: amine Date: Sun, 15 Mar 2020 19:32:32 +0100 Subject: gitlab: fix bugs import url --- bridge/gitlab/import_test.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'bridge') 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), -- cgit From 8389df0711dbd5cb13b187fa31ce0dbd5c781460 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 28 Mar 2020 17:06:33 +0100 Subject: gitlab: match bugs on IDs + baseURL because the URL is not stable --- bridge/gitlab/import.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bridge') 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 } -- cgit From 4397766800fd02517501a969b8212708badd3312 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 28 Mar 2020 17:07:57 +0100 Subject: jira: tag bugs with the base URL, tighten the matching --- bridge/jira/import.go | 12 +++++++++++- bridge/jira/jira.go | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'bridge') 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" -- cgit From fae3b2e7db1249b4a284c80e5050f56c0143d041 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 28 Mar 2020 17:08:27 +0100 Subject: github: tighten the import matching --- bridge/github/import.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bridge') 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 } -- cgit From a8666bfeb8255c2a0a9eed55ba143d65237febbf Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 28 Mar 2020 17:08:58 +0100 Subject: launchpad: tighten the bug matching --- bridge/launchpad/import.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'bridge') 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 -- cgit