1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-30 09:16:47 +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 { errMessage, err := c.RunCommandWithOutputLive(command, func(word string) string {
ttyText = ttyText + " " + word ttyText = ttyText + " " + word
// prompt and patterns to check if the user needs to input a username / password type Prompt struct {
prompts := map[string]string{ pattern string
"password": `Password\s*for\s*'.+':`, canAskFor bool
"username": `Username\s*for\s*'.+':`, }
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 { for askFor, propmt := range prompts {
if match, _ := regexp.MatchString(pattern, ttyText); match { if match, _ := regexp.MatchString(propmt.pattern, ttyText); match && propmt.canAskFor {
propmt.canAskFor = false
ttyText = "" 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
fi fi
done done