| 1 | package lfsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/ |
| 2 | |
| 3 | import ( |
| 4 | "bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/" |
| 5 | "crypto/sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/" |
| 6 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 7 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 8 | |
| 9 | "github.com/git-lfs/git-lfs/v3/configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/" |
| 10 | "github.com/git-lfs/git-lfs/v3/errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/" |
| 11 | "github.com/git-lfs/git-lfs/v3/gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/" |
| 12 | "github.com/git-lfs/git-lfs/v3/trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/" |
| 13 | ) |
| 14 | |
| 15 | // runCatFileBatch() uses an ObjectDatabase from the |
| 16 | // github.com/git-lfs/gitobj/v2 package to get the contents of Git |
| 17 | // blob objects, given their SHA1s, similar to the behaviour of |
| 18 | // 'git cat-file --batch'. |
| 19 | // Git blob SHA1s are read from the revs channel and fed to an |
| 20 | // ObjectScanner which looks them up in the ObjectDatabase. |
| 21 | // The contents will be decoded as Git LFS pointers and any valid pointers |
| 22 | // will be sent to pointerCh. |
| 23 | // If a Git blob is not an LFS pointer, check the lockableSet to see |
| 24 | // if that blob is for a locked file. Any errors are sent to errCh. |
| 25 | func runCatFileBatchscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/runCatFileBatch().(pointerCh chan *WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#, lockableCh chan string, lockableSet *lockableNameSetscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/lockableNameSet#, revs *StringChannelWrapperscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/StringChannelWrapper#, errCh chan error, gitEnv, osEnv configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#) error { |
| 26 | scanner, err := NewPointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewPointerScanner().(gitEnv, osEnv) |
| 27 | if err != nil { |
| 28 | return err |
| 29 | } |
| 30 | |
| 31 | go func() { |
| 32 | canScan := true |
| 33 | for r := range revs.Resultsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/StringChannelWrapper#Results. { |
| 34 | canScan = scanner.Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Scan().(r) |
| 35 | |
| 36 | if err := scanner.Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Err().(); err != nil { |
| 37 | errCh <- err |
| 38 | } else if p := scanner.Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Pointer().(); p != nil { |
| 39 | pointerCh <- p |
| 40 | } else if b := scanner.BlobSHAscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#BlobSHA().(); gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.HasValidObjectIDLengthscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/HasValidObjectIDLength().(b) { |
| 41 | if name, ok := lockableSet.Checkscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/lockableNameSet#Check().(b); ok { |
| 42 | lockableCh <- name |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | if !canScan { |
| 47 | break |
| 48 | } |
| 49 | } |
| 50 | |
| 51 | if canScan { |
| 52 | if err := revs.Waitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tools`/BaseChannelWrapper#Wait().(); err != nil { |
| 53 | errCh <- err |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if err := scanner.Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Close().(); err != nil { |
| 58 | errCh <- err |
| 59 | } |
| 60 | |
| 61 | close(pointerCh) |
| 62 | close(errCh) |
| 63 | close(lockableCh) |
| 64 | }() |
| 65 | |
| 66 | return nil |
| 67 | } |
| 68 | |
| 69 | type PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner# struct { |
| 70 | scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner. *gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.ObjectScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner# |
| 71 | |
| 72 | blobShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#blobSha. string |
| 73 | contentsShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#contentsSha. string |
| 74 | pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#pointer. *WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer# |
| 75 | errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#err. error |
| 76 | } |
| 77 | |
| 78 | func NewPointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/NewPointerScanner().(gitEnv, osEnv configscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/.Environmentscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/config`/Environment#) (*PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#, error) { |
| 79 | scanner, err := gitscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/.NewObjectScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/NewObjectScanner().(gitEnv, osEnv) |
| 80 | if err != nil { |
| 81 | return nil, err |
| 82 | } |
| 83 | |
| 84 | return &PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#{scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner.: scanner}, nil |
| 85 | } |
| 86 | |
| 87 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) BlobSHAscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#BlobSHA().() string { |
| 88 | return s.blobShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#blobSha. |
| 89 | } |
| 90 | |
| 91 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) ContentsShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#ContentsSha().() string { |
| 92 | return s.contentsShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#contentsSha. |
| 93 | } |
| 94 | |
| 95 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Pointer().() *WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer# { |
| 96 | return s.pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#pointer. |
| 97 | } |
| 98 | |
| 99 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Err().() error { |
| 100 | return s.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#err. |
| 101 | } |
| 102 | |
| 103 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Scan().(sha string) bool { |
| 104 | s.pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#pointer., s.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#err. = nil, nil |
| 105 | s.blobShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#blobSha., s.contentsShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#contentsSha. = "", "" |
| 106 | |
| 107 | b, c, p, err := s.nextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#next().(sha) |
| 108 | s.blobShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#blobSha. = b |
| 109 | s.contentsShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#contentsSha. = c |
| 110 | s.pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#pointer. = p |
| 111 | |
| 112 | if err != nil { |
| 113 | if err != ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF. { |
| 114 | s.errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#err. = err |
| 115 | } |
| 116 | return false |
| 117 | } |
| 118 | |
| 119 | return true |
| 120 | } |
| 121 | |
| 122 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Close().() error { |
| 123 | return s.scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner..Closescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner#Close().() |
| 124 | } |
| 125 | |
| 126 | func (s *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#) nextscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#next().(blob string) (string, string, *WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#, error) { |
| 127 | if !s.scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner..Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner#Scan().(blob) { |
| 128 | if err := s.scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner..Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner#Err().(); err != nil { |
| 129 | return "", "", nil, err |
| 130 | } |
| 131 | return "", "", nil, ioscip-go gomod github.com/golang/go/src go1.25.0 io/.EOFscip-go gomod github.com/golang/go/src go1.25.0 io/EOF. |
| 132 | } |
| 133 | |
| 134 | blobSha := s.scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner..Sha1scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner#Sha1().() |
| 135 | size := s.scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner..Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner#Size().() |
| 136 | |
| 137 | sha := sha256scip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `crypto/sha256`/New().() |
| 138 | |
| 139 | var buf *bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer# |
| 140 | var to ioscip-go gomod github.com/golang/go/src go1.25.0 io/.Writerscip-go gomod github.com/golang/go/src go1.25.0 io/Writer# = sha |
| 141 | if size < BlobSizeCutoffscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/BlobSizeCutoff. { |
| 142 | buf = bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewBuffer().(make([]byte, 0, size)) |
| 143 | to = ioscip-go gomod github.com/golang/go/src go1.25.0 io/.MultiWriterscip-go gomod github.com/golang/go/src go1.25.0 io/MultiWriter().(to, buf) |
| 144 | } |
| 145 | |
| 146 | read, err := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.CopyNscip-go gomod github.com/golang/go/src go1.25.0 io/CopyN().(to, s.scannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#scanner..Contentsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/ObjectScanner#Contents().(), int64(size)) |
| 147 | if err != nil { |
| 148 | return blobSha, "", nil, err |
| 149 | } |
| 150 | |
| 151 | if int64(size) != read { |
| 152 | return blobSha, "", nil, errorsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/.Newscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/errors`/New().(trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/.Trscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/tr`/Tr..Getscip-go gomod github.com/leonelquinteros/gotext v1.7.2 `github.com/leonelquinteros/gotext`/Locale#Get().("expected %d bytes, read %d bytes", size, read)) |
| 153 | } |
| 154 | |
| 155 | var pointer *WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer# |
| 156 | var contentsSha string |
| 157 | |
| 158 | if size < BlobSizeCutoffscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/BlobSizeCutoff. { |
| 159 | if p, err := DecodePointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/DecodePointer().(bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/.NewReaderscip-go gomod github.com/golang/go/src go1.25.0 bytes/NewReader().(buf.Bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Bytes().())); err != nil { |
| 160 | contentsSha = fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%x", sha.Sumscip-go gomod github.com/golang/go/src go1.25.0 hash/Hash#Sum().(nil)) |
| 161 | } else { |
| 162 | pointer = &WrappedPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#{ |
| 163 | Sha1scip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#Sha1.: blobSha, |
| 164 | Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/WrappedPointer#Pointer.: p, |
| 165 | } |
| 166 | contentsSha = p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid. |
| 167 | } |
| 168 | } else { |
| 169 | contentsSha = fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.25.0 fmt/Sprintf().("%x", sha.Sumscip-go gomod github.com/golang/go/src go1.25.0 hash/Hash#Sum().(nil)) |
| 170 | } |
| 171 | |
| 172 | return blobSha, contentsSha, pointer, err |
| 173 | } |