aboutsummaryrefslogtreecommitdiffstats
path: root/repository.go
diff options
context:
space:
mode:
authorAlberto Cortés <alberto@sourced.tech>2016-08-02 10:49:06 +0200
committerAlberto Cortés <alberto@sourced.tech>2016-08-02 10:49:06 +0200
commit7dffd7c467af7c7c79398e7997837b6e8c37e14f (patch)
tree535b7310da790ef1070bc60fd2ec617d1e423b74 /repository.go
parentb5613047f0d1fc6f53d5a8ad1a05415ca9c6a92a (diff)
downloadgo-git-7dffd7c467af7c7c79398e7997837b6e8c37e14f.tar.gz
add head support for local repos
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/repository.go b/repository.go
index 0cda947..866f9ff 100644
--- a/repository.go
+++ b/repository.go
@@ -226,6 +226,10 @@ func (r *Repository) Head(remote string) (core.Hash, error) {
return r.localHead()
}
+ return r.remoteHead(remote)
+}
+
+func (r *Repository) remoteHead(remote string) (core.Hash, error) {
rem, ok := r.Remotes[remote]
if !ok {
return core.ZeroHash, fmt.Errorf("unable to find remote %q", remote)
@@ -235,5 +239,11 @@ func (r *Repository) Head(remote string) (core.Hash, error) {
}
func (r *Repository) localHead() (core.Hash, error) {
- return core.ZeroHash, nil
+ storage, ok := r.Storage.(*seekable.ObjectStorage)
+ if !ok {
+ return core.ZeroHash,
+ fmt.Errorf("cannot retrieve local head: no local data found")
+ }
+
+ return storage.Head()
}