actions

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const PRMetadataCommentEnd = "-->\n"
View Source
const PRMetadataCommentHelpText = "" /* 165-byte string literal not displayed */
View Source
const PRMetadataCommentStart = "<!-- av pr metadata\n"

Variables

This section is empty.

Functions

func AddPRMetadata added in v0.0.7

func AddPRMetadata(body string, prMeta PRMetadata) string

func Push

func Push(repo *git.Repo, opts PushOpts) error

Push pushes the current branch to the Git origin. It does not check out the given branch.

Types

type CreatePullRequestOpts

type CreatePullRequestOpts struct {
	BranchName string
	Title      string
	Body       string

	// If true, create the pull request as a GitHub draft PR.
	Draft bool
	// If true, do not push the branch to GitHub
	NoPush bool
	// If true, force push the branch to GitHub
	ForcePush bool
	// If true, create a PR even if we think one already exists
	Force bool
}

type CreatePullRequestResult added in v0.0.6

type CreatePullRequestResult struct {
	// True if the pull request was created
	Created bool
	// The (updated) branch metadata.
	Branch meta.Branch
	// The pull request object that was returned from GitHub
	Pull *gh.PullRequest
}

func CreatePullRequest

func CreatePullRequest(ctx context.Context, repo *git.Repo, client *gh.Client, opts CreatePullRequestOpts) (*CreatePullRequestResult, error)

CreatePullRequest creates a pull request on GitHub for the current branch, if one doesn't already exist.

type ForceOpt

type ForceOpt int
const (
	NoForce ForceOpt = iota
	// ForceWithLease indicates that the push should use the --force-with-lease
	// option which instructs Git that it should only force push to the remote
	// branch if its current HEAD matches what we think it should be.
	ForceWithLease ForceOpt = iota
	ForcePush      ForceOpt = iota
)

type PRMetadata added in v0.0.7

type PRMetadata struct {
	Parent     string `json:"parent"`
	ParentHead string `json:"parentHead"`
	ParentPull int64  `json:"parentPull,omitempty"`
	Trunk      string `json:"trunk"`
}

func ParsePRMetadata added in v0.0.7

func ParsePRMetadata(input string) (commentStart int, commentEnd int, prMeta PRMetadata, reterr error)

func ReadPRMetadata added in v0.0.7

func ReadPRMetadata(body string) (PRMetadata, error)

type PushOpts

type PushOpts struct {
	Force ForceOpt
	// If true, require the upstream tracking information to already be set
	// (otherwise, don't push).
	SkipIfUpstreamNotSet bool
	// If true, skip pushing the branch if the upstream commit is the same as
	// the local HEAD commit. The caller should probably call `git fetch` before
	// running this to make sure remote tracking information is up-to-date.
	SkipIfUpstreamMatches bool
}

type ReparentOpts added in v0.0.5

type ReparentOpts struct {
	// The name of the branch to re-parent.
	Branch string
	// The new parent branch to re-parent the branch to.
	NewParent string
	// If true, consider the NewParent a trunk branch.
	NewParentTrunk bool
}

type ReparentResult added in v0.0.4

type ReparentResult struct {
	Success bool
	Hint    string
}

func Reparent added in v0.0.4

func Reparent(repo *git.Repo, opts ReparentOpts) (*ReparentResult, error)

Reparent changes the parent branch of a stacked branch (performing a rebase if necessary).

func ReparentContinue added in v0.0.4

func ReparentContinue(repo *git.Repo, opts ReparentOpts) (*ReparentResult, error)

type SyncBranchContinuation added in v0.0.8

type SyncBranchContinuation struct {
	// The original HEAD commit of the branch.
	OldHead string `json:"oldHead"`
	// The commit that we were rebasing the branch on top of.
	ParentCommit string `json:"parentCommit"`

	// If set, we need to re-assign the branch to be a stack root that is
	// based on this trunk branch.
	NewTrunk string `json:"newTrunk,omitempty"`
}

type SyncBranchOpts added in v0.0.8

type SyncBranchOpts struct {
	Branch  string
	NoFetch bool
	NoPush  bool
	// If specified, synchronize the branch against the latest version of the
	// trunk branch. This value is ignored if the branch is not a stack root.
	ToTrunk bool

	Continuation *SyncBranchContinuation
}

type SyncBranchResult added in v0.0.8

type SyncBranchResult struct {
	git.RebaseResult

	// If set, the sync needs to be continued.
	// This is set if and only if RebaseResult.Status is RebaseConflict
	Continuation *SyncBranchContinuation

	// The updated branch metadata (if the rebase was successful)
	Branch meta.Branch
}

func SyncBranch added in v0.0.8

func SyncBranch(
	ctx context.Context, repo *git.Repo, client *gh.Client,
	repoMeta meta.Repository, opts SyncBranchOpts,
) (*SyncBranchResult, error)

SyncBranch synchronizes a branch with its parent.

type UpdatePullRequestResult added in v0.0.4

type UpdatePullRequestResult struct {
	// True if the pull request information changed (e.g., a new pull request
	// was found or if the pull request changed state)
	Changed bool
	// The (updated) branch metadata.
	Branch meta.Branch
	// The pull request object that was returned from GitHub
	Pull *gh.PullRequest
}

func UpdatePullRequestState added in v0.0.4

func UpdatePullRequestState(ctx context.Context, repo *git.Repo, client *gh.Client, repoMeta meta.Repository, branchName string) (*UpdatePullRequestResult, error)

UpdatePullRequestState fetches the latest pull request information from GitHub and writes the relevant branch metadata.

Jump to

Keyboard shortcuts

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