diff options
Diffstat (limited to 'object')
| -rw-r--r-- | object/id/algorithm_details.go | 16 | ||||
| -rw-r--r-- | object/id/algorithm_ops.go | 19 | ||||
| -rw-r--r-- | object/id/algorithm_test.go | 42 |
3 files changed, 0 insertions, 77 deletions
diff --git a/object/id/algorithm_details.go b/object/id/algorithm_details.go index 23737ab5..883853c7 100644 --- a/object/id/algorithm_details.go +++ b/object/id/algorithm_details.go @@ -9,11 +9,8 @@ import ( type algorithmDetails struct { name string size int - packHashID uint32 - signatureHeaderName string sum func([]byte) ObjectID new func() hash.Hash - emptyTree ObjectID } func (algo Algorithm) details() algorithmDetails { @@ -26,8 +23,6 @@ var algorithmTable = [...]algorithmDetails{ AlgorithmSHA1: { name: "sha1", size: sha1.Size, - packHashID: 1, - signatureHeaderName: "gpgsig", sum: func(data []byte) ObjectID { sum := sha1.Sum(data) //#nosec G401 @@ -38,13 +33,10 @@ var algorithmTable = [...]algorithmDetails{ return id }, new: sha1.New, - emptyTree: ObjectID{}, //nolint:exhaustruct }, AlgorithmSHA256: { name: "sha256", size: sha256.Size, - packHashID: 2, - signatureHeaderName: "gpgsig-sha256", sum: func(data []byte) ObjectID { sum := sha256.Sum256(data) @@ -55,7 +47,6 @@ var algorithmTable = [...]algorithmDetails{ return id }, new: sha256.New, - emptyTree: ObjectID{}, //nolint:exhaustruct }, } @@ -75,14 +66,7 @@ func init() { //nolint:gochecknoinits // Skip over AlgorithmUnknown. for algo := Algorithm(1); int(algo) < len(algorithmTable); algo++ { info := &algorithmTable[algo] - - info.emptyTree = info.sum([]byte("tree 0\x00")) - algorithmByName[info.name] = algo - if info.signatureHeaderName != "" { - algorithmBySignatureHeaderName[info.signatureHeaderName] = algo - } - supportedAlgorithms = append(supportedAlgorithms, algo) } } diff --git a/object/id/algorithm_ops.go b/object/id/algorithm_ops.go index 01d26c08..80f1f9cd 100644 --- a/object/id/algorithm_ops.go +++ b/object/id/algorithm_ops.go @@ -2,13 +2,6 @@ package id import "hash" -// EmptyTree returns the object ID of -// an empty tree ("tree 0\x00") -// for this algorithm. -func (algo Algorithm) EmptyTree() ObjectID { - return algo.details().emptyTree -} - // HexLen returns the encoded hexadecimal length. func (algo Algorithm) HexLen() int { return algo.Size() * 2 @@ -29,18 +22,6 @@ func (algo Algorithm) New() (hash.Hash, error) { return newFn(), nil } -// PackHashID returns the Git pack/rev hash-id encoding for this algorithm. -// -// Unknown algorithms return 0. -func (algo Algorithm) PackHashID() uint32 { - return algo.details().packHashID -} - -// SignatureHeaderName returns the signature header name for this algorithm. -func (algo Algorithm) SignatureHeaderName() string { - return algo.details().signatureHeaderName -} - // String returns the canonical algorithm name. func (algo Algorithm) String() string { return algo.details().name diff --git a/object/id/algorithm_test.go b/object/id/algorithm_test.go index 15f61ecb..a596236a 100644 --- a/object/id/algorithm_test.go +++ b/object/id/algorithm_test.go @@ -6,39 +6,6 @@ import ( "codeberg.org/lindenii/furgit/object/id" ) -func TestAlgorithmEmptyTree(t *testing.T) { - t.Parallel() - - tests := []struct { - name string - algo id.Algorithm - want string - }{ - { - name: "sha1", - algo: id.AlgorithmSHA1, - want: "4b825dc642cb6eb9a060e54bf8d69288fbee4904", - }, - { - name: "sha256", - algo: id.AlgorithmSHA256, - want: "6ef19b41225c5369f1c104d45d8d85efa9b057b53b14b4b9b939dd74decc5321", - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - t.Parallel() - - got := tt.algo.EmptyTree() - - if got.String() != tt.want { - t.Fatalf("EmptyTree() = %q, want %q", got.String(), tt.want) - } - }) - } -} - func TestParseAlgorithm(t *testing.T) { t.Parallel() @@ -74,12 +41,3 @@ func TestAlgorithmSum(t *testing.T) { t.Fatalf("sha1 and sha256 should differ") } } - -func TestUnknownAlgorithmEmptyTree(t *testing.T) { - t.Parallel() - - got := id.AlgorithmUnknown.EmptyTree() - if got != (id.ObjectID{}) { - t.Fatalf("EmptyTree() for unknown algorithm = %#v, want zero value", got) - } -} |
