summaryrefslogtreecommitdiffstatshomepage
path: root/entity/dag/operation_pack.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2021-02-14 10:02:01 +0100
committerMichael Muré <batolettre@gmail.com>2021-02-14 12:19:04 +0100
commit94f06cd54defa73f5e8b79345597279e454c78e6 (patch)
tree28a1369af0b975e80ed714d5dfacc6ef7ed8911b /entity/dag/operation_pack.go
parent71e22d9f6e49ce0c3bc3b177323b17652a1c45a2 (diff)
downloadgit-bug-94f06cd54defa73f5e8b79345597279e454c78e6.tar.gz
git-bug-94f06cd54defa73f5e8b79345597279e454c78e6.zip
entity: pass the identity resolver instead of defining it once
Having the resolver in Definition doesn't actually work well as the resolver is very situational.
Diffstat (limited to 'entity/dag/operation_pack.go')
-rw-r--r--entity/dag/operation_pack.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/entity/dag/operation_pack.go b/entity/dag/operation_pack.go
index 959b1ae0..d6bce9f2 100644
--- a/entity/dag/operation_pack.go
+++ b/entity/dag/operation_pack.go
@@ -166,7 +166,7 @@ func (opp *operationPack) Write(def Definition, repo repository.Repo, parentComm
// readOperationPack read the operationPack encoded in git at the given Tree hash.
//
// Validity of the Lamport clocks is left for the caller to decide.
-func readOperationPack(def Definition, repo repository.RepoData, commit repository.Commit) (*operationPack, error) {
+func readOperationPack(def Definition, repo repository.RepoData, resolver identity.Resolver, commit repository.Commit) (*operationPack, error) {
entries, err := repo.ReadTree(commit.TreeHash)
if err != nil {
return nil, err
@@ -207,7 +207,7 @@ func readOperationPack(def Definition, repo repository.RepoData, commit reposito
if err != nil {
return nil, errors.Wrap(err, "failed to read git blob data")
}
- ops, author, err = unmarshallPack(def, data)
+ ops, author, err = unmarshallPack(def, resolver, data)
if err != nil {
return nil, err
}
@@ -251,7 +251,7 @@ func readOperationPack(def Definition, repo repository.RepoData, commit reposito
// unmarshallPack delegate the unmarshalling of the Operation's JSON to the decoding
// function provided by the concrete entity. This gives access to the concrete type of each
// Operation.
-func unmarshallPack(def Definition, data []byte) ([]Operation, identity.Interface, error) {
+func unmarshallPack(def Definition, resolver identity.Resolver, data []byte) ([]Operation, identity.Interface, error) {
aux := struct {
Author identity.IdentityStub `json:"author"`
Operations []json.RawMessage `json:"ops"`
@@ -265,7 +265,7 @@ func unmarshallPack(def Definition, data []byte) ([]Operation, identity.Interfac
return nil, nil, fmt.Errorf("missing author")
}
- author, err := def.identityResolver.ResolveIdentity(aux.Author.Id())
+ author, err := resolver.ResolveIdentity(aux.Author.Id())
if err != nil {
return nil, nil, err
}