1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-04 03:48:07 +02:00

A try to hide the password from the error output

This commit is contained in:
mjarkk 2018-12-17 08:58:09 +01:00
parent c56b303b29
commit f5f726e9c4

View File

@ -36,6 +36,8 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
return err
}
lastWritten := ""
var waitForBufio sync.WaitGroup
waitForBufio.Add(1)
@ -47,6 +49,8 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
cmdOutput = append(cmdOutput, toOutput)
toWrite := output(toOutput)
if len(toWrite) > 0 {
toWriteSplit := strings.Split(toWrite, " ")
lastWritten = toWriteSplit[len(toWriteSplit)-1]
// don't do len(cmdOutput)-1 because the next value is the username / password
cmdOutputOffset = len(cmdOutput)
_, _ = tty.WriteString(toWrite + "\n")
@ -59,6 +63,11 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
tty.Close()
if err != nil {
waitForBufio.Wait()
for i, item := range cmdOutput {
if lastWritten == item && cmdOutputOffset < i {
cmdOutputOffset = i + 1
}
}
if cmdOutputOffset > len(cmdOutput)-1 {
cmdOutputOffset = len(cmdOutput) - 1
}