Migration
This is my new public git source viewer. Source coming soon. Please contact with concerns/bugs.
Contact me
internal/modules/refs.go
8d1bb5bfdd2cba82488775b46308efed740132a8
· 515 B · 30 lines
raw
| 1 | package modules |
| 2 | |
| 3 | import ( |
| 4 | "gsg/internal/core" |
| 5 | "gsg/internal/gitx" |
| 6 | ) |
| 7 | |
| 8 | type Refs struct { |
| 9 | Branches []gitx.Ref |
| 10 | Tags []gitx.Ref |
| 11 | } |
| 12 | |
| 13 | func init() { core.Register("refs", refsMod) } |
| 14 | |
| 15 | // refs: branches and tags, split. |
| 16 | func refsMod(c *core.Ctx, args ...string) (any, error) { |
| 17 | all, err := c.Repo.Refs() |
| 18 | if err != nil { |
| 19 | return nil, err |
| 20 | } |
| 21 | var out Refs |
| 22 | for _, r := range all { |
| 23 | if r.Kind == "tag" { |
| 24 | out.Tags = append(out.Tags, r) |
| 25 | } else { |
| 26 | out.Branches = append(out.Branches, r) |
| 27 | } |
| 28 | } |
| 29 | return out, nil |
| 30 | } |