module

package
v3.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllModules

func GetAllModules(workspaceRoot string) util.OrderedMap[string, Module]

GetAllModules return all the names and modules in the workspace

func SetupModule

func SetupModule(modulePath string)

SetupModule runs the SETUP.go file in the root directory of `mod` (it if exists).

func WriteModuleFile

func WriteModuleFile(modulePath string, moduleFile ModuleFile)

WriteModuleFile serializes and writes a Module's Dependencies to a MODULE file.

Types

type Dependency

type Dependency struct {
	URL     string
	Version string
	Hash    string
	Type    string
}

type GitMirror

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

GitMirror is a bare repository that backs a GitModule

type GitModule

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

GitModule is a module backed by a git repository.

func (GitModule) Checkout

func (m GitModule) Checkout(ref string)

Checkout changes the current module's version to `ref`.

func (GitModule) Fetch

func (m GitModule) Fetch() bool

Fetch fetches changes from the default remote and reports whether any updates have been fetched.

func (GitModule) GetCommitAuthorName

func (m GitModule) GetCommitAuthorName(revision string) (string, error)

func (GitModule) GetCommitTitle

func (m GitModule) GetCommitTitle(revision string) (string, error)

func (GitModule) GetCommitsBetweenRefs

func (m GitModule) GetCommitsBetweenRefs(base, head string) ([]string, error)

func (GitModule) GetMergeBase

func (m GitModule) GetMergeBase(revA, revB string) (string, error)

GetMergeBase returns the best common ancestor that could be used for a merge between the two given references.

func (GitModule) Head

func (m GitModule) Head() string

Head returns the commit hash of the HEAD of the underlying git repository.

func (GitModule) IsAncestor

func (m GitModule) IsAncestor(ancestor, rev string) bool

IsAncestor returns whether ancestor is an ancestor of rev in the commit tree.

func (GitModule) IsDirty

func (m GitModule) IsDirty() bool

IsDirty returns whether the underlying repository has any uncommited changes.

func (GitModule) Mirror

func (m GitModule) Mirror() *GitMirror

Mirror returns the path of the mirror

func (GitModule) Name

func (m GitModule) Name() string

func (GitModule) RevParse

func (m GitModule) RevParse(ref string) string

RevParse returns the commit hash for the commit referenced by `ref`.

func (GitModule) RootPath

func (m GitModule) RootPath() string

func (GitModule) Type

func (m GitModule) Type() ModuleType

func (GitModule) URL

func (m GitModule) URL() string

URL returns the url of the underlying git repository.

type GoFile

type GoFile struct {
	// Absolute path to file
	SourcePath string
	// Relatve path from go root
	CopyPath string
}

func ListBuildFiles

func ListBuildFiles(module Module) []GoFile

func ListRules

func ListRules(module Module) []GoFile

type GoModule

type GoModule struct {
	// Module name
	Name string
	// Used modules
	Deps []string
}

func ListGoModules

func ListGoModules(module Module) []GoModule

type Module

type Module interface {
	Name() string
	URL() string

	Head() string
	RevParse(rev string) string
	IsDirty() bool
	IsAncestor(ancestor, rev string) bool

	Fetch() bool
	Checkout(hash string)

	RootPath() string
	Type() ModuleType
}

Module represents a checked-out module.

func CreateGitModule

func CreateGitModule(modulePath, url string) (Module, error)

createGitModule creates a new GitModule in the given `modulePath` by cloning the repository from `url`.

func OpenModule

func OpenModule(modulePath string) Module

OpenModule opens a module checked out on disk.

func OpenModuleByName

func OpenModuleByName(moduleName string) Module

OpenModuleByName opens a module checked out on disk.

func OpenOrCreateModule

func OpenOrCreateModule(modulePath string, url string, moduleTypeString string, expectedHash string) Module

OpenOrCreateModule tries to open the module in `modulePath`. If the `modulePath` directory does not yet exists, it tries to create a new module by cloning / downloading the module from `url`.

type ModuleFile

type ModuleFile struct {
	Version      uint
	Layout       string
	Dependencies map[string]Dependency
	Flags        map[string]string
	PersistFlags *bool `yaml:"persist-flags,omitempty"`
}

func ReadModuleFile

func ReadModuleFile(modulePath string) ModuleFile

ReadModuleFile reads and parses module Dependencies from a MODULE file.

type ModuleType

type ModuleType uint
const (
	GitModuleType ModuleType = iota
	TarGzModuleType
)

func DetermineModuleType

func DetermineModuleType(url, moduleTypeString string) ModuleType

func ParseModuleTypeString

func ParseModuleTypeString(str string) (ModuleType, bool)

func (ModuleType) String

func (t ModuleType) String() string

type TarMirror

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

type TarModule

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

TarModule is a module backed by a tar.gz archive. TarModules only have a single "master" version.

func (TarModule) Checkout

func (m TarModule) Checkout(hash string)

Checkout changes the module's current version to `ref`. TarModules only have a single version. Attempting to check out any other version results in an error.

func (TarModule) Fetch

func (m TarModule) Fetch() bool

Fetch does nothing on TarModules and reports that no changes have been fetched.

func (TarModule) Head

func (m TarModule) Head() string

Head returns the default version for all TarModules.

func (TarModule) IsAncestor

func (m TarModule) IsAncestor(ancestor, rev string) bool

func (TarModule) IsDirty

func (m TarModule) IsDirty() bool

IsDirty returns whether the module has any uncommited changes. TarModules never have any uncommited changes by definition.

func (TarModule) Name

func (m TarModule) Name() string

func (TarModule) RevParse

func (m TarModule) RevParse(rev string) string

RevParse returns the default version for all TarModules.

func (TarModule) RootPath

func (m TarModule) RootPath() string

func (TarModule) Type

func (m TarModule) Type() ModuleType

func (TarModule) URL

func (m TarModule) URL() string

URL returns the url of the underlying tar archive.

Jump to

Keyboard shortcuts

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