aboutsummaryrefslogtreecommitdiffstats
path: root/storage/filesystem/internal/dotgit/dotgit.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-11-03 17:10:43 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-03 17:10:43 +0100
commit3f7fbc6c49e50eb22e3de8a5143817fa7c0c54dd (patch)
tree0bf81a6dd858278000d1d7f7afc578d993fba791 /storage/filesystem/internal/dotgit/dotgit.go
parent94f5e9c949963893d1c3d3e987a591ee15265327 (diff)
downloadgo-git-3f7fbc6c49e50eb22e3de8a5143817fa7c0c54dd.tar.gz
storage/filesystem: implement missing functionality. (#110)
* storage/filesystem: added ObjectStorage Set. * storage/filesystem: now passes all tests, except those specific to transactions. * formats/config: Encoder now encodes subsections with no options. * formats/config: add HasSubsection on Section. * dotgit: add Ref method to get specific reference.
Diffstat (limited to 'storage/filesystem/internal/dotgit/dotgit.go')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index ba293af..6606153 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -215,6 +215,27 @@ func (d *DotGit) Refs() ([]*core.Reference, error) {
return refs, nil
}
+// Ref returns the reference for a given reference name.
+func (d *DotGit) Ref(name core.ReferenceName) (*core.Reference, error) {
+ ref, err := d.readReferenceFile(".", name.String())
+ if err == nil {
+ return ref, nil
+ }
+
+ refs, err := d.Refs()
+ if err != nil {
+ return nil, err
+ }
+
+ for _, ref := range refs {
+ if ref.Name() == name {
+ return ref, nil
+ }
+ }
+
+ return nil, core.ErrReferenceNotFound
+}
+
func (d *DotGit) addRefsFromPackedRefs(refs *[]*core.Reference) (err error) {
f, err := d.fs.Open(packedRefsPath)
if err != nil {