diff options
author | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-27 00:32:30 +0200 |
---|---|---|
committer | Amine Hilaly <hilalyamine@gmail.com> | 2019-08-31 23:02:20 +0200 |
commit | be94780315b85e51204e28c41fcad34e507d3d3c (patch) | |
tree | 39ad8450cbf5fd8c0f4e0c13f4395da67c77ea26 /bridge/github/config.go | |
parent | 77e60aceeac60e02c253a24faba9603c76228e76 (diff) | |
download | git-bug-be94780315b85e51204e28c41fcad34e507d3d3c.tar.gz |
bridge/github: recover terminal state in password prompts
commands: error if a token is provide but not the bridge name and target
Diffstat (limited to 'bridge/github/config.go')
-rw-r--r-- | bridge/github/config.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bridge/github/config.go b/bridge/github/config.go index 954bf845..d1b57e10 100644 --- a/bridge/github/config.go +++ b/bridge/github/config.go @@ -21,6 +21,7 @@ import ( "github.com/MichaelMure/git-bug/bridge/core" "github.com/MichaelMure/git-bug/repository" + "github.com/MichaelMure/git-bug/util/interrupt" ) const ( @@ -236,6 +237,16 @@ func promptTokenOptions(owner, project string) (string, error) { return promptToken() } + // Register restore state cleaner before prompting passwords inputs + termState, err := terminal.GetState(int(syscall.Stdin)) + if err != nil { + return "", err + } + + interrupt.RegisterCleaner(func() error { + return terminal.Restore(int(syscall.Stdin), termState) + }) + return loginAndRequestToken(owner, project) } } |