Documentation ¶
Overview ¶
Package common provides helper functions for reading and parsing Module versioning files, as well as common functions used by multiple commands in the Cobra application.
Index ¶
- Constants
- func CommitChanges(commitMessage string, repo *git.Repository, customAuthor *object.Signature) (plumbing.Hash, error)
- func CommitChangesToNewBranch(branchName string, commitMessage string, repo *git.Repository, ...) (plumbing.Hash, error)
- func GetAllModuleSetNames(versioningFile string, repoRoot string) ([]string, error)
- func GetWorktree(repo *git.Repository) (*git.Worktree, error)
- func IsStableVersion(v string) bool
- func RunGoModTidy(modPathMap ModulePathMap) error
- func UpdateGoModFiles(modFilePaths []ModuleFilePath, newModPaths []ModulePath, newVersion string) error
- func VerifyWorkingTreeClean(repo *git.Repository) error
- type ErrGitTagsAlreadyExist
- type ErrInconsistentGitTagsExist
- type ModuleFilePath
- type ModuleInfo
- type ModuleInfoMap
- type ModulePath
- type ModulePathMap
- type ModuleSet
- type ModuleSetMap
- type ModuleSetRelease
- type ModuleTagName
- type ModuleVersioning
Constants ¶
const ( SemverRegexNumberOnly = `` /* 177-byte string literal not displayed */ SemverRegex = `v` + SemverRegexNumberOnly )
const (
RepoRootTag = ModuleTagName("REPOROOTTAG")
)
Variables ¶
This section is empty.
Functions ¶
func CommitChanges ¶
func CommitChangesToNewBranch ¶
func CommitChangesToNewBranch(branchName string, commitMessage string, repo *git.Repository, customAuthor *object.Signature) (plumbing.Hash, error)
CommitChangesToNewBranch creates a new branch, commits to it, and returns to the original worktree.
func GetAllModuleSetNames ¶
GetAllModuleSetNames returns the name of all module sets given in a versioningFile.
func GetWorktree ¶
func GetWorktree(repo *git.Repository) (*git.Worktree, error)
GetWorktree returns the worktree of a repo.
func IsStableVersion ¶
IsStableVersion returns true if modSet.Version is stable (i.e. version major greater than or equal to v1), else false.
func RunGoModTidy ¶
func RunGoModTidy(modPathMap ModulePathMap) error
RunGoModTidy takes a ModulePathMap and runs "go mod tidy" at each module file path.
func UpdateGoModFiles ¶
func UpdateGoModFiles(modFilePaths []ModuleFilePath, newModPaths []ModulePath, newVersion string) error
UpdateGoModFiles updates the go.mod files in modFilePaths by updating all modules listed in newModPaths to use the newVersion given.
func VerifyWorkingTreeClean ¶
func VerifyWorkingTreeClean(repo *git.Repository) error
VerifyWorkingTreeClean returns nil if the working tree is clean or an error if not.
Types ¶
type ErrGitTagsAlreadyExist ¶
type ErrGitTagsAlreadyExist struct {
// contains filtered or unexported fields
}
func (ErrGitTagsAlreadyExist) Error ¶
func (e ErrGitTagsAlreadyExist) Error() string
type ErrInconsistentGitTagsExist ¶
type ErrInconsistentGitTagsExist struct {
// contains filtered or unexported fields
}
func (ErrInconsistentGitTagsExist) Error ¶
func (e ErrInconsistentGitTagsExist) Error() string
type ModuleFilePath ¶
type ModuleFilePath string
ModuleFilePath holds the file path to the go.mod file within the repo, including the base file name ("go.mod").
type ModuleInfo ¶
ModuleInfo is a reverse of the ModuleSetMap, to allow for quick lookup from module path to its set and version.
type ModuleInfoMap ¶
type ModuleInfoMap map[ModulePath]ModuleInfo
ModuleInfoMap is a mapping from a module's import path to its ModuleInfo struct.
type ModulePath ¶
type ModulePath string
ModulePath holds the module import path, such as "go.opentelemetry.io/otel".
type ModulePathMap ¶
type ModulePathMap map[ModulePath]ModuleFilePath
ModulePathMap is a mapping from a module's import path to its file path.
type ModuleSet ¶
type ModuleSet struct { Version string `mapstructure:"version"` Modules []ModulePath `mapstructure:"modules"` }
ModuleSet holds the version that the specified modules within the set will have.
func GetModuleSet ¶
type ModuleSetMap ¶
ModuleSetMap maps the name of a module set to a ModuleSet struct.
type ModuleSetRelease ¶
type ModuleSetRelease struct { ModuleVersioning ModSetName string ModSet ModuleSet TagNames []ModuleTagName }
ModuleSetRelease contains info about a specific set of modules in the versioning file to be updated.
func NewModuleSetRelease ¶
func NewModuleSetRelease(versioningFilename, modSetToUpdate, repoRoot string) (ModuleSetRelease, error)
NewModuleSetRelease returns a ModuleSetRelease struct by specifying a specific set of modules to update.
func (ModuleSetRelease) CheckGitTagsAlreadyExist ¶
func (modRelease ModuleSetRelease) CheckGitTagsAlreadyExist(repo *git.Repository) error
CheckGitTagsAlreadyExist checks if Git tags have already been created that match the specific module tag name and version number for the modules being updated. If the tag already exists, an error is returned.
func (ModuleSetRelease) ModSetPaths ¶
func (modRelease ModuleSetRelease) ModSetPaths() []ModulePath
ModSetPaths gets the import paths of all modules in the module set to update.
func (ModuleSetRelease) ModSetVersion ¶
func (modRelease ModuleSetRelease) ModSetVersion() string
ModSetVersion gets the version of the module set to update.
func (ModuleSetRelease) ModuleFullTagNames ¶
func (modRelease ModuleSetRelease) ModuleFullTagNames() []string
ModuleFullTagNames gets the full tag names (including the version) of all modules in the module set to update.
type ModuleTagName ¶
type ModuleTagName string
ModuleTagName is the simple file path to the directory of a go.mod file used for Git tagging. For example, the opentelemetry-go/sdk/metric/go.mod file will have a ModuleTagName "sdk/metric".
func ModulePathsToTagNames ¶
func ModulePathsToTagNames(modPaths []ModulePath, modPathMap ModulePathMap, repoRoot string) ([]ModuleTagName, error)
ModulePathsToTagNames returns a list of tag names from a list of module's import paths.
type ModuleVersioning ¶
type ModuleVersioning struct { ModSetMap ModuleSetMap ModPathMap ModulePathMap ModInfoMap ModuleInfoMap }
ModuleVersioning holds info about modules listed in a versioning file.
func NewModuleVersioning ¶
func NewModuleVersioning(versioningFilename string, repoRoot string) (ModuleVersioning, error)
NewModuleVersioning returns a ModuleVersioning struct from a versioning file and repo root.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package commontest provides exported shared helper functions for testing.
|
Package commontest provides exported shared helper functions for testing. |