pkgs

package
v0.0.98 Latest Latest
Warning

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

Go to latest
Published: May 14, 2024 License: MIT Imports: 11 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 ListSystem

func ListSystem(f fs.FS) ([]string, 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.

func ParseRemote

func ParseRemote(urlStr string) (string, error)

ParseRemote parses a remote endpoint and returns a filesystem path representing the repository.

Examples:

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

func Update

func Update(path 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, isBare bool, cfg *git.CloneOptions) (string, error)
}

type ClonerFunc

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

func (ClonerFunc) Clone

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

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

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