models

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: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NO_EXIST = iota
	FILE     = iota
	DIR      = iota
)

Variables

This section is empty.

Functions

func CheckForDuplicateSubmodules

func CheckForDuplicateSubmodules(allowDuplicateOrigins bool, submodules ...Submodule) error

CheckForDuplicateSubmodules syntactically checks if any duplicate submodules exist within a slice of Submodule.

func IsOnCaseSensitiveFilesystem added in v0.0.2

func IsOnCaseSensitiveFilesystem(p Path) (bool, error)

IsOnCaseSensitiveFilesystem returns whether a given path is on a case-sensitive filesystem.

Types

type Checksums added in v0.0.2

type Checksums struct {
	/*
		ConfigurationFile contains the checksum for the `nestmodules.toml` configuration file.
	*/
	ConfigurationFile string
}

Checksums contains checksums for required files at startup

func (Checksums) Validate added in v0.0.2

func (c Checksums) Validate() error

Validate performs validation on this Config.

type Config

type Config struct {
	/*
		AllowDuplicateOrigins defines whether duplicate remote origins are allowed.
	*/
	AllowDuplicateOrigins bool `toml:"allow_duplicate_origins"`

	/*
		AllowUnequalRoots defines whether the project's git root and git-nest root are allowed to not be aligned.
	*/
	AllowUnequalRoots bool `toml:"allow_unequal_roots"`
}

Config represents all git-nest configurable options.

func (Config) Validate

func (c Config) Validate() error

Validate performs validation on this Config.

type NestConfig

type NestConfig struct {
	/*
		Config contains every configuration flag.
	*/
	Config Config `toml:"config"`

	/*
		Submodule contains all Submodule for this configuration.
	*/
	Submodules []Submodule `toml:"submodule"`
}

NestConfig represents a higher-order configuration for git-nest.

func (NestConfig) Validate

func (c NestConfig) Validate() error

Validate performs validation on this NestConfig.

type NestContext

type NestContext struct {

	/*
		WorkingDirectory contains the Path to the working directory the binary was executed from.
	*/
	WorkingDirectory Path

	/*
		ProjectRoot is a Path to the project's root directory.

		A directory counts as project root if a directory contains a `nestmodules.toml` file directly at the
		directory or in a `.Config` subdirectory. If no configuration file could be found, the directory tree
		is traversed up to find the next possible parent project. If the current directory is not part of a
		git-nest project, the string is set to the current working directory.
	*/
	ProjectRoot Path

	/*
		GitRepositoryPath is a Path to the project's repository root
	*/
	GitRepositoryRoot Path

	/*
		ConfigFileExists defines whether a `nestmodules.toml` configuration file exists.
	*/
	ConfigFileExists bool

	/*
		ConfigFile is a Path that points to the project's `nestmodules.toml`.

		If no configuration files has found, it points to `[ProjectRoot]/nestmodules.toml`.
	*/
	ConfigFile Path

	/*
		Config contains the configuration of the project, read from a configuration file.
	*/
	Config NestConfig

	/*
		Checksums contains checksums of every configuration file's contents.
	*/
	Checksums Checksums

	/*
		IsGitInstalled defines whether git is installed in the current environment.
	*/
	IsGitInstalled bool

	/*
		IsGitRepository defines whether the project root is also a git repository.
	*/
	IsGitRepository bool
}

NestContext bundles all relevant information of a project that utilizes git-nest.

type Path

type Path string

Path is a string-typed type that abstracts path operations.

func (*Path) AtRoot

func (p *Path) AtRoot() bool

AtRoot returns whether this Path is at a root-level-directory or at its top-most parent directory of its original path.

func (*Path) BContains

func (p *Path) BContains(pattern string) bool

BContains is a wrapper for Path.Contains and only returns the success boolean value.

func (*Path) Base

func (p *Path) Base() string

Base returns the last element of this Path, based on the stdlib filepath.Base.

func (*Path) Clean

func (p *Path) Clean() Path

Clean returns an OS-fitting, cleaned up copy of this Path, based on the stdlib filepath.Clean.

func (*Path) Contains

func (p *Path) Contains(pattern string) (bool, error)

Contains returns whether the passed pattern exist within this Path's directory, based on the stdlib filepath.Glob.

func (*Path) Empty

func (p *Path) Empty() bool

Empty returns whether this Path is an empty string.

func (*Path) EmptyOrAtRoot

func (p *Path) EmptyOrAtRoot() bool

EmptyOrAtRoot returns whether this Path is an empty string, at a root-level-directory or at its top-most parent directory of its original path.

func (*Path) Equals added in v0.0.2

func (p *Path) Equals(other Path) bool

Equals returns whether this and another path are the same

func (*Path) Exists

func (p *Path) Exists() bool

Exists returns whether this Path exists.

func (*Path) IsDir

func (p *Path) IsDir() bool

IsDir returns whether this Path is an existing directory.

func (*Path) IsFile

func (p *Path) IsFile() bool

IsFile returns whether this Path is an existing file.

func (*Path) Join

func (p *Path) Join(paths ...Path) Path

Join returns a new Path with all passed Path structs joined together using filepath.Join. If strings should be joined on this Path, use SJoin.

func (*Path) MarshalText

func (p *Path) MarshalText() (text []byte, err error)

MarshalText unmarshalls this Path into a string. This is done so that Path implements the encoding.TextMarshaler interface.

func (*Path) Parent

func (p *Path) Parent() Path

Parent is a synonym for Up().

func (*Path) Parts

func (p *Path) Parts() []string

Parts returns all single of the Path. It uses filepath.Separator to split the path string.

func (*Path) Relative

func (p *Path) Relative(o Path) (Path, error)

Relative returns the relative path from another Path to this Path, based on the stdlib filepath.Rel.

func (*Path) SJoin

func (p *Path) SJoin(paths ...string) Path

SJoin returns a new Path with all passed strings joined together using filepath.Join.

func (*Path) String

func (p *Path) String() string

String returns this Path as its base type, removing the need for specific casts.

func (*Path) UnixString

func (p *Path) UnixString() string

UnixString ensures the path is formatted as a UNIX path (using '/' as path separators).

func (*Path) UnmarshalText

func (p *Path) UnmarshalText(text []byte) error

UnmarshalText unmarshalls any byte array into a Path type. This is done so that Path implements the encoding.TextUnmarshaler interface.

func (*Path) Up

func (p *Path) Up() Path

Up returns a copy of this Path in the parent directory, based on the stdlib filepath.Dir.

type Submodule

type Submodule struct {
	Path Path
	Url  *urls.HttpUrl
	Ref  string
}

func (*Submodule) Clean

func (s *Submodule) Clean()

Clean performs a data cleanup on this Submodule.

func (*Submodule) Identifier

func (s *Submodule) Identifier() string

Identifier returns a string to uniquely identify a submodule.

Format: Submodule.Url@Submodule.Ref>Submodule.Path

func (*Submodule) RemoteIdentifier

func (s *Submodule) RemoteIdentifier() string

RemoteIdentifier returns a string to uniquely identify a submodule's remote origin, incl. the reference.

Format: Submodule.Url@Submodule.Ref

func (*Submodule) String

func (s *Submodule) String() string

String returns a string representation of this Submodule.

func (*Submodule) Validate

func (s *Submodule) Validate() error

Validate performs validation on this Submodule.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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