diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-29 20:41:19 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-29 20:41:19 +0200 |
commit | c46d01f8c10e6363b680fa6876e91bd8eaf3bb3e (patch) | |
tree | dde41c1253534bf4ff36e39454f2bdbdf4b9590f /bug/op_set_title.go | |
parent | 41e61a67b63e4d6c517005cf6f427115a664bdb5 (diff) | |
download | git-bug-c46d01f8c10e6363b680fa6876e91bd8eaf3bb3e.tar.gz |
bug: implement comment edition
- add a new operation
- add a new "timeline" in the snapshot that hold a processed version of the operations
Diffstat (limited to 'bug/op_set_title.go')
-rw-r--r-- | bug/op_set_title.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/bug/op_set_title.go b/bug/op_set_title.go index 6049ebd0..74467ec2 100644 --- a/bug/op_set_title.go +++ b/bug/op_set_title.go @@ -8,29 +8,29 @@ import ( "github.com/MichaelMure/git-bug/util/text" ) -// SetTitleOperation will change the title of a bug - -var _ Operation = SetTitleOperation{} +var _ Operation = &SetTitleOperation{} +// SetTitleOperation will change the title of a bug type SetTitleOperation struct { *OpBase Title string `json:"title"` Was string `json:"was"` } -func (op SetTitleOperation) base() *OpBase { +func (op *SetTitleOperation) base() *OpBase { return op.OpBase } -func (op SetTitleOperation) Hash() (git.Hash, error) { +func (op *SetTitleOperation) Hash() (git.Hash, error) { return hashOperation(op) } -func (op SetTitleOperation) Apply(snapshot *Snapshot) { +func (op *SetTitleOperation) Apply(snapshot *Snapshot) { snapshot.Title = op.Title + snapshot.Timeline = append(snapshot.Timeline, op) } -func (op SetTitleOperation) Validate() error { +func (op *SetTitleOperation) Validate() error { if err := opBaseValidate(op, SetTitleOp); err != nil { return err } @@ -58,8 +58,8 @@ func (op SetTitleOperation) Validate() error { return nil } -func NewSetTitleOp(author Person, unixTime int64, title string, was string) SetTitleOperation { - return SetTitleOperation{ +func NewSetTitleOp(author Person, unixTime int64, title string, was string) *SetTitleOperation { + return &SetTitleOperation{ OpBase: newOpBase(SetTitleOp, author, unixTime), Title: title, Was: was, @@ -80,9 +80,9 @@ func SetTitle(b Interface, author Person, unixTime int64, title string) error { var was string if lastTitleOp != nil { - was = lastTitleOp.(SetTitleOperation).Title + was = lastTitleOp.(*SetTitleOperation).Title } else { - was = b.FirstOp().(CreateOperation).Title + was = b.FirstOp().(*CreateOperation).Title } setTitleOp := NewSetTitleOp(author, unixTime, title, was) |