| 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 | "encoding/hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/" |
| 7 | "fmtscip-go gomod github.com/golang/go/src go1.25.0 fmt/" |
| 8 | "ioscip-go gomod github.com/golang/go/src go1.25.0 io/" |
| 9 | "math/randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/" |
| 10 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 11 | |
| 12 | "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`/" |
| 13 | "github.com/git-lfs/gitobj/v2scip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/" |
| 14 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/" |
| 15 | "github.com/stretchr/testify/requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/" |
| 16 | ) |
| 17 | |
| 18 | func TestPointerScannerWithValidOutputscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TestPointerScannerWithValidOutput().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 19 | blobs := []*Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#{ |
| 20 | &Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#{ |
| 21 | Versionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Version.: "https://git-lfs.github.com/spec/v1", |
| 22 | Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid.: "e71eefd918ea175b8f362611f981f648dbf9888ff74865077cb4c9077728f350", |
| 23 | Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Size.: 123, |
| 24 | OidTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#OidType.: "sha256", |
| 25 | }, |
| 26 | &Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#{ |
| 27 | Versionscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Version.: "https://git-lfs.github.com/spec/v1", |
| 28 | Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid.: "0eb69b651be65d5a61d6bebf2c53c811a5bf8031951111000e2077f4d7fe43b1", |
| 29 | Sizescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Size.: 132, |
| 30 | OidTypescip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#OidType.: "sha256", |
| 31 | }, |
| 32 | } |
| 33 | |
| 34 | be, _ := gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.NewMemoryBackendscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/NewMemoryBackend().(nil) |
| 35 | db, _ := gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.FromBackendscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/FromBackend().(be) |
| 36 | shas := fakeObjectsWithRandoDatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/fakeObjectsWithRandoData().(t, db, blobs) |
| 37 | |
| 38 | scanner := &PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#{ |
| 39 | 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`/.NewObjectScannerFromscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/NewObjectScannerFrom().(db), |
| 40 | } |
| 41 | iter := 0 |
| 42 | |
| 43 | for i := 0; i < 5; i++ { |
| 44 | assertNextEmptyPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextEmptyPointer().(t, scanner, shas[iter]) |
| 45 | iter++ |
| 46 | } |
| 47 | |
| 48 | assertNextPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextPointer().(t, scanner, shas[iter], "e71eefd918ea175b8f362611f981f648dbf9888ff74865077cb4c9077728f350") |
| 49 | iter++ |
| 50 | |
| 51 | for i := 0; i < 5; i++ { |
| 52 | assertNextEmptyPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextEmptyPointer().(t, scanner, shas[iter]) |
| 53 | iter++ |
| 54 | } |
| 55 | |
| 56 | assertNextPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextPointer().(t, scanner, shas[iter], "0eb69b651be65d5a61d6bebf2c53c811a5bf8031951111000e2077f4d7fe43b1") |
| 57 | iter++ |
| 58 | |
| 59 | for i := 0; i < 5; i++ { |
| 60 | assertNextEmptyPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextEmptyPointer().(t, scanner, shas[iter]) |
| 61 | iter++ |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestPointerScannerWithLargeBlobsscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/TestPointerScannerWithLargeBlobs().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 66 | 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, 1025)) |
| 67 | 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().() |
| 68 | rng := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/New().(randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.NewSourcescip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/NewSource().(0)) |
| 69 | |
| 70 | _, 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().(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().(sha, buf), rng, 1025) |
| 71 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/Nil().(t, err) |
| 72 | |
| 73 | be, _ := gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.NewMemoryBackendscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/NewMemoryBackend().(nil) |
| 74 | db, _ := gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.FromBackendscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/FromBackend().(be) |
| 75 | |
| 76 | fake := 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().(nil) |
| 77 | oid := writeFakeBufferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/writeFakeBuffer().(t, db, fake, buf.Bytesscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Bytes().(), buf.Lenscip-go gomod github.com/golang/go/src go1.25.0 bytes/Buffer#Len().()) |
| 78 | |
| 79 | scanner := &PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#{ |
| 80 | 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`/.NewObjectScannerFromscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/git`/NewObjectScannerFrom().(db), |
| 81 | } |
| 82 | |
| 83 | requirescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/require`/True().(t, scanner.Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Scan().(oid)) |
| 84 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, scanner.Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Pointer().()) |
| 85 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, 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)), scanner.ContentsShascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#ContentsSha().()) |
| 86 | } |
| 87 | |
| 88 | func assertNextPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextPointer().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, scanner *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#, sha string, oid string) { |
| 89 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, scanner.Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Scan().(sha)) |
| 90 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, scanner.Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Err().()) |
| 91 | |
| 92 | p := scanner.Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Pointer().() |
| 93 | |
| 94 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.NotNilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/NotNil().(t, p) |
| 95 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Equal().(t, oid, p.Oidscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Oid.) |
| 96 | } |
| 97 | |
| 98 | func assertNextEmptyPointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/assertNextEmptyPointer().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, scanner *PointerScannerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#, sha string) { |
| 99 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Truescip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/True().(t, scanner.Scanscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Scan().(sha)) |
| 100 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, scanner.Errscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Err().()) |
| 101 | |
| 102 | assertscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/.Nilscip-go gomod github.com/stretchr/testify v1.11.1 `github.com/stretchr/testify/assert`/Nil().(t, scanner.Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/PointerScanner#Pointer().()) |
| 103 | } |
| 104 | |
| 105 | func fakeObjectsWithRandoDatascip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/fakeObjectsWithRandoData().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, db *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.ObjectDatabasescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#, blobs []*Pointerscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#) []string { |
| 106 | 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#{} |
| 107 | rngbuf := make([]byte, 1000) // just under blob size cutoff |
| 108 | rng := randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.Newscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/New().(randscip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/.NewSourcescip-go gomod github.com/golang/go/src go1.25.0 `math/rand`/NewSource().(0)) |
| 109 | oids := make([]string, 0) |
| 110 | |
| 111 | for i := 0; i < 5; i++ { |
| 112 | n, err := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadFullscip-go gomod github.com/golang/go/src go1.25.0 io/ReadFull().(rng, rngbuf) |
| 113 | if err != nil { |
| 114 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error reading from rng: %+v", err) |
| 115 | } |
| 116 | oids = append(oids, writeFakeBufferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/writeFakeBuffer().(t, db, buf, rngbuf, n)) |
| 117 | } |
| 118 | |
| 119 | for _, b := range blobs { |
| 120 | ptrtext := b.Encodedscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/Pointer#Encoded().() |
| 121 | oids = append(oids, writeFakeBufferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/writeFakeBuffer().(t, db, buf, []byte(ptrtext), len(ptrtext))) |
| 122 | for i := 0; i < 5; i++ { |
| 123 | n, err := ioscip-go gomod github.com/golang/go/src go1.25.0 io/.ReadFullscip-go gomod github.com/golang/go/src go1.25.0 io/ReadFull().(rng, rngbuf) |
| 124 | if err != nil { |
| 125 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("error reading from rng: %+v", err) |
| 126 | } |
| 127 | oids = append(oids, writeFakeBufferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/writeFakeBuffer().(t, db, buf, rngbuf, n)) |
| 128 | } |
| 129 | } |
| 130 | |
| 131 | return oids |
| 132 | } |
| 133 | |
| 134 | func writeFakeBufferscip-go gomod github.com/git-lfs/git-lfs/v3 . `github.com/git-lfs/git-lfs/v3/lfs`/writeFakeBuffer().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#, db *gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.ObjectDatabasescip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#, 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#, by []byte, size int) string { |
| 135 | oid, _ := db.WriteBlobscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/ObjectDatabase#WriteBlob().(gitobjscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/.NewBlobFromBytesscip-go gomod github.com/git-lfs/gitobj/v2 v2.1.1 `github.com/git-lfs/gitobj/v2`/NewBlobFromBytes().(by)) |
| 136 | return hexscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/.EncodeToStringscip-go gomod github.com/golang/go/src go1.25.0 `encoding/hex`/EncodeToString().(oid) |
| 137 | } |