diff options
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 +} |
