util

package
v2.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: MIT Imports: 15 Imported by: 12

Documentation

Index

Constants

View Source
const (
	// Normal repo with working copy
	RepoTypeNormal = RepoType(iota)
	// Bare repo (no working copy)
	RepoTypeBare = RepoType(iota)
	// Repo with working copy but git dir is separate
	RepoTypeSeparateDir = RepoType(iota)
)

Variables

This section is empty.

Functions

func RunGitCommand

func RunGitCommand(callback RepoCallback, failureCheck bool, args ...string) string

Simplistic fire & forget running of git command - returns combined output

Types

type CommitInput

type CommitInput struct {
	// Date that we should commit on (optional, leave blank for 'now')
	CommitDate time.Time
	// List of files to include in this commit
	Files []*FileInput
	// List of parent branches (all branches must have been created in a previous NewBranch or be master)
	// Can be omitted to just use the parent of the previous commit
	ParentBranches []string
	// Name of a new branch we should create at this commit (optional - master not required)
	NewBranch string
	// Names of any tags we should create at this commit (optional)
	Tags []string
	// Name of committer
	CommitterName string
	// Email of committer
	CommitterEmail string
}

Input for defining commits for test repo

type CommitOutput

type CommitOutput struct {
	Sha     string
	Parents []string
	Files   []*lfs.Pointer
}

Output struct with details of commits created for test

type FileInput

type FileInput struct {
	// Name of file (required)
	Filename string
	// Size of file (required)
	Size int64
	// Input data (optional, if provided will be source of data)
	DataReader io.Reader
	// Input data (optional, if provided will be source of data)
	Data string
}

Input data for a single file in a commit

func (*FileInput) AddToIndex

func (infile *FileInput) AddToIndex(output *CommitOutput, repo *Repo)

type PlaceholderDataReader

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

Just a psuedo-random stream of bytes (not cryptographic) Calls RNG a bit less often than using rand.Source directly

func NewPlaceholderDataReader

func NewPlaceholderDataReader(seed, size int64) *PlaceholderDataReader

func (*PlaceholderDataReader) Read

func (r *PlaceholderDataReader) Read(p []byte) (int, error)

type PointersByOid

type PointersByOid []*lfs.Pointer

PointersByOid implements sort.Interface for []*lfs.Pointer based on oid

func (PointersByOid) Len

func (a PointersByOid) Len() int

func (PointersByOid) Less

func (a PointersByOid) Less(i, j int) bool

func (PointersByOid) Swap

func (a PointersByOid) Swap(i, j int)

type RefsByName

type RefsByName []*git.Ref

RefsByName implements sort.Interface for []*git.Ref based on name

func (RefsByName) Len

func (a RefsByName) Len() int

func (RefsByName) Less

func (a RefsByName) Less(i, j int) bool

func (RefsByName) Swap

func (a RefsByName) Swap(i, j int)

type Repo

type Repo struct {
	// Path to the repo, working copy if non-bare
	Path string
	// Path to the git dir
	GitDir string
	// Paths to remotes
	Remotes map[string]*Repo
	// Settings used to create this repo
	Settings *RepoCreateSettings
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo(callback RepoCallback) *Repo

NewRepo creates a new git repo in a new temp dir

func WrapRepo

func WrapRepo(c RepoCallback, path string) *Repo

WrapRepo creates a new Repo instance for an existing git repo

func (*Repo) AddCommits

func (repo *Repo) AddCommits(inputs []*CommitInput) []*CommitOutput

func (*Repo) AddRemote

func (r *Repo) AddRemote(name string) *Repo

Add a new remote (generate a path for it to live in, will be cleaned up)

func (*Repo) Cleanup

func (r *Repo) Cleanup()

func (*Repo) Filesystem

func (r *Repo) Filesystem() *fs.Filesystem

func (*Repo) GitConfig

func (r *Repo) GitConfig() *git.Configuration

func (*Repo) GitEnv

func (r *Repo) GitEnv() config.Environment

func (*Repo) OSEnv

func (r *Repo) OSEnv() config.Environment

func (*Repo) Popd

func (r *Repo) Popd()

func (*Repo) Pushd

func (r *Repo) Pushd()

Change to repo dir but save current dir

type RepoCallback

type RepoCallback interface {
	// Fatalf reports error and fails
	Fatalf(format string, args ...interface{})
	// Errorf reports error and continues
	Errorf(format string, args ...interface{})
}

Callback interface (testing.T compatible)

type RepoCreateSettings

type RepoCreateSettings struct {
	RepoType RepoType
}

type RepoType

type RepoType int

type WrappedPointersByOid

type WrappedPointersByOid []*lfs.WrappedPointer

WrappedPointersByOid implements sort.Interface for []*lfs.WrappedPointer based on oid

func (WrappedPointersByOid) Len

func (a WrappedPointersByOid) Len() int

func (WrappedPointersByOid) Less

func (a WrappedPointersByOid) Less(i, j int) bool

func (WrappedPointersByOid) Swap

func (a WrappedPointersByOid) Swap(i, j int)

Jump to

Keyboard shortcuts

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