aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavi Fontan <jfontan@gmail.com>2018-03-27 17:48:58 +0200
committerJavi Fontan <jfontan@gmail.com>2018-03-27 17:51:57 +0200
commit7a02aee903bebd1f5023793c35171953c1d0a7cf (patch)
tree5d1a18d04fba2b34b7d2fd11be6d8e4d3989731c
parent05c414a169a75ca933402e5be19a5c4304aa4f00 (diff)
downloadgo-git-7a02aee903bebd1f5023793c35171953c1d0a7cf.tar.gz
plumbing: transport, make target repo writeable in tests
Some tests write to an already existent repository retrieved from fixtures. The permissions of these files are read only and make receive pack fail. This was shadowed before as close errors were lost. Signed-off-by: Javi Fontan <jfontan@gmail.com>
-rw-r--r--plumbing/transport/test/receive_pack.go21
1 files changed, 21 insertions, 0 deletions
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) }()