aboutsummaryrefslogtreecommitdiffstats
path: root/bridge/github
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-01-14 22:02:35 +0100
committerMichael Muré <batolettre@gmail.com>2020-02-08 17:18:30 +0100
commitb950c2580dfbf7672ee9e5e1e3f5b45c8cbc2788 (patch)
tree77e8bcbb36391902f3f3c0958c239952df65bbee /bridge/github
parentda0904d23826ebe578305b51e38f49fdf330f992 (diff)
downloadgit-bug-b950c2580dfbf7672ee9e5e1e3f5b45c8cbc2788.tar.gz
more wip
Diffstat (limited to 'bridge/github')
-rw-r--r--bridge/github/config.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go
index fcb94079..30e28d0d 100644
--- a/bridge/github/config.go
+++ b/bridge/github/config.go
@@ -22,6 +22,7 @@ import (
"github.com/MichaelMure/git-bug/bridge/core"
"github.com/MichaelMure/git-bug/bridge/core/auth"
"github.com/MichaelMure/git-bug/cache"
+ "github.com/MichaelMure/git-bug/identity"
"github.com/MichaelMure/git-bug/input"
"github.com/MichaelMure/git-bug/repository"
"github.com/MichaelMure/git-bug/util/colors"
@@ -81,7 +82,18 @@ func (g *Github) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
login := params.Login
if login == "" {
- login, err = input.Prompt("Github login", "login", input.Required, validateUsername)
+ validator := func(name string, value string) (string, error) {
+ ok, err := validateUsername(value)
+ if err != nil {
+ return "", err
+ }
+ if !ok {
+ return "invalid login", nil
+ }
+ return "", nil
+ }
+
+ login, err = input.Prompt("Github login", "login", input.Required, validator)
if err != nil {
return nil, err
}
@@ -128,6 +140,28 @@ func (g *Github) Configure(repo *cache.RepoCache, params core.BridgeParams) (cor
return nil, err
}
+ // TODO
+ func(login string) error {
+ // if no user exist with the given login
+ _, err := repo.ResolveIdentityLogin(login)
+ if err != nil && err != identity.ErrIdentityNotExist {
+ return err
+ }
+
+ // tag the default user with the github login, if any
+ // if not,
+ user, err := repo.GetUserIdentity()
+ if err == identity.ErrNoIdentitySet {
+ return nil
+ }
+ if err != nil {
+ return err
+ }
+
+ repo.GetUserIdentity()
+
+ }(login)
+
// Todo: if no user exist with the given login
// - tag the default user with the github login
// - add a command to manually tag a user ?