aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing
diff options
context:
space:
mode:
Diffstat (limited to 'plumbing')
-rw-r--r--plumbing/format/packfile/common.go3
-rw-r--r--plumbing/format/packfile/scanner.go5
-rw-r--r--plumbing/object/blob.go2
-rw-r--r--plumbing/object/commit.go2
-rw-r--r--plumbing/object/file.go2
-rw-r--r--plumbing/object/tag.go5
-rw-r--r--plumbing/object/tree.go4
-rw-r--r--plumbing/transport/http/common.go6
-rw-r--r--plumbing/transport/test/receive_pack.go21
9 files changed, 36 insertions, 14 deletions
diff --git a/plumbing/format/packfile/common.go b/plumbing/format/packfile/common.go
index 7dad1f6..beb015d 100644
--- a/plumbing/format/packfile/common.go
+++ b/plumbing/format/packfile/common.go
@@ -40,8 +40,7 @@ func UpdateObjectStorage(s storer.EncodedObjectStorer, packfile io.Reader) error
return err
}
-func writePackfileToObjectStorage(sw storer.PackfileWriter, packfile io.Reader) error {
- var err error
+func writePackfileToObjectStorage(sw storer.PackfileWriter, packfile io.Reader) (err error) {
w, err := sw.PackfileWriter()
if err != nil {
return err
diff --git a/plumbing/format/packfile/scanner.go b/plumbing/format/packfile/scanner.go
index 8c216f1..6fc183b 100644
--- a/plumbing/format/packfile/scanner.go
+++ b/plumbing/format/packfile/scanner.go
@@ -279,14 +279,15 @@ func (s *Scanner) NextObject(w io.Writer) (written int64, crc32 uint32, err erro
// from it zlib stream in an object entry in the packfile.
func (s *Scanner) copyObject(w io.Writer) (n int64, err error) {
if s.zr == nil {
- zr, err := zlib.NewReader(s.r)
+ var zr io.ReadCloser
+ zr, err = zlib.NewReader(s.r)
if err != nil {
return 0, fmt.Errorf("zlib initialization error: %s", err)
}
s.zr = zr.(readerResetter)
} else {
- if err := s.zr.Reset(s.r, nil); err != nil {
+ if err = s.zr.Reset(s.r, nil); err != nil {
return 0, fmt.Errorf("zlib reset error: %s", err)
}
}
diff --git a/plumbing/object/blob.go b/plumbing/object/blob.go
index 2608477..f376baa 100644
--- a/plumbing/object/blob.go
+++ b/plumbing/object/blob.go
@@ -67,7 +67,7 @@ func (b *Blob) Decode(o plumbing.EncodedObject) error {
}
// Encode transforms a Blob into a plumbing.EncodedObject.
-func (b *Blob) Encode(o plumbing.EncodedObject) error {
+func (b *Blob) Encode(o plumbing.EncodedObject) (err error) {
o.SetType(plumbing.BlobObject)
w, err := o.Writer()
diff --git a/plumbing/object/commit.go b/plumbing/object/commit.go
index a317714..c9a4c0e 100644
--- a/plumbing/object/commit.go
+++ b/plumbing/object/commit.go
@@ -226,7 +226,7 @@ func (b *Commit) Encode(o plumbing.EncodedObject) error {
return b.encode(o, true)
}
-func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) error {
+func (b *Commit) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
o.SetType(plumbing.CommitObject)
w, err := o.Writer()
if err != nil {
diff --git a/plumbing/object/file.go b/plumbing/object/file.go
index 40b5206..1c5fdbb 100644
--- a/plumbing/object/file.go
+++ b/plumbing/object/file.go
@@ -44,7 +44,7 @@ func (f *File) Contents() (content string, err error) {
}
// IsBinary returns if the file is binary or not
-func (f *File) IsBinary() (bool, error) {
+func (f *File) IsBinary() (bin bool, err error) {
reader, err := f.Reader()
if err != nil {
return false, err
diff --git a/plumbing/object/tag.go b/plumbing/object/tag.go
index 19e55cf..905206b 100644
--- a/plumbing/object/tag.go
+++ b/plumbing/object/tag.go
@@ -95,7 +95,8 @@ func (t *Tag) Decode(o plumbing.EncodedObject) (err error) {
r := bufio.NewReader(reader)
for {
- line, err := r.ReadBytes('\n')
+ var line []byte
+ line, err = r.ReadBytes('\n')
if err != nil && err != io.EOF {
return err
}
@@ -168,7 +169,7 @@ func (t *Tag) Encode(o plumbing.EncodedObject) error {
return t.encode(o, true)
}
-func (t *Tag) encode(o plumbing.EncodedObject, includeSig bool) error {
+func (t *Tag) encode(o plumbing.EncodedObject, includeSig bool) (err error) {
o.SetType(plumbing.TagObject)
w, err := o.Writer()
if err != nil {
diff --git a/plumbing/object/tree.go b/plumbing/object/tree.go
index 2fcd979..c2399f8 100644
--- a/plumbing/object/tree.go
+++ b/plumbing/object/tree.go
@@ -233,7 +233,7 @@ func (t *Tree) Decode(o plumbing.EncodedObject) (err error) {
}
// Encode transforms a Tree into a plumbing.EncodedObject.
-func (t *Tree) Encode(o plumbing.EncodedObject) error {
+func (t *Tree) Encode(o plumbing.EncodedObject) (err error) {
o.SetType(plumbing.TreeObject)
w, err := o.Writer()
if err != nil {
@@ -242,7 +242,7 @@ func (t *Tree) Encode(o plumbing.EncodedObject) error {
defer ioutil.CheckClose(w, &err)
for _, entry := range t.Entries {
- if _, err := fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil {
+ if _, err = fmt.Fprintf(w, "%o %s", entry.Mode, entry.Name); err != nil {
return err
}
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) }()