Documentation
¶
Overview ¶
Package tools contains other helper functions too small to justify their own package NOTE: Subject to change, do not rely on this package from outside git-lfs source
Set is a modification of https://github.com/deckarep/golang-set The MIT License (MIT) Copyright (c) 2013 Ralph Caraveo (deckarep@gmail.com)
Index ¶
- Constants
- func CleanPaths(paths, delim string) (cleaned []string)
- func CloneFile(writer io.Writer, reader io.Reader) (bool, error)
- func CopyWithCallback(writer io.Writer, reader io.Reader, totalSize int64, cb progress.CopyCallback) (int64, error)
- func DirExists(path string) bool
- func FastWalkGitRepo(dir string, cb FastWalkCallback)
- func FileExists(path string) bool
- func FileExistsOfSize(path string, sz int64) bool
- func FileOrDirExists(path string) (exists bool, isDir bool)
- func MaxInt(a, b int) int
- func MinInt(a, b int) int
- func NewLfsContentHash() hash.Hash
- func NewReadSeekCloserWrapper(r io.ReadSeeker) io.ReadCloser
- func NewRetriableReader(r io.Reader) io.Reader
- func RenameFileCopyPermissions(srcfile, destfile string) error
- func ResolveSymlinks(path string) string
- func Spool(to io.Writer, from io.Reader) (n int64, err error)
- func VerifyFileHash(oid, path string) error
- type FastWalkCallback
- type HashingReader
- type RetriableReader
- type StringSet
- func (set StringSet) Add(i string) bool
- func (set StringSet) Cardinality() int
- func (set *StringSet) Clear()
- func (set StringSet) Clone() StringSet
- func (set StringSet) Contains(i string) bool
- func (set StringSet) ContainsAll(i ...string) bool
- func (set StringSet) Difference(other StringSet) StringSet
- func (set StringSet) Equal(other StringSet) bool
- func (set StringSet) Intersect(other StringSet) StringSet
- func (set StringSet) IsSubset(other StringSet) bool
- func (set StringSet) IsSuperset(other StringSet) bool
- func (set StringSet) Iter() <-chan string
- func (set StringSet) Remove(i string)
- func (set StringSet) SymmetricDifference(other StringSet) StringSet
- func (set StringSet) Union(other StringSet) StringSet
Constants ¶
const (
BtrfsIocClone = C.BTRFS_IOC_CLONE
)
Variables ¶
This section is empty.
Functions ¶
func CleanPaths ¶
CleanPaths splits the given `paths` argument by the delimiter argument, and then "cleans" that path according to the path.Clean function (see https://golang.org/pkg/path#Clean). Note always cleans to '/' path separators regardless of platform (git friendly)
func CopyWithCallback ¶
func CopyWithCallback(writer io.Writer, reader io.Reader, totalSize int64, cb progress.CopyCallback) (int64, error)
CopyWithCallback copies reader to writer while performing a progress callback
func FastWalkGitRepo ¶
func FastWalkGitRepo(dir string, cb FastWalkCallback)
FastWalkGitRepo is a more optimal implementation of filepath.Walk for a Git repo. The callback guaranteed to be called sequentially. The function returns once all files and errors have triggered callbacks. It differs in the following ways:
- Uses goroutines to parallelise large dirs and descent into subdirs
- Does not provide sorted output; parents will always be before children but there are no other guarantees. Use parentDir argument in the callback to determine absolute path rather than tracking it yourself
- Automatically ignores any .git directories
- Respects .gitignore contents and skips ignored files/dirs
func FileExists ¶
FileExists determines if a file (NOT dir) exists.
func FileExistsOfSize ¶
FileExistsOfSize determines if a file exists and is of a specific size.
func FileOrDirExists ¶
FileOrDirExists determines if a file/dir exists, returns IsDir() results too.
func NewLfsContentHash ¶
Get a new Hash instance of the type used to hash LFS content
func NewReadSeekCloserWrapper ¶
func NewReadSeekCloserWrapper(r io.ReadSeeker) io.ReadCloser
NewReadSeekCloserWrapper wraps an io.ReadSeeker and implements a no-op Close() function to make it an io.ReadCloser
func RenameFileCopyPermissions ¶
RenameFileCopyPermissions moves srcfile to destfile, replacing destfile if necessary and also copying the permissions of destfile if it already exists
func ResolveSymlinks ¶
ResolveSymlinks ensures that if the path supplied is a symlink, it is resolved to the actual concrete path
func Spool ¶
Spool spools the contents from 'from' to 'to' by buffering the entire contents of 'from' into a temprorary buffer. That buffer is held in memory until the file grows to larger than 'memoryBufferLimit`, then the remaining contents are spooled to disk.
The temporary file is cleaned up after the copy is complete.
The number of bytes written to "to", as well as any error encountered are returned.
func VerifyFileHash ¶
VerifyFileHash reads a file and verifies whether the SHA is correct Returns an error if there is a problem
Types ¶
type FastWalkCallback ¶
FastWalkCallback is the signature for the callback given to FastWalkGitRepo()
type HashingReader ¶
type HashingReader struct {
// contains filtered or unexported fields
}
HashingReader wraps a reader and calculates the hash of the data as it is read
func NewHashingReader ¶
func NewHashingReader(r io.Reader) *HashingReader
func NewHashingReaderPreloadHash ¶
func NewHashingReaderPreloadHash(r io.Reader, hash hash.Hash) *HashingReader
func (*HashingReader) Hash ¶
func (r *HashingReader) Hash() string
type RetriableReader ¶
type RetriableReader struct {
// contains filtered or unexported fields
}
RetriableReader wraps a error response of reader as RetriableError()
type StringSet ¶
type StringSet map[string]struct{}
The primary type that represents a set
func NewStringSetFromSlice ¶
Creates and returns a reference to a set from an existing slice
func NewStringSetWithCapacity ¶
Creates and returns a reference to an empty set with a capacity.
func (StringSet) Cardinality ¶
Cardinality returns how many items are currently in the set.
func (StringSet) ContainsAll ¶
Determines if the given items are all in the set
func (StringSet) Difference ¶
Returns a new set with items in the current set but not in the other set
func (StringSet) Equal ¶
Equal determines if two sets are equal to each other. If they both are the same size and have the same items they are considered equal. Order of items is not relevent for sets to be equal.
func (StringSet) IsSuperset ¶
Determines if every item of this set is in the other set.
func (StringSet) SymmetricDifference ¶
Returns a new set with items in the current set or the other set but not in both.