Documentation
¶
Index ¶
- type Commit
- type PullRequest
- type Remote
- func (f *Remote) AddBranch(repo commit.Repository, branch string, files map[string][]byte)
- func (f *Remote) Approve(_ context.Context, pr commit.PullRequest, body string) error
- func (f *Remote) Close(_ context.Context, pr commit.PullRequest, deleteBranch bool) error
- func (f *Remote) Commit(_ context.Context, repo commit.Repository, branch, message string, ...) error
- func (f *Remote) Commits(repo commit.Repository, branch string) []Commit
- func (f *Remote) CreateBranch(_ context.Context, repo commit.Repository, branch, base string) error
- func (f *Remote) EnableAutoMerge(_ context.Context, pr commit.PullRequest) error
- func (f *Remote) Files(repo commit.Repository, branch string) map[string][]byte
- func (f *Remote) FindPullRequest(_ context.Context, repo commit.Repository, head string) (commit.PullRequest, bool, error)
- func (f *Remote) FindPullRequestsByPrefix(_ context.Context, repo commit.Repository, prefix string) ([]commit.PullRequest, error)
- func (f *Remote) Head(_ context.Context, repo commit.Repository, branch string) (string, error)
- func (f *Remote) ListFiles(_ context.Context, repo commit.Repository, ref, dir string) ([]string, error)
- func (f *Remote) Merge(_ context.Context, pr commit.PullRequest) error
- func (f *Remote) MergedFiles(_ context.Context, pr commit.PullRequest) ([]commit.FileChange, error)
- func (f *Remote) OpenDraftPullRequest(_ context.Context, repo commit.Repository, head, base, title, body string) (commit.PullRequest, error)
- func (f *Remote) OpenPullRequest(_ context.Context, repo commit.Repository, head, base, title, body string) (commit.PullRequest, error)
- func (f *Remote) PullRequests() []PullRequest
- func (f *Remote) ReadFile(_ context.Context, repo commit.Repository, ref, path string) ([]byte, error)
- func (f *Remote) Revert(_ context.Context, pr commit.PullRequest, body string, ...) (commit.PullRequest, error)
- func (f *Remote) SetChecks(pr commit.PullRequest, state commit.CheckState)
- func (f *Remote) SetReview(pr commit.PullRequest, state commit.ReviewState)
- func (f *Remote) Status(_ context.Context, pr commit.PullRequest) (commit.Status, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
Repository commit.Repository
Branch string
Message string
Parent string
MergeParent string
SHA string
Files map[string][]byte
}
Commit is one commit the Remote holds; Files is the full tree at that commit. MergeParent is set on the merge commit CreateBranch makes when it brings an existing branch up to date: the base's head it merged in.
type PullRequest ¶
type PullRequest struct {
commit.PullRequest
Title string
Body string
Draft bool
Merged bool
Closed bool // closed without a merge
AutoMerge bool
Review commit.ReviewState
// Approvals are the bodies of the approving reviews Approve submitted, in order.
Approvals []string
Checks commit.CheckState
// contains filtered or unexported fields
}
PullRequest is a pull request the Remote holds, with what the remote knows about it.
type Remote ¶
type Remote struct {
// Fail maps an operation name (OpCreateBranch, OpCommit, ...) to the error
// that operation returns instead of acting.
Fail map[string]error
// contains filtered or unexported fields
}
Remote is an in-process Remote for tests — the module's own and its callers': branches with commits, pull requests with review and check state, and a way to make any operation fail. It never touches the network.
func NewRemote ¶
func NewRemote() *Remote
NewRemote returns an empty Remote; seed base branches with AddBranch.
func (*Remote) AddBranch ¶
AddBranch seeds branch in repo with one commit holding files (nil for an empty tree).
func (*Remote) Approve ¶
Approve implements Remote: the approval is recorded on the pull request and the review rollup becomes approved unless changes are requested. An unknown or closed pull request is an error.
func (*Remote) Commit ¶
func (f *Remote) Commit(_ context.Context, repo commit.Repository, branch, message string, files map[string][]byte) error
Commit implements Remote.
func (*Remote) Commits ¶
func (f *Remote) Commits(repo commit.Repository, branch string) []Commit
Commits returns the commits made on branch after its seed, oldest first.
func (*Remote) CreateBranch ¶
CreateBranch implements Remote: a new branch starts at base's head; an existing one that lacks base's head takes a merge commit with base's changes since their common ancestor, or ErrStaleBranch when a path changed on both sides differently.
func (*Remote) EnableAutoMerge ¶
EnableAutoMerge implements Remote: the pull request is marked, nothing merges by itself.
func (*Remote) FindPullRequest ¶
func (f *Remote) FindPullRequest(_ context.Context, repo commit.Repository, head string) (commit.PullRequest, bool, error)
FindPullRequest implements Remote.
func (*Remote) FindPullRequestsByPrefix ¶
func (f *Remote) FindPullRequestsByPrefix(_ context.Context, repo commit.Repository, prefix string) ([]commit.PullRequest, error)
FindPullRequestsByPrefix implements PrefixFinder. Every branch of the Remote is in its repository: the Remote holds no forks.
func (*Remote) ListFiles ¶
func (f *Remote) ListFiles(_ context.Context, repo commit.Repository, ref, dir string) ([]string, error)
ListFiles implements Lister.
func (*Remote) MergedFiles ¶
func (f *Remote) MergedFiles(_ context.Context, pr commit.PullRequest) ([]commit.FileChange, error)
MergedFiles implements MergedFilesLister the way GitHub's pull request files endpoint answers: the merged head's tree against the tree at the merge base of the head and the base as it was at the merge, so another pull request merged into the base after this branch was cut is not listed. Results are sorted by path. A removed path whose exact, non-empty content an added path carries is reported as that path's rename; removed and added paths pair in path order. GitHub also detects a rename whose content changed, which the Remote reports as a removal and an addition.
func (*Remote) OpenDraftPullRequest ¶
func (f *Remote) OpenDraftPullRequest(_ context.Context, repo commit.Repository, head, base, title, body string) (commit.PullRequest, error)
OpenDraftPullRequest implements Remote.
func (*Remote) OpenPullRequest ¶
func (f *Remote) OpenPullRequest(_ context.Context, repo commit.Repository, head, base, title, body string) (commit.PullRequest, error)
OpenPullRequest implements Remote.
func (*Remote) PullRequests ¶
func (f *Remote) PullRequests() []PullRequest
PullRequests returns every pull request the Remote holds, oldest first.
func (*Remote) ReadFile ¶
func (f *Remote) ReadFile(_ context.Context, repo commit.Repository, ref, path string) ([]byte, error)
ReadFile implements Reader.
func (*Remote) Revert ¶
func (f *Remote) Revert(_ context.Context, pr commit.PullRequest, body string, overrides map[string][]byte) (commit.PullRequest, error)
Revert implements Remote: the merged pull request's files, inverted against the base as it was at the merge, in one commit on the head of the revert branch, created at the base's tip or brought up to date with it as CreateBranch does.
func (*Remote) SetChecks ¶
func (f *Remote) SetChecks(pr commit.PullRequest, state commit.CheckState)
SetChecks sets the check rollup the Remote reports for pr.
func (*Remote) SetReview ¶
func (f *Remote) SetReview(pr commit.PullRequest, state commit.ReviewState)
SetReview sets the review rollup the Remote reports for pr.