mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-01-06 03:53:59 +02:00
A try to hide the password from the error output
This commit is contained in:
parent
c56b303b29
commit
f5f726e9c4
@ -36,6 +36,8 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastWritten := ""
|
||||||
|
|
||||||
var waitForBufio sync.WaitGroup
|
var waitForBufio sync.WaitGroup
|
||||||
waitForBufio.Add(1)
|
waitForBufio.Add(1)
|
||||||
|
|
||||||
@ -47,6 +49,8 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
|
|||||||
cmdOutput = append(cmdOutput, toOutput)
|
cmdOutput = append(cmdOutput, toOutput)
|
||||||
toWrite := output(toOutput)
|
toWrite := output(toOutput)
|
||||||
if len(toWrite) > 0 {
|
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
|
// don't do len(cmdOutput)-1 because the next value is the username / password
|
||||||
cmdOutputOffset = len(cmdOutput)
|
cmdOutputOffset = len(cmdOutput)
|
||||||
_, _ = tty.WriteString(toWrite + "\n")
|
_, _ = tty.WriteString(toWrite + "\n")
|
||||||
@ -59,6 +63,11 @@ func RunCommandWithOutputLiveWrapper(c *OSCommand, command string, output func(s
|
|||||||
tty.Close()
|
tty.Close()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
waitForBufio.Wait()
|
waitForBufio.Wait()
|
||||||
|
for i, item := range cmdOutput {
|
||||||
|
if lastWritten == item && cmdOutputOffset < i {
|
||||||
|
cmdOutputOffset = i + 1
|
||||||
|
}
|
||||||
|
}
|
||||||
if cmdOutputOffset > len(cmdOutput)-1 {
|
if cmdOutputOffset > len(cmdOutput)-1 {
|
||||||
cmdOutputOffset = len(cmdOutput) - 1
|
cmdOutputOffset = len(cmdOutput) - 1
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user