diff options
| author | 2026-03-06 01:48:44 +0800 | |
|---|---|---|
| committer | 2026-03-06 01:48:44 +0800 | |
| commit | 120509f0aad0e945d8e0fc90a822fa904fb70b68 (patch) | |
| tree | 20a541f059591b35795a1a5d3b7dcf48ec711b6a /repository/algorithm.go | |
| parent | refstore/loose: Fix package-level comment (diff) | |
| signature | No signature | |
repository: Refactor v0.1.55
Diffstat (limited to 'repository/algorithm.go')
| -rw-r--r-- | repository/algorithm.go | 27 |
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 +} |
