diff options
author | Santiago M. Mola <santi@mola.io> | 2016-12-14 23:12:44 +0100 |
---|---|---|
committer | Máximo Cuadros <mcuadros@gmail.com> | 2016-12-14 23:12:44 +0100 |
commit | 0af572dd21c0aa79d13745b633ee24ba6c4d6cf1 (patch) | |
tree | 49e81e74e82d84fd88b2fc1e4b0dc7c7bfe9c40f /cshared/file_cshared.go | |
parent | df0f38af83f972f026d7e14150f3d37b95f13484 (diff) | |
download | go-git-0af572dd21c0aa79d13745b633ee24ba6c4d6cf1.tar.gz |
move plumbing from top level package to plumbing (#183)
* plumbing: rename Object -> EncodedObject.
* plumbing/storer: rename ObjectStorer -> EncodedObjectStorer.
* move difftree to plumbing/difftree.
* move diff -> utils/diff
* make Object/Tag/Blob/Tree/Commit/File depend on storer.
* Object and its implementations now depend only on
storer.EncodedObjectStorer, not git.Repository.
* Tests are decoupled accordingly.
* move Object/Commit/File/Tag/Tree to plumbing/object.
* move Object/Commit/File/Tag/Tree to plumbing/object.
* move checkClose to utils/ioutil.
* move RevListObjects to plumbing/revlist.Objects.
* move DiffTree to plumbing/difftree package.
* rename files with plural nouns to singular
* plumbing/object: add GetBlob/GetCommit/GetTag/GetTree.
Diffstat (limited to 'cshared/file_cshared.go')
-rw-r--r-- | cshared/file_cshared.go | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/cshared/file_cshared.go b/cshared/file_cshared.go index 8ef6427..d9c95b0 100644 --- a/cshared/file_cshared.go +++ b/cshared/file_cshared.go @@ -5,8 +5,9 @@ import ( "io" "io/ioutil" - "gopkg.in/src-d/go-git.v4" "gopkg.in/src-d/go-git.v4/plumbing" + "gopkg.in/src-d/go-git.v4/plumbing/object" + "gopkg.in/src-d/go-git.v4/plumbing/storer" ) //export c_File_get_Name @@ -15,7 +16,7 @@ func c_File_get_Name(f uint64) *C.char { if !ok { return nil } - file := obj.(*git.File) + file := obj.(*object.File) return C.CString(file.Name) } @@ -25,7 +26,7 @@ func c_File_get_Mode(f uint64) uint32 { if !ok { return 0 } - file := obj.(*git.File) + file := obj.(*object.File) return uint32(file.Mode) } @@ -35,7 +36,7 @@ func c_File_get_Hash(b uint64) *C.char { if !ok { return nil } - file := obj.(*git.File) + file := obj.(*object.File) return CBytes(file.Hash[:]) } @@ -45,7 +46,7 @@ func c_File_Size(b uint64) int64 { if !ok { return -1 } - file := obj.(*git.File) + file := obj.(*object.File) return file.Size } @@ -55,8 +56,8 @@ func c_File_Decode(o uint64) uint64 { if !ok { return IH } - cobj := obj.(*plumbing.Object) - file := git.File{} + cobj := obj.(*plumbing.EncodedObject) + file := object.File{} file.Decode(*cobj) return uint64(RegisterObject(&file)) } @@ -67,7 +68,7 @@ func c_File_Read(b uint64) (int, *C.char) { if !ok { return ErrorCodeNotFound, C.CString(MessageNotFound) } - file := obj.(*git.File) + file := obj.(*object.File) reader, err := file.Reader() if err != nil { return ErrorCodeInternal, C.CString(err.Error()) @@ -86,7 +87,7 @@ func c_File_Type(c uint64) int8 { if !ok { return -1 } - file := obj.(*git.File) + file := obj.(*object.File) return int8(file.Type()) } @@ -96,13 +97,13 @@ func c_NewFileIter(r uint64, t uint64) uint64 { if !ok { return IH } - repo := obj.(*git.Repository) + storer := obj.(storer.EncodedObjectStorer) obj, ok = GetObject(Handle(t)) if !ok { return IH } - tree := obj.(*git.Tree) - iter := git.NewFileIter(repo, tree) + tree := obj.(*object.Tree) + iter := object.NewFileIter(storer, tree) return uint64(RegisterObject(iter)) } @@ -112,7 +113,7 @@ func c_FileIter_Next(i uint64) (uint64, int, *C.char) { if !ok { return IH, ErrorCodeNotFound, C.CString(MessageNotFound) } - iter := obj.(*git.FileIter) + iter := obj.(*object.FileIter) file, err := iter.Next() if err != nil { if err == io.EOF { @@ -129,6 +130,6 @@ func c_FileIter_Close(i uint64) { if !ok { return } - iter := obj.(*git.FileIter) + iter := obj.(*object.FileIter) iter.Close() } |