1package operations
2
3import (
4 "github.com/MichaelMure/git-bug/bug"
5)
6
7// SetTitleOperation will change the title of a bug
8
9var _ bug.Operation = SetTitleOperation{}
10
11type SetTitleOperation struct {
12 bug.OpBase
13 Title string
14}
15
16func (op SetTitleOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
17 snapshot.Title = op.Title
18
19 return snapshot
20}
21
22func NewSetTitleOp(author bug.Person, title string) SetTitleOperation {
23 return SetTitleOperation{
24 OpBase: bug.NewOpBase(bug.SetTitleOp, author),
25 Title: title,
26 }
27}
28
29// Convenience function to apply the operation
30func SetTitle(b *bug.Bug, author bug.Person, title string) {
31 setTitleOp := NewSetTitleOp(author, title)
32 b.Append(setTitleOp)
33}