mirror of
https://github.com/go-gitea/gitea.git
synced 2026-07-15 20:40:52 +09:00
chore: fix git commit "rev-list" (#38069)
Fix the copied & pasted messy code, fix #38067 Now, "limit=-1" means "no limit"
This commit is contained in:
+13
-10
@@ -11,6 +11,7 @@ import (
|
||||
|
||||
type ObjectID interface {
|
||||
String() string
|
||||
RefName() RefName
|
||||
IsZero() bool
|
||||
RawValue() []byte
|
||||
Type() ObjectFormat
|
||||
@@ -18,10 +19,16 @@ type ObjectID interface {
|
||||
|
||||
type Sha1Hash [20]byte
|
||||
|
||||
var _ ObjectID = (*Sha1Hash)(nil)
|
||||
|
||||
func (h *Sha1Hash) String() string {
|
||||
return hex.EncodeToString(h[:])
|
||||
}
|
||||
|
||||
func (h *Sha1Hash) RefName() RefName {
|
||||
return RefName(h.String())
|
||||
}
|
||||
|
||||
func (h *Sha1Hash) IsZero() bool {
|
||||
empty := Sha1Hash{}
|
||||
return bytes.Equal(empty[:], h[:])
|
||||
@@ -29,8 +36,6 @@ func (h *Sha1Hash) IsZero() bool {
|
||||
func (h *Sha1Hash) RawValue() []byte { return h[:] }
|
||||
func (*Sha1Hash) Type() ObjectFormat { return Sha1ObjectFormat }
|
||||
|
||||
var _ ObjectID = &Sha1Hash{}
|
||||
|
||||
func MustIDFromString(hexHash string) ObjectID {
|
||||
id, err := NewIDFromString(hexHash)
|
||||
if err != nil {
|
||||
@@ -41,10 +46,16 @@ func MustIDFromString(hexHash string) ObjectID {
|
||||
|
||||
type Sha256Hash [32]byte
|
||||
|
||||
var _ ObjectID = (*Sha256Hash)(nil)
|
||||
|
||||
func (h *Sha256Hash) String() string {
|
||||
return hex.EncodeToString(h[:])
|
||||
}
|
||||
|
||||
func (h *Sha256Hash) RefName() RefName {
|
||||
return RefName(h.String())
|
||||
}
|
||||
|
||||
func (h *Sha256Hash) IsZero() bool {
|
||||
empty := Sha256Hash{}
|
||||
return bytes.Equal(empty[:], h[:])
|
||||
@@ -93,11 +104,3 @@ func IsEmptyCommitID(commitID string) bool {
|
||||
func ComputeBlobHash(hashType ObjectFormat, content []byte) ObjectID {
|
||||
return hashType.ComputeHash(ObjectBlob, content)
|
||||
}
|
||||
|
||||
type ErrInvalidSHA struct {
|
||||
SHA string
|
||||
}
|
||||
|
||||
func (err ErrInvalidSHA) Error() string {
|
||||
return "invalid sha: " + err.SHA
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user