Documentation ¶
Index ¶
- Variables
- func ExtractPrNumber(branchname string) (int, error)
- func FileExists(file string) bool
- func GetBaseBranch() string
- func GetCleanMaster() bool
- func GetGithubMergeMethod() string
- func GetGithubOwner() string
- func GetGithubRepo() string
- func GetGithubRepoName() string
- func GetGithubTimeout() time.Duration
- func GetGithubToken() string
- func GetGithubUsername() string
- func GetRemoteName() string
- func LocalBranchForPr(number int) string
- func Must[K any](k K, err error) K
- func RemoteBranchForPr(number int) string
- type Branch
- type Gh
- type GhIssues
- type GhPullRequest
- type GithubClient
- type LocalPr
- func (b *LocalPr) AddKnownTip(tip plumbing.Hash)
- 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 (b *LocalPr) StateFile() string
- func (b *LocalPr) Url() string
- type PrStates
- type Repo
- func (r *Repo) AllLocalPrs() (map[int]plumbing.Hash, error)
- func (r *Repo) AllPrs(ctx context.Context) []LocalPr
- func (r *Repo) BaseBranch() Branch
- func (r *Repo) Checkout(branch Branch) error
- func (r *Repo) CheckoutRef(ref *plumbing.Reference) 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 plumbing.Hash) (Branch, []*object.Commit, error)
- func (r *Repo) GetBranch(name string) (Branch, error)
- func (r *Repo) GetCommitsNotInBaseBranch(hash plumbing.Hash) ([]*object.Commit, error)
- func (r *Repo) GetLocalTip(b Branch) (*object.Commit, error)
- func (r *Repo) GetRemoteTip(b Branch) (*object.Commit, 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) 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 plumbing.Hash, 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) TryLocalRebaseOntoSilently(ctx context.Context, first plumbing.Hash, onto plumbing.Hash) bool
- func (r *Repo) TryRebaseBranchOnto(ctx context.Context, parent plumbing.Hash, onto Branch) bool
- func (r *Repo) TryRebaseCurrentBranchSilently(ctx context.Context, branch Branch) bool
- func (r *Repo) TryRebaseOntoSilently(ctx context.Context, first plumbing.Hash, onto Branch, interactive bool) bool
- func (r *Repo) Worktree() *git.Worktree
Constants ¶
This section is empty.
Variables ¶
var ErrNotAPrBranch = errors.New("not a pr branch")
Functions ¶
func ExtractPrNumber ¶
func FileExists ¶
func GetBaseBranch ¶
func GetBaseBranch() string
func GetCleanMaster ¶
func GetCleanMaster() bool
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 GetRemoteName ¶
func GetRemoteName() string
func LocalBranchForPr ¶
func RemoteBranchForPr ¶
Types ¶
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 ¶
type LocalPr struct { PrNumber int HasState bool Repo *Repo // contains filtered or unexported fields }
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 ¶
type Repo ¶
type Repo struct {
*git.Repository
}
func (*Repo) BaseBranch ¶
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) InteractiveRebase ¶
When remote is true, rebase on the distant version of the branch. When false, rebase on the local version.
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.