Documentation ¶
Index ¶
- Constants
- Variables
- func AddPRMetadata(body string, prMeta PRMetadata) string
- func AddPullRequestReviewers(ctx context.Context, client *gh.Client, prID githubv4.ID, reviewers []string) error
- func Push(repo *git.Repo, branchName string, opts PushOpts) error
- func Reorder(repo *git.Repo, tx meta.WriteTx, opts ReorderOpts) error
- func SyncStack(ctx context.Context, repo *git.Repo, client *gh.Client, tx meta.WriteTx, ...) error
- func WriteStackSyncState(repo *git.Repo, state *StackSyncState) error
- type CreatePullRequestOpts
- type CreatePullRequestResult
- type ErrExitSilently
- type ForceOpt
- type PRMetadata
- type PushOpts
- type ReorderOpts
- type ReparentOpts
- type ReparentResult
- type StackSyncConfig
- type StackSyncState
- type SyncBranchContinuation
- type SyncBranchOpts
- type SyncStackOpt
- type UpdatePullRequestResult
Constants ¶
const PRMetadataCommentEnd = "-->\n"
const PRMetadataCommentHelpText = "" /* 165-byte string literal not displayed */
const PRMetadataCommentStart = "<!-- av pr metadata\n"
Variables ¶
var ErrRepoNotInitialized = errors.Sentinel(
"this repository is not initialized; please run `av init`",
)
Functions ¶
func AddPRMetadata ¶ added in v0.0.7
func AddPRMetadata(body string, prMeta PRMetadata) string
func AddPullRequestReviewers ¶ added in v0.0.28
func AddPullRequestReviewers( ctx context.Context, client *gh.Client, prID githubv4.ID, reviewers []string, ) error
AddPullRequestReviewers adds the given reviewers to the given pull request. It accepts a list of reviewers, which can be either GitHub user logins or team names in the format `@organization/team`.
func SyncStack ¶ added in v0.0.16
func SyncStack(ctx context.Context, repo *git.Repo, client *gh.Client, tx meta.WriteTx, branchesToSync []string, state StackSyncState, optFns ...SyncStackOpt, ) error
SyncStack performs stack sync on all branches in branchesToSync.
func WriteStackSyncState ¶ added in v0.0.16
func WriteStackSyncState(repo *git.Repo, state *StackSyncState) error
Types ¶
type CreatePullRequestOpts ¶
type CreatePullRequestOpts struct { // The HEAD branch to create a pull request for. BranchName string // The pull request title. Title string // The pull request body (description). Body string // If true, create the pull request as a GitHub draft PR. Draft bool // If true, do not push the branch to GitHub NoPush bool // If true, force push the branch to GitHub ForcePush bool // If true, create a PR even if we think one already exists Force bool // If true, open an editor for editing the title and body Edit bool }
type CreatePullRequestResult ¶ added in v0.0.6
type CreatePullRequestResult struct { // True if the pull request was created Created bool // The (updated) branch metadata. Branch meta.Branch // The pull request object that was returned from GitHub Pull *gh.PullRequest }
func CreatePullRequest ¶
func CreatePullRequest( ctx context.Context, repo *git.Repo, client *gh.Client, tx meta.WriteTx, opts CreatePullRequestOpts, ) (_ *CreatePullRequestResult, reterr error)
CreatePullRequest creates a pull request on GitHub for the current branch, if one doesn't already exist.
type ErrExitSilently ¶ added in v0.0.16
type ErrExitSilently struct {
ExitCode int
}
errExitSilently is an error type that indicates that program should exit without printing any additional information with the given exit code. This is meant for cases where the running commands wants to manage its own error output but still needs to return a non-zero exit code (since returning nil from RunE would cause a exit with a zero code).
func (ErrExitSilently) Error ¶ added in v0.0.16
func (e ErrExitSilently) Error() string
type ForceOpt ¶
type ForceOpt int
const ( NoForce ForceOpt = iota // ForceWithLease indicates that the push should use the --force-with-lease // option which instructs Git that it should only force push to the remote // branch if its current HEAD matches what we think it should be. ForceWithLease ForceOpt = iota ForcePush ForceOpt = iota )
type PRMetadata ¶ added in v0.0.7
type PRMetadata struct { Parent string `json:"parent"` ParentHead string `json:"parentHead"` ParentPull int64 `json:"parentPull,omitempty"` Trunk string `json:"trunk"` }
func ParsePRMetadata ¶ added in v0.0.7
func ParsePRMetadata( input string, ) (commentStart int, commentEnd int, prMeta PRMetadata, reterr error)
func ReadPRMetadata ¶ added in v0.0.7
func ReadPRMetadata(body string) (PRMetadata, error)
type PushOpts ¶
type PushOpts struct { Force ForceOpt // If true, require the corresponding branch exist on the remote (otherwise, don't push). SkipIfRemoteBranchNotExist bool // If true, skip pushing the branch if the corresponding branch on the remote points to the // same commit as the local HEAD commit. The caller should probably call `git fetch` before // running this to make sure remote tracking information is up-to-date. SkipIfRemoteBranchIsUpToDate bool }
type ReorderOpts ¶ added in v0.0.16
type ReparentOpts ¶ added in v0.0.5
type ReparentResult ¶ added in v0.0.4
func Reparent ¶ added in v0.0.4
func Reparent( repo *git.Repo, tx meta.WriteTx, opts ReparentOpts, ) (*ReparentResult, error)
Reparent changes the parent branch of a stacked branch (performing a rebase if necessary).
func ReparentSkipContinue ¶ added in v0.0.15
func ReparentSkipContinue( repo *git.Repo, tx meta.WriteTx, opts ReparentOpts, skip bool, ) (*ReparentResult, error)
type StackSyncConfig ¶ added in v0.0.16
type StackSyncConfig struct { // If set, only sync up to the current branch (do not sync descendants). // This is useful for syncing changes from a parent branch in case the // current branch needs to be updated before continuing the sync. Current bool `json:"current"` // If set, incorporate changes from the trunk (repo base branch) into the stack. // Only valid if synchronizing the root of a stack. // This effectively re-roots the stack on the latest commit from the trunk. Trunk bool `json:"trunk"` // If set, do not push to GitHub. NoPush bool `json:"noPush"` // If set, do not fetch updated PR information from GitHub. NoFetch bool `json:"noFetch"` // The new parent branch to sync the current branch to. Parent string `json:"parent"` // If set, delete the merged branches. Prune bool `json:"prune"` }
StackSyncConfig contains the configuration for a sync operation. It is serializable to JSON to handle the case where the sync is interrupted by a merge conflict (so it can be resumed with the --continue flag).
type StackSyncState ¶ added in v0.0.16
type StackSyncState struct { // The branch to return to when the sync is complete. OriginalBranch string `json:"originalBranch"` // The branch that's currently being synced. CurrentBranch string `json:"currentBranch"` // All of the branches that are being synced (including branches that have // already been synced). // TODO: We should probably store the original HEAD commit for each branch // and revert each branch individually if we --abort. Branches []string `json:"branches"` // The continuation state for the current branch. Continuation *SyncBranchContinuation `json:"continuation,omitempty"` // The config of the sync. Config StackSyncConfig `json:"config"` }
StackSyncState is the state of an in-progress sync operation. It is written to a file if the sync is interrupted (so it can be resumed with the --continue flag).
func ReadStackSyncState ¶ added in v0.0.16
func ReadStackSyncState(repo *git.Repo) (StackSyncState, error)
type SyncBranchContinuation ¶ added in v0.0.8
type SyncBranchContinuation struct { // The new parent name. NewParentName string `json:"parentName"` // If set, set this as the parent HEAD. If unset, the parent is treated as trunk. NewParentCommit string `json:"parentCommit"` }
func SyncBranch ¶ added in v0.0.8
func SyncBranch( ctx context.Context, repo *git.Repo, client *gh.Client, tx meta.WriteTx, opts SyncBranchOpts, ) (*SyncBranchContinuation, error)
SyncBranch synchronizes a branch with its parent.
type SyncBranchOpts ¶ added in v0.0.8
type SyncBranchOpts struct { Branch string Fetch bool Push bool // If specified, synchronize the branch against the latest version of the // trunk branch. This value is ignored if the branch is not a stack root. ToTrunk bool // If true, skip the current commit. // This must only be set after a rebase conflict in a sync. Skip bool Continuation *SyncBranchContinuation }
type SyncStackOpt ¶ added in v0.0.16
type SyncStackOpt func(*syncStackOpts)
func WithSkipNextCommit ¶ added in v0.0.16
func WithSkipNextCommit() SyncStackOpt
type UpdatePullRequestResult ¶ added in v0.0.4
type UpdatePullRequestResult struct { // True if the pull request information changed (e.g., a new pull request // was found or if the pull request changed state) Changed bool // The pull request object that was returned from GitHub Pull *gh.PullRequest }
func UpdatePullRequestState ¶ added in v0.0.4
func UpdatePullRequestState( ctx context.Context, client *gh.Client, tx meta.WriteTx, branchName string, ) (*UpdatePullRequestResult, error)
UpdatePullRequestState fetches the latest pull request information from GitHub and writes the relevant branch metadata.