Fast implementation of Git in pure Go codeberg.org/lindenii/furgit
git go
6
fork

Configure Feed

Select the types of activity you want to include in your feed.

object/id: Add support for signature headers

Runxi Yu 256d945a 65242328

+35 -12
+7 -6
object/id/algorithm_details.go
··· 3 3 import "hash" 4 4 5 5 type algorithmDetails struct { 6 - name string 7 - size int 8 - packHashID uint32 9 - sum func([]byte) ObjectID 10 - new func() hash.Hash 11 - emptyTree ObjectID 6 + name string 7 + size int 8 + packHashID uint32 9 + signatureHeaderName string 10 + sum func([]byte) ObjectID 11 + new func() hash.Hash 12 + emptyTree ObjectID 12 13 } 13 14 14 15 func (algo Algorithm) info() algorithmDetails {
+6
object/id/algorithm_signatureheadername.go
··· 1 + package objectid 2 + 3 + // SignatureHeaderName returns the signature header name for this algorithm. 4 + func (algo Algorithm) SignatureHeaderName() string { 5 + return algo.info().signatureHeaderName 6 + }
+13 -6
object/id/algorithm_tables.go
··· 9 9 var algorithmTable = [...]algorithmDetails{ 10 10 AlgorithmUnknown: {}, 11 11 AlgorithmSHA1: { 12 - name: "sha1", 13 - size: sha1.Size, 14 - packHashID: 1, 12 + name: "sha1", 13 + size: sha1.Size, 14 + packHashID: 1, 15 + signatureHeaderName: "gpgsig", 15 16 sum: func(data []byte) ObjectID { 16 17 sum := sha1.Sum(data) //#nosec G401 17 18 ··· 24 25 new: sha1.New, 25 26 }, 26 27 AlgorithmSHA256: { 27 - name: "sha256", 28 - size: sha256.Size, 29 - packHashID: 2, 28 + name: "sha256", 29 + size: sha256.Size, 30 + packHashID: 2, 31 + signatureHeaderName: "gpgsig-sha256", 30 32 sum: func(data []byte) ObjectID { 31 33 sum := sha256.Sum256(data) 32 34 ··· 44 46 //nolint:gochecknoglobals 45 47 algorithmByName = map[string]Algorithm{} 46 48 //nolint:gochecknoglobals 49 + algorithmBySignatureHeaderName = map[string]Algorithm{} 50 + //nolint:gochecknoglobals 47 51 supportedAlgorithms []Algorithm 48 52 ) 49 53 ··· 58 62 59 63 info.emptyTree = info.sum(emptyTreeInput) 60 64 algorithmByName[info.name] = algo 65 + if info.signatureHeaderName != "" { 66 + algorithmBySignatureHeaderName[info.signatureHeaderName] = algo 67 + } 61 68 supportedAlgorithms = append(supportedAlgorithms, algo) 62 69 } 63 70 }
+9
object/id/signatureheadername_parse.go
··· 1 + package objectid 2 + 3 + // ParseSignatureHeaderName parses one canonical signature header name such as 4 + // "gpgsig" or "gpgsig-sha256". 5 + func ParseSignatureHeaderName(s string) (Algorithm, bool) { 6 + algo, ok := algorithmBySignatureHeaderName[s] 7 + 8 + return algo, ok 9 + }