blob: 78f3aadd9f311d3cf86cebdd5a6c1efdc818e77f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
package git
import (
"bytes"
"regexp"
)
var (
lfsOIDRe = regexp.MustCompile(`(?m)^oid sha256:[0-9a-f]{64}$`)
lfsSizeRe = regexp.MustCompile(`(?m)^size [0-9]+$`)
)
// IsLFSPointer checks to see if a blob is an LFS pointer. It returns the raw data of the pointer if it is
func IsLFSPointer(b []byte) bool {
// ensure the version exists
if !bytes.HasPrefix(b, []byte("version https://git-lfs.github.com/spec")) {
return false
}
// ensure the oid exists
if !lfsOIDRe.Match(b) {
return false
}
// ensure the size exists
if !lfsSizeRe.Match(b) {
return false
}
return true
}
|