teach GitScanner how to ScanLeftToRemote()
This commit is contained in:
parent
6dd78c6bca
commit
496654b2b3
@ -54,9 +54,8 @@ func prePushCommand(cmd *cobra.Command, args []string) {
|
||||
cfg.CurrentRemote = args[0]
|
||||
ctx := newUploadContext(prePushDryRun)
|
||||
|
||||
scanOpt := lfs.NewScanRefsOptions()
|
||||
scanOpt.ScanMode = lfs.ScanLeftToRemoteMode
|
||||
scanOpt.RemoteName = cfg.CurrentRemote
|
||||
gitscanner := lfs.NewGitScanner()
|
||||
gitscanner.Remote(cfg.CurrentRemote)
|
||||
|
||||
// We can be passed multiple lines of refs
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
@ -69,17 +68,16 @@ func prePushCommand(cmd *cobra.Command, args []string) {
|
||||
|
||||
tracerx.Printf("pre-push: %s", line)
|
||||
|
||||
left, right := decodeRefs(line)
|
||||
left, _ := decodeRefs(line)
|
||||
if left == prePushDeleteBranch {
|
||||
continue
|
||||
}
|
||||
|
||||
pointers, err := lfs.ScanRefsToChan(left, right, scanOpt)
|
||||
pointerCh, err := gitscanner.ScanLeftToRemote(left)
|
||||
if err != nil {
|
||||
Panic(err, "Error scanning for Git LFS files")
|
||||
}
|
||||
|
||||
upload(ctx, pointers)
|
||||
upload(ctx, pointerCh)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,15 +1,23 @@
|
||||
package lfs
|
||||
|
||||
type GitScanner struct {
|
||||
remote string
|
||||
}
|
||||
|
||||
func NewGitScanner() *GitScanner {
|
||||
return &GitScanner{}
|
||||
}
|
||||
|
||||
func (s *GitScanner) Remote(r string) {
|
||||
s.remote = r
|
||||
}
|
||||
|
||||
func (s *GitScanner) ScanLeftToRemote(left string) (*PointerChannelWrapper, error) {
|
||||
return ScanRefsToChan(left, "", s.opts(ScanLeftToRemoteMode))
|
||||
}
|
||||
|
||||
func (s *GitScanner) ScanRefRange(left, right string) (*PointerChannelWrapper, error) {
|
||||
opts := NewScanRefsOptions()
|
||||
opts.ScanMode = ScanRefsMode
|
||||
opts := s.opts(ScanRefsMode)
|
||||
opts.SkipDeletedBlobs = false
|
||||
return ScanRefsToChan(left, right, opts)
|
||||
}
|
||||
@ -19,15 +27,22 @@ func (s *GitScanner) ScanRefWithDeleted(ref string) (*PointerChannelWrapper, err
|
||||
}
|
||||
|
||||
func (s *GitScanner) ScanRef(ref string) (*PointerChannelWrapper, error) {
|
||||
opts := NewScanRefsOptions()
|
||||
opts.ScanMode = ScanRefsMode
|
||||
opts := s.opts(ScanRefsMode)
|
||||
opts.SkipDeletedBlobs = true
|
||||
return ScanRefsToChan(ref, "", opts)
|
||||
}
|
||||
|
||||
func (s *GitScanner) ScanAll() (*PointerChannelWrapper, error) {
|
||||
opts := NewScanRefsOptions()
|
||||
opts.ScanMode = ScanAllMode
|
||||
opts := s.opts(ScanAllMode)
|
||||
opts.SkipDeletedBlobs = false
|
||||
return ScanRefsToChan("", "", opts)
|
||||
}
|
||||
|
||||
func (s *GitScanner) opts(mode ScanningMode) *ScanRefsOptions {
|
||||
opts := NewScanRefsOptions()
|
||||
opts.ScanMode = mode
|
||||
if len(s.remote) > 0 {
|
||||
opts.RemoteName = s.remote
|
||||
}
|
||||
return opts
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user