blob: b4b551b4fe36d956ef728cc6c95af9b161c7a379 (
about) (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package repository
import (
"fmt"
"lindenii.org/go/furgit/config"
objectid "lindenii.org/go/furgit/object/id"
)
// detectObjectAlgorithm uses a repository's configuration to detect
// the expected Object ID hashing algorithm.
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
}
|