1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-03-19 21:28:28 +02:00

remove subprocess channel stuff

This commit is contained in:
Jesse Duffield 2019-04-07 16:45:55 +10:00
parent 55538a3695
commit 0f1abcb10c
2 changed files with 13 additions and 38 deletions

View File

@ -601,10 +601,6 @@ func (gui *Gui) handleCreateResetMenu(g *gocui.Gui, v *gocui.View) error {
} }
func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error { func (gui *Gui) handleCustomCommand(g *gocui.Gui, v *gocui.View) error {
// gui.subProcessChan <- gui.OSCommand.RunCustomCommand(`read -p "Name: " name; echo $name; read -p "Okay: " okay; echo $okay`)
// return nil
return gui.createPromptPanel(g, v, gui.Tr.SLocalize("CustomCommand"), func(g *gocui.Gui, v *gocui.View) error { return gui.createPromptPanel(g, v, gui.Tr.SLocalize("CustomCommand"), func(g *gocui.Gui, v *gocui.View) error {
command := gui.trimmedContent(v) command := gui.trimmedContent(v)
gui.SubProcess = gui.OSCommand.RunCustomCommand(command) gui.SubProcess = gui.OSCommand.RunCustomCommand(command)

View File

@ -64,20 +64,19 @@ type Teml i18n.Teml
// Gui wraps the gocui Gui object which handles rendering and events // Gui wraps the gocui Gui object which handles rendering and events
type Gui struct { type Gui struct {
g *gocui.Gui g *gocui.Gui
Log *logrus.Entry Log *logrus.Entry
GitCommand *commands.GitCommand GitCommand *commands.GitCommand
OSCommand *commands.OSCommand OSCommand *commands.OSCommand
SubProcess *exec.Cmd SubProcess *exec.Cmd
subProcessChan chan (*exec.Cmd) State guiState
State guiState Config config.AppConfigurer
Config config.AppConfigurer Tr *i18n.Localizer
Tr *i18n.Localizer Errors SentinelErrors
Errors SentinelErrors Updater *updates.Updater
Updater *updates.Updater statusManager *statusManager
statusManager *statusManager credentials credentials
credentials credentials waitForIntro sync.WaitGroup
waitForIntro sync.WaitGroup
} }
// for now the staging panel state, unlike the other panel states, is going to be // for now the staging panel state, unlike the other panel states, is going to be
@ -533,8 +532,6 @@ func (gui *Gui) loadNewRepo() error {
return err return err
} }
} }
go gui.listenForSubprocesses()
return nil return nil
} }
@ -646,24 +643,6 @@ func (gui *Gui) Run() error {
return err return err
} }
func (gui *Gui) listenForSubprocesses() {
// every time there is a subprocess, we're going to halt the execution of the UI via an update block, and wait for the command to finish
gui.subProcessChan = make(chan *exec.Cmd, 0)
for {
subProcess := <-gui.subProcessChan
gui.g.Update(func(*gocui.Gui) error {
subProcess.Stdin = os.Stdin
output, _ := runCommand(subProcess)
gui.State.SubProcessOutput = output
subProcess.Stdout = ioutil.Discard
subProcess.Stderr = ioutil.Discard
subProcess.Stdin = nil
return nil
})
}
}
// RunWithSubprocesses loops, instantiating a new gocui.Gui with each iteration // RunWithSubprocesses loops, instantiating a new gocui.Gui with each iteration
// if the error returned from a run is a ErrSubProcess, it runs the subprocess // if the error returned from a run is a ErrSubProcess, it runs the subprocess
// otherwise it handles the error, possibly by quitting the application // otherwise it handles the error, possibly by quitting the application