mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-19 15:40:50 +00:00
Only use SHA256 feature when git >= 2.42 (#28466)
And fix some comments
This commit is contained in:
parent
52046b934d
commit
9947af639c
4 changed files with 11 additions and 12 deletions
|
@ -20,7 +20,6 @@ type ObjectID interface {
|
|||
Type() ObjectFormat
|
||||
}
|
||||
|
||||
/* SHA1 */
|
||||
type Sha1Hash [20]byte
|
||||
|
||||
func (h *Sha1Hash) String() string {
|
||||
|
@ -38,7 +37,7 @@ func NewSha1() *Sha1Hash {
|
|||
return &Sha1Hash{}
|
||||
}
|
||||
|
||||
// generic implementations
|
||||
// NewHash is for generic implementations
|
||||
func NewHash(hash string) (ObjectID, error) {
|
||||
hash = strings.ToLower(hash)
|
||||
switch hash {
|
||||
|
@ -73,7 +72,6 @@ func genericIDFromString(h ObjectFormat, s string) (ObjectID, error) {
|
|||
return h.NewID(b)
|
||||
}
|
||||
|
||||
// utils
|
||||
func IDFromString(hexHash string) (ObjectID, error) {
|
||||
switch len(hexHash) {
|
||||
case 40:
|
||||
|
@ -101,7 +99,7 @@ func IsEmptyCommitID(commitID string) bool {
|
|||
return id.IsZero()
|
||||
}
|
||||
|
||||
// HashInterface is a struct that will generate a Hash
|
||||
// HasherInterface is a struct that will generate a Hash
|
||||
type HasherInterface interface {
|
||||
hash.Hash
|
||||
|
||||
|
@ -127,7 +125,7 @@ func ComputeHash(hashType ObjectFormat, t ObjectType, content []byte) ObjectID {
|
|||
return h.HashSum()
|
||||
}
|
||||
|
||||
// Sum generates a SHA1 for the provided hash
|
||||
// HashSum generates a SHA1 for the provided hash
|
||||
func (h *Sha1Hasher) HashSum() ObjectID {
|
||||
var sha1 Sha1Hash
|
||||
copy(sha1[:], h.Hash.Sum(nil))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue