From b950c2580dfbf7672ee9e5e1e3f5b45c8cbc2788 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 14 Jan 2020 22:02:35 +0100 Subject: more wip --- bridge/github/config.go | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) (limited to 'bridge/github/config.go') 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 ? -- cgit