Skip to content

forge

A Go library and CLI for working with git forges. Routes requests to the right backend based on the URL domain, with a common data model across GitHub, GitLab, Gitea/Forgejo, and Bitbucket Cloud.

import (
    "context"
    "github.com/git-pkgs/forge"
)

client := forges.NewClient(
    forges.WithToken("github.com", os.Getenv("GITHUB_TOKEN")),
)

repo, err := client.FetchRepository(ctx, "https://github.com/lodash/lodash")
if err != nil {
    panic(err)
}
fmt.Printf("%s: %s (%s)\n", repo.FullName, repo.Description, repo.License)

tags, _ := client.FetchTags(ctx, "https://github.com/lodash/lodash")
for _, t := range tags {
    fmt.Printf("%s (%s)\n", t.Name, t.Commit[:8])
}

repos, _ := client.ListRepositories(ctx, "github.com", "lodash", forges.ListRepoOpts{
    Archived: forges.ArchivedExclude,
    Forks:    forges.ForkExclude,
})