meta

package
v0.0.17 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChildrenNames added in v0.0.16

func ChildrenNames(tx ReadTx, name string) []string

func PreviousBranches added in v0.0.6

func PreviousBranches(tx ReadTx, name string) ([]string, error)

PreviousBranches finds all the ancestor branches of the given branch name in "dependency order" (i.e., A comes before B if A is an ancestor of B).

func Root added in v0.0.17

func Root(tx ReadTx, name string) (string, bool)

Root determines the stack root of a branch.

func SubsequentBranches added in v0.0.6

func SubsequentBranches(tx ReadTx, name string) []string

SubsequentBranches finds all the child branches of the given branch name in "dependency order" (i.e., A comes before B if A is an ancestor of B). If the tree is not a straight line (which isn't explicitly supported!), the branches will be returned in depth-first traversal order.

func Trunk added in v0.0.7

func Trunk(tx ReadTx, name string) (string, bool)

Trunk determines the trunk of a branch.

Types

type Branch

type Branch struct {
	// The branch name associated with this stack.
	// Not stored in JSON because the name can always be derived from the name
	// of the git ref.
	Name string `json:"name"`

	// Information about the parent branch.
	Parent BranchState `json:"parent,omitempty"`

	// The associated pull request information, if any.
	PullRequest *PullRequest `json:"pullRequest,omitempty"`

	// The merge commit onto the trunk branch, if any
	MergeCommit string `json:"mergeCommit,omitempty"`
}

func Children added in v0.0.16

func Children(tx ReadTx, name string) []Branch

Children returns all the immediate children of the given branch.

func (*Branch) IsStackRoot added in v0.0.5

func (b *Branch) IsStackRoot() bool

func (*Branch) UnmarshalJSON added in v0.0.5

func (b *Branch) UnmarshalJSON(bytes []byte) error

type BranchState added in v0.0.5

type BranchState struct {
	// The branch name associated with the parent of the stack (if any).
	// If empty, this branch (potentially*) is considered a stack root.
	// (*depending on the context, we only consider the branch a stack root if
	// it also has children branches; for example, any "vanilla" branch off of
	// trunk will have no parent, but we usually don't explicitly consider it a
	// stack unless it also has stack children)
	Name string `json:"name"`

	// If true, consider the branch a trunk branch. A trunk branch is one that
	// that stacks can target for merge. Usually, the only trunk branch for a
	// repository is main or master.
	Trunk bool `json:"trunk,omitempty"`

	// The commit SHA of the parent's latest commit. This is used when syncing
	// the branch with the parent to identify the commits that belong to the
	// child branch (since the HEAD of the parent branch may change).
	// This will be unset if Trunk is true.
	Head string `json:"head,omitempty"`
}

type DB added in v0.0.15

type DB interface {
	ReadTx() ReadTx
	WriteTx() WriteTx
}

type PullRequest

type PullRequest struct {
	// The GitHub (GraphQL) ID of the pull request.
	ID string `json:"id"`
	// The pull request number.
	Number int64 `json:"number"`
	// The web URL for the pull request.
	Permalink string `json:"permalink"`
	// The state of the pull request (open, closed, or merged).
	State githubv4.PullRequestState `json:"state"`
}

func (*PullRequest) GetNumber added in v0.0.8

func (p *PullRequest) GetNumber() int64

GetNumber returns the number of the pull request or zero if the PullRequest is nil.

type ReadTx added in v0.0.15

type ReadTx interface {
	// Repository returns the repository information.
	Repository() (Repository, bool)
	// Branch returns the branch with the given name. If no such branch exists,
	// the second return value is false.
	Branch(name string) (Branch, bool)
	// AllBranches returns a map of all branches in the database.
	AllBranches() map[string]Branch
}

ReadTx is a transaction that can be used to read from the database. It presents a consistent view of the underlying database.

type Repository

type Repository struct {
	// The GitHub (GraphQL) ID of the repository (e.g., R_kgDOHMmHmg).
	ID string `json:"id"`
	// The owner of the repository (e.g., aviator-co)
	Owner string `json:"owner"`
	// The name of the repository (e.g., av)
	Name string `json:"name"`
}

type WriteTx added in v0.0.15

type WriteTx interface {
	ReadTx
	// Abort finalizes the transaction without committing any changes.
	// Abort can be called even after the transaction has been finalized (which
	// is effectively a no-op).
	Abort()
	// Commit finalizes the transaction and commits all changes.
	// If an error is returned, the data could not be committed.
	// Commit will panic if called after the transaction has been finalized.
	Commit() error
	// SetBranch sets the given branch in the database.
	SetBranch(branch Branch)
	// DeleteBranch deletes the given branch in the database.
	DeleteBranch(name string)
	// SetRepository sets the repository information in the database.
	SetRepository(repository Repository)
}

WriteTx is a transaction that can be used to modify the database. The transaction MUST be finalized by calling either Abort or Commit.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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