Documentation ¶
Overview ¶
Package lfs brings together the core LFS functionality NOTE: Subject to change, do not rely on this package from outside git-lfs source
Index ¶
- Constants
- Variables
- func AllObjects() []localstorage.Object
- func ClearTempObjects() error
- func ConvertCwdFilesRelativeToRepo(cwdchan <-chan string) (<-chan string, error)
- func ConvertRepoFilesRelativeToCwd(repochan <-chan string) (<-chan string, error)
- func CopyCallbackFile(event, filename string, index, totalFiles int) (progress.CopyCallback, *os.File, error)
- func CopyFileContents(src string, dst string) error
- func EncodePointer(writer io.Writer, pointer *Pointer) (int, error)
- func Environ(cfg *config.Configuration, manifest *transfer.Manifest) []string
- func GetHookInstallSteps() string
- func InRepo() bool
- func InstallFilters(opt InstallOptions, passThrough bool) error
- func InstallHooks(force bool) error
- func IsWindows() bool
- func LinkOrCopy(src string, dst string) error
- func LinkOrCopyFromReference(oid string, size int64) error
- func LocalMediaDir() string
- func LocalMediaPath(oid string) (string, error)
- func LocalMediaPathReadOnly(oid string) string
- func LocalObjectTempDir() string
- func LocalReferencePath(sha string) string
- func ObjectExistsOfSize(oid string, size int64) bool
- func PointerClean(reader io.Reader, fileName string, fileSize int64, cb progress.CopyCallback) (*cleanedAsset, error)
- func PointerSmudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, ...) error
- func PointerSmudgeToFile(filename string, ptr *Pointer, download bool, manifest *transfer.Manifest, ...) error
- func ScanObjectsChan() <-chan localstorage.Object
- func TempDir() string
- func TempFile(prefix string) (*os.File, error)
- func UninstallFilters() error
- func UninstallHooks() error
- type Attribute
- type BaseChannelWrapper
- type Batcher
- type ByPriority
- type ChannelWrapper
- type Downloadable
- func (d *Downloadable) LegacyCheck() (*api.ObjectResource, error)
- func (d *Downloadable) Name() string
- func (d *Downloadable) Object() *api.ObjectResource
- func (d *Downloadable) Oid() string
- func (d *Downloadable) Path() string
- func (d *Downloadable) SetObject(o *api.ObjectResource)
- func (d *Downloadable) Size() int64
- type Hook
- type InstallOptions
- type LogDiffDirection
- type Platform
- type Pointer
- type PointerChannelWrapper
- func NewPointerChannelWrapper(pointerChan <-chan *WrappedPointer, errorChan <-chan error) *PointerChannelWrapper
- func ScanPreviousVersionsToChan(ref string, since time.Time) (*PointerChannelWrapper, error)
- func ScanRefsToChan(refLeft, refRight string, opt *ScanRefsOptions) (*PointerChannelWrapper, error)
- func ScanUnpushedToChan(remoteName string) (*PointerChannelWrapper, error)
- type PointerExtension
- type ScanRefsOptions
- type ScanningMode
- type StringChannelWrapper
- type TransferQueue
- type Transferable
- type TreeBlob
- type TreeBlobChannelWrapper
- type Uploadable
- func (u *Uploadable) LegacyCheck() (*api.ObjectResource, error)
- func (u *Uploadable) Name() string
- func (u *Uploadable) Object() *api.ObjectResource
- func (u *Uploadable) Oid() string
- func (u *Uploadable) Path() string
- func (u *Uploadable) SetObject(o *api.ObjectResource)
- func (u *Uploadable) Size() int64
- type WrappedPointer
- func ScanIndex(ref string) ([]*WrappedPointer, error)
- func ScanPreviousVersions(ref string, since time.Time) ([]*WrappedPointer, error)
- func ScanRefs(refLeft, refRight string, opt *ScanRefsOptions) ([]*WrappedPointer, error)
- func ScanTree(ref string) ([]*WrappedPointer, error)
- func ScanUnpushed(remoteName string) ([]*WrappedPointer, error)
Constants ¶
const ( ScanRefsMode = ScanningMode(iota) // 0 - or default scan mode ScanAllMode = ScanningMode(iota) ScanLeftToRemoteMode = ScanningMode(iota) )
const ( LogDiffAdditions = LogDiffDirection('+') // include '+' diffs LogDiffDeletions = LogDiffDirection('-') // include '-' diffs )
const ( PlatformWindows = Platform(iota) PlatformLinux = Platform(iota) PlatformOSX = Platform(iota) PlatformOther = Platform(iota) // most likely a *nix variant e.g. freebsd PlatformUndetermined = Platform(iota) )
const (
Version = "1.5.4"
)
Variables ¶
var (
LargeSizeThreshold = 5 * 1024 * 1024
)
Functions ¶
func ClearTempObjects ¶ added in v1.0.1
func ClearTempObjects() error
func ConvertCwdFilesRelativeToRepo ¶ added in v0.6.0
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
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 CopyCallbackFile ¶
func CopyFileContents ¶ added in v1.2.0
func EncodePointer ¶ added in v0.5.1
func GetHookInstallSteps ¶ added in v1.2.1
func GetHookInstallSteps() string
Get user-readable manual install steps for hooks
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 ¶
InstallHooks installs all hooks in the `hooks` var.
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 LinkOrCopyFromReference ¶ added in v1.2.0
func LocalMediaPath ¶
func LocalMediaPathReadOnly ¶ added in v1.3.0
func LocalObjectTempDir ¶ added in v1.0.1
func LocalObjectTempDir() string
func LocalReferencePath ¶ added in v1.2.0
func ObjectExistsOfSize ¶ added in v0.6.0
func PointerClean ¶ added in v0.5.1
func PointerSmudge ¶ added in v0.5.1
func PointerSmudgeToFile ¶ added in v0.6.0
func ScanObjectsChan ¶ added in v1.2.0
func ScanObjectsChan() <-chan localstorage.Object
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.
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 // Previous values of these attributes that can be automatically upgraded Upgradeables 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.
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
- Flush() is called, forcing the batch to be returned immediately, as-is
- Exit() is called
When an Exit() or Flush() occurs, the group may be smaller than the batch size.
func NewBatcher ¶ added in v0.6.0
NewBatcher creates a Batcher with the batchSize.
func (*Batcher) Add ¶ added in v0.6.0
func (b *Batcher) Add(ts ...interface{})
Add adds one or more items 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.
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 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 Downloadable ¶ added in v0.5.2
type Downloadable struct {
// contains filtered or unexported fields
}
func NewDownloadable ¶ added in v0.5.2
func NewDownloadable(p *WrappedPointer) *Downloadable
func (*Downloadable) LegacyCheck ¶ added in v1.3.0
func (d *Downloadable) LegacyCheck() (*api.ObjectResource, error)
TODO remove this legacy method & only support batch
func (*Downloadable) Name ¶ added in v0.5.2
func (d *Downloadable) Name() string
func (*Downloadable) Object ¶ added in v0.5.2
func (d *Downloadable) Object() *api.ObjectResource
func (*Downloadable) Oid ¶ added in v0.5.2
func (d *Downloadable) Oid() string
func (*Downloadable) Path ¶ added in v1.3.0
func (d *Downloadable) Path() string
func (*Downloadable) SetObject ¶ added in v0.5.2
func (d *Downloadable) SetObject(o *api.ObjectResource)
func (*Downloadable) Size ¶ added in v0.5.2
func (d *Downloadable) Size() int64
type Hook ¶ added in v0.6.0
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) Dir ¶ added in v1.3.1
Dir returns the directory used by LFS for storing Git hooks. By default, it will return the hooks/ sub-directory of the local repository's .git directory. If `core.hooksPath` is configured and supported (Git verison is greater than "2.9.0"), it will return that instead.
func (*Hook) Install ¶ added in v0.6.0
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
Path returns the desired (or actual, if installed) location where this hook should be installed. It returns an absolute path in all cases.
type InstallOptions ¶ added in v1.0.0
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 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
DecodeFrom decodes an *lfs.Pointer from the given io.Reader, "reader". If the pointer encoded in the reader could successfully be read and decoded, it will be returned with a nil error.
If the pointer could not be decoded, an io.Reader containing the entire blob's data will be returned, along with a parse error.
func DecodePointerFromFile ¶ added in v0.6.0
func NewPointer ¶ added in v0.5.1
func NewPointer(oid string, size int64, exts []*PointerExtension) *Pointer
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
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 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 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 TransferQueue ¶ added in v0.5.2
type TransferQueue struct {
// contains filtered or unexported fields
}
TransferQueue organises the wider process of uploading and downloading, including calling the API, passing the actual transfer request to transfer adapters, and dealing with progress, errors and retries.
func NewDownloadCheckQueue ¶ added in v0.6.0
func NewDownloadCheckQueue(files int, size int64) *TransferQueue
NewDownloadCheckQueue builds a checking queue, checks that objects are there but doesn't download
func NewDownloadQueue ¶ added in v0.5.2
func NewDownloadQueue(files int, size int64, dryRun bool) *TransferQueue
NewDownloadQueue builds a DownloadQueue, allowing 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. It only increments the amount of waiting the TransferQueue has to do if the Transferable "t" is new.
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 { Oid() string Size() int64 Name() string Path() string Object() *api.ObjectResource SetObject(*api.ObjectResource) // Legacy API check - TODO remove this and only support batch LegacyCheck() (*api.ObjectResource, error) }
type TreeBlob ¶ added in v0.6.0
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
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) LegacyCheck ¶ added in v1.3.0
func (u *Uploadable) LegacyCheck() (*api.ObjectResource, error)
TODO LEGACY API: remove when legacy API removed
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() *api.ObjectResource
func (*Uploadable) Oid ¶ added in v0.5.2
func (u *Uploadable) Oid() string
func (*Uploadable) Path ¶ added in v1.3.0
func (u *Uploadable) Path() string
func (*Uploadable) SetObject ¶ added in v0.5.2
func (u *Uploadable) SetObject(o *api.ObjectResource)
func (*Uploadable) Size ¶ added in v0.5.1
func (u *Uploadable) Size() int64
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(ref string) ([]*WrappedPointer, error)
ScanIndex returns a slice of WrappedPointer objects for all Git LFS pointers it finds in the index.
Ref is the ref at which to scan, which may be "HEAD" if there is at least one commit.
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'