oid.go 573 B

123456789101112131415161718192021
  1. // Copyright 2020 The Gogs Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package lfsutil
  5. import (
  6. "gogs.io/gogs/internal/lazyregexp"
  7. )
  8. // OID is an LFS object ID.
  9. type OID string
  10. // An OID is a 64-char lower case hexadecimal, produced by SHA256.
  11. // Spec: https://github.com/git-lfs/git-lfs/blob/master/docs/spec.md
  12. var oidRe = lazyregexp.New("^[a-f0-9]{64}$")
  13. // ValidOID returns true if given oid is valid.
  14. func ValidOID(oid OID) bool {
  15. return oidRe.MatchString(string(oid))
  16. }