No description
Find a file
2025-12-22 15:51:10 +00:00
.github Dependencies: switch to weekly with cooldown 2025-11-26 11:58:51 +00:00
.gitignore Initial version 2021-09-24 22:19:35 +01:00
CHANGELOG.md Add WithAuth option 2025-11-20 13:42:08 +00:00
go.mod Bump github.com/hashicorp/go-version from 1.7.0 to 1.8.0 2025-12-22 14:01:50 +00:00
go.sum Bump github.com/hashicorp/go-version from 1.7.0 to 1.8.0 2025-12-22 14:01:50 +00:00
LICENCE Initial version 2021-09-24 22:19:35 +01:00
README.md Initial version 2021-09-24 22:19:35 +01:00
refs.go Add WithAuth option 2025-11-20 13:42:08 +00:00
tags.go Add support for ignoring prefixes in tags 2023-08-20 12:04:55 +01:00
tags_test.go Filter out dereferenced/annotated tags 2025-11-06 21:14:56 +00:00

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: