提交 5d42499f 编写于 作者: M Mislav Marohnić 提交者: Mislav Marohnić

go compat

上级 af715092
...@@ -504,9 +504,9 @@ Feature: OAuth authentication ...@@ -504,9 +504,9 @@ Feature: OAuth authentication
Scenario: Config file is not writeable, should exit before asking for credentials Scenario: Config file is not writeable, should exit before asking for credentials
Given $HUB_CONFIG is "/InvalidConfigFile" Given $HUB_CONFIG is "/InvalidConfigFile"
When I run `hub create` interactively 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 exit status should be 1
And the file "../home/.config/hub" should not exist And the file "../home/.config/hub" should not exist
......
...@@ -35,6 +35,8 @@ type Host struct { ...@@ -35,6 +35,8 @@ type Host struct {
type Config struct { type Config struct {
Hosts []*Host `toml:"hosts"` Hosts []*Host `toml:"hosts"`
stdinScanner *bufio.Scanner
} }
func (c *Config) PromptForHost(host string) (h *Host, err error) { func (c *Config) PromptForHost(host string) (h *Host, err error) {
...@@ -181,8 +183,11 @@ func (c *Config) PromptForOTP() string { ...@@ -181,8 +183,11 @@ func (c *Config) PromptForOTP() string {
} }
func (c *Config) scanLine() string { func (c *Config) scanLine() string {
if c.stdinScanner == nil {
c.stdinScanner = bufio.NewScanner(os.Stdin)
}
var line string var line string
scanner := bufio.NewScanner(os.Stdin) scanner := c.stdinScanner
if scanner.Scan() { if scanner.Scan() {
line = scanner.Text() line = scanner.Text()
} }
......
...@@ -14,6 +14,6 @@ require ( ...@@ -14,6 +14,6 @@ require (
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 // indirect github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95 // indirect
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0 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 gopkg.in/yaml.v2 v2.0.0-20190319135612-7b8349ac747c
) )
...@@ -21,8 +21,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk ...@@ -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 h1:2mqDk8w/o6UmeUCu5Qiq2y7iMf6anbx+YA8d1JFoFrs=
golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 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-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-20220319134239-a9b59b0215f8 h1:OH54vjqzRWmbJ62fjuhxy7AxFFgoHN0/DPc/UrL8cAs=
golang.org/x/sys v0.0.0-20190531175056-4c3a928424d2/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 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 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 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= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册