pkgs

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package pkgs contains functions for parsing remote urls and checking if a directory is a git repository.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoMatchingScaffold = fmt.Errorf("no matching scaffold")

Functions

func IsRemote

func IsRemote(str string, shorts map[string]string) (expanded string, ok bool)

IsRemote checks if the string is a remote url or an alias for a remote url if it is a remote url, it returns the url. If the string uses and alias it returns the expanded url

Examples:

IsRemote(gh:foo/bar) -> https://github.com/foo/bar, true

func ListLocal

func ListLocal(f fs.FS) ([]string, error)

func Update

func Update(cacheRoot string, scaffoldPath string) (updated bool, err error)

Update updates a git repository to the latest commit

Types

type AuthProvider

type AuthProvider interface {
	Authenticator(pkgurl string) (auth transport.AuthMethod, ok bool)
}

type AuthProviderFunc

type AuthProviderFunc func(pkgurl string) (auth transport.AuthMethod, ok bool)

func (AuthProviderFunc) Authenticator

func (f AuthProviderFunc) Authenticator(pkgurl string) (auth transport.AuthMethod, ok bool)

type Cloner

type Cloner interface {
	Clone(path string, version string, isBare bool, cfg *git.CloneOptions) (string, error)
}

type ClonerFunc

type ClonerFunc func(path string, version string, isBare bool, cfg *git.CloneOptions) (string, error)

func (ClonerFunc) Clone

func (f ClonerFunc) Clone(path string, version string, isBare bool, cfg *git.CloneOptions) (string, error)

type Package added in v0.5.0

type Package struct {
	RemoteRef string
	Version   string
	Subdir    string
	// contains filtered or unexported fields
}

func ParseRemote

func ParseRemote(urlStr string) (Package, error)

ParseRemote parses a remote endpoint and returns a filesystem path representing the repository. In addition, it returns the subdirectory of the repository to be used, if any.

Examples:

	ParseRemote("https://github.com/hay-kot/scaffold-go-cli")
	github.com
	└── hay-kot
	    └── scaffold-go-cli
			     └── repository files

	ParseRemote("https://github.com/hay-kot/scaffold-go-cli#subdir")
	github.com
	└── hay-kot
	    └── scaffold-go-cli
		 	    └── subdir
              └── files to use

func (Package) CloneDir added in v0.5.0

func (p Package) CloneDir(root string) string

CloneDir returns the directory where the repository will be cloned.

func (Package) ScaffoldDir added in v0.5.0

func (p Package) ScaffoldDir(root string) string

ScaffoldDir returns the directory where the repository will be cloned and the subdirectory to use if the package reference was specified with a subdirectory argument.

type PackageList added in v0.5.0

type PackageList struct {
	Root        string
	SubPackages []string
}

func ListSystem

func ListSystem(f fs.FS) ([]PackageList, error)

ListSystem traverses the filesystem and returns a list of all the package paths and references. This lists only the system scaffolds, and not the ones in the local .scaffold directory.

type Resolver

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

func NewResolver

func NewResolver(shorts map[string]string, cache, cwd string, opts ...ResolverOption) *Resolver

func (*Resolver) Resolve

func (r *Resolver) Resolve(arg string, checkDirs []string, authprovider AuthProvider) (path string, err error)

type ResolverOption

type ResolverOption func(*Resolver)

func WithCloner

func WithCloner(cloner Cloner) ResolverOption

type Version added in v0.4.0

type Version struct {
	Repository string
	Commit     string
}

func GetVersion added in v0.4.0

func GetVersion(path string) (Version, error)

func (Version) CommitShort added in v0.4.0

func (v Version) CommitShort() string

func (Version) IsZero added in v0.4.0

func (v Version) IsZero() bool

func (Version) String added in v0.4.0

func (v Version) String() string

Directories

Path Synopsis
Package pkgurl contains functions for parsing remote urls
Package pkgurl contains functions for parsing remote urls

Jump to

Keyboard shortcuts

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