diff options
author | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-12 21:58:47 +0530 |
---|---|---|
committer | Anirudh Oppiliappan <x@icyphox.sh> | 2022-12-12 21:58:47 +0530 |
commit | 7a6ff3565e8e5f55d50c509c9ee12438b61c850e (patch) | |
tree | 58d609ef2fba68fb82bd0e8a47d6c98692361f6e /git/git.go | |
parent | 01f27147baf80e2222927ddca9369c7d99b4ff3c (diff) | |
download | legit-7a6ff3565e8e5f55d50c509c9ee12438b61c850e.tar.gz legit-7a6ff3565e8e5f55d50c509c9ee12438b61c850e.tar.bz2 legit-7a6ff3565e8e5f55d50c509c9ee12438b61c850e.zip |
routes: refs view
Diffstat (limited to '')
-rw-r--r-- | git/git.go | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -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 +} |