From fe595229e41f9aea5c08d5ab3889804b77a70359 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 21 Feb 2026 00:22:40 +0800 Subject: objectid: Add SupportedAlgorithms --- objectid/objectid.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'objectid') diff --git a/objectid/objectid.go b/objectid/objectid.go index f97fd197..4058bc20 100644 --- a/objectid/objectid.go +++ b/objectid/objectid.go @@ -69,13 +69,16 @@ var algorithmTable = [...]algorithmDetails{ } var algorithmByName = map[string]Algorithm{} +var supportedAlgorithms []Algorithm func init() { for algo, info := range algorithmTable { if info.name == "" { continue } - algorithmByName[info.name] = Algorithm(algo) + parsed := Algorithm(algo) + algorithmByName[info.name] = parsed + supportedAlgorithms = append(supportedAlgorithms, parsed) } } @@ -83,6 +86,12 @@ func (algo Algorithm) info() algorithmDetails { return algorithmTable[algo] } +// SupportedAlgorithms returns all object ID algorithms supported by furgit. +// Do not mutate. +func SupportedAlgorithms() []Algorithm { + return supportedAlgorithms +} + // ParseAlgorithm parses a canonical algorithm name (e.g. "sha1", "sha256"). func ParseAlgorithm(s string) (Algorithm, bool) { algo, ok := algorithmByName[s] -- cgit v1.3.1-10-gc9f91