diff options
author | mjarkk <mkopenga@gmail.com> | 2018-11-10 18:10:53 +0100 |
---|---|---|
committer | mjarkk <mkopenga@gmail.com> | 2018-11-10 18:10:53 +0100 |
commit | 9fafd7ebc1f100064ae1acd8881d0de296612b81 (patch) | |
tree | b15543f2a2f0dcf7a198ec1442ea9cfb0f235400 /pkg | |
parent | bc14b01d03c127f5a92feccd20cb651d88e65e44 (diff) |
Fixed case that a commit message will break git push
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/commands/os.go | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/pkg/commands/os.go b/pkg/commands/os.go index b1f17c85f..23f097449 100644 --- a/pkg/commands/os.go +++ b/pkg/commands/os.go @@ -70,16 +70,26 @@ func (c *OSCommand) DetectUnamePass(command string, ask func(string) string) err errMessage, err := c.RunCommandWithOutputLive(command, func(word string) string { ttyText = ttyText + " " + word - // prompt and patterns to check if the user needs to input a username / password - prompts := map[string]string{ - "password": `Password\s*for\s*'.+':`, - "username": `Username\s*for\s*'.+':`, + type Prompt struct { + pattern string + canAskFor bool + } + prompts := map[string]Prompt{ + "password": Prompt{ + pattern: `Password\s*for\s*'.+':`, + canAskFor: true, + }, + "username": Prompt{ + pattern: `Username\s*for\s*'.+':`, + canAskFor: true, + }, } - for prompt, pattern := range prompts { - if match, _ := regexp.MatchString(pattern, ttyText); match { + for askFor, propmt := range prompts { + if match, _ := regexp.MatchString(propmt.pattern, ttyText); match && propmt.canAskFor { + propmt.canAskFor = false ttyText = "" - return ask(prompt) + return ask(askFor) } } |