diff --git a/features/authentication.feature b/features/authentication.feature index 2675530b9835fd9ac9fce3e53757aac50fec6882..77dbc07d03b46e465202c948a15f70f467abd212 100644 --- a/features/authentication.feature +++ b/features/authentication.feature @@ -504,9 +504,9 @@ Feature: OAuth authentication Scenario: Config file is not writeable, should exit before asking for credentials Given $HUB_CONFIG is "/InvalidConfigFile" When I run `hub create` interactively - Then the output should contain exactly: + Then the output should contain: """ - open /InvalidConfigFile: permission denied\n + open /InvalidConfigFile: """ And the exit status should be 1 And the file "../home/.config/hub" should not exist diff --git a/github/config.go b/github/config.go index 4177ce65bff3dde0c55f8b0b94345f4502b14845..6fbf7dc47d7db43111443a6c33b486fb21da07e1 100644 --- a/github/config.go +++ b/github/config.go @@ -35,6 +35,8 @@ type Host struct { type Config struct { Hosts []*Host `toml:"hosts"` + + stdinScanner *bufio.Scanner } func (c *Config) PromptForHost(host string) (h *Host, err error) { @@ -181,8 +183,11 @@ func (c *Config) PromptForOTP() string { } func (c *Config) scanLine() string { + if c.stdinScanner == nil { + c.stdinScanner = bufio.NewScanner(os.Stdin) + } var line string - scanner := bufio.NewScanner(os.Stdin) + scanner := c.stdinScanner if scanner.Scan() { line = scanner.Text() } diff --git a/go.mod b/go.mod index fa9a48a459ee70a1b5d1f555249dbb9014bc8f97..9ebf79e9cec09107d52f4b3d537b4864c8be6119 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,6 @@ require ( github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 // indirect golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 - golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2 // indirect + golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect gopkg.in/yaml.v2 v2.0.0-20190319135612-7b8349ac747c ) diff --git a/go.sum b/go.sum index e70f2300358e473535dbf4b3b31c4b9adc4538d2..69beb0ab0a52b3bf4edcd13a8138632a2afe738f 100644 --- a/go.sum +++ b/go.sum @@ -21,8 +21,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 h1:2mqDk8w/o6UmeUCu5Qiq2y7iMf6anbx+YA8d1JFoFrs= golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2 h1:T5DasATyLQfmbTpfEXx/IOL9vfjzW6up+ZDkmHvIf2s= -golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs= +golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=