1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-26 09:00:57 +02:00

Fixed case that a commit message will break git push

This commit is contained in:
mjarkk 2018-11-10 18:10:53 +01:00
parent bc14b01d03
commit 9fafd7ebc1
2 changed files with 17 additions and 8 deletions

View File

@ -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)
}
}

View File

@ -12,4 +12,3 @@ for d in $( find ./* -maxdepth 10 ! -path "./vendor*" ! -path "./.git*" ! -path
fi
fi
done