mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-06-08 23:56:15 +02:00
Pass cmdObj instead of task to processOutput
This is a preparation for the next commit, where we will need more from the cmdObj in processOutput.
This commit is contained in:
parent
c4bfdaeaf3
commit
75a8c0c73e
@ -10,7 +10,6 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/go-errors/errors"
|
"github.com/go-errors/errors"
|
||||||
"github.com/jesseduffield/gocui"
|
|
||||||
"github.com/jesseduffield/lazygit/pkg/utils"
|
"github.com/jesseduffield/lazygit/pkg/utils"
|
||||||
"github.com/sasha-s/go-deadlock"
|
"github.com/sasha-s/go-deadlock"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
@ -340,7 +339,7 @@ func (self *cmdObjRunner) runAndDetectCredentialRequest(
|
|||||||
tr := io.TeeReader(handler.stdoutPipe, cmdWriter)
|
tr := io.TeeReader(handler.stdoutPipe, cmdWriter)
|
||||||
|
|
||||||
go utils.Safe(func() {
|
go utils.Safe(func() {
|
||||||
self.processOutput(tr, handler.stdinPipe, promptUserForCredential, cmdObj.GetTask())
|
self.processOutput(tr, handler.stdinPipe, promptUserForCredential, cmdObj)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -349,9 +348,10 @@ func (self *cmdObjRunner) processOutput(
|
|||||||
reader io.Reader,
|
reader io.Reader,
|
||||||
writer io.Writer,
|
writer io.Writer,
|
||||||
promptUserForCredential func(CredentialType) <-chan string,
|
promptUserForCredential func(CredentialType) <-chan string,
|
||||||
task gocui.Task,
|
cmdObj *CmdObj,
|
||||||
) {
|
) {
|
||||||
checkForCredentialRequest := self.getCheckForCredentialRequestFunc()
|
checkForCredentialRequest := self.getCheckForCredentialRequestFunc()
|
||||||
|
task := cmdObj.GetTask()
|
||||||
|
|
||||||
scanner := bufio.NewScanner(reader)
|
scanner := bufio.NewScanner(reader)
|
||||||
scanner.Split(bufio.ScanBytes)
|
scanner.Split(bufio.ScanBytes)
|
||||||
|
@ -120,8 +120,8 @@ func TestProcessOutput(t *testing.T) {
|
|||||||
reader := strings.NewReader(scenario.output)
|
reader := strings.NewReader(scenario.output)
|
||||||
writer := &strings.Builder{}
|
writer := &strings.Builder{}
|
||||||
|
|
||||||
task := gocui.NewFakeTask()
|
cmdObj := &CmdObj{task: gocui.NewFakeTask()}
|
||||||
runner.processOutput(reader, writer, toChanFn(scenario.promptUserForCredential), task)
|
runner.processOutput(reader, writer, toChanFn(scenario.promptUserForCredential), cmdObj)
|
||||||
|
|
||||||
if writer.String() != scenario.expectedToWrite {
|
if writer.String() != scenario.expectedToWrite {
|
||||||
t.Errorf("expected to write '%s' but got '%s'", scenario.expectedToWrite, writer.String())
|
t.Errorf("expected to write '%s' but got '%s'", scenario.expectedToWrite, writer.String())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user