aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github
diff options
context:
space:
mode:
Diffstat (limited to 'bridge/github')
-rw-r--r--bridge/github/config.go9
-rw-r--r--bridge/github/export.go2
-rw-r--r--bridge/github/export_test.go2
-rw-r--r--bridge/github/github.go21
-rw-r--r--bridge/github/import.go6
-rw-r--r--bridge/github/import_test.go2
6 files changed, 24 insertions, 18 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index ed32f398..9477801d 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -27,15 +27,6 @@ import (
"github.com/MichaelMure/git-bug/util/colors"
)
-const (
- target = "github"
- githubV3Url = "https://api.github.com"
- keyOwner = "owner"
- keyProject = "project"
-
- defaultTimeout = 60 * time.Second
-)
-
var (
ErrBadProjectURL = errors.New("bad project url")
)
diff --git a/bridge/github/export.go b/bridge/github/export.go
index 1e27be4a..c363e188 100644
--- a/bridge/github/export.go
+++ b/bridge/github/export.go
@@ -76,7 +76,7 @@ func (ge *githubExporter) Init(repo *cache.RepoCache, conf core.Configuration) e
}
login := user.ImmutableMetadata()[metaKeyGithubLogin]
- creds, err := auth.List(repo, auth.WithMeta(metaKeyGithubLogin, login), auth.WithTarget(target), auth.WithKind(auth.KindToken))
+ creds, err := auth.List(repo, auth.WithMeta(auth.MetaKeyLogin, login), auth.WithTarget(target), auth.WithKind(auth.KindToken))
if err != nil {
return err
}
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go
index cb6bacc1..89040d8f 100644
--- a/bridge/github/export_test.go
+++ b/bridge/github/export_test.go
@@ -179,7 +179,7 @@ func TestPushPull(t *testing.T) {
})
token := auth.NewToken(envToken, target)
- token.SetMetadata(metaKeyGithubLogin, login)
+ token.SetMetadata(auth.MetaKeyLogin, login)
err = auth.Store(repo, token)
require.NoError(t, err)
diff --git a/bridge/github/github.go b/bridge/github/github.go
index 874c2d11..19dc8a08 100644
--- a/bridge/github/github.go
+++ b/bridge/github/github.go
@@ -3,6 +3,7 @@ package github
import (
"context"
+ "time"
"github.com/shurcooL/githubv4"
"golang.org/x/oauth2"
@@ -11,12 +12,32 @@ import (
"github.com/MichaelMure/git-bug/bridge/core/auth"
)
+const (
+ target = "github"
+
+ metaKeyGithubId = "github-id"
+ metaKeyGithubUrl = "github-url"
+ metaKeyGithubLogin = "github-login"
+
+ keyOwner = "owner"
+ keyProject = "project"
+
+ githubV3Url = "https://api.github.com"
+ defaultTimeout = 60 * time.Second
+)
+
+var _ core.BridgeImpl = &Github{}
+
type Github struct{}
func (*Github) Target() string {
return target
}
+func (g *Github) LoginMetaKey() string {
+ return metaKeyGithubLogin
+}
+
func (*Github) NewImporter() core.Importer {
return &githubImporter{}
}
diff --git a/bridge/github/import.go b/bridge/github/import.go
index f2c9a53d..6a4c0110 100644
--- a/bridge/github/import.go
+++ b/bridge/github/import.go
@@ -15,12 +15,6 @@ import (
"github.com/MichaelMure/git-bug/util/text"
)
-const (
- metaKeyGithubId = "github-id"
- metaKeyGithubUrl = "github-url"
- metaKeyGithubLogin = "github-login"
-)
-
// githubImporter implement the Importer interface
type githubImporter struct {
conf core.Configuration
diff --git a/bridge/github/import_test.go b/bridge/github/import_test.go
index 73eaa096..a8f8e346 100644
--- a/bridge/github/import_test.go
+++ b/bridge/github/import_test.go
@@ -145,7 +145,7 @@ func Test_Importer(t *testing.T) {
author.SetMetadata(metaKeyGithubLogin, login)
token := auth.NewToken(envToken, target)
- token.SetMetadata(metaKeyGithubLogin, login)
+ token.SetMetadata(auth.MetaKeyLogin, login)
err = auth.Store(repo, token)
require.NoError(t, err)