Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

Commit 7a02aee

Browse files
committed
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>
1 parent 05c414a commit 7a02aee

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

plumbing/transport/test/receive_pack.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"context"
99
"io"
1010
"io/ioutil"
11+
"os"
12+
"path/filepath"
1113

1214
"gopkg.in/src-d/go-git.v4/plumbing"
1315
"gopkg.in/src-d/go-git.v4/plumbing/format/packfile"
@@ -225,6 +227,25 @@ func (s *ReceivePackSuite) receivePackNoCheck(c *C, ep *transport.Endpoint,
225227
ep.String(), url, callAdvertisedReferences,
226228
)
227229

230+
// Set write permissions to endpoint directory files. By default
231+
// fixtures are generated with read only permissions, this casuses
232+
// errors deleting or modifying files.
233+
rootPath := ep.Path
234+
println("STAT", rootPath)
235+
stat, err := os.Stat(ep.Path)
236+
237+
if rootPath != "" && err == nil && stat.IsDir() {
238+
objectPath := filepath.Join(rootPath, "objects/pack")
239+
files, err := ioutil.ReadDir(objectPath)
240+
c.Assert(err, IsNil)
241+
242+
for _, file := range files {
243+
path := filepath.Join(objectPath, file.Name())
244+
err = os.Chmod(path, 0644)
245+
c.Assert(err, IsNil)
246+
}
247+
}
248+
228249
r, err := s.Client.NewReceivePackSession(ep, s.EmptyAuth)
229250
c.Assert(err, IsNil, comment)
230251
defer func() { c.Assert(r.Close(), IsNil, comment) }()

0 commit comments

Comments
 (0)