From 7a02aee903bebd1f5023793c35171953c1d0a7cf Mon Sep 17 00:00:00 2001 From: Javi Fontan Date: Tue, 27 Mar 2018 17:48:58 +0200 Subject: 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 --- plumbing/transport/test/receive_pack.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'plumbing/transport/test/receive_pack.go') 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) }() -- cgit