lfs

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2016 License: MIT Imports: 38 Imported by: 0

Documentation

Overview

Set is a modification of https://github.com/deckarep/golang-set The MIT License (MIT) Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)

Index

Constants

View Source
const (
	ScanRefsMode         = ScanningMode(iota) // 0 - or default scan mode
	ScanAllMode          = ScanningMode(iota)
	ScanLeftToRemoteMode = ScanningMode(iota)
)
View Source
const (
	LogDiffAdditions = LogDiffDirection('+') // include '+' diffs
	LogDiffDeletions = LogDiffDirection('-') // include '-' diffs
)
View Source
const (
	PlatformWindows      = Platform(iota)
	PlatformLinux        = Platform(iota)
	PlatformOSX          = Platform(iota)
	PlatformOther        = Platform(iota) // most likely a *nix variant e.g. freebsd
	PlatformUndetermined = Platform(iota)
)
View Source
const (
	BtrfsIocClone = C.BTRFS_IOC_CLONE
)
View Source
const EndpointUrlUnknown = "<unknown>"
View Source
const (
	Version = "1.2.0"
)

Variables

View Source
var (
	Config             = NewConfig()
	ShowConfigWarnings = false
)
View Source
var (
	LargeSizeThreshold = 5 * 1024 * 1024
	TempDir            = filepath.Join(os.TempDir(), "git-lfs")
	GitCommit          string
	UserAgent          string
	LocalWorkingDir    string
	LocalGitDir        string // parent of index / config / hooks etc
	LocalGitStorageDir string // parent of objects/lfs (may be same as LocalGitDir but may not)
	LocalMediaDir      string // root of lfs objects
	LocalObjectTempDir string // where temporarily downloading objects are stored
	LocalReferenceDir  string // alternative local media dir (relative to clone reference repo)

	LocalLogDir string
)

Functions

func AllObjects added in v1.2.0

func AllObjects() []localstorage.Object

only used in tests

func ClearTempObjects added in v1.0.1

func ClearTempObjects() error

func CloneFile added in v1.1.1

func CloneFile(writer io.Writer, reader io.Reader) (bool, error)

func ConvertCwdFilesRelativeToRepo added in v0.6.0

func ConvertCwdFilesRelativeToRepo(cwdchan <-chan string) (<-chan string, error)

Convert filenames expressed relative to the current directory to be relative to the repo root. Useful when calling git with arguments that requires them to be rooted but the user is in a subdir of their repo & expects to use relative args Pass in a channel which you will fill with relative files & receive a channel which will get results

func ConvertRepoFilesRelativeToCwd added in v0.6.0

func ConvertRepoFilesRelativeToCwd(repochan <-chan string) (<-chan string, error)

Convert filenames expressed relative to the root of the repo relative to the current working dir. Useful when needing to calling git with results from a rooted command, but the user is in a subdir of their repo Pass in a channel which you will fill with relative files & receive a channel which will get results

func CopyFileContents added in v1.2.0

func CopyFileContents(src string, dst string) error

func CopyWithCallback

func CopyWithCallback(writer io.Writer, reader io.Reader, totalSize int64, cb CopyCallback) (int64, error)

func DirExists added in v0.6.0

func DirExists(path string) bool

DirExists determines if a dir (NOT file) exists.

func DoNTLMRequest added in v1.1.0

func DoNTLMRequest(request *http.Request, retry bool) (*http.Response, error)

func Download

func Download(oid string, size int64) (io.ReadCloser, int64, error)

Download will attempt to download the object with the given oid. The batched API will be used, but if the server does not implement the batch operations it will fall back to the legacy API.

func DownloadLegacy added in v1.0.1

func DownloadLegacy(oid string) (io.ReadCloser, int64, error)

DownloadLegacy attempts to download the object for the given oid using the legacy API.

func DownloadObject added in v0.5.2

func DownloadObject(obj *ObjectResource) (io.ReadCloser, int64, error)

func EncodePointer added in v0.5.1

func EncodePointer(writer io.Writer, pointer *Pointer) (int, error)

func Environ

func Environ() []string

func Error

func Error(err error) error

Error wraps an error with an empty message.

func ErrorContext added in v0.6.0

func ErrorContext(err error) map[string]interface{}

ErrorContext returns the context map for an error if it is a wrappedError. If it is not a wrappedError it will return an empty map.

func ErrorDelContext added in v0.6.0

func ErrorDelContext(err error, key string)

ErrorDelContext removes a value from the error's context. If the error has not been wrapped, it does nothing.

func ErrorGetContext added in v0.6.0

func ErrorGetContext(err error, key string) interface{}

ErrorGetContext gets a value from the error's context. If the error has not been wrapped, it returns an empty string.

func ErrorSetContext added in v0.6.0

func ErrorSetContext(err error, key string, value interface{})

ErrorSetContext sets a value in the error's context. If the error has not been wrapped, it does nothing.

func ErrorStack added in v0.6.0

func ErrorStack(err error) []byte

ErrorStack returns the stack for an error if it is a wrappedError. If it is not a wrappedError it will return an empty byte slice.

func Errorf

func Errorf(err error, format string, args ...interface{}) error

Errorf wraps an error with an additional formatted message.

func FileExists added in v0.6.0

func FileExists(path string) bool

FileExists determines if a file (NOT dir) exists.

func FileExistsOfSize added in v0.6.0

func FileExistsOfSize(path string, sz int64) bool

FileExistsOfSize determines if a file exists and is of a specific size.

func FileOrDirExists added in v0.6.0

func FileOrDirExists(path string) (exists bool, isDir bool)

FileOrDirExists determines if a file/dir exists, returns IsDir() results too.

func FilenamePassesIncludeExcludeFilter added in v0.6.0

func FilenamePassesIncludeExcludeFilter(filename string, includePaths, excludePaths []string) bool

Return whether a given filename passes the include / exclude path filters Only paths that are in includePaths and outside excludePaths are passed If includePaths is empty that filter always passes and the same with excludePaths Both path lists support wildcard matches

func GetInnerError added in v1.1.2

func GetInnerError(err error) error

func InRepo

func InRepo() bool

func InstallFilters

func InstallFilters(opt InstallOptions, passThrough bool) error

InstallFilters installs filters necessary for git-lfs to process normal git operations. Currently, that list includes:

  • smudge filter
  • clean filter

An error will be returned if a filter is unable to be set, or if the required filters were not present.

func InstallHooks

func InstallHooks(force bool) error

InstallHooks installs all hooks in the `hooks` var.

func IsAuthError added in v0.6.0

func IsAuthError(err error) bool

IsAuthError indicates the client provided a request with invalid or no authentication credentials when credentials are required (e.g. HTTP 401).

func IsBadPointerKeyError added in v1.0.0

func IsBadPointerKeyError(err error) bool

IsBadPointerKeyError indicates that the parsed data has an invalid key.

func IsCleanPointerError added in v0.6.0

func IsCleanPointerError(err error) bool

IsCleanPointerError indicates an error while cleaning a file.

func IsDownloadDeclinedError added in v0.6.0

func IsDownloadDeclinedError(err error) bool

IsDownloadDeclinedError indicates that the smudge operation should not download. TODO: I don't really like using errors to control that flow, it should be refactored.

func IsFatalError added in v0.6.0

func IsFatalError(err error) bool

IsFatalError indicates that the error is fatal and the process should exit immediately after handling the error.

func IsInvalidPointerError added in v0.6.0

func IsInvalidPointerError(err error) bool

IsInvalidPointerError indicates an attempt to parse data that was not a valid pointer.

func IsInvalidRepoError added in v0.6.0

func IsInvalidRepoError(err error) bool

IsInvalidRepoError indicates an operation was attempted from outside a git repository.

func IsNotAPointerError added in v0.6.0

func IsNotAPointerError(err error) bool

IsNotAPointerError indicates the parsed data is not an LFS pointer.

func IsNotImplementedError added in v0.6.0

func IsNotImplementedError(err error) bool

IsNotImplementedError indicates the client attempted to use a feature the server has not implemented (e.g. the batch endpoint).

func IsRetriableError added in v0.6.0

func IsRetriableError(err error) bool

IsRetriableError indicates the low level transfer had an error but the caller may retry the operation.

func IsSmudgeError added in v0.6.0

func IsSmudgeError(err error) bool

IsSmudgeError indicates an error while smudging a files.

func IsWindows added in v0.6.0

func IsWindows() bool

Are we running on Windows? Need to handle some extra path shenanigans

func LinkOrCopy added in v1.2.0

func LinkOrCopy(src string, dst string) error

func LinkOrCopyFromReference added in v1.2.0

func LinkOrCopyFromReference(oid string, size int64) error

func LocalMediaPath

func LocalMediaPath(oid string) (string, error)

func LocalReferencePath added in v1.2.0

func LocalReferencePath(sha string) string

func LogHttpStats added in v0.5.2

func LogHttpStats()

LogHttpStats is intended to be called after all HTTP operations for the commmand have finished. It dumps k/v logs, one line per transfer into a log file with the current timestamp.

func LogTransfer added in v0.5.2

func LogTransfer(key string, res *http.Response)

func ObjectExistsOfSize added in v0.6.0

func ObjectExistsOfSize(oid string, size int64) bool

func ObjectUrl

func ObjectUrl(endpoint Endpoint, oid string) (*url.URL, error)

func PointerClean added in v0.5.1

func PointerClean(reader io.Reader, fileName string, fileSize int64, cb CopyCallback) (*cleanedAsset, error)

func PointerSmudge added in v0.5.1

func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, cb CopyCallback) error

func PointerSmudgeObject added in v0.5.2

func PointerSmudgeObject(ptr *Pointer, obj *ObjectResource, cb CopyCallback) error

PointerSmudgeObject uses a Pointer and ObjectResource to download the object to the media directory. It does not write the file to the working directory.

func PointerSmudgeToFile added in v0.6.0

func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, cb CopyCallback) error

func ResetTempDir

func ResetTempDir() error

func ResolveDirs added in v0.6.0

func ResolveDirs()
func ResolveSymlinks(path string) string

ResolveSymlinks ensures that if the path supplied is a symlink, it is resolved to the actual concrete path

func ScanObjectsChan added in v1.2.0

func ScanObjectsChan() <-chan localstorage.Object

func Stack

func Stack() []byte

Stack returns a byte slice containing the runtime.Stack()

func TempFile

func TempFile(prefix string) (*os.File, error)

func UninstallFilters added in v0.5.3

func UninstallFilters() error

UninstallFilters proxies into the Uninstall method on the Filters type to remove all installed filters.

func UninstallHooks added in v0.5.3

func UninstallHooks() error

UninstallHooks removes all hooks in range of the `hooks` var.

func UploadObject added in v0.5.2

func UploadObject(o *ObjectResource, cb CopyCallback) error

Types

type Attribute added in v0.6.0

type Attribute struct {
	// The Section of an Attribute refers to the location at which all
	// properties are relative to. For example, for a Section with the value
	// "core", Git will produce something like:
	//
	// [core]
	//	autocrlf = true
	//	...
	Section string

	// The Properties of an Attribute refer to all of the keys and values
	// that define that Attribute.
	Properties map[string]string
}

Attribute wraps the structure and some operations of Git's conception of an "attribute", as defined here: http://git-scm.com/docs/gitattributes.

func (*Attribute) Install added in v0.6.0

func (a *Attribute) Install(opt InstallOptions) error

Install instructs Git to set all keys and values relative to the root location of this Attribute. For any particular key/value pair, if a matching key is already set, it will be overridden if it is either a) empty, or b) the `force` argument is passed as true. If an attribute is already set to a different value than what is given, and force is false, an error will be returned immediately, and the rest of the attributes will not be set.

func (*Attribute) Uninstall added in v0.6.0

func (a *Attribute) Uninstall()

Uninstall removes all properties in the path of this property.

type BaseChannelWrapper added in v1.2.0

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

Base implementation of channel wrapper to just deal with errors

func (*BaseChannelWrapper) Wait added in v1.2.0

func (w *BaseChannelWrapper) Wait() error

type Batcher added in v0.6.0

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

Batcher provides a way to process a set of items in groups of n. Items can be added to the batcher from multiple goroutines and pulled off in groups when one of the following conditions occurs:

  • The batch size is reached
  • Exit() is called

When an Exit() occurs, the group may be smaller than the batch size.

func NewBatcher added in v0.6.0

func NewBatcher(batchSize int) *Batcher

NewBatcher creates a Batcher with the batchSize.

func (*Batcher) Add added in v0.6.0

func (b *Batcher) Add(t Transferable)

Add adds an item to the batcher. Add is safe to call from multiple goroutines.

func (*Batcher) Exit added in v0.6.0

func (b *Batcher) Exit()

Exit stops all batching and allows Next() to return. Calling Add() after calling Exit() will reset the batcher.

func (*Batcher) Next added in v0.6.0

func (b *Batcher) Next() []Transferable

Next will wait for the one of the above batch triggers to occur and return the accumulated batch.

type ByPriority added in v0.6.0

type ByPriority []*PointerExtension

func (ByPriority) Len added in v0.6.0

func (p ByPriority) Len() int

func (ByPriority) Less added in v0.6.0

func (p ByPriority) Less(i, j int) bool

func (ByPriority) Swap added in v0.6.0

func (p ByPriority) Swap(i, j int)

type CallbackReader

type CallbackReader struct {
	C         CopyCallback
	TotalSize int64
	ReadSize  int64
	io.Reader
}

func (*CallbackReader) Read

func (w *CallbackReader) Read(p []byte) (int, error)

type ChannelWrapper added in v1.2.0

type ChannelWrapper interface {
	// Call this after processing results channel to check for async errors
	Wait() error
}

Interface for all types of wrapper around a channel of results and an error channel Implementors will expose a type-specific channel for results Call the Wait() function after processing the results channel to catch any errors that occurred during the async processing

type ClientError

type ClientError struct {
	Message          string `json:"message"`
	DocumentationUrl string `json:"documentation_url,omitempty"`
	RequestId        string `json:"request_id,omitempty"`
}

func (*ClientError) Error

func (e *ClientError) Error() string

type Configuration

type Configuration struct {
	CurrentRemote string
	// contains filtered or unexported fields
}

func NewConfig

func NewConfig() *Configuration

func (*Configuration) Access added in v0.6.0

func (c *Configuration) Access(operation string) string

Access returns the access auth type.

func (*Configuration) AllGitConfig added in v0.6.0

func (c *Configuration) AllGitConfig() map[string]string

func (*Configuration) BatchTransfer added in v0.5.2

func (c *Configuration) BatchTransfer() bool

func (*Configuration) ConcurrentTransfers added in v0.5.2

func (c *Configuration) ConcurrentTransfers() int

func (*Configuration) Endpoint

func (c *Configuration) Endpoint(operation string) Endpoint

func (*Configuration) EndpointAccess added in v0.6.0

func (c *Configuration) EndpointAccess(e Endpoint) string

func (*Configuration) Extensions added in v0.6.0

func (c *Configuration) Extensions() map[string]Extension

func (*Configuration) FetchExcludePaths added in v0.6.0

func (c *Configuration) FetchExcludePaths() []string

func (*Configuration) FetchIncludePaths added in v0.6.0

func (c *Configuration) FetchIncludePaths() []string

func (*Configuration) FetchPruneConfig added in v0.6.0

func (c *Configuration) FetchPruneConfig() *FetchPruneConfig

func (*Configuration) FindNetrcHost added in v1.2.0

func (c *Configuration) FindNetrcHost(host string) (*netrc.Machine, error)

func (*Configuration) Getenv added in v0.5.2

func (c *Configuration) Getenv(key string) string

func (*Configuration) GetenvBool added in v0.5.2

func (c *Configuration) GetenvBool(key string, def bool) bool

GetenvBool parses a boolean environment variable and returns the result as a bool. If the environment variable is unset, empty, or if the parsing fails, the value of def (default) is returned instead.

func (*Configuration) GitConfig

func (c *Configuration) GitConfig(key string) (string, bool)

func (*Configuration) GitConfigInt added in v1.1.1

func (c *Configuration) GitConfigInt(key string, def int) int

GitConfigInt parses a git config value and returns it as an integer.

func (*Configuration) GitProtocol added in v1.1.1

func (c *Configuration) GitProtocol() string

GitProtocol returns the protocol for the LFS API when converting from a git:// remote url.

func (*Configuration) GitRemoteUrl added in v1.1.1

func (c *Configuration) GitRemoteUrl(remote string, forpush bool) string

GitRemoteUrl returns the git clone/push url for a given remote (blank if not found) the forpush argument is to cater for separate remote.name.pushurl settings

func (*Configuration) HttpClient

func (c *Configuration) HttpClient(host string) *HttpClient

HttpClient returns a new HttpClient for the given host (which may be "host:port")

func (*Configuration) NtlmAccess added in v1.1.0

func (c *Configuration) NtlmAccess(operation string) bool

func (*Configuration) PrivateAccess added in v0.5.3

func (c *Configuration) PrivateAccess(operation string) bool

PrivateAccess will retrieve the access value and return true if the value is set to private. When a repo is marked as having private access, the http requests for the batch api will fetch the credentials before running, otherwise the request will run without credentials.

func (*Configuration) RemoteEndpoint

func (c *Configuration) RemoteEndpoint(remote, operation string) Endpoint

func (*Configuration) Remotes

func (c *Configuration) Remotes() []string

func (*Configuration) SetAccess added in v0.6.0

func (c *Configuration) SetAccess(operation string, authType string)

SetAccess will set the private access flag in .git/config.

func (*Configuration) SetEndpointAccess added in v0.6.0

func (c *Configuration) SetEndpointAccess(e Endpoint, authType string)

func (*Configuration) SetManualEndpoint added in v1.1.1

func (c *Configuration) SetManualEndpoint(e Endpoint)

Manually set an Endpoint to use instead of deriving from Git config

func (*Configuration) Setenv added in v0.5.3

func (c *Configuration) Setenv(key, value string) error

type CopyCallback

type CopyCallback func(totalSize int64, readSoFar int64, readSinceLast int) error

func CopyCallbackFile

func CopyCallbackFile(event, filename string, index, totalFiles int) (CopyCallback, *os.File, error)

type Creds

type Creds map[string]string

func (Creds) Buffer

func (c Creds) Buffer() *bytes.Buffer

type DownloadCheckable added in v0.6.0

type DownloadCheckable struct {
	Pointer *WrappedPointer
	// contains filtered or unexported fields
}

The ability to check that a file can be downloaded

func NewDownloadCheckable added in v0.6.0

func NewDownloadCheckable(p *WrappedPointer) *DownloadCheckable

func (*DownloadCheckable) Check added in v0.6.0

func (d *DownloadCheckable) Check() (*ObjectResource, error)

func (*DownloadCheckable) Name added in v0.6.0

func (d *DownloadCheckable) Name() string

func (*DownloadCheckable) Object added in v0.6.0

func (d *DownloadCheckable) Object() *ObjectResource

func (*DownloadCheckable) Oid added in v0.6.0

func (d *DownloadCheckable) Oid() string

func (*DownloadCheckable) SetObject added in v0.6.0

func (d *DownloadCheckable) SetObject(o *ObjectResource)

func (*DownloadCheckable) Size added in v0.6.0

func (d *DownloadCheckable) Size() int64

func (*DownloadCheckable) Transfer added in v0.6.0

func (d *DownloadCheckable) Transfer(cb CopyCallback) error

type Downloadable added in v0.5.2

type Downloadable struct {
	*DownloadCheckable
}

The ability to actually download

func NewDownloadable added in v0.5.2

func NewDownloadable(p *WrappedPointer) *Downloadable

func (*Downloadable) Transfer added in v0.5.2

func (d *Downloadable) Transfer(cb CopyCallback) error

type Endpoint

type Endpoint struct {
	Url            string
	SshUserAndHost string
	SshPath        string
	SshPort        string
}

An Endpoint describes how to access a Git LFS server.

func NewEndpoint added in v0.5.2

func NewEndpoint(rawurl string) Endpoint

NewEndpoint initializes a new Endpoint for a given URL.

func NewEndpointFromCloneURL added in v0.5.2

func NewEndpointFromCloneURL(url string) Endpoint

NewEndpointFromCloneURL creates an Endpoint from a git clone URL by appending "[.git]/info/lfs".

func NewEndpointFromCloneURLWithConfig added in v1.1.1

func NewEndpointFromCloneURLWithConfig(url string, c *Configuration) Endpoint

NewEndpointFromCloneURLWithConfig creates an Endpoint from a git clone URL by appending "[.git]/info/lfs".

func NewEndpointWithConfig added in v1.1.1

func NewEndpointWithConfig(rawurl string, c *Configuration) Endpoint

NewEndpointWithConfig initializes a new Endpoint for a given URL.

type Extension added in v0.6.0

type Extension struct {
	Name     string
	Clean    string
	Smudge   string
	Priority int
}

An Extension describes how to manipulate files during smudge and clean. Extensions are parsed from the Git config.

func SortExtensions added in v0.6.0

func SortExtensions(m map[string]Extension) ([]Extension, error)

SortExtensions sorts a map of extensions in ascending order by Priority

type FetchPruneConfig added in v0.6.0

type FetchPruneConfig struct {
	// The number of days prior to current date for which (local) refs other than HEAD
	// will be fetched with --recent (default 7, 0 = only fetch HEAD)
	FetchRecentRefsDays int
	// Makes the FetchRecentRefsDays option apply to remote refs from fetch source as well (default true)
	FetchRecentRefsIncludeRemotes bool
	// number of days prior to latest commit on a ref that we'll fetch previous
	// LFS changes too (default 0 = only fetch at ref)
	FetchRecentCommitsDays int
	// Whether to always fetch recent even without --recent
	FetchRecentAlways bool
	// Number of days added to FetchRecent*; data outside combined window will be
	// deleted when prune is run. (default 3)
	PruneOffsetDays int
	// Always verify with remote before pruning
	PruneVerifyRemoteAlways bool
	// Name of remote to check for unpushed and verify checks
	PruneRemoteName string
}

FetchPruneConfig collects together the config options that control fetching and pruning

type Hook added in v0.6.0

type Hook struct {
	Type         string
	Contents     string
	Upgradeables []string
}

A Hook represents a githook as described in http://git-scm.com/docs/githooks. Hooks have a type, which is the type of hook that they are, and a body, which represents the thing they will execute when invoked by Git.

func (*Hook) Exists added in v0.6.0

func (h *Hook) Exists() bool

func (*Hook) Install added in v0.6.0

func (h *Hook) Install(force bool) error

Install installs this Git hook on disk, or upgrades it if it does exist, and is upgradeable. It will create a hooks directory relative to the local Git directory. It returns and halts at any errors, and returns nil if the operation was a success.

func (*Hook) Path added in v0.6.0

func (h *Hook) Path() string

Path returns the desired (or actual, if installed) location where this hook should be installed, relative to the local Git directory.

func (*Hook) Uninstall added in v0.6.0

func (h *Hook) Uninstall() error

Uninstall removes the hook on disk so long as it matches the current version, or any of the past versions of this hook.

func (*Hook) Upgrade added in v0.6.0

func (h *Hook) Upgrade() error

Upgrade upgrades the (assumed to be) existing git hook to the current contents. A hook is considered "upgrade-able" if its contents are matched in the member variable `Upgradeables`. It halts and returns any errors as they arise.

type HttpClient added in v0.5.2

type HttpClient struct {
	*http.Client
}

func (*HttpClient) Do added in v0.5.2

func (c *HttpClient) Do(req *http.Request) (*http.Response, error)

type InstallOptions added in v1.0.0

type InstallOptions struct {
	Force bool
	Local bool
}

InstallOptions serves as an argument to Install().

type LogDiffDirection added in v0.6.0

type LogDiffDirection byte

When scanning diffs e.g. parseLogOutputToPointers, which direction of diff to include data from, i.e. '+' or '-'. Depending on what you're scanning for either might be useful

type ObjectError added in v1.1.1

type ObjectError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

func (*ObjectError) Error added in v1.1.1

func (e *ObjectError) Error() string

type ObjectResource added in v1.1.1

type ObjectResource struct {
	Oid     string                   `json:"oid,omitempty"`
	Size    int64                    `json:"size"`
	Actions map[string]*linkRelation `json:"actions,omitempty"`
	Links   map[string]*linkRelation `json:"_links,omitempty"`
	Error   *ObjectError             `json:"error,omitempty"`
}

func Batch added in v0.5.2

func Batch(objects []*ObjectResource, operation string) ([]*ObjectResource, error)

func DownloadCheck added in v0.5.2

func DownloadCheck(oid string) (*ObjectResource, error)

func UploadCheck added in v0.5.2

func UploadCheck(oidPath string) (*ObjectResource, error)

func (*ObjectResource) NewRequest added in v1.1.1

func (o *ObjectResource) NewRequest(relation, method string) (*http.Request, error)

func (*ObjectResource) Rel added in v1.1.1

func (o *ObjectResource) Rel(name string) (*linkRelation, bool)

type Platform added in v0.6.0

type Platform int

func GetPlatform added in v0.6.0

func GetPlatform() Platform

type Pointer added in v0.5.1

type Pointer struct {
	Version    string
	Oid        string
	Size       int64
	OidType    string
	Extensions []*PointerExtension
}

func DecodeFrom added in v0.5.1

func DecodeFrom(reader io.Reader) ([]byte, *Pointer, error)

func DecodePointer added in v0.5.1

func DecodePointer(reader io.Reader) (*Pointer, error)

func DecodePointerFromFile added in v0.6.0

func DecodePointerFromFile(file string) (*Pointer, error)

func NewPointer added in v0.5.1

func NewPointer(oid string, size int64, exts []*PointerExtension) *Pointer

func (*Pointer) Encode added in v0.5.1

func (p *Pointer) Encode(writer io.Writer) (int, error)

func (*Pointer) Encoded added in v0.5.1

func (p *Pointer) Encoded() string

func (*Pointer) Smudge added in v0.5.1

func (p *Pointer) Smudge(writer io.Writer, workingfile string, download bool, cb CopyCallback) error

type PointerChannelWrapper added in v1.2.0

type PointerChannelWrapper struct {
	*BaseChannelWrapper
	Results <-chan *WrappedPointer
}

ChannelWrapper for pointer Scan* functions to more easily return async error data via Wait() See NewPointerChannelWrapper for construction / use

func NewPointerChannelWrapper added in v1.2.0

func NewPointerChannelWrapper(pointerChan <-chan *WrappedPointer, errorChan <-chan error) *PointerChannelWrapper

Construct a new channel wrapper for WrappedPointer Caller can use s.Results directly for normal processing then call Wait() to finish & check for errors Scan function is required to create error channel large enough not to block (usually 1 is ok)

func ScanPreviousVersionsToChan added in v1.1.0

func ScanPreviousVersionsToChan(ref string, since time.Time) (*PointerChannelWrapper, error)

ScanPreviousVersionsToChan scans changes reachable from ref (commit) back to since. Returns channel of pointers for *previous* versions that overlap that time. Does not include pointers which were still in use at ref (use ScanRefsToChan for that)

func ScanRefsToChan added in v0.6.0

func ScanRefsToChan(refLeft, refRight string, opt *ScanRefsOptions) (*PointerChannelWrapper, error)

ScanRefsToChan takes a ref and returns a channel of WrappedPointer objects for all Git LFS pointers it finds for that ref. Reports unique oids once only, not multiple times if >1 file uses the same content

func ScanUnpushedToChan added in v1.1.0

func ScanUnpushedToChan(remoteName string) (*PointerChannelWrapper, error)

ScanUnpushedToChan scans history for all LFS pointers which have been added but not pushed to the named remote. remoteName can be left blank to mean 'any remote' return progressively in a channel

type PointerExtension added in v0.6.0

type PointerExtension struct {
	Name     string
	Priority int
	Oid      string
	OidType  string
}

A PointerExtension is parsed from the Git LFS Pointer file.

func NewPointerExtension added in v0.6.0

func NewPointerExtension(name string, priority int, oid string) *PointerExtension

type ProgressMeter added in v0.6.0

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

ProgressMeter provides a progress bar type output for the TransferQueue. It is given an estimated file count and size up front and tracks the number of files and bytes transferred as well as the number of files and bytes that get skipped because the transfer is unnecessary.

func NewProgressMeter added in v0.6.0

func NewProgressMeter(estFiles int, estBytes int64, dryRun bool) *ProgressMeter

NewProgressMeter creates a new ProgressMeter for the number and size of files given.

func (*ProgressMeter) Add added in v0.6.0

func (p *ProgressMeter) Add(name string)

Add tells the progress meter that a transferring file is being added to the TransferQueue.

func (*ProgressMeter) Finish added in v0.6.0

func (p *ProgressMeter) Finish()

Finish shuts down the ProgressMeter

func (*ProgressMeter) FinishTransfer added in v0.6.0

func (p *ProgressMeter) FinishTransfer(name string)

FinishTransfer increments the finished transfer count

func (*ProgressMeter) Skip added in v0.6.0

func (p *ProgressMeter) Skip(size int64)

Skip tells the progress meter that a file of size `size` is being skipped because the transfer is unnecessary.

func (*ProgressMeter) Start added in v0.6.0

func (p *ProgressMeter) Start()

func (*ProgressMeter) TransferBytes added in v0.6.0

func (p *ProgressMeter) TransferBytes(direction, name string, read, total int64, current int)

TransferBytes increments the number of bytes transferred

type ScanRefsOptions added in v0.5.3

type ScanRefsOptions struct {
	ScanMode         ScanningMode
	RemoteName       string
	SkipDeletedBlobs bool
	// contains filtered or unexported fields
}

func NewScanRefsOptions added in v1.0.2

func NewScanRefsOptions() *ScanRefsOptions

func (*ScanRefsOptions) GetName added in v1.0.2

func (o *ScanRefsOptions) GetName(sha string) (string, bool)

func (*ScanRefsOptions) SetName added in v1.0.2

func (o *ScanRefsOptions) SetName(sha, name string)

type ScanningMode added in v0.6.0

type ScanningMode int

type Spinner added in v0.6.0

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

Indeterminate progress indicator 'spinner'

func NewSpinner added in v0.6.0

func NewSpinner() *Spinner

func (*Spinner) Finish added in v0.6.0

func (s *Spinner) Finish(out io.Writer, finishMsg string)

Finish the spinner with a completion message & newline

func (*Spinner) Print added in v0.6.0

func (s *Spinner) Print(out io.Writer, msg string)

Print a spinner (stage) to out followed by msg (no linefeed)

func (*Spinner) Spin added in v0.6.0

func (s *Spinner) Spin(out io.Writer)

Just spin the spinner one more notch & use the last message

type StringChannelWrapper added in v1.2.0

type StringChannelWrapper struct {
	*BaseChannelWrapper
	Results <-chan string
}

ChannelWrapper for string channel functions to more easily return async error data via Wait() Caller can use s.Results directly for normal processing then call Wait() to finish & check for errors See NewStringChannelWrapper for construction / use

func NewStringChannelWrapper added in v1.2.0

func NewStringChannelWrapper(stringChan <-chan string, errorChan <-chan error) *StringChannelWrapper

Construct a new channel wrapper for string Caller can use s.Results directly for normal processing then call Wait() to finish & check for errors

type StringSet added in v1.1.0

type StringSet map[string]struct{}

The primary type that represents a set

func NewStringSet added in v1.1.0

func NewStringSet() StringSet

Creates and returns a reference to an empty set.

func NewStringSetFromSlice added in v1.1.0

func NewStringSetFromSlice(s []string) StringSet

Creates and returns a reference to a set from an existing slice

func NewStringSetWithCapacity added in v1.1.0

func NewStringSetWithCapacity(capacity int) StringSet

Creates and returns a reference to an empty set with a capacity.

func (StringSet) Add added in v1.1.0

func (set StringSet) Add(i string) bool

Adds an item to the current set if it doesn't already exist in the set.

func (StringSet) Cardinality added in v1.1.0

func (set StringSet) Cardinality() int

Cardinality returns how many items are currently in the set.

func (*StringSet) Clear added in v1.1.0

func (set *StringSet) Clear()

Clears the entire set to be the empty set.

func (StringSet) Clone added in v1.1.0

func (set StringSet) Clone() StringSet

Returns a clone of the set. Does NOT clone the underlying elements.

func (StringSet) Contains added in v1.1.0

func (set StringSet) Contains(i string) bool

Determines if a given item is already in the set.

func (StringSet) ContainsAll added in v1.1.0

func (set StringSet) ContainsAll(i ...string) bool

Determines if the given items are all in the set

func (StringSet) Difference added in v1.1.0

func (set StringSet) Difference(other StringSet) StringSet

Returns a new set with items in the current set but not in the other set

func (StringSet) Equal added in v1.1.0

func (set StringSet) Equal(other StringSet) bool

Equal determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.

func (StringSet) Intersect added in v1.1.0

func (set StringSet) Intersect(other StringSet) StringSet

Returns a new set with items that exist only in both sets.

func (StringSet) IsSubset added in v1.1.0

func (set StringSet) IsSubset(other StringSet) bool

Determines if every item in the other set is in this set.

func (StringSet) IsSuperset added in v1.1.0

func (set StringSet) IsSuperset(other StringSet) bool

Determines if every item of this set is in the other set.

func (StringSet) Iter added in v1.1.0

func (set StringSet) Iter() <-chan string

Iter() returns a channel of type string that you can range over.

func (StringSet) Remove added in v1.1.0

func (set StringSet) Remove(i string)

Allows the removal of a single item in the set.

func (StringSet) SymmetricDifference added in v1.1.0

func (set StringSet) SymmetricDifference(other StringSet) StringSet

Returns a new set with items in the current set or the other set but not in both.

func (StringSet) Union added in v1.1.0

func (set StringSet) Union(other StringSet) StringSet

Returns a new set with all items in both sets.

type TransferQueue added in v0.5.2

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

TransferQueue provides a queue that will allow concurrent transfers.

func NewDownloadCheckQueue added in v0.6.0

func NewDownloadCheckQueue(files int, size int64, dryRun bool) *TransferQueue

NewDownloadCheckQueue builds a checking queue, allowing `workers` concurrent check operations.

func NewDownloadQueue added in v0.5.2

func NewDownloadQueue(files int, size int64, dryRun bool) *TransferQueue

NewDownloadQueue builds a DownloadQueue, allowing `workers` concurrent downloads.

func NewUploadQueue added in v0.5.1

func NewUploadQueue(files int, size int64, dryRun bool) *TransferQueue

NewUploadQueue builds an UploadQueue, allowing `workers` concurrent uploads.

func (*TransferQueue) Add added in v0.5.2

func (q *TransferQueue) Add(t Transferable)

Add adds a Transferable to the transfer queue.

func (*TransferQueue) Errors added in v0.5.2

func (q *TransferQueue) Errors() []error

Errors returns any errors encountered during transfer.

func (*TransferQueue) Skip added in v1.2.0

func (q *TransferQueue) Skip(size int64)

func (*TransferQueue) Wait added in v0.6.0

func (q *TransferQueue) Wait()

Wait waits for the queue to finish processing all transfers. Once Wait is called, Add will no longer add transferables to the queue. Any failed transfers will be automatically retried once.

func (*TransferQueue) Watch added in v0.5.2

func (q *TransferQueue) Watch() chan string

Watch returns a channel where the queue will write the OID of each transfer as it completes. The channel will be closed when the queue finishes processing.

type Transferable added in v0.5.2

type Transferable interface {
	Check() (*ObjectResource, error)
	Transfer(CopyCallback) error
	Object() *ObjectResource
	Oid() string
	Size() int64
	Name() string
	SetObject(*ObjectResource)
}

type TreeBlob added in v0.6.0

type TreeBlob struct {
	Sha1     string
	Filename string
}

An entry from ls-tree or rev-list including a blob sha and tree path

type TreeBlobChannelWrapper added in v1.2.0

type TreeBlobChannelWrapper struct {
	*BaseChannelWrapper
	Results <-chan TreeBlob
}

ChannelWrapper for TreeBlob channel functions to more easily return async error data via Wait() See NewTreeBlobChannelWrapper for construction / use

func NewTreeBlobChannelWrapper added in v1.2.0

func NewTreeBlobChannelWrapper(treeBlobChan <-chan TreeBlob, errorChan <-chan error) *TreeBlobChannelWrapper

Construct a new channel wrapper for TreeBlob Caller can use s.Results directly for normal processing then call Wait() to finish & check for errors

type Uploadable added in v0.5.1

type Uploadable struct {
	OidPath  string
	Filename string
	// contains filtered or unexported fields
}

Uploadable describes a file that can be uploaded.

func NewUploadable added in v0.5.1

func NewUploadable(oid, filename string) (*Uploadable, error)

NewUploadable builds the Uploadable from the given information. "filename" can be empty if a raw object is pushed (see "object-id" flag in push command)/

func (*Uploadable) Check added in v0.5.2

func (u *Uploadable) Check() (*ObjectResource, error)

func (*Uploadable) Name added in v0.5.2

func (u *Uploadable) Name() string

func (*Uploadable) Object added in v0.5.2

func (u *Uploadable) Object() *ObjectResource

func (*Uploadable) Oid added in v0.5.2

func (u *Uploadable) Oid() string

func (*Uploadable) SetObject added in v0.5.2

func (u *Uploadable) SetObject(o *ObjectResource)

func (*Uploadable) Size added in v0.5.1

func (u *Uploadable) Size() int64

func (*Uploadable) Transfer added in v0.5.2

func (u *Uploadable) Transfer(cb CopyCallback) error

type WrappedPointer added in v0.5.2

type WrappedPointer struct {
	Sha1    string
	Name    string
	SrcName string
	Size    int64
	Status  string
	*Pointer
}

WrappedPointer wraps a pointer.Pointer and provides the git sha1 and the file name associated with the object, taken from the rev-list output.

func ScanIndex added in v0.5.1

func ScanIndex() ([]*WrappedPointer, error)

ScanIndex returns a slice of WrappedPointer objects for all Git LFS pointers it finds in the index. Reports unique oids once only, not multiple times if >1 file uses the same content

func ScanPreviousVersions added in v0.6.0

func ScanPreviousVersions(ref string, since time.Time) ([]*WrappedPointer, error)

ScanPreviousVersions scans changes reachable from ref (commit) back to since. Returns pointers for *previous* versions that overlap that time. Does not return pointers which were still in use at ref (use ScanRef for that)

func ScanRefs added in v0.5.1

func ScanRefs(refLeft, refRight string, opt *ScanRefsOptions) ([]*WrappedPointer, error)

ScanRefs takes a ref and returns a slice of WrappedPointer objects for all Git LFS pointers it finds for that ref. Reports unique oids once only, not multiple times if >1 file uses the same content

func ScanTree added in v0.6.0

func ScanTree(ref string) ([]*WrappedPointer, error)

ScanTree takes a ref and returns a slice of WrappedPointer objects in the tree at that ref Differs from ScanRefs in that multiple files in the tree with the same content are all reported

func ScanUnpushed added in v0.6.0

func ScanUnpushed(remoteName string) ([]*WrappedPointer, error)

ScanUnpushed scans history for all LFS pointers which have been added but not pushed to the named remote. remoteName can be left blank to mean 'any remote'

Jump to

Keyboard shortcuts

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