patch

package
v0.6.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoPatches = errors.New("no patches configured for repository")
)

Functions

func Apply

func Apply(repoDir string, patch config.PackageRepoPatch, tmplCtx config.TemplateContext) error

Apply applies a single patch to the repository.

func ApplyMany

func ApplyMany(repoDir string, patches []config.PackageRepoPatch, tmplCtx config.TemplateContext) error

ApplyMany applies a series of patches in sequence using Apply.

Types

type Patcher

type Patcher struct {
	// contains filtered or unexported fields
}

Patcher is the manager for managing repositories and patching them, as well as pushing the changes in form of GitHub pull requests.

This is the main integration code between the other packages.

func New

func New(cfg *config.Config) (Patcher, error)

New creates a new Patcher using a base config.

func (Patcher) CloneAndPublishAll

func (p Patcher) CloneAndPublishAll(pkgRepos []config.PackageRepo, tmplCtx config.TemplateContext) ([]github.PullRequest, error)

CloneAndPublishAll will clone a list of Git repository, apply all the configured patches, and then publish the changes in the form of GitHub pull requests.

func (Patcher) CloneAndPublishRepo

func (p Patcher) CloneAndPublishRepo(pkgRepo config.PackageRepo, tmplCtx config.TemplateContext) (github.PullRequest, error)

CloneAndPublishRepo will clone a Git repository, apply all the configured patches, and then publish the changes in the form of a GitHub pull requests.

func (Patcher) CloneRepo

func (p Patcher) CloneRepo(remote string, tmplCtx config.TemplateContext) (*Repo, error)

CloneRepo will download a Git repository from GitHub using the configured credentials. It is cloned using HTTPS instead of SSH.

func (Patcher) CloneWithConfig added in v0.5.0

func (p Patcher) CloneWithConfig(cfg *config.Config) Patcher

CloneWithConfig creates a copy of this object, but with a new config.Config applied. Useful if you want to change just a few fields, such as the dry-run setting, while still reusing the GitHub App cache.

func (Patcher) TestGitHubConnection

func (p Patcher) TestGitHubConnection(ctx context.Context) error

TestGitHubConnection is practically a ping towards GitHub, to ensure the credentials from the config are working.

type Repo

type Repo struct {
	// contains filtered or unexported fields
}

Repo is an object to manage patches for a single repository. It is obtained from the Patcher object.

func (*Repo) ApplyManyAndCommit

func (p *Repo) ApplyManyAndCommit(patches []config.PackageRepoPatch) (git.Commit, error)

ApplyManyAndCommit uses [ApplyManyInNewBranch] to apply a series of patches in a new Git branch, followed by creating a Git commit.

func (*Repo) ApplyManyInNewBranch

func (p *Repo) ApplyManyInNewBranch(patches []config.PackageRepoPatch) error

ApplyManyInNewBranch creates a new Git branch and then applies multiple patches in series using ApplyMany.

func (*Repo) Close

func (p *Repo) Close() error

Close cleans up the Git repository by removing the entire directory.

func (*Repo) PublishChanges

func (p *Repo) PublishChanges(commit git.Commit) (github.PullRequest, error)

PublishChanges will push the current Git branch to the remote, and then create a GitHub pull request.

func (*Repo) PublishChangesUnlessDryRun

func (p *Repo) PublishChangesUnlessDryRun(commit git.Commit) (github.PullRequest, error)

PublishChangesUnlessDryRun calls [PublishChanges], unless dry-run is set in the configs.

If dry-run is enabled, then this function templates all PR fields (title, description, etc), and then returns it as-is without pushing anything to the Git remote.

func (*Repo) TemplateNewPullRequest added in v0.5.0

func (p *Repo) TemplateNewPullRequest(commit git.Commit) (github.NewPullRequest, error)

TemplateNewPullRequest will template using text/template the pull request fields (title, description, etc), based on what's set in the config.

Directories

Path Synopsis
Package filestore contains a simple and minimal abstraction over OS operations for reading and writing to files.
Package filestore contains a simple and minimal abstraction over OS operations for reading and writing to files.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL