Skip to content

Latest commit

 

History

History
52 lines (38 loc) · 869 Bytes

README.md

File metadata and controls

52 lines (38 loc) · 869 Bytes

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: