blob: fc57991a86e5865cc6162fcbe784f834edc656c7 (
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
|
package main
import (
"fmt"
objectid "codeberg.org/lindenii/furgit/object/id"
"codeberg.org/lindenii/furgit/repository"
)
func resolveAlgorithm(repo *repository.Repository, objectFormat string) (objectid.Algorithm, error) {
if objectFormat != "" {
algo, ok := objectid.ParseAlgorithm(objectFormat)
if !ok {
return objectid.AlgorithmUnknown, fmt.Errorf("invalid object format %q", objectFormat)
}
return algo, nil
}
if repo != nil {
return repo.Algorithm(), nil
}
return objectid.AlgorithmSHA1, nil
}
|