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 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 *tq.Manifest) []string
- func GetHookInstallSteps() string
- func InRepo() bool
- func InstallFilters(opt InstallOptions, passThrough bool) error
- func InstallHooks(force bool) error
- func IsCallbackMissing(err error) bool
- 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 *tq.Manifest, ...) error
- func ScanObjectsChan() <-chan localstorage.Object
- func TempDir() string
- func TempFile(prefix string) (*os.File, error)
- func UninstallFilters(opt InstallOptions) error
- func UninstallHooks() error
- type Attribute
- type ByPriority
- type GitScanner
- func (s *GitScanner) Close()
- func (s *GitScanner) RemoteForPush(r string) error
- func (s *GitScanner) ScanAll(cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanIndex(ref string, cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanLeftToRemote(left string, cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanPreviousVersions(ref string, since time.Time, cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanRef(ref string, cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanRefWithDeleted(ref string, cb GitScannerFoundPointer) error
- func (s *GitScanner) ScanTree(ref string) error
- func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerFoundPointer) error
- type GitScannerFoundLockable
- type GitScannerFoundPointer
- type GitScannerSet
- type Hook
- type InstallOptions
- type LogDiffDirection
- type PathConverter
- type Platform
- type Pointer
- type PointerChannelWrapper
- type PointerExtension
- type ScanRefsOptions
- type ScanningMode
- type StringChannelWrapper
- type TreeBlob
- type TreeBlobChannelWrapper
- type WrappedPointer
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 )
Variables ¶
var (
LargeSizeThreshold = 5 * 1024 * 1024
)
Functions ¶
func ClearTempObjects ¶
func ClearTempObjects() error
func CopyCallbackFile ¶
func CopyFileContents ¶
func EncodePointer ¶ added in v0.5.1
func GetHookInstallSteps ¶
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 IsCallbackMissing ¶
IsCallbackMissing returns a boolean indicating whether the error is reporting that a GitScanner is missing a required GitScannerCallback.
func IsWindows ¶
func IsWindows() bool
Are we running on Windows? Need to handle some extra path shenanigans
func LinkOrCopy ¶
func LinkOrCopyFromReference ¶
func LocalMediaPath ¶
func LocalMediaPathReadOnly ¶
func LocalObjectTempDir ¶
func LocalObjectTempDir() string
func LocalReferencePath ¶
func ObjectExistsOfSize ¶
func PointerClean ¶ added in v0.5.1
func PointerSmudge ¶ added in v0.5.1
func PointerSmudgeToFile ¶
func ScanObjectsChan ¶
func ScanObjectsChan() <-chan localstorage.Object
func UninstallFilters ¶ added in v0.5.3
func UninstallFilters(opt InstallOptions) 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 ¶
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 ¶
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 ¶
func (a *Attribute) Uninstall(opt InstallOptions)
Uninstall removes all properties in the path of this property.
type ByPriority ¶
type ByPriority []*PointerExtension
func (ByPriority) Len ¶
func (p ByPriority) Len() int
func (ByPriority) Less ¶
func (p ByPriority) Less(i, j int) bool
func (ByPriority) Swap ¶
func (p ByPriority) Swap(i, j int)
type GitScanner ¶
type GitScanner struct { Filter *filepathfilter.Filter FoundPointer GitScannerFoundPointer FoundLockable GitScannerFoundLockable PotentialLockables GitScannerSet // contains filtered or unexported fields }
GitScanner scans objects in a Git repository for LFS pointers.
func NewGitScanner ¶
func NewGitScanner(cb GitScannerFoundPointer) *GitScanner
NewGitScanner initializes a *GitScanner for a Git repository in the current working directory.
func (*GitScanner) Close ¶
func (s *GitScanner) Close()
Close stops exits once all processing has stopped, and all resources are tracked and cleaned up.
func (*GitScanner) RemoteForPush ¶
func (s *GitScanner) RemoteForPush(r string) error
RemoteForPush sets up this *GitScanner to scan for objects to push to the given remote. Needed for ScanLeftToRemote().
func (*GitScanner) ScanAll ¶
func (s *GitScanner) ScanAll(cb GitScannerFoundPointer) error
ScanAll scans through all objects in the git repository.
func (*GitScanner) ScanIndex ¶
func (s *GitScanner) ScanIndex(ref string, cb GitScannerFoundPointer) error
ScanIndex scans the git index for modified LFS objects.
func (*GitScanner) ScanLeftToRemote ¶
func (s *GitScanner) ScanLeftToRemote(left string, cb GitScannerFoundPointer) error
ScanLeftToRemote scans through all commits starting at the given ref that the given remote does not have. See RemoteForPush().
func (*GitScanner) ScanPreviousVersions ¶
func (s *GitScanner) ScanPreviousVersions(ref string, since time.Time, cb GitScannerFoundPointer) error
ScanPreviousVersions 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 (*GitScanner) ScanRef ¶
func (s *GitScanner) ScanRef(ref string, cb GitScannerFoundPointer) error
ScanRef scans through all objects in the current ref, excluding git objects that have been modified or deleted before the ref.
func (*GitScanner) ScanRefRange ¶
func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerFoundPointer) error
ScanRefRange scans through all commits from the given left and right refs, including git objects that have been modified or deleted.
func (*GitScanner) ScanRefWithDeleted ¶
func (s *GitScanner) ScanRefWithDeleted(ref string, cb GitScannerFoundPointer) error
ScanRefWithDeleted scans through all objects in the given ref, including git objects that have been modified or deleted.
func (*GitScanner) ScanTree ¶
func (s *GitScanner) ScanTree(ref string) error
ScanTree takes a ref and returns 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 (*GitScanner) ScanUnpushed ¶
func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerFoundPointer) error
ScanUnpushed scans history for all LFS pointers which have been added but not pushed to the named remote. remote can be left blank to mean 'any remote'.
type GitScannerFoundLockable ¶
type GitScannerFoundLockable func(filename string)
type GitScannerFoundPointer ¶
type GitScannerFoundPointer func(*WrappedPointer, error)
type GitScannerSet ¶
type Hook ¶
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 NewStandardHook ¶
NewStandardHook creates a new hook using the template script calling 'git lfs theType'
func (*Hook) Dir ¶
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 ¶
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 ¶
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 ¶
InstallOptions serves as an argument to Install().
type LogDiffDirection ¶
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 PathConverter ¶
func NewCurrentToRepoPathConverter ¶
func NewCurrentToRepoPathConverter() (PathConverter, 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 NewRepoToCurrentPathConverter ¶
func NewRepoToCurrentPathConverter() (PathConverter, 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
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 ¶
func NewPointer ¶ added in v0.5.1
func NewPointer(oid string, size int64, exts []*PointerExtension) *Pointer
type PointerChannelWrapper ¶
type PointerChannelWrapper struct { *tools.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 ¶
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)
type PointerExtension ¶
A PointerExtension is parsed from the Git LFS Pointer file.
func NewPointerExtension ¶
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 (*ScanRefsOptions) SetName ¶
func (o *ScanRefsOptions) SetName(sha, name string)
type ScanningMode ¶
type ScanningMode int
type StringChannelWrapper ¶
type StringChannelWrapper struct { *tools.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 ¶
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 TreeBlobChannelWrapper ¶
type TreeBlobChannelWrapper struct { *tools.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 ¶
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