Documentation ¶
Index ¶
- Variables
- func DeleteBranch(repo *git.Repo, name string) error
- func PreviousBranches(branches map[string]Branch, name string) ([]string, error)
- func ReadAllBranches(repo *git.Repo) (map[string]Branch, error)
- func SubsequentBranches(branches map[string]Branch, name string) ([]string, error)
- func Trunk(repo *git.Repo, branchName string) (string, error)
- func WriteBranch(repo *git.Repo, s Branch) error
- func WriteRepository(repo *git.Repo, meta Repository) error
- type Branch
- type BranchState
- type PullRequest
- type Repository
Constants ¶
This section is empty.
Variables ¶
var ErrRepoNotInitialized = errors.New("this repository not initialized: please run `av init`")
Functions ¶
func PreviousBranches ¶ added in v0.0.6
Find all the ancestor branches of the given branch name and append them to the given slice (in topological order: a comes before b if a is an ancestor of b).
func ReadAllBranches ¶
ReadAllBranches fetches all branch metadata stored in the git repository. It returns a map where the key is the name of the branch.
func SubsequentBranches ¶ added in v0.0.6
Find all the child branches of the given branch name and append them to the given slice (in topological order: a comes before b if a is an ancestor of b).
func WriteBranch ¶
WriteBranch writes branch metadata to the git repository. It can be loaded again with ReadBranch.
func WriteRepository ¶
func WriteRepository(repo *git.Repo, meta Repository) error
WriteRepository writes repository metadata to the git repo. It can be loaded again with ReadRepository.
Types ¶
type Branch ¶
type Branch struct { // The branch name associated with this stack. // Not stored in JSON because the name can always be derived from the name // of the git ref. Name string `json:"-"` // Information about the parent branch. Parent BranchState `json:"parent,omitempty"` // The children branches of this branch within the stack (if any). Children []string `json:"children,omitempty"` // The associated pull request information, if any. PullRequest *PullRequest `json:"pullRequest,omitempty"` // The merge commit onto the trunk branch, if any MergeCommit string `json:"mergeCommit,omitempty"` }
func FindStackRoot ¶ added in v0.0.7
func ReadBranch ¶
ReadBranch loads information about the branch from the git repository. Returns the branch metadata and a boolean indicating if the branch metadata already existed and was loaded. If the branch metadata does not exist, a useful default is returned.
func (Branch) BaseCommit ¶ added in v0.0.5
BaseCommit determines the base commit for the given branch. The base commit is defined as the latest commit on the branch that should not be considered one of the critical commits on the stacked branch itself. This is essentially the merge-base of the branch and its parent and should be used as the `<upstream>` in the `git rebase --onto <parent-branch> <upstream>` command.
func (*Branch) IsStackRoot ¶ added in v0.0.5
func (*Branch) UnmarshalJSON ¶ added in v0.0.5
type BranchState ¶ added in v0.0.5
type BranchState struct { // The branch name associated with the parent of the stack (if any). // If empty, this branch (potentially*) is considered a stack root. // (*depending on the context, we only consider the branch a stack root if // it also has children branches; for example, any "vanilla" branch off of // trunk will have no parent, but we usually don't explicitly consider it a // stack unless it also has stack children) Name string `json:"name"` // If true, consider the branch a trunk branch. A trunk branch is one that // that stacks can target for merge. Usually, the only trunk branch for a // repository is main or master. Trunk bool `json:"trunk,omitempty"` // The commit SHA of the parent's latest commit. This is used when syncing // the branch with the parent to identify the commits that belong to the // child branch (since the HEAD of the parent branch may change). // This will be unset if Trunk is true. Head string `json:"head,omitempty"` }
func ReadBranchState ¶ added in v0.0.5
type PullRequest ¶
type PullRequest struct { // The GitHub (GraphQL) ID of the pull request. ID string `json:"id"` // The pull request number. Number int64 `json:"number"` // The web URL for the pull request. Permalink string `json:"permalink"` // The state of the pull request (open, closed, or merged). State githubv4.PullRequestState }
type Repository ¶
type Repository struct { // The GitHub (GraphQL) ID of the repository (e.g., R_kgDOHMmHmg). ID string `json:"id"` // The owner of the repository (e.g., aviator-co) Owner string `json:"owner"` // The name of the repository (e.g., av) Name string `json:"name"` }
func ReadRepository ¶
func ReadRepository(repo *git.Repo) (Repository, error)
ReadRepository reads repository metadata from the git repo. Returns the metadata and a boolean indicating if the metadata was found.