From feab9412dffe5772048aad29893c4cb01d566387 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 21 Nov 2018 18:56:12 +0100 Subject: WIP identity in git --- bug/operation_pack.go | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) (limited to 'bug/operation_pack.go') diff --git a/bug/operation_pack.go b/bug/operation_pack.go index f33d94bf..fc395d90 100644 --- a/bug/operation_pack.go +++ b/bug/operation_pack.go @@ -20,7 +20,7 @@ const formatVersion = 1 type OperationPack struct { Operations []Operation - // Private field so not serialized by gob + // Private field so not serialized commitHash git.Hash } @@ -57,6 +57,7 @@ func (opp *OperationPack) UnmarshalJSON(data []byte) error { return err } + // delegate to specialized unmarshal function op, err := opp.unmarshalOp(raw, t.OperationType) if err != nil { return err @@ -73,28 +74,36 @@ func (opp *OperationPack) UnmarshalJSON(data []byte) error { func (opp *OperationPack) unmarshalOp(raw []byte, _type OperationType) (Operation, error) { switch _type { + case AddCommentOp: + op := &AddCommentOperation{} + err := json.Unmarshal(raw, &op) + return op, err case CreateOp: op := &CreateOperation{} err := json.Unmarshal(raw, &op) return op, err - case SetTitleOp: - op := &SetTitleOperation{} + case EditCommentOp: + op := &EditCommentOperation{} err := json.Unmarshal(raw, &op) return op, err - case AddCommentOp: - op := &AddCommentOperation{} + case LabelChangeOp: + op := &LabelChangeOperation{} err := json.Unmarshal(raw, &op) return op, err - case SetStatusOp: - op := &SetStatusOperation{} + case NoOpOp: + op := &NoOpOperation{} err := json.Unmarshal(raw, &op) return op, err - case LabelChangeOp: - op := &LabelChangeOperation{} + case SetMetadataOp: + op := &SetMetadataOperation{} err := json.Unmarshal(raw, &op) return op, err - case EditCommentOp: - op := &EditCommentOperation{} + case SetStatusOp: + op := &SetStatusOperation{} + err := json.Unmarshal(raw, &op) + return op, err + case SetTitleOp: + op := &SetTitleOperation{} err := json.Unmarshal(raw, &op) return op, err default: -- cgit From d10c76469d40f13e27739fd363145e89bf74c3e0 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 19 Jan 2019 19:23:31 +0100 Subject: identity: somewhat getting closer ! --- bug/operation_pack.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bug/operation_pack.go') diff --git a/bug/operation_pack.go b/bug/operation_pack.go index fc395d90..18b2a478 100644 --- a/bug/operation_pack.go +++ b/bug/operation_pack.go @@ -139,6 +139,14 @@ func (opp *OperationPack) Validate() error { // Write will serialize and store the OperationPack as a git blob and return // its hash func (opp *OperationPack) Write(repo repository.Repo) (git.Hash, error) { + // First, make sure that all the identities are properly Commit as well + for _, op := range opp.Operations { + err := op.base().Author.Commit(repo) + if err != nil { + return "", err + } + } + data, err := json.Marshal(opp) if err != nil { -- cgit From 14b240af8fef269d2c1d5dde2fff192b656c50f3 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 20 Jan 2019 15:41:27 +0100 Subject: identity: more cleaning and fixes after a code review --- bug/operation_pack.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'bug/operation_pack.go') diff --git a/bug/operation_pack.go b/bug/operation_pack.go index 18b2a478..1ffc1d1a 100644 --- a/bug/operation_pack.go +++ b/bug/operation_pack.go @@ -139,6 +139,12 @@ func (opp *OperationPack) Validate() error { // Write will serialize and store the OperationPack as a git blob and return // its hash func (opp *OperationPack) Write(repo repository.Repo) (git.Hash, error) { + // make sure we don't write invalid data + err := opp.Validate() + if err != nil { + return "", errors.Wrap(err, "validation error") + } + // First, make sure that all the identities are properly Commit as well for _, op := range opp.Operations { err := op.base().Author.Commit(repo) -- cgit From d2483d83dd52365741f51eca106aa18c4e8d6420 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 16 Feb 2019 17:32:30 +0100 Subject: identity: I can compile again !! --- bug/operation_pack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bug/operation_pack.go') diff --git a/bug/operation_pack.go b/bug/operation_pack.go index 1ffc1d1a..55fc018e 100644 --- a/bug/operation_pack.go +++ b/bug/operation_pack.go @@ -147,7 +147,7 @@ func (opp *OperationPack) Write(repo repository.Repo) (git.Hash, error) { // First, make sure that all the identities are properly Commit as well for _, op := range opp.Operations { - err := op.base().Author.Commit(repo) + err := op.base().Author.CommitAsNeeded(repo) if err != nil { return "", err } -- cgit From 71f9290fdae7551f3d3ada2179ece4084304d734 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Tue, 19 Feb 2019 00:19:27 +0100 Subject: identity: store the times properly --- bug/operation_pack.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bug/operation_pack.go') diff --git a/bug/operation_pack.go b/bug/operation_pack.go index 55fc018e..5f3e9da8 100644 --- a/bug/operation_pack.go +++ b/bug/operation_pack.go @@ -138,7 +138,7 @@ func (opp *OperationPack) Validate() error { // Write will serialize and store the OperationPack as a git blob and return // its hash -func (opp *OperationPack) Write(repo repository.Repo) (git.Hash, error) { +func (opp *OperationPack) Write(repo repository.ClockedRepo) (git.Hash, error) { // make sure we don't write invalid data err := opp.Validate() if err != nil { -- cgit