Documentation
¶
Index ¶
- Variables
- type Applier
- func (a *Applier) Apply(ctx context.Context, f *gitdiff.File) (*github.TreeEntry, error)
- func (a *Applier) Commit(ctx context.Context, header *gitdiff.PatchHeader) (*github.Commit, error)
- func (a *Applier) CreateTree(ctx context.Context) (*github.Tree, error)
- func (a *Applier) Entries() []*github.TreeEntry
- func (a *Applier) Reset(c *github.Commit)
- type Reference
- type Repository
Constants ¶
This section is empty.
Variables ¶
var DefaultCommitMessage = "Apply patch with patch2pr"
DefaultCommitMessage is the commit message used when no message is provided in a patch header.
Functions ¶
This section is empty.
Types ¶
type Applier ¶
type Applier struct {
// contains filtered or unexported fields
}
Applier applies patches to create trees and commits in a repository.
func NewApplier ¶
NewApplier creates a new Applier for a repository. The Applier applies changes on top of commit c.
func (*Applier) Apply ¶
Apply applies the changes in a file, adds the result to the list of pending tree entries, and returns the entry. If the application succeeds, Apply creates a blob in the repository with the modified content.
func (*Applier) Commit ¶
Commit commits the latest tree, optionally using the details in header. If there are pending tree entries, it calls CreateTree before creating the commit. If header is nil or missing fields, Commit uses a default message, the current time, and the authenticated user as needed for the commit details. Commit returns an error if there are no pending trees or tree entries.
func (*Applier) CreateTree ¶
CreateTree creates a tree from the pending tree entries and clears the entry list. The new tree serves as the base tree for future Apply calls. CreateTree returns an error if there are no pending tree entires.
type Reference ¶
type Reference struct {
// contains filtered or unexported fields
}
Reference is a named reference in a repository.
func NewReference ¶
func NewReference(client *github.Client, repo Repository, ref string) *Reference
NewReference creates a new Reference for ref in repo.
func (*Reference) PullRequest ¶
func (r *Reference) PullRequest(ctx context.Context, spec *github.NewPullRequest) (*github.PullRequest, error)
PullRequest create a new pull request for the reference. The reference must be a branch (start with "refs/heads/".) The pull request takes values from spec, except for Head, which is set to the reference.
type Repository ¶
Repository identifies a GitHub repository.
func ParseRepository ¶
func ParseRepository(s string) (Repository, error)
ParseRepository parses a Repository from a string in "owner/name" format.
func (Repository) String ¶
func (r Repository) String() string