aboutsummaryrefslogtreecommitdiff
path: root/repository/algorithm.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-03-06 01:48:44 +0800
committerGravatar Runxi Yu2026-03-06 01:48:44 +0800
commit120509f0aad0e945d8e0fc90a822fa904fb70b68 (patch)
tree20a541f059591b35795a1a5d3b7dcf48ec711b6a /repository/algorithm.go
parentrefstore/loose: Fix package-level comment (diff)
signatureNo signature
repository: Refactor v0.1.55
Diffstat (limited to 'repository/algorithm.go')
-rw-r--r--repository/algorithm.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/repository/algorithm.go b/repository/algorithm.go
new file mode 100644
index 00000000..22326cbd
--- /dev/null
+++ b/repository/algorithm.go
@@ -0,0 +1,27 @@
+package repository
+
+import (
+ "fmt"
+
+ "codeberg.org/lindenii/furgit/config"
+ "codeberg.org/lindenii/furgit/objectid"
+)
+
+func detectObjectAlgorithm(cfg *config.Config) (objectid.Algorithm, error) {
+ algoName := cfg.Lookup("extensions", "", "objectformat").Value
+ if algoName == "" {
+ algoName = objectid.AlgorithmSHA1.String()
+ }
+
+ algo, ok := objectid.ParseAlgorithm(algoName)
+ if !ok {
+ return objectid.AlgorithmUnknown, fmt.Errorf("repository: unsupported object format %q", algoName)
+ }
+
+ return algo, nil
+}
+
+// Algorithm returns the repository object ID algorithm.
+func (repo *Repository) Algorithm() objectid.Algorithm {
+ return repo.algo
+}