Skip to content

Commit

Permalink
lfs: rename git scanner callback type
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Feb 15, 2017
1 parent f3a3a1c commit 81d7177
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions lfs/gitscanner.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ func IsCallbackMissing(err error) bool {
// GitScanner scans objects in a Git repository for LFS pointers.
type GitScanner struct {
Filter *filepathfilter.Filter
callback GitScannerCallback
callback GitScannerFoundPointer
remote string
skippedRefs []string

Expand All @@ -30,11 +30,11 @@ type GitScanner struct {
mu sync.Mutex
}

type GitScannerCallback func(*WrappedPointer, error)
type GitScannerFoundPointer func(*WrappedPointer, error)

// NewGitScanner initializes a *GitScanner for a Git repository in the current
// working directory.
func NewGitScanner(cb GitScannerCallback) *GitScanner {
func NewGitScanner(cb GitScannerFoundPointer) *GitScanner {
return &GitScanner{started: time.Now(), callback: cb}
}

Expand Down Expand Up @@ -69,7 +69,7 @@ func (s *GitScanner) RemoteForPush(r string) error {

// ScanLeftToRemote scans through all commits starting at the given ref that the
// given remote does not have. See RemoteForPush().
func (s *GitScanner) ScanLeftToRemote(left string, cb GitScannerCallback) error {
func (s *GitScanner) ScanLeftToRemote(left string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -87,7 +87,7 @@ func (s *GitScanner) ScanLeftToRemote(left string, cb GitScannerCallback) error

// ScanRefRange scans through all commits from the given left and right refs,
// including git objects that have been modified or deleted.
func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerCallback) error {
func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -100,13 +100,13 @@ func (s *GitScanner) ScanRefRange(left, right string, cb GitScannerCallback) err

// ScanRefWithDeleted scans through all objects in the given ref, including
// git objects that have been modified or deleted.
func (s *GitScanner) ScanRefWithDeleted(ref string, cb GitScannerCallback) error {
func (s *GitScanner) ScanRefWithDeleted(ref string, cb GitScannerFoundPointer) error {
return s.ScanRefRange(ref, "", cb)
}

// ScanRef scans through all objects in the current ref, excluding git objects
// that have been modified or deleted before the ref.
func (s *GitScanner) ScanRef(ref string, cb GitScannerCallback) error {
func (s *GitScanner) ScanRef(ref string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -118,7 +118,7 @@ func (s *GitScanner) ScanRef(ref string, cb GitScannerCallback) error {
}

// ScanAll scans through all objects in the git repository.
func (s *GitScanner) ScanAll(cb GitScannerCallback) error {
func (s *GitScanner) ScanAll(cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -142,7 +142,7 @@ func (s *GitScanner) ScanTree(ref string) 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'.
func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerCallback) error {
func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -154,7 +154,7 @@ func (s *GitScanner) ScanUnpushed(remote string, cb GitScannerCallback) error {
// 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 (s *GitScanner) ScanPreviousVersions(ref string, since time.Time, cb GitScannerCallback) error {
func (s *GitScanner) ScanPreviousVersions(ref string, since time.Time, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -163,7 +163,7 @@ func (s *GitScanner) ScanPreviousVersions(ref string, since time.Time, cb GitSca
}

// ScanIndex scans the git index for modified LFS objects.
func (s *GitScanner) ScanIndex(ref string, cb GitScannerCallback) error {
func (s *GitScanner) ScanIndex(ref string, cb GitScannerFoundPointer) error {
callback, err := firstGitScannerCallback(cb, s.callback)
if err != nil {
return err
Expand All @@ -182,7 +182,7 @@ func (s *GitScanner) opts(mode ScanningMode) *ScanRefsOptions {
return opts
}

func firstGitScannerCallback(callbacks ...GitScannerCallback) (GitScannerCallback, error) {
func firstGitScannerCallback(callbacks ...GitScannerFoundPointer) (GitScannerFoundPointer, error) {
for _, cb := range callbacks {
if cb == nil {
continue
Expand Down
2 changes: 1 addition & 1 deletion lfs/gitscanner_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
//
// Ref is the ref at which to scan, which may be "HEAD" if there is at least one
// commit.
func scanIndex(cb GitScannerCallback, ref string) error {
func scanIndex(cb GitScannerFoundPointer, ref string) error {
indexMap := &indexFileMap{
nameMap: make(map[string][]*indexFile),
nameShaPairs: make(map[string]bool),
Expand Down
6 changes: 3 additions & 3 deletions lfs/gitscanner_log.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type gitscannerResult struct {
Err error
}

func scanUnpushed(cb GitScannerCallback, remote string) error {
func scanUnpushed(cb GitScannerFoundPointer, remote string) error {
logArgs := []string{"log",
"--branches", "--tags", // include all locally referenced commits
"--not"} // but exclude everything that comes after
Expand All @@ -62,7 +62,7 @@ func scanUnpushed(cb GitScannerCallback, remote string) error {
return nil
}

func parseScannerLogOutput(cb GitScannerCallback, direction LogDiffDirection, cmd *wrappedCmd) {
func parseScannerLogOutput(cb GitScannerFoundPointer, direction LogDiffDirection, cmd *wrappedCmd) {
ch := make(chan gitscannerResult, chanBufSize)

go func() {
Expand All @@ -88,7 +88,7 @@ func parseScannerLogOutput(cb GitScannerCallback, direction LogDiffDirection, cm

// logPreviousVersions scans history for all previous versions of LFS pointers
// from 'since' up to (but not including) the final state at ref
func logPreviousSHAs(cb GitScannerCallback, ref string, since time.Time) error {
func logPreviousSHAs(cb GitScannerFoundPointer, ref string, since time.Time) error {
logArgs := []string{"log",
fmt.Sprintf("--since=%v", git.FormatGitDate(since)),
}
Expand Down
2 changes: 1 addition & 1 deletion lfs/gitscanner_refs.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ 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
func scanRefsToChan(cb GitScannerCallback, refLeft, refRight string, opt *ScanRefsOptions) error {
func scanRefsToChan(cb GitScannerFoundPointer, refLeft, refRight string, opt *ScanRefsOptions) error {
if opt == nil {
panic("no scan ref options")
}
Expand Down
2 changes: 1 addition & 1 deletion lfs/gitscanner_tree.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type TreeBlob struct {
Filename string
}

func runScanTree(cb GitScannerCallback, ref string, filter *filepathfilter.Filter) error {
func runScanTree(cb GitScannerFoundPointer, ref string, filter *filepathfilter.Filter) error {
// We don't use the nameMap approach here since that's imprecise when >1 file
// can be using the same content
treeShas, err := lsTreeBlobs(ref, filter)
Expand Down

0 comments on commit 81d7177

Please sign in to comment.