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 /identity/version.go | |
parent | b01aa18d3925a23ba0ad32a322617de7dc9a299e (diff) | |
download | git-bug-2bf2b2d765c5003307544885b9321b32cc09d8bb.tar.gz |
entity: unique function to generate IDs
Diffstat (limited to 'identity/version.go')
-rw-r--r-- | identity/version.go | 12 |
1 files changed, 3 insertions, 9 deletions
diff --git a/identity/version.go b/identity/version.go index ae2474bf..ce5cc7d6 100644 --- a/identity/version.go +++ b/identity/version.go @@ -2,7 +2,6 @@ package identity import ( "crypto/rand" - "crypto/sha256" "encoding/json" "fmt" "strings" @@ -106,16 +105,11 @@ func (v *version) Id() entity.Id { if err != nil { panic(err) } - v.id = deriveId(data) + v.id = entity.DeriveId(data) } return v.id } -func deriveId(data []byte) entity.Id { - sum := sha256.Sum256(data) - return entity.Id(fmt.Sprintf("%x", sum)) -} - // Make a deep copy func (v *version) Clone() *version { // copy direct fields @@ -172,7 +166,7 @@ func (v *version) UnmarshalJSON(data []byte) error { return entity.NewErrNewFormatVersion(aux.FormatVersion) } - v.id = deriveId(data) + v.id = entity.DeriveId(data) v.times = aux.Times v.unixTime = aux.UnixTime v.name = aux.Name @@ -256,7 +250,7 @@ func (v *version) Write(repo repository.Repo) (repository.Hash, error) { } // make sure we set the Id when writing in the repo - v.id = deriveId(data) + v.id = entity.DeriveId(data) return hash, nil } |