utils

package
v0.0.0-...-3133d3c Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const Separator = string(filepath.Separator)

Variables

View Source
var (
	ErrApplicationNotFound = errors.New("application not found")
)

Functions

func Copy

func Copy(ctx context.Context, src, targetDir string) error

func CreateGithubPullRequest

func CreateGithubPullRequest(ctx context.Context, repoDir string, title string) error

func ExecuteQuietPathApplicationWithOutput

func ExecuteQuietPathApplicationWithOutput(ctx context.Context, workingDir, cmd string, args ...string) (lines []string, err error)

ExecuteQuietPathApplicationWithOutput executes a linux/windows command

func Exists

func Exists(filePath string) (fs.FileInfo, bool, error)

func FindGitDirs

func FindGitDirs(rootPath string) ([]string, error)

func FindGoRepoDirs

func FindGoRepoDirs(rootPath string) ([]string, error)

FindGoRepoDirs returns the parent directories of all found Go repo directories which are also git directories.

func FindRepoDirs

func FindRepoDirs(rootPath string) ([]string, error)

func GitAddAll

func GitAddAll(ctx context.Context, repoDir string) error

func GitBumpVersionTag

func GitBumpVersionTag(ctx context.Context, repoDir, remoteName string, major, minor, patch bool) (err error)

Creates a new local version tag BUT does NOT push it. Use GitPushTags(ctx, repoDir, remoteName) to also push the tag to the origin

func GitChangeRemoteUrl

func GitChangeRemoteUrl(ctx context.Context, repoDir, remoteName, targetUrl string) error

func GitCheckRemoteUrl

func GitCheckRemoteUrl(ctx context.Context, repoDir, targetUrl string) error

func GitCheckoutBranch

func GitCheckoutBranch(ctx context.Context, repoDir string, targetBranch string) error

func GitCheckoutNewBranch

func GitCheckoutNewBranch(ctx context.Context, repoDir string, targetBranch string) (err error)

func GitCommit

func GitCommit(ctx context.Context, repoDir string, message string) error

func GitCreateTag

func GitCreateTag(ctx context.Context, repoDir, tagName string) (err error)

func GitDeleteBranch

func GitDeleteBranch(ctx context.Context, repoDir string, targetBranch string) error

func GitDeleteRemoteBranch

func GitDeleteRemoteBranch(ctx context.Context, repoDir string, remoteName, targetBranch string) error

func GitExistsBranch

func GitExistsBranch(ctx context.Context, repoDir, branchName string) bool

func GitFetchPrune

func GitFetchPrune(ctx context.Context, repoDir string) error

func GitGetBranchName

func GitGetBranchName(ctx context.Context, repoDir string) (branch string, err error)

func GitGetDefaultBranch

func GitGetDefaultBranch(ctx context.Context, repoDir, remoteName string) (branchName string, err error)

func GitGetLatestTag

func GitGetLatestTag(ctx context.Context, repoDir string) (version semver.Version, err error)

func GitPull

func GitPull(ctx context.Context, repoDir string) error

func GitPullPrune

func GitPullPrune(ctx context.Context, repoDir string) error

GitPullPrune removes everything that does not exist in the remote repo

func GitPushTags

func GitPushTags(ctx context.Context, repoDir, remoteName string) (err error)

func GitPushUpstream

func GitPushUpstream(ctx context.Context, repoDir string, remoteName, targetBranch string) error

func GitRefreshIndex

func GitRefreshIndex(ctx context.Context, repoDir string) error

func GitRemoteUrl

func GitRemoteUrl(ctx context.Context, repoDir, remoteName string) (url string, err error)

func GoBuildAll

func GoBuildAll(ctx context.Context, repoDir string) error

func GoFmt

func GoFmt(ctx context.Context, repoDir string) error

func GoGet

func GoGet(ctx context.Context, repoDir string, dependency string) error

func GoModTidy

func GoModTidy(ctx context.Context, repoDir string) error

func IsApplicationAvailable

func IsApplicationAvailable(ctx context.Context, name string) bool

func NewReplacer

func NewReplacer(m map[string]string) *strings.Replacer

func NewUpdatedVersion

func NewUpdatedVersion(versionStr string, major, minor, patch bool) (semver.Version, error)

func NewVersion

func NewVersion(v string) (version semver.Version, err error)

func ReplaceInDir

func ReplaceInDir(rootPath string, exclude, include []*regexp.Regexp, replacer *strings.Replacer) ([]string, error)

func StripUnsafe

func StripUnsafe(s string) string

StripUnsafe remove non-printable runes, e.g. control characters in a string that is meant for consumption by terminals that support control characters.

func ToModuleUrl

func ToModuleUrl(gitUrl string) (string, error)

func WalkMatching

func WalkMatching(rootPath string, exclude, include []*regexp.Regexp, walk filepath.WalkFunc) error

Types

type ErrExec

type ErrExec struct {
	ExitCode  int
	Output    string
	ErrOutput string
	Cmd       string
	Args      []string

	// Optional Error Code which might be provided by Windows
	SubExitCode int
}

func (ErrExec) Error

func (e ErrExec) Error() string

Jump to

Keyboard shortcuts

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