You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

object_id_gogit.go 589B

123456789101112131415161718192021222324252627282930
  1. // Copyright 2023 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. //go:build gogit
  4. package git
  5. import (
  6. "github.com/go-git/go-git/v5/plumbing"
  7. "github.com/go-git/go-git/v5/plumbing/hash"
  8. )
  9. func ParseGogitHash(h plumbing.Hash) ObjectID {
  10. switch hash.Size {
  11. case 20:
  12. return Sha1ObjectFormat.MustID(h[:])
  13. case 32:
  14. return Sha256ObjectFormat.MustID(h[:])
  15. }
  16. return nil
  17. }
  18. func ParseGogitHashArray(objectIDs []plumbing.Hash) []ObjectID {
  19. ret := make([]ObjectID, len(objectIDs))
  20. for i, h := range objectIDs {
  21. ret[i] = ParseGogitHash(h)
  22. }
  23. return ret
  24. }