diff options
author | Michael Muré <batolettre@gmail.com> | 2022-07-31 14:38:32 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2022-07-31 14:38:32 +0200 |
commit | d179b8b7ec7815ccac73e00f35f5cfbdc4ddbe2e (patch) | |
tree | d3faa7217cb287c7b20f2769f5c5808373aca63b /bug/op_set_title.go | |
parent | 3d454d9dc8ba2409046c0938618a70864e6eb8ef (diff) | |
download | git-bug-d179b8b7ec7815ccac73e00f35f5cfbdc4ddbe2e.tar.gz |
bug: fix an issue where Id would be used, then changed due to metadata
Diffstat (limited to 'bug/op_set_title.go')
-rw-r--r-- | bug/op_set_title.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/bug/op_set_title.go b/bug/op_set_title.go index 7f078795..d26a60fa 100644 --- a/bug/op_set_title.go +++ b/bug/op_set_title.go @@ -80,10 +80,10 @@ func (s SetTitleTimelineItem) Id() entity.Id { } // IsAuthored is a sign post method for gqlgen -func (s *SetTitleTimelineItem) IsAuthored() {} +func (s SetTitleTimelineItem) IsAuthored() {} -// Convenience function to apply the operation -func SetTitle(b Interface, author identity.Interface, unixTime int64, title string) (*SetTitleOperation, error) { +// SetTitle is a convenience function to change a bugs title +func SetTitle(b Interface, author identity.Interface, unixTime int64, title string, metadata map[string]string) (*SetTitleOperation, error) { var lastTitleOp *SetTitleOperation for _, op := range b.Operations() { switch op := op.(type) { @@ -99,12 +99,14 @@ func SetTitle(b Interface, author identity.Interface, unixTime int64, title stri was = b.FirstOp().(*CreateOperation).Title } - setTitleOp := NewSetTitleOp(author, unixTime, title, was) - - if err := setTitleOp.Validate(); err != nil { + op := NewSetTitleOp(author, unixTime, title, was) + for key, value := range metadata { + op.SetMetadata(key, value) + } + if err := op.Validate(); err != nil { return nil, err } - b.Append(setTitleOp) - return setTitleOp, nil + b.Append(op) + return op, nil } |