continue gutting lfs/scanner.go
This commit is contained in:
parent
7275bf2ae4
commit
422f3ead09
@ -131,3 +131,40 @@ func (s *GitScanner) opts(mode ScanningMode) *ScanRefsOptions {
|
||||
opts.skippedRefs = s.skippedRefs
|
||||
return opts
|
||||
}
|
||||
|
||||
type ScanningMode int
|
||||
|
||||
const (
|
||||
ScanRefsMode = ScanningMode(iota) // 0 - or default scan mode
|
||||
ScanAllMode = ScanningMode(iota)
|
||||
ScanLeftToRemoteMode = ScanningMode(iota)
|
||||
)
|
||||
|
||||
type ScanRefsOptions struct {
|
||||
ScanMode ScanningMode
|
||||
RemoteName string
|
||||
SkipDeletedBlobs bool
|
||||
skippedRefs []string
|
||||
nameMap map[string]string
|
||||
mutex *sync.Mutex
|
||||
}
|
||||
|
||||
func (o *ScanRefsOptions) GetName(sha string) (string, bool) {
|
||||
o.mutex.Lock()
|
||||
name, ok := o.nameMap[sha]
|
||||
o.mutex.Unlock()
|
||||
return name, ok
|
||||
}
|
||||
|
||||
func (o *ScanRefsOptions) SetName(sha, name string) {
|
||||
o.mutex.Lock()
|
||||
o.nameMap[sha] = name
|
||||
o.mutex.Unlock()
|
||||
}
|
||||
|
||||
func newScanRefsOptions() *ScanRefsOptions {
|
||||
return &ScanRefsOptions{
|
||||
nameMap: make(map[string]string, 0),
|
||||
mutex: &sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +174,15 @@ func revListIndex(atRef string, cache bool, indexMap *indexFileMap) (*StringChan
|
||||
return NewStringChannelWrapper(revs, errchan), nil
|
||||
}
|
||||
|
||||
// indexFile is used when scanning the index. It stores the name of
|
||||
// the file, the status of the file in the index, and, in the case of
|
||||
// a moved or copied file, the original name of the file.
|
||||
type indexFile struct {
|
||||
Name string
|
||||
SrcName string
|
||||
Status string
|
||||
}
|
||||
|
||||
type indexFileMap struct {
|
||||
// mutex guards nameMap and nameShaPairs
|
||||
mutex *sync.Mutex
|
||||
|
@ -13,6 +13,8 @@ import (
|
||||
"github.com/rubyist/tracerx"
|
||||
)
|
||||
|
||||
var z40 = regexp.MustCompile(`\^?0{40}`)
|
||||
|
||||
// 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
|
||||
|
@ -1,10 +1,6 @@
|
||||
package lfs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"sync"
|
||||
)
|
||||
import "fmt"
|
||||
|
||||
const (
|
||||
// blobSizeCutoff is used to determine which files to scan for Git LFS
|
||||
@ -30,54 +26,6 @@ type WrappedPointer struct {
|
||||
*Pointer
|
||||
}
|
||||
|
||||
// indexFile is used when scanning the index. It stores the name of
|
||||
// the file, the status of the file in the index, and, in the case of
|
||||
// a moved or copied file, the original name of the file.
|
||||
type indexFile struct {
|
||||
Name string
|
||||
SrcName string
|
||||
Status string
|
||||
}
|
||||
|
||||
var z40 = regexp.MustCompile(`\^?0{40}`)
|
||||
|
||||
type ScanningMode int
|
||||
|
||||
const (
|
||||
ScanRefsMode = ScanningMode(iota) // 0 - or default scan mode
|
||||
ScanAllMode = ScanningMode(iota)
|
||||
ScanLeftToRemoteMode = ScanningMode(iota)
|
||||
)
|
||||
|
||||
type ScanRefsOptions struct {
|
||||
ScanMode ScanningMode
|
||||
RemoteName string
|
||||
SkipDeletedBlobs bool
|
||||
skippedRefs []string
|
||||
nameMap map[string]string
|
||||
mutex *sync.Mutex
|
||||
}
|
||||
|
||||
func (o *ScanRefsOptions) GetName(sha string) (string, bool) {
|
||||
o.mutex.Lock()
|
||||
name, ok := o.nameMap[sha]
|
||||
o.mutex.Unlock()
|
||||
return name, ok
|
||||
}
|
||||
|
||||
func (o *ScanRefsOptions) SetName(sha, name string) {
|
||||
o.mutex.Lock()
|
||||
o.nameMap[sha] = name
|
||||
o.mutex.Unlock()
|
||||
}
|
||||
|
||||
func newScanRefsOptions() *ScanRefsOptions {
|
||||
return &ScanRefsOptions{
|
||||
nameMap: make(map[string]string, 0),
|
||||
mutex: &sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
// catFileBatchCheck uses git cat-file --batch-check to get the type
|
||||
// and size of a git object. Any object that isn't of type blob and
|
||||
// under the blobSizeCutoff will be ignored. revs is a channel over
|
||||
|
Loading…
Reference in New Issue
Block a user