Documentation ¶
Overview ¶
source is a package that can retrieve and analyze details around source code. Many of the items found here are wrappers on git.
Index ¶
Constants ¶
const ( CacheDirName = "proctor" CacheRepoDirName = "repos" )
Variables ¶
This section is empty.
Functions ¶
func NewMapOfTags ¶
NewMapOfTags returns a map representation of a list of tags where the key is set to the tag name.
Types ¶
type CommitReader ¶
type GetCommitsOpts ¶
type GetCommitsOpts struct { }
GetCommitsOpts enables putting constraints on the commit data you'd like to retrieve.
type GitManager ¶
type GitManager struct {
GitManagerConfig
}
GitManager operates on git repositories in order to facilitate the metadata around source repositories. Examples of lookups include commits, tags, and artifacts. This may also extend to the platform hosting git repostiories such as GitHub. This is where the asset artifacts may be retrieved from.
func NewGitManager ¶
func NewGitManager(config ...GitManagerConfig) GitManager
NewGitManager returns and instance of a GitManager based on the specified config. The config argument is optional. If a config is not passed or required values are left out, defaults will be set.
The variadic nature of config is only to facilitate optional config arguments. Do not pass more than one instance of config into this function. If more than one is passed, the last config in the argument's slice will be used.
func (*GitManager) GetCommits ¶
func (gm *GitManager) GetCommits(r Repository, opts ...GetCommitsOpts) ([]Commit, error)
GetCommits takes a Repository, which should be generated using [NewInMemRepo], and provides a slice of commits related to the repository. If you'd like to retrieve a subset of commits, an optional opts argument can be provided.
If there is an issue retrieving the commits from the repository, an error is returned.
func (*GitManager) GetCommitsForTag ¶
func (gm *GitManager) GetCommitsForTag(tagName string, r Repository, opts ...GetCommitsOpts) ([]Commit, error)
GetCommitsForTag takes a tagName and its associated repository and returns a slice of every commit associated with it. It looks up the commits **exclusively** by looking up the Tag.LastCommit field. The commits are found by doing the equivelant of a git log against the latest (newest) commit associated with the tag. Commits within the slice are arranged in order by date. When commits are unable to be retrieved from the repository, an error is returned.
func (*GitManager) GetTagsFromRepository ¶
func (gm *GitManager) GetTagsFromRepository(r Repository) ([]Tag, error)
GetTagsFromRepository accepts a repository returns all tags that are associated in it.
type GitManagerConfig ¶
type GitManagerConfig struct { // Represents a [presonal access token] provided by GitHub. // // [personal access token]: https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/creating-a-personal-access-token AccessToken string }
GitManagerConfig provides the configuation settings used to create a GitManager. The struct should be created and used when calling the NewGitManager function.
type Repository ¶
type Repository struct { URL string RepoRef *git.Repository }
func ResolveRepo ¶
func ResolveRepo(url string, opts ...ResolveRepoOpts) (*Repository, error)
ResolveRepo accepts a repository's URL and opts for how the repo should be retrieved. By default, it looks up the [getDefaultCacheLocation] to determine if the repository was previously cached on the filesystem. If it is, it will do a git fetch to grab any new changes and return a reference to the repository. If the repo does not exist on the filesystem (cache), it will perform a clone that persists it to [getDefaultCacheLocation]. The directory name within the cache will be a base64 encoded representation of the url.
If you wish to get a repository reference for a repo held entirely in memeory, you can set InMemory to true within the ResolveRepoOpts argument. Note that doing an in-memory clone can consume substatial system resouces (heap space) when the repository is large.
type ResolveRepoOpts ¶
type ResolveRepoOpts struct { // instructs doing all retrieval in memory. Note that for medium to large // size repos, this can cause significant memory consumption. InMemory bool }
ResolveRepoOpts provides instructions for how a repository should be retrieved.