lfs

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2016 License: MIT Imports: 30 Imported by: 0

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)
)
View Source
const (
	Version = "1.3.1"
)

Variables

View Source
var (
	LargeSizeThreshold = 5 * 1024 * 1024
)

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

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

func CopyFileContents added in v1.2.0

func CopyFileContents(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() []string

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

func GetHookInstallSteps() string

Get user-readable manual install steps for hooks

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

func LocalMediaDir() string

LocalMediaDir returns the root of lfs objects

func LocalMediaPath

func LocalMediaPath(oid string) (string, error)

func LocalMediaPathReadOnly added in v1.3.0

func LocalMediaPathReadOnly(oid string) string

func LocalObjectTempDir added in v1.0.1

func LocalObjectTempDir() string

func LocalReferencePath added in v1.2.0

func LocalReferencePath(sha string) string

func ObjectExistsOfSize added in v0.6.0

func ObjectExistsOfSize(oid string, size int64) bool

func PointerClean added in v0.5.1

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

func PointerSmudge added in v0.5.1

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

func PointerSmudgeToFile added in v0.6.0

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

func ScanObjectsChan added in v1.2.0

func ScanObjectsChan() <-chan localstorage.Object

func TempDir

func TempDir() string

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.

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 interface{})

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() []interface{}

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

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) Dir added in v1.3.1

func (h *Hook) Dir() string

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) 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. It returns an absolute path in all cases.

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

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

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) 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() ([]*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