aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:36:12 +0200
committerMáximo Cuadros <mcuadros@gmail.com>2021-05-02 23:36:12 +0200
commit67af9d7223b0cc643025d958c592291f7475ac75 (patch)
treea8d14d0e88fd57ae84c2614d7c2fb9c6527438a5
parentc69d5331743e49d3672897cf1c552e5e123d4509 (diff)
downloadgo-git-67af9d7223b0cc643025d958c592291f7475ac75.tar.gz
utils: ioutil, Pipe implementatio
-rw-r--r--plumbing/transport/file/client.go3
-rw-r--r--plumbing/transport/server/server.go2
-rw-r--r--remote.go2
-rw-r--r--utils/ioutil/common.go12
-rw-r--r--utils/ioutil/pipe.go9
-rw-r--r--utils/ioutil/pipe_js.go9
6 files changed, 33 insertions, 4 deletions
diff --git a/plumbing/transport/file/client.go b/plumbing/transport/file/client.go
index 38714e2..6f0a380 100644
--- a/plumbing/transport/file/client.go
+++ b/plumbing/transport/file/client.go
@@ -11,6 +11,7 @@ import (
"github.com/go-git/go-git/v5/plumbing/transport"
"github.com/go-git/go-git/v5/plumbing/transport/internal/common"
+ "github.com/go-git/go-git/v5/utils/ioutil"
"golang.org/x/sys/execabs"
)
@@ -111,7 +112,7 @@ func (c *command) Start() error {
func (c *command) StderrPipe() (io.Reader, error) {
// Pipe returned by Command.StderrPipe has a race with Read + Command.Wait.
// We use an io.Pipe and close it after the command finishes.
- r, w := io.Pipe()
+ r, w := ioutil.Pipe()
c.cmd.Stderr = w
c.stderrCloser = r
return r, nil
diff --git a/plumbing/transport/server/server.go b/plumbing/transport/server/server.go
index 6f89ec3..8ab70fe 100644
--- a/plumbing/transport/server/server.go
+++ b/plumbing/transport/server/server.go
@@ -166,7 +166,7 @@ func (s *upSession) UploadPack(ctx context.Context, req *packp.UploadPackRequest
return nil, err
}
- pr, pw := io.Pipe()
+ pr, pw := ioutil.Pipe()
e := packfile.NewEncoder(pw, s.storer, false)
go func() {
// TODO: plumb through a pack window.
diff --git a/remote.go b/remote.go
index ef1c04c..47af638 100644
--- a/remote.go
+++ b/remote.go
@@ -1125,7 +1125,7 @@ func pushHashes(
allDelete bool,
) (*packp.ReportStatus, error) {
- rd, wr := io.Pipe()
+ rd, wr := ioutil.Pipe()
config, err := s.Config()
if err != nil {
diff --git a/utils/ioutil/common.go b/utils/ioutil/common.go
index e9dcbfe..b52e85a 100644
--- a/utils/ioutil/common.go
+++ b/utils/ioutil/common.go
@@ -7,7 +7,7 @@ import (
"errors"
"io"
- "github.com/jbenet/go-context/io"
+ ctxio "github.com/jbenet/go-context/io"
)
type readPeeker interface {
@@ -168,3 +168,13 @@ func (r *writerOnError) Write(p []byte) (n int, err error) {
return
}
+
+type PipeReader interface {
+ io.ReadCloser
+ CloseWithError(err error) error
+}
+
+type PipeWriter interface {
+ io.WriteCloser
+ CloseWithError(err error) error
+}
diff --git a/utils/ioutil/pipe.go b/utils/ioutil/pipe.go
new file mode 100644
index 0000000..f30c452
--- /dev/null
+++ b/utils/ioutil/pipe.go
@@ -0,0 +1,9 @@
+// +build !js
+
+package ioutil
+
+import "io"
+
+func Pipe() (PipeReader, PipeWriter) {
+ return io.Pipe()
+}
diff --git a/utils/ioutil/pipe_js.go b/utils/ioutil/pipe_js.go
new file mode 100644
index 0000000..cf102e6
--- /dev/null
+++ b/utils/ioutil/pipe_js.go
@@ -0,0 +1,9 @@
+// +build js
+
+package ioutil
+
+import "github.com/acomagu/bufpipe"
+
+func Pipe() (PipeReader, PipeWriter) {
+ return bufpipe.New(nil)
+}