diff options
author | Michael Muré <batolettre@gmail.com> | 2019-11-19 19:25:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-19 19:25:43 +0100 |
commit | e01cefff9826589b77bd34464301f196112d68f7 (patch) | |
tree | 44b32dfc7727c957ce7e364c6dc631ba8d76a4a5 /bridge/launchpad/import.go | |
parent | 67c82f4a2d683e746df5f8af9e0725acd252d29d (diff) | |
parent | 8ffe2a9b03f5d489e12d2d4d2677bbe67a1b53d7 (diff) | |
download | git-bug-e01cefff9826589b77bd34464301f196112d68f7.tar.gz |
Merge pull request #247 from MichaelMure/bridge-origin
bridge: move keyOrigin to core package
Diffstat (limited to 'bridge/launchpad/import.go')
-rw-r--r-- | bridge/launchpad/import.go | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/bridge/launchpad/import.go b/bridge/launchpad/import.go index 7f50d898..178945b6 100644 --- a/bridge/launchpad/import.go +++ b/bridge/launchpad/import.go @@ -20,12 +20,14 @@ func (li *launchpadImporter) Init(conf core.Configuration) error { return nil } -const keyLaunchpadID = "launchpad-id" -const keyLaunchpadLogin = "launchpad-login" +const ( + metaKeyLaunchpadID = "launchpad-id" + metaKeyLaunchpadLogin = "launchpad-login" +) func (li *launchpadImporter) ensurePerson(repo *cache.RepoCache, owner LPPerson) (*cache.IdentityCache, error) { // Look first in the cache - i, err := repo.ResolveIdentityImmutableMetadata(keyLaunchpadLogin, owner.Login) + i, err := repo.ResolveIdentityImmutableMetadata(metaKeyLaunchpadLogin, owner.Login) if err == nil { return i, nil } @@ -39,7 +41,7 @@ func (li *launchpadImporter) ensurePerson(repo *cache.RepoCache, owner LPPerson) owner.Login, "", map[string]string{ - keyLaunchpadLogin: owner.Login, + metaKeyLaunchpadLogin: owner.Login, }, ) } @@ -65,7 +67,7 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach return default: lpBugID := fmt.Sprintf("%d", lpBug.ID) - b, err := repo.ResolveBugCreateMetadata(keyLaunchpadID, lpBugID) + b, err := repo.ResolveBugCreateMetadata(metaKeyLaunchpadID, lpBugID) if err != nil && err != bug.ErrBugNotExist { out <- core.NewImportError(err, entity.Id(lpBugID)) return @@ -86,7 +88,8 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach lpBug.Description, nil, map[string]string{ - keyLaunchpadID: lpBugID, + core.MetaKeyOrigin: target, + metaKeyLaunchpadID: lpBugID, }, ) if err != nil { @@ -108,7 +111,7 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach // The Launchpad API returns the bug description as the first // comment, so skip it. for _, lpMessage := range lpBug.Messages[1:] { - _, err := b.ResolveOperationWithMetadata(keyLaunchpadID, lpMessage.ID) + _, err := b.ResolveOperationWithMetadata(metaKeyLaunchpadID, lpMessage.ID) if err != nil && err != cache.ErrNoMatchingOp { out <- core.NewImportError(err, entity.Id(lpMessage.ID)) return @@ -136,7 +139,7 @@ func (li *launchpadImporter) ImportAll(ctx context.Context, repo *cache.RepoCach lpMessage.Content, nil, map[string]string{ - keyLaunchpadID: lpMessage.ID, + metaKeyLaunchpadID: lpMessage.ID, }) if err != nil { out <- core.NewImportError(err, op.Id()) |