summaryrefslogtreecommitdiffstats
path: root/git/git.go
diff options
context:
space:
mode:
authorLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-12 21:58:47 +0530
committerLibravatar Anirudh Oppiliappan <x@icyphox.sh>2022-12-12 21:58:47 +0530
commit7a6ff3565e8e5f55d50c509c9ee12438b61c850e (patch)
tree58d609ef2fba68fb82bd0e8a47d6c98692361f6e /git/git.go
parent01f27147baf80e2222927ddca9369c7d99b4ff3c (diff)
downloadlegit-7a6ff3565e8e5f55d50c509c9ee12438b61c850e.tar.gz
legit-7a6ff3565e8e5f55d50c509c9ee12438b61c850e.tar.bz2
legit-7a6ff3565e8e5f55d50c509c9ee12438b61c850e.zip
routes: refs view
Diffstat (limited to 'git/git.go')
-rw-r--r--git/git.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/git/git.go b/git/git.go
index 34a25e5..a34d679 100644
--- a/git/git.go
+++ b/git/git.go
@@ -78,3 +78,35 @@ func (g *GitRepo) FileContent(path string) (string, error) {
return file.Contents()
}
+
+func (g *GitRepo) Tags() ([]*object.Tag, error) {
+ ti, err := g.r.TagObjects()
+ if err != nil {
+ return nil, fmt.Errorf("tag objects: %w", err)
+ }
+
+ tags := []*object.Tag{}
+
+ _ = ti.ForEach(func(t *object.Tag) error {
+ tags = append(tags, t)
+ return nil
+ })
+
+ return tags, nil
+}
+
+func (g *GitRepo) Branches() ([]*plumbing.Reference, error) {
+ bi, err := g.r.Branches()
+ if err != nil {
+ return nil, fmt.Errorf("branchs: %w", err)
+ }
+
+ branches := []*plumbing.Reference{}
+
+ _ = bi.ForEach(func(ref *plumbing.Reference) error {
+ branches = append(branches, ref)
+ return nil
+ })
+
+ return branches, nil
+}