Bladeren bron

Switch to go-git v4.7.1

Signed-off-by: Vadim Markovtsev <vadim@sourced.tech>
Vadim Markovtsev 6 jaren geleden
bovenliggende
commit
c0089732ff
5 gewijzigde bestanden met toevoegingen van 11 en 15 verwijderingen
  1. 1 1
      .appveyor.yml
  2. 1 1
      .travis.yml
  3. 3 8
      cmd/hercules/root.go
  4. 2 5
      cmd/hercules/root_test.go
  5. 4 0
      internal/plumbing/identity/identity_test.go

+ 1 - 1
.appveyor.yml

@@ -6,7 +6,7 @@ clone_folder: c:\gopath\src\gopkg.in\src-d\hercules.v5
 
 environment:
   GOPATH: c:\gopath
-  GOGIT_TAG: v4.7.0
+  GOGIT_TAG: v4.7.1
 
 install:
   - curl -SLko protoc.zip https://github.com/google/protobuf/releases/download/v3.5.1/protoc-3.5.1-win32.zip

+ 1 - 1
.travis.yml

@@ -35,7 +35,7 @@ stages:
   - deploy
 
 env:
-  - PROTOC_VERSION=3.6.0 TENSORFLOW_VERSION=1.8.0 GOGIT_TAG=v4.7.0
+  - PROTOC_VERSION=3.6.0 TENSORFLOW_VERSION=1.8.0 GOGIT_TAG=v4.7.1
 
 before_install:
   - wget -O protoc.zip https://github.com/google/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-linux-x86_64.zip

+ 3 - 8
cmd/hercules/root.go

@@ -27,6 +27,7 @@ import (
 	"gopkg.in/src-d/go-billy.v4/memfs"
 	"gopkg.in/src-d/go-billy.v4/osfs"
 	"gopkg.in/src-d/go-git.v4"
+	"gopkg.in/src-d/go-git.v4/plumbing/cache"
 	"gopkg.in/src-d/go-git.v4/plumbing/object"
 	"gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
 	"gopkg.in/src-d/go-git.v4/storage"
@@ -69,10 +70,7 @@ func loadRepository(uri string, cachePath string, disableStatus bool, sshIdentit
 	var err error
 	if strings.Contains(uri, "://") || regexp.MustCompile("^[A-Za-z]\\w*@[A-Za-z0-9][\\w.]*:").MatchString(uri) {
 		if cachePath != "" {
-			backend, err = filesystem.NewStorage(osfs.New(cachePath))
-			if err != nil {
-				panic(err)
-			}
+			backend = filesystem.NewStorage(osfs.New(cachePath), cache.NewObjectLRUDefault())
 			_, err = os.Stat(cachePath)
 			if !os.IsNotExist(err) {
 				log.Printf("warning: deleted %s\n", cachePath)
@@ -107,10 +105,7 @@ func loadRepository(uri string, cachePath string, disableStatus bool, sshIdentit
 		if err2 != nil {
 			log.Panicf("unable to create a siva filesystem from %s: %v", uri, err2)
 		}
-		sivaStorage, err2 := filesystem.NewStorage(fs)
-		if err2 != nil {
-			log.Panicf("unable to create a new storage backend for siva file %s: %v", uri, err2)
-		}
+		sivaStorage := filesystem.NewStorage(fs, cache.NewObjectLRUDefault())
 		repository, err = git.Open(sivaStorage, tmpFs)
 	} else {
 		if uri[len(uri)-1] == os.PathSeparator {

+ 2 - 5
cmd/hercules/root_test.go

@@ -11,6 +11,7 @@ import (
 	"github.com/stretchr/testify/assert"
 	"gopkg.in/src-d/go-billy.v4/osfs"
 	"gopkg.in/src-d/go-git.v4"
+	"gopkg.in/src-d/go-git.v4/plumbing/cache"
 	"gopkg.in/src-d/go-git.v4/storage/filesystem"
 )
 
@@ -25,11 +26,7 @@ func TestLoadRepository(t *testing.T) {
 		assert.FailNow(t, "ioutil.TempDir")
 	}
 	defer os.RemoveAll(tempdir)
-	backend, err := filesystem.NewStorage(osfs.New(tempdir))
-	assert.Nil(t, err)
-	if err != nil {
-		assert.FailNow(t, "filesystem.NewStorage")
-	}
+	backend := filesystem.NewStorage(osfs.New(tempdir), cache.NewObjectLRUDefault())
 	cloneOptions := &git.CloneOptions{URL: "https://github.com/src-d/hercules"}
 	_, err = git.Clone(backend, nil, cloneOptions)
 	assert.Nil(t, err)

+ 4 - 0
internal/plumbing/identity/identity_test.go

@@ -328,6 +328,10 @@ func (strr fakeEncodedObjectStorer) IterEncodedObjects(plumbing.ObjectType) (sto
 	return nil, nil
 }
 
+func (strr fakeEncodedObjectStorer) EncodedObjectSize(plumbing.Hash) (int64, error) {
+	return 0, nil
+}
+
 func getFakeCommitWithFile(name string, contents string) *object.Commit {
 	c := object.Commit{
 		Hash: plumbing.NewHash("ffffffffffffffffffffffffffffffffffffffff"),