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
- func CopyFileContents(cfg *config.Configuration, src string, dst string) error
- func EncodePointer(writer io.Writer, pointer *Pointer) (int, error)
- func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string
- func IsCallbackMissing(err error) bool
- func IsWindows() bool
- func LinkOrCopy(cfg *config.Configuration, src string, dst string) error
- func LinkOrCopyFromReference(cfg *config.Configuration, oid string, size int64) error
- type Attribute
- type ByPriority
- type DiffIndexEntry
- type DiffIndexScanner
- type DiffIndexStatus
- type FetchPruneConfig
- type FilterOptions
- type GitFilter
- func (f *GitFilter) Clean(reader io.Reader, fileName string, fileSize int64, cb tools.CopyCallback) (*cleanedAsset, error)
- func (f *GitFilter) CopyCallbackFile(event, filename string, index, totalFiles int) (tools.CopyCallback, *os.File, error)
- func (f *GitFilter) ObjectPath(oid string) (string, error)
- func (f *GitFilter) RemoteRef() *git.Ref
- func (f *GitFilter) Smudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, ...) (int64, error)
- func (f *GitFilter) SmudgeToFile(filename string, ptr *Pointer, download bool, manifest *tq.Manifest, ...) error
- 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) ScanRefs(include, exclude []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 LogDiffDirection
- type PathConverter
- type Platform
- type Pointer
- type PointerChannelWrapper
- type PointerExtension
- type PointerScanner
- 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 ¶
This section is empty.
Functions ¶
func CopyFileContents ¶
func CopyFileContents(cfg *config.Configuration, src string, dst string) error
func EncodePointer ¶ added in v0.5.1
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 LinkOrCopy(cfg *config.Configuration, src string, dst string) error
func LinkOrCopyFromReference ¶
func LinkOrCopyFromReference(cfg *config.Configuration, oid string, size int64) error
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 *FilterOptions) 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 *FilterOptions)
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 DiffIndexEntry ¶
type DiffIndexEntry struct { // SrcMode is the file mode of the "src" file, stored as a string-based // octal. SrcMode string // DstMode is the file mode of the "dst" file, stored as a string-based // octal. DstMode string // SrcSha is the Git blob ID of the "src" file. SrcSha string // DstSha is the Git blob ID of the "dst" file. DstSha string // Status is the status of the file in the index. Status DiffIndexStatus // StatusScore is the optional "score" associated with a particular // status. StatusScore int // SrcName is the name of the file in its "src" state as it appears in // the index. SrcName string // DstName is the name of the file in its "dst" state as it appears in // the index. DstName string }
DiffIndexEntry holds information about a single item in the results of a `git diff-index` command.
type DiffIndexScanner ¶
type DiffIndexScanner struct {
// contains filtered or unexported fields
}
DiffIndexScanner scans the output of the `git diff-index` command.
func NewDiffIndexScanner ¶
func NewDiffIndexScanner(ref string, cached bool) (*DiffIndexScanner, error)
NewDiffIndexScanner initializes a new `DiffIndexScanner` scanning at the given ref, "ref".
If "cache" is given, the DiffIndexScanner will scan for differences between the given ref and the index. If "cache" is _not_ given, DiffIndexScanner will scan for differences between the given ref and the currently checked out tree.
If any error was encountered in starting the command or closing its `stdin`, that error will be returned immediately. Otherwise, a `*DiffIndexScanner` will be returned with a `nil` error.
func (*DiffIndexScanner) Entry ¶
func (s *DiffIndexScanner) Entry() *DiffIndexEntry
Entry returns the last entry that was Scan()'d by the DiffIndexScanner.
func (*DiffIndexScanner) Err ¶
func (s *DiffIndexScanner) Err() error
Entry returns the last error that was encountered by the DiffIndexScanner.
func (*DiffIndexScanner) Scan ¶
func (s *DiffIndexScanner) Scan() bool
Scan advances the scan line and yields either a new value for Entry(), or an Err(). It returns true or false, whether or not it can continue scanning for more entries.
type DiffIndexStatus ¶
type DiffIndexStatus rune
Status represents the status of a file that appears in the output of `git diff-index`.
More information about each of its valid instances can be found: https://git-scm.com/docs/git-diff-index
const ( StatusAddition DiffIndexStatus = 'A' StatusCopy DiffIndexStatus = 'C' StatusDeletion DiffIndexStatus = 'D' StatusModification DiffIndexStatus = 'M' StatusRename DiffIndexStatus = 'R' StatusTypeChange DiffIndexStatus = 'T' StatusUnmerged DiffIndexStatus = 'U' StatusUnknown DiffIndexStatus = 'X' )
func (DiffIndexStatus) Format ¶
func (s DiffIndexStatus) Format(state fmt.State, c rune)
Format implements fmt.Formatter. If printed as "%+d", "%+s", or "%+v", the status will be written out as an English word: i.e., "addition", "copy", "deletion", etc.
If the '+' flag is not given, the shorthand will be used instead: 'A', 'C', and 'D', respectively.
If any other format verb is given, this function will panic().
func (DiffIndexStatus) String ¶
func (s DiffIndexStatus) String() string
String implements fmt.Stringer by returning a human-readable name for each status.
type FetchPruneConfig ¶
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
func NewFetchPruneConfig ¶
func NewFetchPruneConfig(git config.Environment) FetchPruneConfig
type FilterOptions ¶
type FilterOptions struct { GitConfig *git.Configuration Force bool Local bool System bool SkipSmudge bool }
FilterOptions serves as an argument to Install().
func (*FilterOptions) Install ¶
func (o *FilterOptions) Install() error
func (*FilterOptions) Uninstall ¶
func (o *FilterOptions) Uninstall() error
type GitFilter ¶
type GitFilter struct {
// contains filtered or unexported fields
}
GitFilter provides clean and smudge capabilities
func NewGitFilter ¶
func NewGitFilter(cfg *config.Configuration) *GitFilter
NewGitFilter initializes a new *GitFilter
func (*GitFilter) CopyCallbackFile ¶
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) ScanRefs ¶
func (s *GitScanner) ScanRefs(include, exclude []string, cb GitScannerFoundPointer) error
ScanRefs through all commits reachable by refs contained in "include" and not reachable by any refs included in "excluded"
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 ¶
type Hook struct { Type string Contents string Dir string // contains filtered or unexported fields }
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) 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 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(cfg *config.Configuration) (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(cfg *config.Configuration) (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 PointerScanner ¶
type PointerScanner struct {
// contains filtered or unexported fields
}
func NewPointerScanner ¶
func NewPointerScanner() (*PointerScanner, error)
func (*PointerScanner) BlobSHA ¶
func (s *PointerScanner) BlobSHA() string
func (*PointerScanner) Close ¶
func (s *PointerScanner) Close() error
func (*PointerScanner) ContentsSha ¶
func (s *PointerScanner) ContentsSha() string
func (*PointerScanner) Err ¶
func (s *PointerScanner) Err() error
func (*PointerScanner) Pointer ¶
func (s *PointerScanner) Pointer() *WrappedPointer
func (*PointerScanner) Scan ¶
func (s *PointerScanner) Scan(sha string) bool
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
Source Files ¶
- attribute.go
- config.go
- diff_index_scanner.go
- extension.go
- gitfilter.go
- gitfilter_clean.go
- gitfilter_smudge.go
- gitscanner.go
- gitscanner_catfilebatch.go
- gitscanner_catfilebatchcheck.go
- gitscanner_index.go
- gitscanner_log.go
- gitscanner_refs.go
- gitscanner_remotes.go
- gitscanner_tree.go
- hook.go
- lfs.go
- pointer.go
- scanner.go
- util.go