This repository was archived by the owner on Sep 11, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -51,7 +51,13 @@ func WritePackfileToObjectStorage(
5151 }
5252
5353 defer ioutil .CheckClose (w , & err )
54- _ , err = io .Copy (w , packfile )
54+
55+ var n int64
56+ n , err = io .Copy (w , packfile )
57+ if err == nil && n == 0 {
58+ return ErrEmptyPackfile
59+ }
60+
5561 return err
5662}
5763
Original file line number Diff line number Diff line change 11package packfile
22
33import (
4+ "bytes"
45 "testing"
56
67 "gopkg.in/src-d/go-git.v4/plumbing"
8+ "gopkg.in/src-d/go-git.v4/storage/memory"
79
810 . "gopkg.in/check.v1"
911)
1012
1113func Test (t * testing.T ) { TestingT (t ) }
1214
15+ type CommonSuite struct {}
16+
17+ var _ = Suite (& CommonSuite {})
18+
19+ func (s * CommonSuite ) TestEmptyUpdateObjectStorage (c * C ) {
20+ var buf bytes.Buffer
21+ sto := memory .NewStorage ()
22+
23+ err := UpdateObjectStorage (sto , & buf )
24+ c .Assert (err , Equals , ErrEmptyPackfile )
25+ }
26+
1327func newObject (t plumbing.ObjectType , cont []byte ) plumbing.EncodedObject {
1428 o := plumbing.MemoryObject {}
1529 o .SetType (t )
Original file line number Diff line number Diff line change 4141 ErrTagExists = errors .New ("tag already exists" )
4242 // ErrTagNotFound an error stating the specified tag does not exist
4343 ErrTagNotFound = errors .New ("tag not found" )
44+ // ErrFetching is returned when the packfile could not be downloaded
45+ ErrFetching = errors .New ("unable to fetch packfile" )
4446
4547 ErrInvalidReference = errors .New ("invalid reference, should be a tag or a branch" )
4648 ErrRepositoryNotExists = errors .New ("repository does not exist" )
@@ -858,6 +860,8 @@ func (r *Repository) fetchAndUpdateReferences(
858860 remoteRefs , err := remote .fetch (ctx , o )
859861 if err == NoErrAlreadyUpToDate {
860862 objsUpdated = false
863+ } else if err == packfile .ErrEmptyPackfile {
864+ return nil , ErrFetching
861865 } else if err != nil {
862866 return nil , err
863867 }
You can’t perform that action at this time.
0 commit comments