mirror of
https://github.com/csmith/gitrefs
synced 2026-01-21 01:46:19 +01:00
No description
| .github | ||
| .gitignore | ||
| CHANGELOG.md | ||
| go.mod | ||
| go.sum | ||
| LICENCE | ||
| README.md | ||
| refs.go | ||
| tags.go | ||
| tags_test.go | ||
gitrefs
Provides a simple way to list references from a remote git repository over HTTP, without needing a full git client or a checkout of the remote repository.
Example:
package main
import (
"fmt"
"github.com/csmith/gitrefs"
)
func main() {
refs, err := gitrefs.Fetch("https://github.com/csmith/gitrefs")
if err != nil {
panic(err)
}
for r := range refs {
fmt.Printf("Ref %s at commit %s\n", r, refs[r])
}
}
A utility method to retrieve only the latest semver tag is included:
package main
import (
"fmt"
"github.com/csmith/gitrefs"
)
func main() {
tag, hash, err := gitrefs.LatestTag("https://github.com/csmith/gitrefs")
if err != nil {
panic(err)
}
fmt.Printf("Latest tag is %s at commit %s\n", tag, hash)
}
Protocol docs: