fork of go-git with some jj specific features
1package main
2
3import (
4 "fmt"
5 "os"
6
7 "gopkg.in/src-d/go-git.v4"
8 . "gopkg.in/src-d/go-git.v4/_examples"
9 "gopkg.in/src-d/go-git.v4/plumbing"
10 "gopkg.in/src-d/go-git.v4/plumbing/object"
11)
12
13// Basic example of how to list tags.
14func main() {
15 CheckArgs("<path>")
16 path := os.Args[1]
17
18 // We instanciate a new repository targeting the given path (the .git folder)
19 r, err := git.PlainOpen(path)
20 CheckIfError(err)
21
22 // List all tag references, both lightweight tags and annotated tags
23 Info("git show-ref --tag")
24
25 tagrefs, err := r.Tags()
26 CheckIfError(err)
27 err = tagrefs.ForEach(func(t *plumbing.Reference) error {
28 fmt.Println(t)
29 return nil
30 })
31 CheckIfError(err)
32
33 // Print each annotated tag object (lightweight tags are not included)
34 Info("for t in $(git show-ref --tag); do if [ \"$(git cat-file -t $t)\" = \"tag\" ]; then git cat-file -p $t ; fi; done")
35
36 tags, err := r.TagObjects()
37 CheckIfError(err)
38 err = tags.ForEach(func(t *object.Tag) error {
39 fmt.Println(t)
40 return nil
41 })
42 CheckIfError(err)
43}