diff options
Diffstat (limited to 'identity')
-rw-r--r-- | identity/identity_test.go | 10 | ||||
-rw-r--r-- | identity/version.go | 9 |
2 files changed, 16 insertions, 3 deletions
diff --git a/identity/identity_test.go b/identity/identity_test.go index 36d07be6..ad8317ce 100644 --- a/identity/identity_test.go +++ b/identity/identity_test.go @@ -204,6 +204,16 @@ func TestMetadata(t *testing.T) { assertHasKeyValue(t, loaded.ImmutableMetadata(), "key1", "value1") assertHasKeyValue(t, loaded.MutableMetadata(), "key1", "value2") + + // set metadata after commit + versionCount := len(identity.versions) + identity.SetMetadata("foo", "bar") + require.True(t, identity.NeedCommit()) + require.Len(t, identity.versions, versionCount+1) + + err = identity.Commit(repo) + require.NoError(t, err) + require.Len(t, identity.versions, versionCount+1) } func assertHasKeyValue(t *testing.T, metadata map[string]string, key, value string) { diff --git a/identity/version.go b/identity/version.go index bbf0a3f5..ae2474bf 100644 --- a/identity/version.go +++ b/identity/version.go @@ -18,10 +18,9 @@ import ( // 1: original format // 2: Identity Ids are generated from the first version serialized data instead of from the first git commit +// + Identity hold multiple lamport clocks from other entities, instead of just bug edit const formatVersion = 2 -// TODO ^^ - // version is a complete set of information about an Identity at a point in time. type version struct { name string @@ -42,7 +41,7 @@ type version struct { // version of a bug, used to later generate the ID // len(Nonce) should be > 20 and < 64 bytes // It has no functional purpose and should be ignored. - // TODO: optional? + // TODO: optional after first version? nonce []byte // A set of arbitrary key/value to store metadata about a version or about an Identity in general. @@ -122,6 +121,10 @@ func (v *version) Clone() *version { // copy direct fields clone := *v + // reset some fields + clone.commitHash = "" + clone.id = entity.UnsetId + clone.times = make(map[string]lamport.Time) for name, t := range v.times { clone.times[name] = t |