mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-17 22:32:58 +02:00
Changed the waitForGroup to a channel
This commit is contained in:
parent
b0eaf507a5
commit
adfc00bcdc
@ -3,7 +3,6 @@ package gui
|
|||||||
import (
|
import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"github.com/jesseduffield/gocui"
|
"github.com/jesseduffield/gocui"
|
||||||
)
|
)
|
||||||
@ -52,17 +51,11 @@ func (gui *Gui) handleCommitFocused(g *gocui.Gui, v *gocui.View) error {
|
|||||||
return gui.renderString(g, "options", message)
|
return gui.renderString(g, "options", message)
|
||||||
}
|
}
|
||||||
|
|
||||||
type credentials struct {
|
type credentials chan string
|
||||||
unamePassMessage string
|
|
||||||
waitForGroup sync.WaitGroup
|
|
||||||
waitForGroupActie bool
|
|
||||||
}
|
|
||||||
|
|
||||||
// waitForPassUname wait for a username or password input from the pushPassUname popup
|
// waitForPassUname wait for a username or password input from the pushPassUname popup
|
||||||
func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUname string) string {
|
func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUname string) string {
|
||||||
gui.credentials.waitForGroupActie = true
|
gui.credentials = make(chan string)
|
||||||
gui.credentials.waitForGroup.Add(1)
|
|
||||||
|
|
||||||
pushPassUnameView, _ := g.View("pushPassUname")
|
pushPassUnameView, _ := g.View("pushPassUname")
|
||||||
if passOrUname == "username" {
|
if passOrUname == "username" {
|
||||||
pushPassUnameView.Title = gui.Tr.SLocalize("PushUsername")
|
pushPassUnameView.Title = gui.Tr.SLocalize("PushUsername")
|
||||||
@ -85,8 +78,8 @@ func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUn
|
|||||||
})
|
})
|
||||||
|
|
||||||
// wait for username/passwords input
|
// wait for username/passwords input
|
||||||
gui.credentials.waitForGroup.Wait()
|
userInput := <-gui.credentials
|
||||||
return gui.credentials.unamePassMessage
|
return userInput
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) handlePushConfirm(g *gocui.Gui, v *gocui.View) error {
|
func (gui *Gui) handlePushConfirm(g *gocui.Gui, v *gocui.View) error {
|
||||||
@ -96,11 +89,7 @@ func (gui *Gui) handlePushConfirm(g *gocui.Gui, v *gocui.View) error {
|
|||||||
// if not dune the push progress will run forever
|
// if not dune the push progress will run forever
|
||||||
message = "-"
|
message = "-"
|
||||||
}
|
}
|
||||||
gui.credentials.unamePassMessage = message
|
gui.credentials <- message
|
||||||
if gui.credentials.waitForGroupActie {
|
|
||||||
gui.credentials.waitForGroup.Done()
|
|
||||||
gui.credentials.waitForGroupActie = false
|
|
||||||
}
|
|
||||||
err := gui.refreshFiles(g)
|
err := gui.refreshFiles(g)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -126,11 +115,7 @@ func (gui *Gui) handlePushClose(g *gocui.Gui, v *gocui.View) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
gui.credentials.unamePassMessage = ""
|
gui.credentials <- ""
|
||||||
if gui.credentials.waitForGroupActie {
|
|
||||||
gui.credentials.waitForGroup.Done()
|
|
||||||
gui.credentials.waitForGroupActie = false
|
|
||||||
}
|
|
||||||
return gui.switchFocus(g, v, gui.getFilesView(g))
|
return gui.switchFocus(g, v, gui.getFilesView(g))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user