Documentation ¶
Index ¶
- func NewCensoringExecutor(dir string, censor Censor, logger *logrus.Entry) (executor, error)
- func OrgRepo(full string) (string, string, error)
- type Censor
- type ClientFactory
- type ClientFactoryOpt
- type ClientFactoryOpts
- type GitUserGetter
- type Interactor
- type LoginGetter
- type MergeOpt
- type Publisher
- type RemoteResolver
- type RemoteResolverFactory
- type RepoClient
- type TokenGetter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCensoringExecutor ¶
Types ¶
type ClientFactory ¶
type ClientFactory interface { // ClientFromDir creates a client that operates on a repo that has already // been cloned to the given directory. ClientFromDir(org, repo, dir string) (RepoClient, error) // ClientFor creates a client that operates on a new clone of the repo. ClientFor(org, repo string) (RepoClient, error) // Clean removes the caches used to generate clients Clean() error }
ClientFactory knows how to create clientFactory for repos
func ClientFactoryFrom ¶
func ClientFactoryFrom(c *git.Client) ClientFactory
ClientFactoryFrom adapts the v1 client to a v2 client
func NewClientFactory ¶
func NewClientFactory(opts ...ClientFactoryOpt) (ClientFactory, error)
NewClientFactory allows for the creation of repository clients. It uses github.com without authentication by default, if UseSSH then returns sshRemoteResolverFactory, and if CookieFilePath is provided then returns gerritResolverFactory(Assuming that git http.cookiefile is used only by Gerrit, this function needs to be updated if it turned out that this assumtpion is not correct.)
func NewLocalClientFactory ¶
func NewLocalClientFactory(baseDir string, gitUser GitUserGetter, censor Censor) (ClientFactory, error)
NewLocalClientFactory allows for the creation of repository clients based on a local filepath remote for testing
type ClientFactoryOpt ¶
type ClientFactoryOpt func(*ClientFactoryOpts)
ClientFactoryOpts allows to manipulate the options for a ClientFactory
type ClientFactoryOpts ¶
type ClientFactoryOpts struct { // Host, defaults to "github.com" if unset Host string // UseSSH, defaults to false UseSSH *bool // The directory in which the cache should be // created. Defaults to the "/var/tmp" on // Linux and os.TempDir otherwise CacheDirBase *string // If unset, publishing action will error Username LoginGetter // If unset, publishing action will error Token TokenGetter // The git user to use. GitUser GitUserGetter // The censor to use. Not needed for anonymous // actions. Censor Censor // Path to the httpCookieFile that will be used to authenticate client CookieFilePath string }
func (*ClientFactoryOpts) Apply ¶
func (cfo *ClientFactoryOpts) Apply(target *ClientFactoryOpts)
Apply allows to use a ClientFactoryOpts as Opt
type GitUserGetter ¶
GitUserGetter fetches a name and email for us in git commits on-demand
type Interactor ¶
type Interactor interface { // Directory exposes the directory in which the repository has been cloned Directory() string // Clean removes the repository. It is up to the user to call this once they are done Clean() error // ResetHard runs `git reset --hard` ResetHard(commitlike string) error // IsDirty checks whether the repo is dirty or not IsDirty() (bool, error) // Checkout runs `git checkout` Checkout(commitlike string) error // RevParse runs `git rev-parse` RevParse(commitlike string) (string, error) // BranchExists determines if a branch with the name exists BranchExists(branch string) bool // CommitExists determines if the commit SHA exists locally CommitExists(sha string) (bool, error) // CheckoutNewBranch creates a new branch from HEAD and checks it out CheckoutNewBranch(branch string) error // Merge merges the commitlike into the current HEAD Merge(commitlike string) (bool, error) // MergeWithStrategy merges the commitlike into the current HEAD with the strategy MergeWithStrategy(commitlike, mergeStrategy string, opts ...MergeOpt) (bool, error) // MergeAndCheckout merges all commitlikes into the current HEAD with the appropriate strategy MergeAndCheckout(baseSHA string, mergeStrategy string, headSHAs ...string) error // Am calls `git am` Am(path string) error // Fetch calls `git fetch arg...` Fetch(arg ...string) error // FetchRef fetches the refspec FetchRef(refspec string) error // FetchFromRemote fetches the branch of the given remote FetchFromRemote(remote RemoteResolver, branch string) error // CheckoutPullRequest fetches and checks out the synthetic refspec from GitHub for a pull request HEAD CheckoutPullRequest(number int) error // Config runs `git config` Config(args ...string) error // Diff runs `git diff` Diff(head, sha string) (changes []string, err error) // MergeCommitsExistBetween determines if merge commits exist between target and HEAD MergeCommitsExistBetween(target, head string) (bool, error) // ShowRef returns the commit for a commitlike. Unlike rev-parse it does not require a checkout. ShowRef(commitlike string) (string, error) }
Interactor knows how to operate on a git repository cloned from GitHub using a local cache.
type LoginGetter ¶
LoginGetter fetches a GitHub login on-demand
type MergeOpt ¶
type MergeOpt struct {
CommitMessage string
}
MergeOpt holds options for git merge operations. Currently only commit message option is supported.
type Publisher ¶
type Publisher interface { // Commit stages all changes and commits them with the message Commit(title, body string) error // PushToFork pushes the local state to the fork remote PushToFork(branch string, force bool) error // PushToNamedFork is used for when the fork has a different name than the original repp PushToNamedFork(forkName, branch string, force bool) error // PushToCentral pushes the local state to the central remote PushToCentral(branch string, force bool) error }
Publisher knows how to publish local work to a remote
type RemoteResolver ¶
RemoteResolver knows how to construct a remote URL for git calls
func HttpResolver ¶
func HttpResolver(remote func() (*url.URL, error), username LoginGetter, token TokenGetter) RemoteResolver
HttpResolver builds http URLs that may optionally contain simple auth credentials, resolved dynamically.
type RemoteResolverFactory ¶
type RemoteResolverFactory interface { // CentralRemote returns a resolver for a remote server with an // authoritative version of the repository. This type of remote // is useful for fetching refs and cloning. CentralRemote(org, repo string) RemoteResolver // PublishRemote returns a resolver for a remote server with a // personal fork of the repository. This type of remote is most // useful for publishing local changes. PublishRemote(org, repo string) RemoteResolver }
RemoteResolverFactory knows how to construct remote resolvers for authoritative central remotes (to pull from) and publish remotes (to push to) for a repository. These resolvers are called at run-time to determine remotes for git commands.
type RepoClient ¶
type RepoClient interface { Publisher Interactor }
RepoClient exposes interactions with a git repo
type TokenGetter ¶
type TokenGetter func() []byte
TokenGetter fetches a GitHub OAuth token on-demand