aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorMáximo Cuadros <mcuadros@gmail.com>2016-11-08 23:46:38 +0100
committerGitHub <noreply@github.com>2016-11-08 23:46:38 +0100
commitac095bb12c4d29722b60ba9f20590fa7cfa6bc7d (patch)
tree223f36f336ba3414b1e45cac8af6c4744a5d7ef6 /repository.go
parente523701393598f4fa241dd407af9ff8925507a1a (diff)
downloadgo-git-ac095bb12c4d29722b60ba9f20590fa7cfa6bc7d.tar.gz
new plumbing package (#118)
* plumbing: now core was renamed to core, and formats and clients moved inside
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go63
1 files changed, 32 insertions, 31 deletions
diff --git a/repository.go b/repository.go
index 899127b..ec3a1f9 100644
--- a/repository.go
+++ b/repository.go
@@ -5,7 +5,8 @@ import (
"fmt"
"gopkg.in/src-d/go-git.v4/config"
- "gopkg.in/src-d/go-git.v4/core"
+ "gopkg.in/src-d/go-git.v4/plumbing"
+ "gopkg.in/src-d/go-git.v4/plumbing/storer"
"gopkg.in/src-d/go-git.v4/storage/filesystem"
"gopkg.in/src-d/go-git.v4/storage/memory"
osfs "gopkg.in/src-d/go-git.v4/utils/fs/os"
@@ -176,7 +177,7 @@ func (r *Repository) updateRemoteConfig(
return nil
}
- head, err := core.ResolveReference(remote.Info().Refs, o.ReferenceName)
+ head, err := storer.ResolveReference(remote.Info().Refs, o.ReferenceName)
if err != nil {
return err
}
@@ -195,10 +196,10 @@ func (r *Repository) updateRemoteConfig(
}
-func (r *Repository) createReferences(ref *core.Reference) error {
+func (r *Repository) createReferences(ref *plumbing.Reference) error {
if !ref.IsBranch() {
// detached HEAD mode
- head := core.NewHashReference(core.HEAD, ref.Hash())
+ head := plumbing.NewHashReference(plumbing.HEAD, ref.Hash())
return r.s.SetReference(head)
}
@@ -206,7 +207,7 @@ func (r *Repository) createReferences(ref *core.Reference) error {
return err
}
- head := core.NewSymbolicReference(core.HEAD, ref.Name())
+ head := plumbing.NewSymbolicReference(plumbing.HEAD, ref.Name())
return r.s.SetReference(head)
}
@@ -218,7 +219,7 @@ func (r *Repository) IsEmpty() (bool, error) {
}
var count int
- return count == 0, iter.ForEach(func(r *core.Reference) error {
+ return count == 0, iter.ForEach(func(r *plumbing.Reference) error {
count++
return nil
})
@@ -264,8 +265,8 @@ func (r *Repository) Pull(o *PullOptions) error {
}
// Commit return the commit with the given hash
-func (r *Repository) Commit(h core.Hash) (*Commit, error) {
- commit, err := r.Object(core.CommitObject, h)
+func (r *Repository) Commit(h plumbing.Hash) (*Commit, error) {
+ commit, err := r.Object(plumbing.CommitObject, h)
if err != nil {
return nil, err
}
@@ -275,7 +276,7 @@ func (r *Repository) Commit(h core.Hash) (*Commit, error) {
// Commits decode the objects into commits
func (r *Repository) Commits() (*CommitIter, error) {
- iter, err := r.s.IterObjects(core.CommitObject)
+ iter, err := r.s.IterObjects(plumbing.CommitObject)
if err != nil {
return nil, err
}
@@ -284,8 +285,8 @@ func (r *Repository) Commits() (*CommitIter, error) {
}
// Tree return the tree with the given hash
-func (r *Repository) Tree(h core.Hash) (*Tree, error) {
- tree, err := r.Object(core.TreeObject, h)
+func (r *Repository) Tree(h plumbing.Hash) (*Tree, error) {
+ tree, err := r.Object(plumbing.TreeObject, h)
if err != nil {
return nil, err
}
@@ -295,7 +296,7 @@ func (r *Repository) Tree(h core.Hash) (*Tree, error) {
// Trees decodes the objects into trees
func (r *Repository) Trees() (*TreeIter, error) {
- iter, err := r.s.IterObjects(core.TreeObject)
+ iter, err := r.s.IterObjects(plumbing.TreeObject)
if err != nil {
return nil, err
}
@@ -304,8 +305,8 @@ func (r *Repository) Trees() (*TreeIter, error) {
}
// Blob returns the blob with the given hash
-func (r *Repository) Blob(h core.Hash) (*Blob, error) {
- blob, err := r.Object(core.BlobObject, h)
+func (r *Repository) Blob(h plumbing.Hash) (*Blob, error) {
+ blob, err := r.Object(plumbing.BlobObject, h)
if err != nil {
return nil, err
}
@@ -315,7 +316,7 @@ func (r *Repository) Blob(h core.Hash) (*Blob, error) {
// Blobs decodes the objects into blobs
func (r *Repository) Blobs() (*BlobIter, error) {
- iter, err := r.s.IterObjects(core.BlobObject)
+ iter, err := r.s.IterObjects(plumbing.BlobObject)
if err != nil {
return nil, err
}
@@ -324,8 +325,8 @@ func (r *Repository) Blobs() (*BlobIter, error) {
}
// Tag returns a tag with the given hash.
-func (r *Repository) Tag(h core.Hash) (*Tag, error) {
- tag, err := r.Object(core.TagObject, h)
+func (r *Repository) Tag(h plumbing.Hash) (*Tag, error) {
+ tag, err := r.Object(plumbing.TagObject, h)
if err != nil {
return nil, err
}
@@ -336,7 +337,7 @@ func (r *Repository) Tag(h core.Hash) (*Tag, error) {
// Tags returns a TagIter that can step through all of the annotated tags
// in the repository.
func (r *Repository) Tags() (*TagIter, error) {
- iter, err := r.s.IterObjects(core.TagObject)
+ iter, err := r.s.IterObjects(plumbing.TagObject)
if err != nil {
return nil, err
}
@@ -345,37 +346,37 @@ func (r *Repository) Tags() (*TagIter, error) {
}
// Object returns an object with the given hash.
-func (r *Repository) Object(t core.ObjectType, h core.Hash) (Object, error) {
+func (r *Repository) Object(t plumbing.ObjectType, h plumbing.Hash) (Object, error) {
obj, err := r.s.Object(t, h)
if err != nil {
- if err == core.ErrObjectNotFound {
+ if err == plumbing.ErrObjectNotFound {
return nil, ErrObjectNotFound
}
return nil, err
}
switch obj.Type() {
- case core.CommitObject:
+ case plumbing.CommitObject:
commit := &Commit{r: r}
return commit, commit.Decode(obj)
- case core.TreeObject:
+ case plumbing.TreeObject:
tree := &Tree{r: r}
return tree, tree.Decode(obj)
- case core.BlobObject:
+ case plumbing.BlobObject:
blob := &Blob{}
return blob, blob.Decode(obj)
- case core.TagObject:
+ case plumbing.TagObject:
tag := &Tag{r: r}
return tag, tag.Decode(obj)
default:
- return nil, core.ErrInvalidType
+ return nil, plumbing.ErrInvalidType
}
}
// Objects returns an ObjectIter that can step through all of the annotated tags
// in the repository.
func (r *Repository) Objects() (*ObjectIter, error) {
- iter, err := r.s.IterObjects(core.AnyObject)
+ iter, err := r.s.IterObjects(plumbing.AnyObject)
if err != nil {
return nil, err
}
@@ -384,20 +385,20 @@ func (r *Repository) Objects() (*ObjectIter, error) {
}
// Head returns the reference where HEAD is pointing
-func (r *Repository) Head() (*core.Reference, error) {
- return core.ResolveReference(r.s, core.HEAD)
+func (r *Repository) Head() (*plumbing.Reference, error) {
+ return storer.ResolveReference(r.s, plumbing.HEAD)
}
// Ref returns the Hash pointing the given refName
-func (r *Repository) Ref(name core.ReferenceName, resolved bool) (*core.Reference, error) {
+func (r *Repository) Ref(name plumbing.ReferenceName, resolved bool) (*plumbing.Reference, error) {
if resolved {
- return core.ResolveReference(r.s, name)
+ return storer.ResolveReference(r.s, name)
}
return r.s.Reference(name)
}
// Refs returns a map with all the References
-func (r *Repository) Refs() (core.ReferenceIter, error) {
+func (r *Repository) Refs() (storer.ReferenceIter, error) {
return r.s.IterReferences()
}