aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/transport
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing/transport')
-rw-r--r--plumbing/transport/http/common.go6
-rw-r--r--plumbing/transport/test/receive_pack.go21
2 files changed, 24 insertions, 3 deletions
diff --git a/plumbing/transport/http/common.go b/plumbing/transport/http/common.go
index 24e63a4..2c337b7 100644
--- a/plumbing/transport/http/common.go
+++ b/plumbing/transport/http/common.go
@@ -31,7 +31,7 @@ func applyHeadersToRequest(req *http.Request, content *bytes.Buffer, host string
const infoRefsPath = "/info/refs"
-func advertisedReferences(s *session, serviceName string) (*packp.AdvRefs, error) {
+func advertisedReferences(s *session, serviceName string) (ref *packp.AdvRefs, err error) {
url := fmt.Sprintf(
"%s%s?service=%s",
s.endpoint.String(), infoRefsPath, serviceName,
@@ -52,12 +52,12 @@ func advertisedReferences(s *session, serviceName string) (*packp.AdvRefs, error
s.ModifyEndpointIfRedirect(res)
defer ioutil.CheckClose(res.Body, &err)
- if err := NewErr(res); err != nil {
+ if err = NewErr(res); err != nil {
return nil, err
}
ar := packp.NewAdvRefs()
- if err := ar.Decode(res.Body); err != nil {
+ if err = ar.Decode(res.Body); err != nil {
if err == packp.ErrEmptyAdvRefs {
err = transport.ErrEmptyRemoteRepository
}
diff --git a/plumbing/transport/test/receive_pack.go b/plumbing/transport/test/receive_pack.go
index a68329e..6179850 100644
--- a/plumbing/transport/test/receive_pack.go
+++ b/plumbing/transport/test/receive_pack.go
@@ -8,6 +8,8 @@ import (
"context"
"io"
"io/ioutil"
+ "os"
+ "path/filepath"
"gopkg.in/src-d/go-git.v4/plumbing"
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
@@ -225,6 +227,25 @@ func (s *ReceivePackSuite) receivePackNoCheck(c *C, ep *transport.Endpoint,
ep.String(), url, callAdvertisedReferences,
)
+ // Set write permissions to endpoint directory files. By default
+ // fixtures are generated with read only permissions, this casuses
+ // errors deleting or modifying files.
+ rootPath := ep.Path
+ println("STAT", rootPath)
+ stat, err := os.Stat(ep.Path)
+
+ if rootPath != "" && err == nil && stat.IsDir() {
+ objectPath := filepath.Join(rootPath, "objects/pack")
+ files, err := ioutil.ReadDir(objectPath)
+ c.Assert(err, IsNil)
+
+ for _, file := range files {
+ path := filepath.Join(objectPath, file.Name())
+ err = os.Chmod(path, 0644)
+ c.Assert(err, IsNil)
+ }
+ }
+
r, err := s.Client.NewReceivePackSession(ep, s.EmptyAuth)
c.Assert(err, IsNil, comment)
defer func() { c.Assert(r.Close(), IsNil, comment) }()