1
0
Fork 0
forked from forgejo/forgejo

Adjust object format interface (#28469)

- Remove `ObjectFormatID`
- Remove function `ObjectFormatFromID`.
- Use `Sha1ObjectFormat` directly but not a pointer because it's an
empty struct.
- Store `ObjectFormatName` in `repository` struct
This commit is contained in:
Lunny Xiao 2023-12-17 19:56:08 +08:00 committed by GitHub
parent 7fb6b51470
commit 408a484224
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
54 changed files with 191 additions and 203 deletions

View file

@ -12,7 +12,7 @@ import (
)
func TestParseTreeEntriesLong(t *testing.T) {
objectFormat := ObjectFormatFromID(Sha1)
objectFormat := Sha1ObjectFormat
testCases := []struct {
Input string
@ -66,7 +66,7 @@ func TestParseTreeEntriesLong(t *testing.T) {
}
func TestParseTreeEntriesShort(t *testing.T) {
objectFormat := ObjectFormatFromID(Sha1)
objectFormat := Sha1ObjectFormat
testCases := []struct {
Input string
@ -102,7 +102,7 @@ func TestParseTreeEntriesShort(t *testing.T) {
func TestParseTreeEntriesInvalid(t *testing.T) {
// there was a panic: "runtime error: slice bounds out of range" when the input was invalid: #20315
entries, err := ParseTreeEntries(ObjectFormatFromID(Sha1), []byte("100644 blob ea0d83c9081af9500ac9f804101b3fd0a5c293af"))
entries, err := ParseTreeEntries(Sha1ObjectFormat, []byte("100644 blob ea0d83c9081af9500ac9f804101b3fd0a5c293af"))
assert.Error(t, err)
assert.Len(t, entries, 0)
}