diff options
author | Michael Muré <batolettre@gmail.com> | 2020-11-08 23:56:32 +0100 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-02-14 12:17:47 +0100 |
commit | b01aa18d3925a23ba0ad32a322617de7dc9a299e (patch) | |
tree | efb1ab12812d0dbf91609f0647060d713c9ba058 | |
parent | ab57d74a312f325b9d889752aa92c00c395de20f (diff) | |
download | git-bug-b01aa18d3925a23ba0ad32a322617de7dc9a299e.tar.gz |
identity: PR fixes
-rw-r--r-- | bridge/github/export_test.go | 2 | ||||
-rw-r--r-- | bridge/github/import_test.go | 2 | ||||
-rw-r--r-- | bridge/gitlab/export_test.go | 2 | ||||
-rw-r--r-- | bridge/gitlab/import_test.go | 2 | ||||
-rw-r--r-- | identity/identity_test.go | 10 | ||||
-rw-r--r-- | identity/version.go | 9 |
6 files changed, 20 insertions, 7 deletions
diff --git a/bridge/github/export_test.go b/bridge/github/export_test.go index 5b9a3495..b7a36bcf 100644 --- a/bridge/github/export_test.go +++ b/bridge/github/export_test.go @@ -126,7 +126,7 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase { } } -func TestPushPull(t *testing.T) { +func TestGithubPushPull(t *testing.T) { // repo owner envUser := os.Getenv("GITHUB_TEST_USER") diff --git a/bridge/github/import_test.go b/bridge/github/import_test.go index 3d0004c1..84bf774e 100644 --- a/bridge/github/import_test.go +++ b/bridge/github/import_test.go @@ -18,7 +18,7 @@ import ( "github.com/MichaelMure/git-bug/util/interrupt" ) -func Test_Importer(t *testing.T) { +func TestGithubImporter(t *testing.T) { envToken := os.Getenv("GITHUB_TOKEN_PRIVATE") if envToken == "" { t.Skip("Env var GITHUB_TOKEN_PRIVATE missing") diff --git a/bridge/gitlab/export_test.go b/bridge/gitlab/export_test.go index 58f3d63c..88b0d44e 100644 --- a/bridge/gitlab/export_test.go +++ b/bridge/gitlab/export_test.go @@ -134,7 +134,7 @@ func testCases(t *testing.T, repo *cache.RepoCache) []*testCase { } } -func TestPushPull(t *testing.T) { +func TestGitlabPushPull(t *testing.T) { // token must have 'repo' and 'delete_repo' scopes envToken := os.Getenv("GITLAB_API_TOKEN") if envToken == "" { diff --git a/bridge/gitlab/import_test.go b/bridge/gitlab/import_test.go index 7e47e149..2956ad8b 100644 --- a/bridge/gitlab/import_test.go +++ b/bridge/gitlab/import_test.go @@ -18,7 +18,7 @@ import ( "github.com/MichaelMure/git-bug/util/interrupt" ) -func TestImport(t *testing.T) { +func TestGitlabImport(t *testing.T) { envToken := os.Getenv("GITLAB_API_TOKEN") if envToken == "" { t.Skip("Env var GITLAB_API_TOKEN missing") 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 |