@@ -104,7 +104,9 @@ func Receive(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)
104104 log .Debugf (c , "Working Dir: %s" , cmd .Dir )
105105 log .Debugf (c , "Environment: %s" , strings .Join (cmd .Env , "," ))
106106
107- plumbCommand (cmd , channel , & errbuff )
107+ if err := plumbCommand (cmd , channel , & errbuff ); err != nil {
108+ return nil , err
109+ }
108110
109111 if err := cmd .Start (); err != nil {
110112 err = fmt .Errorf ("Failed to start git pre-receive hook: %s (%s)" , err , errbuff .Bytes ())
@@ -141,15 +143,18 @@ func cleanRepoName(name string) (string, error) {
141143// plumbCommand connects the exec in/output and the channel in/output.
142144//
143145// The sidechannel is for sending errors to logs.
144- func plumbCommand (cmd * exec.Cmd , channel ssh.Channel , sidechannel io.Writer ) {
145- inpipe , _ := cmd .StdinPipe ()
146+ func plumbCommand (cmd * exec.Cmd , channel ssh.Channel , sidechannel io.Writer ) error {
147+ inpipe , err := cmd .StdinPipe ()
148+ if err != nil {
149+ return err
150+ }
151+ cmd .Stdout = channel
152+ cmd .Stderr = io .MultiWriter (channel .Stderr (), sidechannel )
146153 go func () {
147154 io .Copy (inpipe , channel )
148155 inpipe .Close ()
149156 }()
150157
151- cmd .Stdout = channel
152- cmd .Stderr = io .MultiWriter (channel .Stderr (), sidechannel )
153158}
154159
155160var createLock sync.Mutex
0 commit comments