Documentation ¶
Overview ¶
Package git implements functionality to work with git and GitHub.
To leverage it, create a RepoManager and call Init() on it with the appropriate arguments. Then, you can manage git repositories as a collection of items coming from GitHub.
The filesystem is organized like so:
- rootpath
- parentOrg1
- repo1
- repo1
- parentOrg2
- repo1
No original clones of the forks are kept. These are stored as remotes in each parent repository. This allows us to keep the filesystem footprint simple as well as keeping a cache for each fork in a reliable way.
Clones are done over HTTPS with a login script that is used in conjunction with the token provided from the queuesvc to auth against github. SSH cloning has a lot of intermediate caching challenges that we were trying to avoid for future works; this is aside from how hard it can be to orchestrate automated SSH without leaking secrets.
Index ¶
- type Config
- type RepoManager
- func (rm *RepoManager) AddOrFetchFork() *errors.Error
- func (rm *RepoManager) Checkout(ref string) *errors.Error
- func (rm *RepoManager) CloneOrFetch(ctx context.Context, defaultBranch string) *errors.Error
- func (rm *RepoManager) Init(config Config, log *log.SubLogger, repoName, forkRepoName string) *errors.Error
- func (rm *RepoManager) Merge(ref string) (retErr *errors.Error)
- func (rm *RepoManager) Rebase(ref string) (retErr *errors.Error)
- func (rm *RepoManager) Run(command ...string) *errors.Error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { LoginScriptPath string `yaml:"login_script_path"` BaseRepoPath string `yaml:"base_repo_path"` }
Config manages various one-off tidbits about the runner's git paths and other data. You must manually merge this with your runner's configuration if you wish to use the runner framework, see fw/config documentation for more information.
type RepoManager ¶
type RepoManager struct { // Config addresses the configuration of certain git-centric items such as // the root repo path Config Config // Logger is the logsvc client Logger *log.SubLogger // Log is an IO stream that will be sent output from git. Log io.Writer // AccessToken is the github access token used to auth over https. AccessToken string // Env is the set of environ(7)-style environment variable listings. They // will be appended to each git call. Env []string // // The following fields are populated at init time and should be left blank // or they will be overwritten. // // RepoPath is the path to the repository, computed from name and base path. RepoPath string // RepoName is the parent repo in owner/repo format. RepoName string // ForkRepoName is the name of the fork repo in owner/repo format ForkRepoName string // ForkRemote is the computed owner name from the fork repo definition. ForkRemote string }
RepoManager manages a series of repositories. Call Init() before using it.
func (*RepoManager) AddOrFetchFork ¶
func (rm *RepoManager) AddOrFetchFork() *errors.Error
AddOrFetchFork retrieves the fork's contents, or adds the fork as a remote, and then does that.
func (*RepoManager) Checkout ¶
func (rm *RepoManager) Checkout(ref string) *errors.Error
Checkout sets the working copy to the ref provided.
func (*RepoManager) CloneOrFetch ¶
CloneOrFetch either clones a new repository, or fetches from an existing origin.
func (*RepoManager) Init ¶
func (rm *RepoManager) Init(config Config, log *log.SubLogger, repoName, forkRepoName string) *errors.Error
Init initializes the repomanager for use. Must be called before using other functions.
func (*RepoManager) Merge ¶
func (rm *RepoManager) Merge(ref string) (retErr *errors.Error)
Merge merges the ref into the currently checked out ref.