Documentation ¶
Index ¶
- Variables
- type BranchInfo
- type CommitStatus
- type FakeRepoClient
- func (frc *FakeRepoClient) GetBranch(ctx context.Context, repo string, branch string) (BranchInfo, error)
- func (frc *FakeRepoClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
- func (frc *FakeRepoClient) GetCommitMessage(ctx context.Context, repo string, sha string) (string, error)
- func (frc *FakeRepoClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
- func (frc *FakeRepoClient) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
- func (frc *FakeRepoClient) GetPRStatus(ctx context.Context, repo string, pr uint) (string, error)
- func (frc *FakeRepoClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
- func (frc *FakeRepoClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
- type FileContents
- type GitHubClient
- func (ghc *GitHubClient) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
- func (ghc *GitHubClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
- func (ghc *GitHubClient) GetCommitMessage(ctx context.Context, repo string, sha string) (string, error)
- func (ghc *GitHubClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
- func (ghc *GitHubClient) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
- func (ghc *GitHubClient) GetPRStatus(ctx context.Context, repo string, pr uint) (string, error)
- func (ghc *GitHubClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
- func (ghc *GitHubClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
- type LocalRepoInfo
- type LocalWrapper
- func (lw *LocalWrapper) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
- func (lw *LocalWrapper) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
- func (lw *LocalWrapper) GetCommitMessage(ctx context.Context, repo, sha string) (string, error)
- func (lw *LocalWrapper) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
- func (lw *LocalWrapper) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
- func (lw *LocalWrapper) GetPRStatus(context.Context, string, uint) (string, error)
- func (lw *LocalWrapper) GetTags(context.Context, string) ([]BranchInfo, error)
- func (lw *LocalWrapper) SetStatus(context.Context, string, string, *CommitStatus) error
- type RepoClient
- type RepoFinder
Constants ¶
This section is empty.
Variables ¶
var ErrBranchNotFound = errors.New("branch not found")
var ErrRefNotFound = errors.New("reference not found")
var MaxFileDownloadSizeBytes = 500 * 1000000
MaxFileDownloadSizeBytes contains the size limit for file content downloads. Attempting to GetFileContents for a file larger than this will return an error.
Functions ¶
This section is empty.
Types ¶
type BranchInfo ¶
BranchInfo includes the information about a specific branch of a git repo
type CommitStatus ¶
CommitStatus describes a status associated with a git commit
type FakeRepoClient ¶
type FakeRepoClient struct { GetBranchFunc func(context.Context, string, string) (BranchInfo, error) GetBranchesFunc func(context.Context, string) ([]BranchInfo, error) GetTagsFunc func(context.Context, string) ([]BranchInfo, error) SetStatusFunc func(context.Context, string, string, *CommitStatus) error GetPRStatusFunc func(context.Context, string, uint) (string, error) GetCommitMessageFunc func(context.Context, string, string) (string, error) GetFileContentsFunc func(ctx context.Context, repo string, path string, ref string) ([]byte, error) GetDirectoryContentsFunc func(ctx context.Context, repo, path, ref string) (map[string]FileContents, error) }
FakeRepoClient is fake implementaiton of RepoClient that runs user-supplied functions for each method
func (*FakeRepoClient) GetBranch ¶
func (frc *FakeRepoClient) GetBranch(ctx context.Context, repo string, branch string) (BranchInfo, error)
func (*FakeRepoClient) GetBranches ¶
func (frc *FakeRepoClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
func (*FakeRepoClient) GetCommitMessage ¶
func (*FakeRepoClient) GetDirectoryContents ¶
func (frc *FakeRepoClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
func (*FakeRepoClient) GetFileContents ¶
func (*FakeRepoClient) GetPRStatus ¶
func (*FakeRepoClient) GetTags ¶
func (frc *FakeRepoClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
func (*FakeRepoClient) SetStatus ¶
func (frc *FakeRepoClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
type FileContents ¶
FileContents models a file from a repository
type GitHubClient ¶
type GitHubClient struct {
// contains filtered or unexported fields
}
GitHubClient is an object that interacts with the GitHub API
func NewGitHubClient ¶
func NewGitHubClient(token string) *GitHubClient
NewGitHubClient returns a GitHubClient instance that authenticates using the personal access token provided
func (*GitHubClient) GetBranch ¶
func (ghc *GitHubClient) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
GetBranch gets the information for a specific branch
func (*GitHubClient) GetBranches ¶
func (ghc *GitHubClient) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
GetBranches returns the extant branches for repo (assumed to be "owner/repo-name")
func (*GitHubClient) GetCommitMessage ¶
func (ghc *GitHubClient) GetCommitMessage(ctx context.Context, repo string, sha string) (string, error)
GetCommitMessage returns the git message associated with a particular commit
func (*GitHubClient) GetDirectoryContents ¶
func (ghc *GitHubClient) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
GetDirectoryContents fetches path from repo at ref, returning a map of file path to file contents. If path is not a directory, an error is returned. The contents may include symlinks that point to arbitrary locations (ie, outside of the directory root).
func (*GitHubClient) GetFileContents ¶
func (ghc *GitHubClient) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error)
GetFileContents returns the file contents of path (which must be a regular file or a symlink to a regular file) in the specified repo at ref
func (*GitHubClient) GetPRStatus ¶
GetPRStatus returns the status of a PR on a repo
func (*GitHubClient) GetTags ¶
func (ghc *GitHubClient) GetTags(ctx context.Context, repo string) ([]BranchInfo, error)
GetTags returns the extant tags for repo (assumed to be "owner/repo-name")
func (*GitHubClient) SetStatus ¶
func (ghc *GitHubClient) SetStatus(ctx context.Context, repo string, sha string, status *CommitStatus) error
SetStatus creates or updates a status on repo at commit sha
type LocalRepoInfo ¶
type LocalRepoInfo struct {
GitHubRepoName, HeadBranch, HeadSHA string
}
LocalRepoInfo models information about a local git repo
type LocalWrapper ¶
type LocalWrapper struct { Backend RepoClient // FSFunc is a function that returns a filesystem given a path FSFunc func(path string) billy.Filesystem // RepoPathMap is a map of GitHub repo names (ex: "owner/repo") to absolute local filesystem path (which must be a valid git repository) RepoPathMap map[string]string // WorkingTreeRepos are the repos to read contents directly from disk (not via commit SHA) WorkingTreeRepos []string // contains filtered or unexported fields }
LocalWrapper is on object that satisfies RepoClient and which can optionally use local git repositories for repo names according to RepoPathMap, falling back to Backend if not found
func (*LocalWrapper) GetBranch ¶
func (lw *LocalWrapper) GetBranch(ctx context.Context, repo, branch string) (BranchInfo, error)
func (*LocalWrapper) GetBranches ¶
func (lw *LocalWrapper) GetBranches(ctx context.Context, repo string) ([]BranchInfo, error)
func (*LocalWrapper) GetCommitMessage ¶
func (*LocalWrapper) GetDirectoryContents ¶
func (lw *LocalWrapper) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error)
func (*LocalWrapper) GetFileContents ¶
func (*LocalWrapper) GetPRStatus ¶
func (*LocalWrapper) GetTags ¶
func (lw *LocalWrapper) GetTags(context.Context, string) ([]BranchInfo, error)
stubs to satisfy the interface
func (*LocalWrapper) SetStatus ¶
func (lw *LocalWrapper) SetStatus(context.Context, string, string, *CommitStatus) error
type RepoClient ¶
type RepoClient interface { GetBranch(context.Context, string, string) (BranchInfo, error) GetBranches(context.Context, string) ([]BranchInfo, error) GetTags(context.Context, string) ([]BranchInfo, error) SetStatus(context.Context, string, string, *CommitStatus) error GetPRStatus(context.Context, string, uint) (string, error) GetCommitMessage(context.Context, string, string) (string, error) GetFileContents(ctx context.Context, repo string, path string, ref string) ([]byte, error) GetDirectoryContents(ctx context.Context, repo, path, ref string) (map[string]FileContents, error) }
RepoClient describes an object capable of operating on git repositories
type RepoFinder ¶
type RepoFinder struct { // GitHubHostname is the GitHub hostname to use when finding GitHub repos // (some people use fake GitHub hostnames to toggle SSH keys ("me.github.com") via ~/.ssh/config) GitHubHostname string FSFunc func(path string) afero.Fs LF func(string, ...interface{}) }
RepoFinder is an object that searches the local filesystem for git repositories configured for use with GitHub
func (*RepoFinder) Find ¶
func (rf *RepoFinder) Find(searchPaths []string) (map[string]string, error)
Find recursively searches searchPaths and finds any valid git repositories with remotes configured for GitHub. It returns a map of GitHub repo name ("owner/repo") to absolute local filesystem path, or error.