bumper

package
v0.0.0-...-37c3036 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(stdout, stderr io.Writer, cmd string, args []string, opts ...CallOption) error

func GitCommitAndPush

func GitCommitAndPush(remote, remoteBranch, name, email, message string, stdout, stderr io.Writer, dryrun bool) error

GitCommitAndPush runs a sequence of git commands to commit. The "name", "email", and "message" are used for git-commit command

func GitCommitSignoffAndPush

func GitCommitSignoffAndPush(remote, remoteBranch, name, email, message string, stdout, stderr io.Writer, signoff bool, dryrun bool) error

GitCommitSignoffAndPush runs a sequence of git commands to commit with optional signoff for the commit. The "name", "email", and "message" are used for git-commit command

func GitHash

func GitHash(hashing string) string

func GitPush

func GitPush(remote, remoteBranch string, stdout, stderr io.Writer, workingDir string, opts ...CallOption) error

GitPush push the changes to the given remote and branch.

func HasChanges

func HasChanges() (bool, error)

HasChanges checks if the current git repo contains any changes

func MakeGitCommit

func MakeGitCommit(remote, remoteBranch, name, email string, stdout, stderr io.Writer, summary string, dryrun bool) error

MakeGitCommit runs a sequence of git commands to commit and push the changes the "remote" on "remoteBranch" "name" and "email" are used for git-commit command "images" contains the tag replacements that have been made which is returned from "updateReferences([]string{"."}, extraFiles)" "images" is used to generate commit message

func MinimalGitPush

func MinimalGitPush(remote, remoteBranch string, stdout, stderr io.Writer, dryrun bool, opts ...CallOption) error

MinimalGitPush pushes the content of the local repository to the remote, checking to make sure that there are real changes that need updating by diffing the tree refs, ensuring that no metadata-only pushes occur, as those re-trigger tests, remove LGTM, and cause churn whithout changing the content being proposed in the PR.

func Run

func Run(ctx context.Context, o *Options, prh PRHandler) error

Run is the entrypoint which will update Prow config files based on the provided options.

updateFunc: a function that returns commit message and error

func UpdatePR

func UpdatePR(gc github.Client, org, repo string, extraLineInPRBody, login, baseBranch, headBranch string, allowMods bool, summary, body string) error

UpdatePR updates with github client "gc" the PR of github repo org/repo with headBranch from "source" to "baseBranch" "images" contains the tag replacements that have been made which is returned from "updateReferences([]string{"."}, extraFiles)" "images" and "extraLineInPRBody" are used to generate commit summary and body of the PR

func UpdatePullRequest

func UpdatePullRequest(gc github.Client, org, repo, title, body, source, baseBranch, headBranch string, allowMods bool, dryrun bool) error

UpdatePullRequest updates with github client "gc" the PR of github repo org/repo with "title" and "body" of PR matching author and headBranch from "source" to "baseBranch"

func UpdatePullRequestWithLabels

func UpdatePullRequestWithLabels(gc github.Client, org, repo, title, body, source, baseBranch,
	headBranch string, allowMods bool, labels []string, dryrun bool) error

UpdatePullRequestWithLabels updates with github client "gc" the PR of github repo org/repo with "title" and "body" of PR matching author and headBranch from "source" to "baseBranch" with labels

Types

type CallOption

type CallOption func(*callOptions)

func WithContext

func WithContext(ctx context.Context) CallOption

func WithDir

func WithDir(dir string) CallOption

type Gerrit

type Gerrit struct {
	// Unique tag in commit messages to identify a Gerrit bump CR. Required if using gerrit
	AutobumpPRIdentifier string `json:"autobumpPRIdentifier"`
	// Gerrit CR Author. Only Required if using gerrit
	Author string `json:"author"`
	// Email account associated with gerrit author. Only required if using gerrit.
	Email string `json:"email"`
	// The path to the Gerrit httpcookie file. Only Required if using gerrit
	CookieFile string `json:"cookieFile"`
	// The path to the hosted Gerrit repo
	HostRepo string `json:"hostRepo"`
}

Information needed for gerrit bump

type GitAuthorOptions

type GitAuthorOptions struct {
	GitName  string
	GitEmail string
}

GitAuthorOptions is specifically to read the author info for a commit

func (*GitAuthorOptions) AddFlags

func (o *GitAuthorOptions) AddFlags(fs *flag.FlagSet)

AddFlags will read the author info from the command line parameters

func (*GitAuthorOptions) Validate

func (o *GitAuthorOptions) Validate() error

Validate will validate the input GitAuthorOptions

type GitCommand

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

GitCommand is used to pass the various components of the git command which needs to be executed

func (GitCommand) Call

func (gc GitCommand) Call(stdout, stderr io.Writer, opts ...CallOption) error

Call will execute the Git command and switch the working directory if specified

type HideSecretsWriter

type HideSecretsWriter struct {
	Delegate io.Writer
	Censor   func(content []byte) []byte
}

func (HideSecretsWriter) Write

func (w HideSecretsWriter) Write(content []byte) (int, error)

type Options

type Options struct {
	// The target GitHub org name where the autobump PR will be created. Only required when SkipPullRequest is false.
	GitHubOrg string `json:"gitHubOrg"`
	// The target GitHub repo name where the autobump PR will be created. Only required when SkipPullRequest is false.
	GitHubRepo string `json:"gitHubRepo"`
	// The name of the branch in the target GitHub repo on which the autobump PR will be based.  If not specified, will be autodetected via GitHub API.
	GitHubBaseBranch string `json:"gitHubBaseBranch"`
	// The GitHub username to use. If not specified, uses values from the user associated with the access token.
	GitHubLogin string `json:"gitHubLogin"`
	// The path to the GitHub token file. Only required when SkipPullRequest is false.
	GitHubToken string `json:"gitHubToken"`
	// The name to use on the git commit. Only required when GitEmail is specified and SkipPullRequest is false. If not specified, uses values from the user associated with the access token
	GitName string `json:"gitName"`
	// The email to use on the git commit. Only required when GitName is specified and SkipPullRequest is false. If not specified, uses values from the user associated with the access token.
	GitEmail string `json:"gitEmail"`
	// AssignTo specifies who to assign the created PR to. Takes precedence over onCallAddress and onCallGroup if set.
	AssignTo string `json:"assign_to"`
	// Whether to skip creating the pull request for this bump.
	SkipPullRequest bool `json:"skipPullRequest"`
	// Whether to signoff the commits.
	Signoff bool `json:"signoff"`
	// Information needed to do a gerrit bump. Do not include if doing github bump
	Gerrit *Gerrit `json:"gerrit"`
	// The name used in the address when creating remote. This should be the same name as the fork. If fork does not exist this will be the name of the fork that is created.
	// If it is not the same as the fork, the robot will change the name of the fork to this. Format will be git@github.com:{GitLogin}/{RemoteName}.git
	RemoteName string `json:"remoteName"`
	// The name of the branch that will be used when creating the pull request. If unset, defaults to "autobump".
	HeadBranchName string `json:"headBranchName"`
	// Optional list of labels to add to the bump PR
	Labels []string `json:"labels"`
}

Options is the options for autobumper operations.

type PRHandler

type PRHandler interface {
	// Changes returns a slice of functions, each one does some stuff, and
	// returns commit message for the changes
	Changes() []func(context.Context) (string, error)
	// PRTitleBody returns the body of the PR, this function runs after all
	// changes have been executed
	PRTitleBody() (string, string)
}

PRHandler is the interface implemented by consumer of prcreator, for manipulating the repo, and provides commit messages, PR title and body.

Jump to

Keyboard shortcuts

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