files

package
v0.0.0-...-c25eef7 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package files handles logic for interacting with files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVersionFilesInDirectory

func GetVersionFilesInDirectory(dir string) ([]string, error)

GetVersionFilesInDirectory checks the provided directory for supported version files and returns a list of ones found.

func GetVersionFromFile

func GetVersionFromFile(dir string, inputFile string) (string, error)

GetVersionFromFile reads the version file and returns the semantic version contained.

func GetVersionFromString

func GetVersionFromString(fileName string, input string) (string, error)

GetVersionFromString handles extracting the version from an file that has already been read and is passed as a string such as when getting the contents of a file from a git branch.

func IsGitDir

func IsGitDir(dir string) (bool, error)

IsGitDir returns if the specified directory is a git dir.

func WriteVersionToFile

func WriteVersionToFile(dir string, inputFile string, newVersion string) error

WriteVersionToFile updates the version file with the provided new version value.

Types

type Error

type Error uint

Error is the error type.

const (
	// ErrNoVersionFilesInDir is the error when no version files are found.
	ErrNoVersionFilesInDir Error = iota
	// ErrMultipleVersionFiles is the error when there are multiple valid version
	// file types found in a directory.
	ErrMultipleVersionFiles
	// ErrGettingVersionFromCMakeLists is the error when the version can't be
	// found inside a CMakeLists.txt file.
	ErrGettingVersionFromCMakeLists
	// ErrGettingVersionFromBuildGradle is the error when the a version key can't
	// be found inside a build.gradle or build.gradle.kts file.
	ErrGettingVersionFromBuildGradle
	// ErrGettingVersionFromPackageJSON is the error when a version key can't be
	// found inside a package.json file.
	ErrGettingVersionFromPackageJSON
	// ErrGettingVersionFromSetupPy is the error when a version key can't be found
	// inside a setup.py file.
	ErrGettingVersionFromSetupPy
	// ErrGettingVersionFromTOML is the error when a version key can't be found
	// inside a toml file.
	ErrGettingVersionFromTOML
	// ErrGettingVersionFromVERSION is the error when the VERSION file is empty.
	ErrGettingVersionFromVERSION
)

func (Error) Error

func (e Error) Error() string

Error returns the error string for the error enum.

type VersionFileFinder

type VersionFileFinder struct {
	ErrorOnNoFilesFound bool
	FileFlag            string
	Logger              logger.Basic
	SearchDir           string
}

VersionFileFinder looks for the relevant version file based on the options specified.

func (VersionFileFinder) Find

func (v VersionFileFinder) Find() (string, error)

Find returns the version file based on the config provided.

Jump to

Keyboard shortcuts

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