Documentation
¶
Index ¶
- Variables
- func ClipboardWrite(pr *LocalPr, title string)
- func EnrichPrBodyWithStoryEnabled() bool
- func ExtractPrNumber(branchname string) (int, error)
- func FileExists(file string) bool
- func GetBaseBranch() string
- func GetGithubMergeMethod() string
- func GetGithubOwner() string
- func GetGithubRepo() string
- func GetGithubRepoName() string
- func GetGithubTimeout() time.Duration
- func GetGithubToken() string
- func GetGithubUsername() string
- func GetPushCommand() string
- func GetRemoteName() string
- func GetStoryTool() string
- func GetStoryToolToken() string
- func GetStoryToolUrl() string
- func LocalBranchForPr(number int) string
- func Must[K any](k K, err error) K
- func RemoteBranchForPr(number int) string
- type Branch
- type BranchState
- type Commit
- type Gh
- type GhIssues
- type GhPullRequest
- type GithubClient
- type LocalPr
- func (b *LocalPr) AddKnownTip(tip string)
- func (b *LocalPr) AllAncestors() []*LocalPr
- func (b *LocalPr) AncestorTips() []string
- func (b *LocalPr) DeleteState()
- func (b *LocalPr) GetAncestor() (Branch, error)
- func (b *LocalPr) IsPr() bool
- func (b *LocalPr) LocalBranch() string
- func (b *LocalPr) LocalName() string
- func (b *LocalPr) Push(ctx context.Context) error
- func (b *LocalPr) ReloadState()
- func (b *LocalPr) RememberCurrentTip()
- func (b *LocalPr) RemoteBranch() string
- func (b *LocalPr) RemoteName() string
- func (b *LocalPr) SetAncestor(branch Branch)
- func (b *LocalPr) SetKnownTipsFromAncestor(ancestor *LocalPr)
- func (pr *LocalPr) StateIsLoaded() bool
- func (b *LocalPr) Url() string
- type Repo
- func (r *Repo) AllLocalPrs() (map[int]string, error)
- func (r *Repo) AllPrs(ctx context.Context) []LocalPr
- func (r *Repo) BaseBranch() Branch
- func (r *Repo) Checkout(ctx context.Context, branch Branch) error
- func (r *Repo) CheckoutRef(ctx context.Context, ref string) error
- func (r *Repo) CleanupAfterMerge(ctx context.Context, pr *LocalPr)
- func (r *Repo) CleanupMultiple(ctx context.Context, toclean []*LocalPr, others []LocalPr)
- func (r *Repo) Config() string
- func (r *Repo) CurrentBranch() (Branch, error)
- func (r *Repo) DeleteLocalAndRemoteBranch(ctx context.Context, branch Branch) error
- func (r *Repo) DeleteRemoteBranch(ctx context.Context, branch Branch) error
- func (r *Repo) DetachHead(ctx context.Context) error
- func (r *Repo) DotOpDir() string
- func (r *Repo) Fetch(ctx context.Context) error
- func (r *Repo) FindBranchingPoint(headCommit string) (Branch, []Commit, error)
- func (r *Repo) GetBranch(name string) (Branch, error)
- func (r *Repo) GetCommitsNotInBaseBranch(hash string) ([]Commit, error)
- func (r *Repo) GetCurrentBranchName(ctx context.Context) (string, error)
- func (r *Repo) GetHeadHash(ctx context.Context) (string, error)
- func (r *Repo) GetHeadRef(ctx context.Context) (string, error)
- func (r *Repo) GetLocalTip(b Branch) (string, error)
- func (r *Repo) GetMainBranch(ctx context.Context, remoteName string) (string, error)
- func (r *Repo) GetRefHash(ctx context.Context, refName string) (string, error)
- func (r *Repo) GetRemoteTip(b Branch) (string, error)
- func (r *Repo) GitExec(ctx context.Context, format string, args ...any) *exec.Cmd
- func (r *Repo) InteractiveRebase(ctx context.Context, branch Branch) error
- func (r *Repo) IsAncestor(ctx context.Context, ancestor, descendant string) bool
- func (r *Repo) NoLocalChanges(ctx context.Context) bool
- func (r *Repo) OppEnabled() bool
- func (r *Repo) Path() string
- func (r *Repo) PrForHead() (*LocalPr, bool)
- func (r *Repo) Push(ctx context.Context, hash string, branch string) error
- func (r *Repo) Rebase(ctx context.Context, branch Branch) error
- func (r *Repo) SetTrackingBranch(localBranch Branch, remoteBranch Branch) error
- func (r *Repo) StateStore() *StateStore
- func (r *Repo) TryLocalRebaseOntoSilently(ctx context.Context, first string, onto string) bool
- func (r *Repo) TryRebaseBranchOnto(ctx context.Context, parent string, onto Branch) bool
- func (r *Repo) TryRebaseCurrentBranchSilently(ctx context.Context, branch Branch) bool
- func (r *Repo) TryRebaseOntoSilently(ctx context.Context, first string, onto Branch, interactive bool) bool
- type StateStore
- func (s *StateStore) AllLocalPrNumbers(ctx context.Context) []int
- func (s *StateStore) DeleteBranchState(b Branch)
- func (s *StateStore) GetBranchState(b Branch) *BranchState
- func (s *StateStore) SaveBranchState(b Branch, state *BranchState) error
- func (s *StateStore) StateBranchFile(b Branch) string
Constants ¶
This section is empty.
Variables ¶
var ErrNotAPrBranch = errors.New("not a pr branch")
var ErrReferenceNotFound = errors.New("reference not found")
Functions ¶
func ClipboardWrite ¶
func EnrichPrBodyWithStoryEnabled ¶
func EnrichPrBodyWithStoryEnabled() bool
func ExtractPrNumber ¶
func FileExists ¶
func GetBaseBranch ¶
func GetBaseBranch() string
func GetGithubMergeMethod ¶
func GetGithubMergeMethod() string
func GetGithubRepo ¶
func GetGithubRepo() string
func GetGithubRepoName ¶
func GetGithubRepoName() string
The second part of the repo, after the slash.
func GetGithubTimeout ¶
func GetGithubToken ¶
func GetGithubToken() string
func GetGithubUsername ¶
func GetGithubUsername() string
func GetPushCommand ¶
func GetPushCommand() string
func GetRemoteName ¶
func GetRemoteName() string
func GetStoryTool ¶
func GetStoryTool() string
func GetStoryToolToken ¶
func GetStoryToolToken() string
func GetStoryToolUrl ¶
func GetStoryToolUrl() string
func LocalBranchForPr ¶
func RemoteBranchForPr ¶
Types ¶
type BranchState ¶
type Gh ¶
type Gh interface {
PullRequests() GhPullRequest
Issues() GhIssues
}
type GhIssues ¶
type GhIssues interface {
ListByRepo(ctx context.Context, owner string, repo string, opts *github.IssueListByRepoOptions) ([]*github.Issue, *github.Response, error)
CreateComment(ctx context.Context, owner string, repo string, number int, comment *github.IssueComment) (*github.IssueComment, *github.Response, error)
}
type GhPullRequest ¶
type GhPullRequest interface {
List(ctx context.Context, owner string, repo string, opt *github.PullRequestListOptions) ([]*github.PullRequest, *github.Response, error)
Create(ctx context.Context, owner string, repo string, pull *github.NewPullRequest) (*github.PullRequest, *github.Response, error)
Get(ctx context.Context, owner string, repo string, number int) (*github.PullRequest, *github.Response, error)
Merge(ctx context.Context, owner string, repo string, number int, commitMessage string, options *github.PullRequestOptions) (*github.PullRequestMergeResult, *github.Response, error)
}
type GithubClient ¶
func NewClient ¶
func NewClient(ctx context.Context) *GithubClient
func (*GithubClient) Issues ¶
func (c *GithubClient) Issues() GhIssues
func (*GithubClient) PullRequests ¶
func (c *GithubClient) PullRequests() GhPullRequest
type LocalPr ¶
func NewLocalPr ¶
func (*LocalPr) AddKnownTip ¶
func (*LocalPr) AllAncestors ¶
Returns all ancestor but not itself.
func (*LocalPr) AncestorTips ¶
func (*LocalPr) DeleteState ¶
func (b *LocalPr) DeleteState()
func (*LocalPr) GetAncestor ¶
func (*LocalPr) LocalBranch ¶
func (*LocalPr) ReloadState ¶
func (b *LocalPr) ReloadState()
func (*LocalPr) RememberCurrentTip ¶
func (b *LocalPr) RememberCurrentTip()
func (*LocalPr) RemoteBranch ¶
func (*LocalPr) RemoteName ¶
func (*LocalPr) SetAncestor ¶
func (*LocalPr) SetKnownTipsFromAncestor ¶
func (*LocalPr) StateIsLoaded ¶
type Repo ¶
type Repo struct {
RootPath string
// contains filtered or unexported fields
}
func NewRepo ¶
NewRepo creates a Repo rooted at the given folder. It walks up the directory tree to find the .git folder.
func (*Repo) BaseBranch ¶
func (*Repo) CheckoutRef ¶
CheckoutRef checks out the given ref (branch name or commit hash).
func (*Repo) CleanupMultiple ¶
func (*Repo) CurrentBranch ¶
func (*Repo) DeleteLocalAndRemoteBranch ¶
func (*Repo) DeleteRemoteBranch ¶
func (*Repo) FindBranchingPoint ¶
Takes all commit that are ancestors of headCommit and not in the base branch and walks them until it finds one that is the tip of an exisiting pr/XXX branch. Returns all the commits that were touched during the walk, in git children -> parent order. (e.g. the first commit is always headCommit)
func (*Repo) GetCommitsNotInBaseBranch ¶
Returns all of the commits between the given hash and its merge-base with the base branch of the repository
func (*Repo) GetCurrentBranchName ¶
GetCurrentBranchName returns the name of the current branch. Returns an error if HEAD is detached (not on a branch). This replaces the pattern: head.Name().Short() and checking head.Name().IsBranch()
func (*Repo) GetHeadHash ¶
GetHeadHash returns the SHA of the current HEAD commit. This replaces the pattern: Repository.Head().Hash()
func (*Repo) GetHeadRef ¶
GetHeadRef returns a string representing the current HEAD. If on a branch, returns the branch name. If detached, returns the commit hash.
func (*Repo) GetMainBranch ¶
func (*Repo) GetRefHash ¶
GetRefHash returns the commit hash that a reference points to. refName should be a full reference name like "refs/heads/main" or "refs/remotes/origin/main". Returns an error if the reference doesn't exist. This replaces the pattern: Repository.Reference(name, true).Hash()
func (*Repo) InteractiveRebase ¶
When remote is true, rebase on the distant version of the branch. When false, rebase on the local version.
func (*Repo) IsAncestor ¶
IsAncestor returns true if ancestor is an ancestor of descendant.
func (*Repo) NoLocalChanges ¶
NoLocalChanges returns true when all files are either unmodified or untracked.
func (*Repo) OppEnabled ¶
func (*Repo) Rebase ¶
When remote is true, rebase on the distant version of the branch. When false, rebase on the local version.
func (*Repo) SetTrackingBranch ¶
func (*Repo) StateStore ¶
func (r *Repo) StateStore() *StateStore
func (*Repo) TryLocalRebaseOntoSilently ¶
func (*Repo) TryRebaseBranchOnto ¶
func (*Repo) TryRebaseCurrentBranchSilently ¶
type StateStore ¶
type StateStore struct {
// contains filtered or unexported fields
}
func NewStateStore ¶
func NewStateStore(r *Repo) *StateStore
func (*StateStore) AllLocalPrNumbers ¶
func (s *StateStore) AllLocalPrNumbers(ctx context.Context) []int
func (*StateStore) DeleteBranchState ¶
func (s *StateStore) DeleteBranchState(b Branch)
func (*StateStore) GetBranchState ¶
func (s *StateStore) GetBranchState(b Branch) *BranchState
func (*StateStore) SaveBranchState ¶
func (s *StateStore) SaveBranchState(b Branch, state *BranchState) error
func (*StateStore) StateBranchFile ¶
func (s *StateStore) StateBranchFile(b Branch) string