github

package
v0.6.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGithubURL

func ParseGithubURL(u string) (string, string, error)

ParseGithubURL will parse a github URL and return the owner and repo name.

Types

type GithubRepoClient

type GithubRepoClient struct {
	// contains filtered or unexported fields
}

func NewGithubRepoClient

func NewGithubRepoClient(client *github.Client, owner, repo string) *GithubRepoClient

func (*GithubRepoClient) GetTags

func (grc *GithubRepoClient) GetTags(ctx context.Context, tags []string) (map[string]*TagData, error)

GetTags will fetch the specified tags from the repo. Since API calls are rate limited, you should grab all the tags up front, and then pass them in here. Returns a map going from tag->TagData, where tag is typically the version, but again there are variances to this. Some versions for example are called v1.21, but the corresponding tag would be release_v1.21. You can explicitly pass a value for "highest" and it will then go through all the tags, and try to find the highest one based on the latest commit by timestamp. This is useful for example packages that don't have a releases, but just tags for example (github.com/eliben/pycparser)

func (*GithubRepoClient) GetVersions

func (grc *GithubRepoClient) GetVersions(ctx context.Context, version string) ([]TagData, error)

GetVersions will try to find a version of the specified package. In addition to the specified version, it will try to find a latest version, and if it is different from the specified version, it will return it as well. There are quite a few different cases / heuristics here to cover. Some projects have a latest release, some don't. Some have releases, and some don't, and they just have tags, and so forth. I reckon there will be more heuristics coming as we learn.

func (*GithubRepoClient) Repo

func (grc *GithubRepoClient) Repo() string

type TagData

type TagData struct {
	// Version of the tag. This is typically the same as the tag, but there are
	// differences. Sometimes the Version is 2.21 but tag is v2.21, or
	// release_v2.21, etc.
	// In our example, this would be 2.21
	Version string
	// Repo URL, for example https://github.com/eliben/pycparser
	Repo string
	// GitHub tag name. Full tag that GH knows, for example using above, this
	// would be the one that would be release_v2.21.
	Tag string
	// Commit SHA for this tag, for above: 3cf6bf5eb16f5eadd4a058e41596145c407a79ad
	SHA string
	// Some tags have a prefix. For our example, this would be release_v
	TagPrefix string
	// Is this the latest release from Github
	IsLatest bool
	// Is this the "newest" tag from GitHub. This is based on timestamp only
	// if there is not Latest release found.
	IsNewest bool
}

To show what all these different fields mean, we'll use the example of pycparser, which in pypi lists things as version 2.21, but the tag is listed as release_v2.21

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL