git

package
v0.0.0-...-703489d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeCommit

func MakeCommit(gi Info, message string, dryrun bool) (bool, error)

MakeCommit adds the changed files and create a new Git commit.

func ReleaseBranchVersion

func ReleaseBranchVersion(v semver.Version) string

ReleaseBranchVersion returns a formatted release branch for a given version.

func ReleaseVersion

func ReleaseVersion(v semver.Version) string

ReleaseVersion returns a formatted release tag for a given version.

func Rulesets

func Rulesets() []string

Rulesets returns the valid strings to use to parse into a RulesetType.

Types

type Info

type Info struct {
	Org      string
	Repo     string
	Head     string // PR head branch
	Base     string // PR base branch
	UserID   string // Github User ID of PR creator
	UserName string // User display name for Git commit
	Email    string // User email address for Git commit
}

Info saves information that can be used to interact with GitHub.

func (*Info) GetHeadRef

func (gi *Info) GetHeadRef() string

GetHeadRef returns the HeadRef with the given Git Info. HeadRef is in the form of "user:head", i.e. "github_user:branch_foo"

type RefType

type RefType int
const (
	// BranchRef - branch
	BranchRef RefType = iota
	// DefaultBranchRef - default branch
	DefaultBranchRef
	// ReleaseBranchRef - release branch
	ReleaseBranchRef
	// ReleaseRef - tagged release
	ReleaseRef
	// NoRef - ref not found
	NoRef
	// UndefinedRef is not defined
	UndefinedRef
)

func ParseRef

func ParseRef(ref string) (string, string, RefType)

ParseRef takes a go module ref and converts it to the module name and RefType. ParseRef expects ref to be in the form "module@ref". Only release branches and

func (RefType) String

func (rt RefType) String() string

String returns the string of RefType in human readable form.

type Repo

type Repo struct {
	Ref           string
	DefaultBranch string
	Tags          []string
	Branches      []string
}

Repo is a simplified git remote, containing only the list of tags, default branch and branches.

func GetRepo

func GetRepo(ref, url string) (*Repo, error)

GetRepo will fetch a git repo and process it into a Repo object.

func (*Repo) BestRefFor

func (r *Repo) BestRefFor(release, moduleRelease semver.Version, ruleset RulesetType) (string, RefType)

BestRefFor Returns module@ref, isRelease based on the provided ruleset for a this release.

type RulesetType

type RulesetType int

RulesetType defines the rules to use for calculating repo.BestRefFor.

const (
	// AnyRule - release tag, release branch, or default branch
	AnyRule RulesetType = iota
	// ReleaseOrReleaseBranchRule - only release tag or release branch
	ReleaseOrReleaseBranchRule
	// ReleaseRule - only release tag
	ReleaseRule
	// ReleaseBranchRule - only release branch
	ReleaseBranchRule
	// InvalidRule - unable to parse
	InvalidRule
)

func Ruleset

func Ruleset(rule string) RulesetType

Ruleset converts a rule string into a RulesetType.

func (RulesetType) String

func (rt RulesetType) String() string

String returns the string represented by the Ruleset.

Jump to

Keyboard shortcuts

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