Documentation
¶
Index ¶
- type Commit
- type PullRequest
- type Remote
- func (f *Remote) AddBranch(repo forge.Repository, branch string, files map[string][]byte)
- func (f *Remote) Approve(_ context.Context, pr forge.PullRequest, body string) error
- func (f *Remote) CanReadRepository(_ context.Context, repo forge.Repository) (bool, error)
- func (f *Remote) Close(_ context.Context, pr forge.PullRequest, deleteBranch bool) error
- func (f *Remote) Commit(_ context.Context, repo forge.Repository, branch, message string, ...) error
- func (f *Remote) CommitURL(repo forge.Repository, sha string) string
- func (f *Remote) Commits(repo forge.Repository, branch string) []Commit
- func (f *Remote) CreateBranch(_ context.Context, repo forge.Repository, branch, base string) error
- func (f *Remote) EnableAutoMerge(_ context.Context, pr forge.PullRequest) error
- func (f *Remote) FileURL(repo forge.Repository, ref, path string) string
- func (f *Remote) Files(repo forge.Repository, branch string) map[string][]byte
- func (f *Remote) FindPullRequest(_ context.Context, repo forge.Repository, head string) (forge.PullRequest, bool, error)
- func (f *Remote) FindPullRequestsByPrefix(_ context.Context, repo forge.Repository, prefix string) ([]forge.PullRequest, error)
- func (f *Remote) Head(_ context.Context, repo forge.Repository, branch string) (string, error)
- func (f *Remote) ListFiles(_ context.Context, repo forge.Repository, ref, dir string) ([]string, error)
- func (f *Remote) Merge(_ context.Context, pr forge.PullRequest) error
- func (f *Remote) MergedFiles(_ context.Context, pr forge.PullRequest) ([]forge.FileChange, error)
- func (f *Remote) OpenDraftPullRequest(_ context.Context, repo forge.Repository, head, base, title, body string) (forge.PullRequest, error)
- func (f *Remote) OpenPullRequest(_ context.Context, repo forge.Repository, head, base, title, body string) (forge.PullRequest, error)
- func (f *Remote) PullRequests() []PullRequest
- func (f *Remote) ReadFile(_ context.Context, repo forge.Repository, ref, path string) ([]byte, error)
- func (f *Remote) Revert(_ context.Context, pr forge.PullRequest, body string, ...) (forge.PullRequest, error)
- func (f *Remote) SetChecks(pr forge.PullRequest, state forge.CheckState)
- func (f *Remote) SetReview(pr forge.PullRequest, state forge.ReviewState)
- func (f *Remote) Status(_ context.Context, pr forge.PullRequest) (forge.Status, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Commit ¶
type Commit struct {
Repository forge.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 {
forge.PullRequest
Title string
Body string
Draft bool
Merged bool
Closed bool // closed without a merge
AutoMerge bool
Review forge.ReviewState
// Approvals are the bodies of the approving reviews Approve submitted, in order.
Approvals []string
Checks forge.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
UnreadableRepositories []forge.Repository
// 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) CanReadRepository ¶
CanReadRepository implements forge.RepositoryAccess: false for the repositories in UnreadableRepositories.
func (*Remote) Commit ¶
func (f *Remote) Commit(_ context.Context, repo forge.Repository, branch, message string, files map[string][]byte) error
Commit implements Remote.
func (*Remote) CommitURL ¶
func (f *Remote) CommitURL(repo forge.Repository, sha string) string
CommitURL implements forge.Linker on the host the pull request URLs name.
func (*Remote) Commits ¶
func (f *Remote) Commits(repo forge.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, or at base when it is a commit the Remote holds; an existing one that lacks that commit 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) FileURL ¶
func (f *Remote) FileURL(repo forge.Repository, ref, path string) string
FileURL implements forge.Linker on the host the pull request URLs name.
func (*Remote) FindPullRequest ¶
func (f *Remote) FindPullRequest(_ context.Context, repo forge.Repository, head string) (forge.PullRequest, bool, error)
FindPullRequest implements Remote.
func (*Remote) FindPullRequestsByPrefix ¶
func (f *Remote) FindPullRequestsByPrefix(_ context.Context, repo forge.Repository, prefix string) ([]forge.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 forge.Repository, ref, dir string) ([]string, error)
ListFiles implements Lister.
func (*Remote) MergedFiles ¶
func (f *Remote) MergedFiles(_ context.Context, pr forge.PullRequest) ([]forge.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 forge.Repository, head, base, title, body string) (forge.PullRequest, error)
OpenDraftPullRequest implements Remote.
func (*Remote) OpenPullRequest ¶
func (f *Remote) OpenPullRequest(_ context.Context, repo forge.Repository, head, base, title, body string) (forge.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 forge.Repository, ref, path string) ([]byte, error)
ReadFile implements Reader.
func (*Remote) Revert ¶
func (f *Remote) Revert(_ context.Context, pr forge.PullRequest, body string, overrides map[string][]byte) (forge.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 forge.PullRequest, state forge.CheckState)
SetChecks sets the check rollup the Remote reports for pr.
func (*Remote) SetReview ¶
func (f *Remote) SetReview(pr forge.PullRequest, state forge.ReviewState)
SetReview sets the review rollup the Remote reports for pr.