set_title.go

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