diff options
author | Michael Muré <batolettre@gmail.com> | 2020-02-04 22:05:34 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2020-02-08 17:19:57 +0100 |
commit | 646fd681ffba59d4a74ec3d99558d2ed70b0106b (patch) | |
tree | 377a8b82701690fa1648d393a39034e0b6a77539 /bridge/github | |
parent | f515b9a1291ddd3e4fe1b43bf5891ab19569e33f (diff) | |
download | git-bug-646fd681ffba59d4a74ec3d99558d2ed70b0106b.tar.gz |
it compiles \o/
Diffstat (limited to 'bridge/github')
-rw-r--r-- | bridge/github/config.go | 9 | ||||
-rw-r--r-- | bridge/github/export.go | 2 | ||||
-rw-r--r-- | bridge/github/export_test.go | 2 | ||||
-rw-r--r-- | bridge/github/github.go | 21 | ||||
-rw-r--r-- | bridge/github/import.go | 6 | ||||
-rw-r--r-- | bridge/github/import_test.go | 2 |
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) |