Documentation
¶
Index ¶
- Variables
- func ApprovePR(nodeID string, pat string) error
- func EnablePRAutoMerge(nodeID string, pat string) error
- func GetUsername(pat string) string
- func MutateGraphQL(pat string, query string, variables map[string]interface{}) error
- func QueryGraphQL(pat string, query string, variables map[string]interface{}, result interface{}) error
- type ExistingPR
- type GitHubRequest
- type GitHubRequestError
- type GitHubResponse
- type MirrorRefSet
- type PRRefSet
- type Remote
- type SyncPRRefSet
- func (b SyncPRRefSet) ForkFromMainRefspec(mainBranch string) string
- func (b SyncPRRefSet) UpstreamFetchRefspec() string
- func (b SyncPRRefSet) UpstreamLocalBranch() string
- func (b SyncPRRefSet) UpstreamLocalSyncTarget() string
- func (b SyncPRRefSet) UpstreamMirrorFetchRefspec() string
- func (b SyncPRRefSet) UpstreamMirrorLocalBranch() string
- func (b SyncPRRefSet) UpstreamMirrorRefspec() string
Constants ¶
This section is empty.
Variables ¶
var ErrPRAlreadyExists = errors.New("PR already exists")
ErrPRAlreadyExists is returned when a PR already exists for the given branch.
Functions ¶
func ApprovePR ¶
ApprovePR adds an approving review on the target GraphQL PR node ID. The review author is the user associated with the PAT.
func EnablePRAutoMerge ¶
EnablePRAutoMerge enables PR automerge on the target GraphQL PR node ID.
func GetUsername ¶
GetUsername queries GitHub for the username associated with a PAT.
func MutateGraphQL ¶
Types ¶
type ExistingPR ¶
func FindExistingPR ¶
func FindExistingPR(r *GitHubRequest, head, target *Remote, headBranch, submitterUser, githubPAT string) (*ExistingPR, error)
FindExistingPR looks for a PR submitted to a target branch with a set of filters. Returns the result's graphql identity if one match is found, empty string if no matches are found, and an error if more than one match was found.
type GitHubRequest ¶
type GitHubRequest struct { Head string `json:"head"` Base string `json:"base"` Title string `json:"title"` Body string `json:"body"` MaintainerCanModify bool `json:"maintainer_can_modify"` Draft bool `json:"draft"` }
GitHubRequest is the payload for a GitHub PR creation API call, marshallable as JSON.
type GitHubRequestError ¶
type GitHubRequestError struct {
Message string `json:"message"`
}
type GitHubResponse ¶
type GitHubResponse struct { // GitHub success response: HTMLURL string `json:"html_url"` NodeID string `json:"node_id"` Number int `json:"number"` }
GitHubResponse is a successful PR creation response from GitHub.
func PostGitHub ¶
func PostGitHub(ownerRepo string, request *GitHubRequest, pat string) (*GitHubResponse, error)
PostGitHub creates a PR on GitHub using pat for the given owner/repo and request details. If the PR already exists, returns a wrapped ErrPRAlreadyExists.
type MirrorRefSet ¶
type MirrorRefSet struct {
UpstreamPattern string
}
MirrorRefSet calculates the set of refs that correspond to a pure mirroring operation, where the set of mirrored branches is specified by a pattern.
func (MirrorRefSet) UpstreamMirrorFetchRefspec ¶
func (b MirrorRefSet) UpstreamMirrorFetchRefspec() string
UpstreamMirrorFetchRefspec fetches the remote refs that match the pattern to local branches.
func (MirrorRefSet) UpstreamMirrorLocalBranchPattern ¶
func (b MirrorRefSet) UpstreamMirrorLocalBranchPattern() string
UpstreamMirrorLocalBranchPattern is the name of the local ref (or pattern matching multiple local refs) after it has been fetched from the upstream.
func (MirrorRefSet) UpstreamMirrorRefspec ¶
func (b MirrorRefSet) UpstreamMirrorRefspec() string
UpstreamMirrorRefspec pushes the local mirroring branches to back to branches with the same name as the branches they were fetched from.
type PRRefSet ¶
type PRRefSet struct { // Name of the base branch to update. Do not include "refs/heads/". Name string // Purpose of the PR. This is used to generate the PR branch name, "dev/{Purpose}/{Name}". Purpose string }
PRRefSet contains information about an automatic PR branch and calculates the set of refs that would correspond to that PR.
func (PRRefSet) BaseBranchFetchRefspec ¶
BaseBranchFetchRefspec is the refspec with src: PR base branch src, dst: PR head branch dst. This can be used with "fetch" to create a fresh dev branch.
func (PRRefSet) CreateGitHubPR ¶
func (b PRRefSet) CreateGitHubPR(headOwner, title, body string) *GitHubRequest
CreateGitHubPR creates the data model that can be sent to GitHub to create a PR for this branch.
func (PRRefSet) PRBranch ¶
PRBranch is the name of the "head" branch name for this PR, under "dev/{Purpose}/{Name}" convention, without the "refs/heads/" prefix.
func (PRRefSet) PRBranchRefspec ¶
PRBranchRefspec is the refspec that syncs the dev branch between two repos.
type Remote ¶
type Remote struct {
// contains filtered or unexported fields
}
Remote is a parsed version of a Git Remote. It helps determine how to send a GitHub PR.
func ParseRemoteURL ¶
ParseRemoteURL takes the URL ("https://github.com/microsoft/go", "git@github.com:microsoft/go") and grabs the owner ("microsoft") and repository name ("go"). This assumes the URL follows one of these two patterns, or something that's compatible. Returns an initialized 'Remote'.
func (Remote) GetOwnerRepo ¶
func (Remote) GetOwnerSlashRepo ¶
type SyncPRRefSet ¶
type SyncPRRefSet struct { // UpstreamName is the name of the upstream branch being synced from. UpstreamName string // Commit is either the specific commit hash to sync to, or empty string to sync from the latest // commit in the branch. Commit is expected to already be contained in the upstream branch. Commit string PRRefSet }
SyncPRRefSet calculates the set of refs that correspond to a PR branch that is performing a Git sync from an upstream repository.
func (SyncPRRefSet) ForkFromMainRefspec ¶
func (b SyncPRRefSet) ForkFromMainRefspec(mainBranch string) string
ForkFromMainRefspec fetches the specified main branch on the target repo into the local branch.
func (SyncPRRefSet) UpstreamFetchRefspec ¶
func (b SyncPRRefSet) UpstreamFetchRefspec() string
UpstreamFetchRefspec fetches the current upstream ref into the local branch.
func (SyncPRRefSet) UpstreamLocalBranch ¶
func (b SyncPRRefSet) UpstreamLocalBranch() string
UpstreamLocalBranch is the name of the upstream ref after it has been fetched locally.
func (SyncPRRefSet) UpstreamLocalSyncTarget ¶
func (b SyncPRRefSet) UpstreamLocalSyncTarget() string
UpstreamLocalSyncTarget is the commit (or branch) that should be synced to. Normally, it is the tip of the upstream ref, but it may be a specific commit if the config struct specified one.
func (SyncPRRefSet) UpstreamMirrorFetchRefspec ¶
func (b SyncPRRefSet) UpstreamMirrorFetchRefspec() string
UpstreamMirrorFetchRefspec fetches the current upstream ref as it is in an upstream mirror into a local branch.
func (SyncPRRefSet) UpstreamMirrorLocalBranch ¶
func (b SyncPRRefSet) UpstreamMirrorLocalBranch() string
UpstreamMirrorLocalBranch is the name of the upstream ref after it has been fetched locally from the mirror of the upstream.
func (SyncPRRefSet) UpstreamMirrorRefspec ¶
func (b SyncPRRefSet) UpstreamMirrorRefspec() string
UpstreamMirrorRefspec is the refspec that mirrors the original branch name to the same name in another repo. This can be used with "push" for a mirror operation.