lfs

package
v2.5.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2018 License: MIT Imports: 30 Imported by: 55

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

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)
)

Variables

This section is empty.

Functions

func CopyFileContents added in v1.5.6

func CopyFileContents(cfg *config.Configuration, src string, dst string) error

func EncodePointer added in v0.5.1

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

func Environ

func Environ(cfg *config.Configuration, manifest *tq.Manifest) []string

func IsCallbackMissing

func IsCallbackMissing(err error) bool

IsCallbackMissing returns a boolean indicating whether the error is reporting that a GitScanner is missing a required GitScannerCallback.

func IsWindows added in v1.5.6

func IsWindows() bool

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

func LinkOrCopy added in v1.5.6

func LinkOrCopy(cfg *config.Configuration, src string, dst string) error

func LinkOrCopyFromReference added in v1.5.6

func LinkOrCopyFromReference(cfg *config.Configuration, oid string, size int64) error

Types

type Attribute added in v1.5.6

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 v1.5.6

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 added in v1.5.6

func (a *Attribute) Uninstall(opt *FilterOptions)

Uninstall removes all properties in the path of this property.

type ByPriority added in v1.5.6

type ByPriority []*PointerExtension

func (ByPriority) Len added in v1.5.6

func (p ByPriority) Len() int

func (ByPriority) Less added in v1.5.6

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

func (ByPriority) Swap added in v1.5.6

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) Clean

func (f *GitFilter) Clean(reader io.Reader, fileName string, fileSize int64, cb tools.CopyCallback) (*cleanedAsset, error)

func (*GitFilter) CopyCallbackFile

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

func (*GitFilter) ObjectPath

func (f *GitFilter) ObjectPath(oid string) (string, error)

func (*GitFilter) RemoteRef

func (f *GitFilter) RemoteRef() *git.Ref

func (*GitFilter) Smudge

func (f *GitFilter) Smudge(writer io.Writer, ptr *Pointer, workingfile string, download bool, manifest *tq.Manifest, cb tools.CopyCallback) (int64, error)

func (*GitFilter) SmudgeToFile

func (f *GitFilter) SmudgeToFile(filename string, ptr *Pointer, download bool, manifest *tq.Manifest, cb tools.CopyCallback) error

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 GitScannerSet interface {
	Contains(string) bool
}

type Hook added in v1.5.6

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 LoadHooks

func LoadHooks(hookDir string) []*Hook

func NewStandardHook

func NewStandardHook(theType, hookDir string, upgradeables []string) *Hook

NewStandardHook creates a new hook using the template script calling 'git lfs theType'

func (*Hook) Exists added in v1.5.6

func (h *Hook) Exists() bool

func (*Hook) Install added in v1.5.6

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 v1.5.6

func (h *Hook) Path() string

Path returns the desired (or actual, if installed) location where this hook should be installed. It returns an absolute path in all cases.

func (*Hook) Uninstall added in v1.5.6

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 v1.5.6

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 LogDiffDirection added in v1.5.6

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

type PathConverter interface {
	Convert(string) string
}

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 Platform added in v1.5.6

type Platform int

func GetPlatform added in v1.5.6

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) (*Pointer, io.Reader, error)

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 DecodePointer added in v0.5.1

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

func DecodePointerFromFile added in v1.5.6

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

type PointerChannelWrapper added in v1.5.6

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 added in v1.5.6

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 added in v1.5.6

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 v1.5.6

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) GetName added in v1.5.6

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

func (*ScanRefsOptions) SetName added in v1.5.6

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

type ScanningMode added in v1.5.6

type ScanningMode int

type StringChannelWrapper added in v1.5.6

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 added in v1.5.6

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 TreeBlob added in v1.5.6

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.5.6

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 added in v1.5.6

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 WrappedPointer added in v0.5.2

type WrappedPointer struct {
	Sha1    string
	Name    string
	SrcName string
	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.

Jump to

Keyboard shortcuts

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