internal

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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

func FindProjectRoot(p models.Path) (models.Path, error)

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 FmtSubmoduleExistOutput(status int, payload string, err error) (string, error)

func FmtSubmodulesGitIgnore

func FmtSubmodulesGitIgnore(submodules []models.Submodule) string

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

func HandleOsTerminationSignals(c <-chan os.Signal, callback func())

HandleOsTerminationSignals handles received system signals, calls a callback and exists.

func PathContainsUp

func PathContainsUp(p models.Path) bool

PathContainsUp returns whether the passed models.Path contains any "..".

func PathOutsideRoot

func PathOutsideRoot(root models.Path, p models.Path) bool

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

func SubmoduleExists(s models.Submodule, root models.Path) (int, string, error)

SubmoduleExists returns whether and in what state a possible submodule exists.

func SubmoduleStatusValid added in v0.0.2

func SubmoduleStatusValid(status int) bool

SubmoduleStatusValid returns if a status belongs to being valid

func SubmoduleToTomlConfig

func SubmoduleToTomlConfig(s models.Submodule, indent string) string

SubmoduleToTomlConfig returns a configuration string in TOML's markup language for a single models.Submodule.

func SubmoduleValid added in v0.0.2

func SubmoduleValid(submodule models.Submodule, root models.Path) bool

SubmoduleValid takes multiple submodules and verifies their existence in bulk

func SubmodulesToTomlConfig

func SubmodulesToTomlConfig(indent string, submodules ...models.Submodule) string

SubmodulesToTomlConfig returns a configuration string in TOML's markup language for more structs of type models.Submodule.

func ValidSubmodulesCount added in v0.0.2

func ValidSubmodulesCount(submodules []models.Submodule, root models.Path) int

ValidSubmodulesCount how many passed submodules are valid.

func WriteNestConfig

func WriteNestConfig(p models.Path, modules []models.Submodule) error

WriteNestConfig writes models.Submodule configuration into the git-nest configuration file, preserving the first [config] section.

func WriteSubmoduleIgnoreConfig

func WriteSubmoduleIgnoreConfig(p models.Path, modules []models.Submodule) error

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 LockFile added in v0.0.2

type LockFile struct {
	// contains filtered or unexported fields
}

func CreateLockFile added in v0.0.2

func CreateLockFile(p models.Path) (LockFile, error)

func (*LockFile) Release added in v0.0.2

func (l *LockFile) Release() error

type SubmoduleExistsMapValue

type SubmoduleExistsMapValue struct {
	Status  int
	Payload string
	Error   error
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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