diff options
author | Michael Muré <batolettre@gmail.com> | 2020-11-09 00:34:48 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-02-14 12:17:47 +0100 |
commit | 2bf2b2d765c5003307544885b9321b32cc09d8bb (patch) | |
tree | 3832cad40ca8d19faf08a947e4f09fa004762f2d /bug | |
parent | b01aa18d3925a23ba0ad32a322617de7dc9a299e (diff) | |
download | git-bug-2bf2b2d765c5003307544885b9321b32cc09d8bb.tar.gz |
entity: unique function to generate IDs
Diffstat (limited to 'bug')
-rw-r--r-- | bug/operation.go | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/bug/operation.go b/bug/operation.go index 107c954e..bdaa2016 100644 --- a/bug/operation.go +++ b/bug/operation.go @@ -1,7 +1,6 @@ package bug import ( - "crypto/sha256" "encoding/json" "fmt" "time" @@ -55,11 +54,6 @@ type Operation interface { IsOperation() } -func deriveId(data []byte) entity.Id { - sum := sha256.Sum256(data) - return entity.Id(fmt.Sprintf("%x", sum)) -} - func idOperation(op Operation) entity.Id { base := op.base() @@ -78,7 +72,7 @@ func idOperation(op Operation) entity.Id { panic(err) } - base.id = deriveId(data) + base.id = entity.DeriveId(data) } return base.id } @@ -109,7 +103,7 @@ func newOpBase(opType OperationType, author identity.Interface, unixTime int64) func (op *OpBase) UnmarshalJSON(data []byte) error { // Compute the Id when loading the op from disk. - op.id = deriveId(data) + op.id = entity.DeriveId(data) aux := struct { OperationType OperationType `json:"type"` |