summaryrefslogtreecommitdiffstatshomepage
path: root/bridge/launchpad/import.go
diff options
context:
space:
mode:
authoramine <hilalyamine@gmail.com>2019-11-10 17:48:13 +0100
committeramine <hilalyamine@gmail.com>2019-11-19 19:16:16 +0100
commit8ffe2a9b03f5d489e12d2d4d2677bbe67a1b53d7 (patch)
tree165e7aeda2b17b992762fae34863108c345b4524 /bridge/launchpad/import.go
parent57e23c8ada0a9d921a6b68187a76eb5c8b8a407d (diff)
downloadgit-bug-8ffe2a9b03f5d489e12d2d4d2677bbe67a1b53d7.tar.gz
git-bug-8ffe2a9b03f5d489e12d2d4d2677bbe67a1b53d7.zip
bridge/launchpad: add missing metadata
bridge: use a specific key for origin metadata
Diffstat (limited to 'bridge/launchpad/import.go')
-rw-r--r--bridge/launchpad/import.go19
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())