gitget

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// The target directory to clone into. If empty, the repository name is used.
	Dir string
	// The Git branch to clone.
	Branch string
	// The Git tag to clone.
	Tag string
	// The Git commit hash to clone.
	Commit string
	// Forcefully write files into the existing target directory.
	Force bool
}

The configuration for the `Clone` function.

type Result

type Result struct {
	// The relative path to the target directory.
	TargetDirRel string
	// The absolute path to the target directory.
	TargetDirAbs string
	// The owner of the repository, typically the user or organisation.
	RepoOwner string
	// The name of the repository.
	RepoName string
	// The commit, tag, or branch used to clone the repository.
	RepoFragment string
}

The result of the `Clone` function.

func Clone

func Clone(repository string, config Config) (Result, error)

Clones the given repository using the configuration provided. The default behaviour clones the HEAD of the default branch.

res, err := gitget.Clone("github.com/AaronCQL/gitget", gitget.Config{})
if err != nil {
	panic(err)
}
fmt.Printf(
	"Cloned %v/%v (%v) into %v\n",
	res.RepoOwner, res.RepoName, res.RepoFragment, res.TargetDirRel,
)

Jump to

Keyboard shortcuts

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