Documentation ¶
Index ¶
- Constants
- func AddCleanup(f func() error)
- func Cleanup()
- func CreateContext(p models.Path) (models.NestContext, error)
- func CreateContextFromCurrentWorkingDir() (models.NestContext, error)
- func EvaluateContext() (models.NestContext, error)
- func FindProjectRoot(p models.Path) (models.Path, error)
- func FmtSubmoduleExistOutput(status int, payload string, err error) (string, error)
- func FmtSubmodulesGitIgnore(submodules []models.Submodule) string
- func HandleOsTerminationSignals(c <-chan os.Signal, callback func())
- func PathContainsUp(p models.Path) bool
- func PathOutsideRoot(root models.Path, p models.Path) bool
- func PathRelativeToRootWithJoinedOriginIfNotAbs(root models.Path, origin models.Path, p models.Path) (models.Path, error)
- func PopulateNestConfigFromToml(nestConfig *models.NestConfig, s string, strict bool) error
- func SubmoduleExists(s models.Submodule, root models.Path) (int, string, error)
- func SubmoduleStatusValid(status int) bool
- func SubmoduleToTomlConfig(s models.Submodule, indent string) string
- func SubmoduleValid(submodule models.Submodule, root models.Path) bool
- func SubmodulesToTomlConfig(indent string, submodules ...models.Submodule) string
- func ValidSubmodulesCount(submodules []models.Submodule, root models.Path) int
- func WriteNestConfig(p models.Path, modules []models.Submodule) error
- func WriteSubmoduleIgnoreConfig(p models.Path, modules []models.Submodule) error
- type LockFile
- type SubmoduleExistsMapValue
- type WriteProjectConfigFilesReturn
Constants ¶
const ( SUBMODULE_EXISTS_OK = iota SUBMODULE_EXISTS_UNDEFINED_REF SUBMODULE_EXISTS_ERR_NO_EXIST SUBMODULE_EXISTS_ERR_FILE SUBMODULE_EXISTS_ERR_NO_GIT SUBMODULE_EXISTS_ERR_REMOTE SUBMODULE_EXISTS_ERR_HEAD )
Variables ¶
This section is empty.
Functions ¶
func AddCleanup ¶ added in v0.0.2
func AddCleanup(f func() error)
AddCleanup adds a function to the cleanup stack.
func Cleanup ¶
func Cleanup()
Cleanup is responsible for cleaning up any left-over files and things. Gets called by the main function on exiting.
func CreateContext ¶
func CreateContext(p models.Path) (models.NestContext, error)
CreateContext returns a fresh evaluated models.NestContext for the passed path.
func CreateContextFromCurrentWorkingDir ¶
func CreateContextFromCurrentWorkingDir() (models.NestContext, error)
CreateContextFromCurrentWorkingDir returns a fresh evaluated models.NestContext from the current working directory.
func EvaluateContext ¶
func EvaluateContext() (models.NestContext, error)
EvaluateContext is a wrapper function for internal.CreateContext that also performs automatic validation on the context's configuration.
func FindProjectRoot ¶
FindProjectRoot takes a directory and searches this and upper directories for a `nestmodules.toml` configuration file in its root- or a `.config` subdirectory. The first directory that fits these conditions is chosen as the project root. Returns an error if no root directory found.
FindProjectRoot will not check the config file's integrity. Its existence is enough.
func FmtSubmoduleExistOutput ¶
func FmtSubmodulesGitIgnore ¶
FmtSubmodulesGitIgnore returns a string that formats a slice of models.Submodule into a string that can be used by git to ignore the submodules' paths.
func HandleOsTerminationSignals ¶
HandleOsTerminationSignals handles received system signals, calls a callback and exists.
func PathContainsUp ¶
PathContainsUp returns whether the passed models.Path contains any "..".
func PathOutsideRoot ¶
PathOutsideRoot returns whether a given path is not located within a root path. This check is purely lexical.
func PathRelativeToRootWithJoinedOriginIfNotAbs ¶
func PathRelativeToRootWithJoinedOriginIfNotAbs(root models.Path, origin models.Path, p models.Path) (models.Path, error)
PathRelativeToRootWithJoinedOriginIfNotAbs is a somewhat complicated function. It calculates the relative path between root and p if p is an absolute path. But in case p is not absolute, it is first joined on the origin path.
func PopulateNestConfigFromToml ¶
func PopulateNestConfigFromToml(nestConfig *models.NestConfig, s string, strict bool) error
PopulateNestConfigFromToml populates a models.NestConfig from a configuration in TOML's markup language.
func SubmoduleExists ¶
SubmoduleExists returns whether and in what state a possible submodule exists.
func SubmoduleStatusValid ¶ added in v0.0.2
SubmoduleStatusValid returns if a status belongs to being valid
func SubmoduleToTomlConfig ¶
SubmoduleToTomlConfig returns a configuration string in TOML's markup language for a single models.Submodule.
func SubmoduleValid ¶ added in v0.0.2
SubmoduleValid takes multiple submodules and verifies their existence in bulk
func SubmodulesToTomlConfig ¶
SubmodulesToTomlConfig returns a configuration string in TOML's markup language for more structs of type models.Submodule.
func ValidSubmodulesCount ¶ added in v0.0.2
ValidSubmodulesCount how many passed submodules are valid.
func WriteNestConfig ¶
WriteNestConfig writes models.Submodule configuration into the git-nest configuration file, preserving the first [config] section.
func WriteSubmoduleIgnoreConfig ¶
WriteSubmoduleIgnoreConfig uses internal.FmtSubmodulesGitIgnore, wraps it with some user information and writes that into the passed file. Pre-existing configuration is replaced using utils.StringInsertAtFirst.
Types ¶
type SubmoduleExistsMapValue ¶
func SubmodulesExist ¶
func SubmodulesExist(submodules []models.Submodule, root models.Path) []SubmoduleExistsMapValue
SubmodulesExist takes multiple submodules and verifies their existence in bulk
type WriteProjectConfigFilesReturn ¶ added in v0.0.2
type WriteProjectConfigFilesReturn struct { ConfigWritten bool GitExcludeWritten bool ConfigWriteError error GitExcludeWriteError error }
func WriteProjectConfigFiles ¶
func WriteProjectConfigFiles(c models.NestContext) (WriteProjectConfigFilesReturn, error)
WriteProjectConfigFiles is a total wrapper function for internal.WriteSubmoduleIgnoreConfig and internal.WriteNestConfig, calling both functions based on the passed models.NestContext.