Skip to content

Commit 67af9d7

Browse files
committed
utils: ioutil, Pipe implementatio
1 parent c69d533 commit 67af9d7

File tree

6 files changed

+33
-4
lines changed

6 files changed

+33
-4
lines changed

plumbing/transport/file/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111

1212
"github.com/go-git/go-git/v5/plumbing/transport"
1313
"github.com/go-git/go-git/v5/plumbing/transport/internal/common"
14+
"github.com/go-git/go-git/v5/utils/ioutil"
1415
"golang.org/x/sys/execabs"
1516
)
1617

@@ -111,7 +112,7 @@ func (c *command) Start() error {
111112
func (c *command) StderrPipe() (io.Reader, error) {
112113
// Pipe returned by Command.StderrPipe has a race with Read + Command.Wait.
113114
// We use an io.Pipe and close it after the command finishes.
114-
r, w := io.Pipe()
115+
r, w := ioutil.Pipe()
115116
c.cmd.Stderr = w
116117
c.stderrCloser = r
117118
return r, nil

plumbing/transport/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ func (s *upSession) UploadPack(ctx context.Context, req *packp.UploadPackRequest
166166
return nil, err
167167
}
168168

169-
pr, pw := io.Pipe()
169+
pr, pw := ioutil.Pipe()
170170
e := packfile.NewEncoder(pw, s.storer, false)
171171
go func() {
172172
// TODO: plumb through a pack window.

remote.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ func pushHashes(
11251125
allDelete bool,
11261126
) (*packp.ReportStatus, error) {
11271127

1128-
rd, wr := io.Pipe()
1128+
rd, wr := ioutil.Pipe()
11291129

11301130
config, err := s.Config()
11311131
if err != nil {

utils/ioutil/common.go

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import (
77
"errors"
88
"io"
99

10-
"github.com/jbenet/go-context/io"
10+
ctxio "github.com/jbenet/go-context/io"
1111
)
1212

1313
type readPeeker interface {
@@ -168,3 +168,13 @@ func (r *writerOnError) Write(p []byte) (n int, err error) {
168168

169169
return
170170
}
171+
172+
type PipeReader interface {
173+
io.ReadCloser
174+
CloseWithError(err error) error
175+
}
176+
177+
type PipeWriter interface {
178+
io.WriteCloser
179+
CloseWithError(err error) error
180+
}

utils/ioutil/pipe.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// +build !js
2+
3+
package ioutil
4+
5+
import "io"
6+
7+
func Pipe() (PipeReader, PipeWriter) {
8+
return io.Pipe()
9+
}

utils/ioutil/pipe_js.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// +build js
2+
3+
package ioutil
4+
5+
import "github.com/acomagu/bufpipe"
6+
7+
func Pipe() (PipeReader, PipeWriter) {
8+
return bufpipe.New(nil)
9+
}

0 commit comments

Comments
 (0)