mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-07-01 00:54:58 +02:00
pass callback directly
This commit is contained in:
@ -9,9 +9,9 @@ import (
|
|||||||
type credentials chan string
|
type credentials chan string
|
||||||
|
|
||||||
// waitForPassUname wait for a username or password input from the credentials popup
|
// waitForPassUname wait for a username or password input from the credentials popup
|
||||||
func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUname string) string {
|
func (gui *Gui) waitForPassUname(passOrUname string) string {
|
||||||
gui.credentials = make(chan string)
|
gui.credentials = make(chan string)
|
||||||
g.Update(func(g *gocui.Gui) error {
|
gui.g.Update(func(g *gocui.Gui) error {
|
||||||
credentialsView, _ := g.View("credentials")
|
credentialsView, _ := g.View("credentials")
|
||||||
if passOrUname == "username" {
|
if passOrUname == "username" {
|
||||||
credentialsView.Title = gui.Tr.SLocalize("CredentialsUsername")
|
credentialsView.Title = gui.Tr.SLocalize("CredentialsUsername")
|
||||||
@ -20,7 +20,7 @@ func (gui *Gui) waitForPassUname(g *gocui.Gui, currentView *gocui.View, passOrUn
|
|||||||
credentialsView.Title = gui.Tr.SLocalize("CredentialsPassword")
|
credentialsView.Title = gui.Tr.SLocalize("CredentialsPassword")
|
||||||
credentialsView.Mask = '*'
|
credentialsView.Mask = '*'
|
||||||
}
|
}
|
||||||
err := gui.switchFocus(g, currentView, credentialsView)
|
err := gui.switchFocus(g, gui.g.CurrentView(), credentialsView)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -477,9 +477,7 @@ func (gui *Gui) pullFiles(v *gocui.View, args string) error {
|
|||||||
// what if we had a struct which contained an array of functions to run, each of which return a function, or perhaps write to a channel when they're done, and if there is no error, we run the next thing. In this case we first want to fetch, potentially handling a credential popup, then we want to rebase.
|
// what if we had a struct which contained an array of functions to run, each of which return a function, or perhaps write to a channel when they're done, and if there is no error, we run the next thing. In this case we first want to fetch, potentially handling a credential popup, then we want to rebase.
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
err := gui.GitCommand.Pull(args, func(passOrUname string) string {
|
err := gui.GitCommand.Pull(args, gui.waitForPassUname)
|
||||||
return gui.waitForPassUname(gui.g, v, passOrUname)
|
|
||||||
})
|
|
||||||
// gui.handleGenericMergeCommandResult(err)
|
// gui.handleGenericMergeCommandResult(err)
|
||||||
gui.HandleCredentialsPopup(gui.g, err)
|
gui.HandleCredentialsPopup(gui.g, err)
|
||||||
}()
|
}()
|
||||||
@ -493,9 +491,7 @@ func (gui *Gui) pushWithForceFlag(g *gocui.Gui, v *gocui.View, force bool, upstr
|
|||||||
}
|
}
|
||||||
go func() {
|
go func() {
|
||||||
branchName := gui.getCheckedOutBranch().Name
|
branchName := gui.getCheckedOutBranch().Name
|
||||||
err := gui.GitCommand.Push(branchName, force, upstream, args, func(passOrUname string) string {
|
err := gui.GitCommand.Push(branchName, force, upstream, args, gui.waitForPassUname)
|
||||||
return gui.waitForPassUname(g, v, passOrUname)
|
|
||||||
})
|
|
||||||
gui.HandleCredentialsPopup(g, err)
|
gui.HandleCredentialsPopup(g, err)
|
||||||
}()
|
}()
|
||||||
return nil
|
return nil
|
||||||
|
@ -167,9 +167,7 @@ func (gui *Gui) handleInfoClick(g *gocui.Gui, v *gocui.View) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) fetch(g *gocui.Gui, v *gocui.View, canAskForCredentials bool) (err error) {
|
func (gui *Gui) fetch(g *gocui.Gui, v *gocui.View, canAskForCredentials bool) (err error) {
|
||||||
err = gui.GitCommand.Fetch(func(passOrUname string) string {
|
err = gui.GitCommand.Fetch(gui.waitForPassUname, canAskForCredentials)
|
||||||
return gui.waitForPassUname(gui.g, v, passOrUname)
|
|
||||||
}, canAskForCredentials)
|
|
||||||
|
|
||||||
if canAskForCredentials && err != nil && strings.Contains(err.Error(), "exit status 128") {
|
if canAskForCredentials && err != nil && strings.Contains(err.Error(), "exit status 128") {
|
||||||
colorFunction := color.New(color.FgRed).SprintFunc()
|
colorFunction := color.New(color.FgRed).SprintFunc()
|
||||||
|
Reference in New Issue
Block a user