dirtools

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompileDirPath

func CompileDirPath(root, repoDirTree string) string

CompileDirPath prefixes a directory tree with constant roots. it expects input to be normalized with NormalizeRepoURL.

func FindGitDirs

func FindGitDirs(root string) ([]string, error)

FindGitDirs uses filepath.Walk to recursively identify git repos, returning the slice of git paths repos are identified as `parent directory of a .git directory`.

func NormalizeRepoURL

func NormalizeRepoURL(repoURL string) (string, error)

NormalizeRepoURL normalizes repoURL to a partial directory tree. repoURL is a git clone url, and resulting string is safe for os.MkdirAll it handles removing/replacing ports, protocols, git users, .git suffix, and other conversions.

func SetUserPaths added in v0.0.8

func SetUserPaths(ctx context.Context, paths *UserPaths) context.Context

func WriteExecFile added in v0.0.8

func WriteExecFile(scriptPath, content string) error

WriteExecFile is used to write temporary shell scripts with +x . It should not be used for general file-writing.

Types

type LocalRepoPath

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

LocalRepoPath represents a directory path string with or without a common prefix stripped.

func NewLocalRepoPath

func NewLocalRepoPath(root, full string) *LocalRepoPath

func (*LocalRepoPath) Long

func (rp *LocalRepoPath) Long() string

Long returns the full, unmodified directory path.

func (*LocalRepoPath) Path added in v0.0.8

func (rp *LocalRepoPath) Path(full bool) string

Path returns the dir path. <full> determines if the full or short path is returned

func (*LocalRepoPath) Short

func (rp *LocalRepoPath) Short() string

Short returns the dir path with common prefix trimmed.

type RepoList

type RepoList map[string]*LocalRepoPath

RepoList is a string-indexed map of *LocalRepoPath.

func NewRepoList

func NewRepoList(root string, paths []string) RepoList

func (RepoList) Keys

func (rl RepoList) Keys() []string

Keys returns a sorted list of the map keys.

type UserPaths added in v0.0.8

type UserPaths struct {
	// OwnBinaryName is the name of this binary, as installed/executed
	OwnBinaryName string
	// user os' home dir
	UserHomeDir string
	// user os' cache dir
	UserCacheDir string
	// path to cd shell script. this sh is updated as part of the cd subcommand
	CDScriptPath string
	// CollectionRoot is the root path for all git dirs
	CollectionRoot string
}

UserPaths stores root-level paths used by the application

func GetUserPaths added in v0.0.8

func GetUserPaths(ctx context.Context) *UserPaths

Jump to

Keyboard shortcuts

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