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