From 1779a0f3b92d58654b43444addeaf437a64d77a8 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Fri, 13 Jul 2018 21:21:24 +0200 Subject: serialize a Bug to git as a blob+tree+commit+ref --- bug/operations/create.go | 14 ++++++++------ bug/operations/set_title.go | 10 ++++------ 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'bug/operations') diff --git a/bug/operations/create.go b/bug/operations/create.go index 57cca907..9911ee89 100644 --- a/bug/operations/create.go +++ b/bug/operations/create.go @@ -10,22 +10,24 @@ import ( var _ bug.Operation = CreateOperation{} type CreateOperation struct { - Title string - Message string - Author bug.Person + bug.OpBase + Title string `json:"t"` + Message string `json:"m"` + Author bug.Person `json:"a"` } func NewCreateOp(author bug.Person, title, message string) CreateOperation { return CreateOperation{ + OpBase: bug.OpBase{OperationType: bug.CREATE}, Title: title, Message: message, Author: author, } } -func (op CreateOperation) OpType() bug.OperationType { - return bug.CREATE -} +//func (op CreateOperation) OpType() bug.OperationType { +// return bug.CREATE +//} func (op CreateOperation) Apply(snapshot bug.Snapshot) bug.Snapshot { empty := bug.Snapshot{} diff --git a/bug/operations/set_title.go b/bug/operations/set_title.go index 1e2ef20a..39f4b332 100644 --- a/bug/operations/set_title.go +++ b/bug/operations/set_title.go @@ -5,19 +5,17 @@ import "github.com/MichaelMure/git-bug/bug" var _ bug.Operation = SetTitleOperation{} type SetTitleOperation struct { - Title string + bug.OpBase + Title string `json:"t"` } func NewSetTitleOp(title string) SetTitleOperation { return SetTitleOperation{ - Title: title, + OpBase: bug.OpBase{OperationType: bug.SET_TITLE}, + Title: title, } } -func (op SetTitleOperation) OpType() bug.OperationType { - return bug.SET_TITLE -} - func (op SetTitleOperation) Apply(snapshot bug.Snapshot) bug.Snapshot { snapshot.Title = op.Title return snapshot -- cgit