1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-02-09 13:47:11 +02:00

Handled some errors

This commit is contained in:
mjarkk 2018-10-20 19:44:56 +02:00
parent 1be44eae84
commit ac03665df3
3 changed files with 15 additions and 3 deletions

View File

@ -85,6 +85,7 @@ func (c *OSCommand) RunCommandWithOutputLive(command string, output func(string)
go func() {
// Regex to cleanup the command output
// sometimes the output words include unneeded spaces at eatch end of the string
re := regexp.MustCompile(`(^\s*)|(\s*$)`)
scanner := bufio.NewScanner(tty)

View File

@ -60,10 +60,11 @@ var waitForGroupActie = false
func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUname string) string {
waitForGroupActie = true
waitForGroup.Add(1)
pushPassUnameView := gui.getPushPassUnameView(g)
if passOrUname == "username" {
pushPassUnameView.Title = gui.Tr.SLocalize("PushUsername")
// pushPassUnameView.Mask = 1
pushPassUnameView.Mask = 0
} else {
pushPassUnameView.Title = gui.Tr.SLocalize("PushPassword")
pushPassUnameView.Mask = '*'
@ -80,15 +81,23 @@ func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUn
gui.RenderCommitLength()
return nil
})
// wait for username/passwords input
waitForGroup.Wait()
return unamePassMessage
}
func (gui *Gui) handlePushConfirm(g *gocui.Gui, v *gocui.View) error {
message := gui.trimmedContent(v)
if message == "" {
// make sure to input something
// if not dune the push progress will run forever
message = "-"
}
unamePassMessage = message
if waitForGroupActie {
defer waitForGroup.Done()
waitForGroup.Done()
waitForGroupActie = false
}
err := gui.refreshFiles(g)
if err != nil {
@ -117,7 +126,8 @@ func (gui *Gui) handlePushClose(g *gocui.Gui, v *gocui.View) error {
}
unamePassMessage = ""
if waitForGroupActie {
defer waitForGroup.Done()
waitForGroup.Done()
waitForGroupActie = false
}
return gui.switchFocus(g, v, gui.getFilesView(g))
}

View File

@ -364,6 +364,7 @@ func (gui *Gui) pushWithForceFlag(g *gocui.Gui, currentView *gocui.View, force b
err := gui.GitCommand.Push(branchName, force, func(passOrUname string) string {
return gui.waitForPassUname(g, currentView, passOrUname)
})
_, _ = g.SetViewOnBottom("pushPassUname")
if err != nil {
errMessage := err.Error()
if errMessage == "exit status 128" {