aboutsummaryrefslogtreecommitdiffstats
path: root/bug/op_create.go
diff options
context:
space:
mode:
Diffstat (limited to 'bug/op_create.go')
-rw-r--r--bug/op_create.go26
1 files changed, 11 insertions, 15 deletions
diff --git a/bug/op_create.go b/bug/op_create.go
index ed2fd994..ca4f3d8a 100644
--- a/bug/op_create.go
+++ b/bug/op_create.go
@@ -97,20 +97,16 @@ type CreateTimelineItem struct {
// IsAuthored is a sign post method for gqlgen
func (c *CreateTimelineItem) IsAuthored() {}
-// Convenience function to apply the operation
-func Create(author identity.Interface, unixTime int64, title, message string) (*Bug, *CreateOperation, error) {
- return CreateWithFiles(author, unixTime, title, message, nil)
-}
-
-func CreateWithFiles(author identity.Interface, unixTime int64, title, message string, files []repository.Hash) (*Bug, *CreateOperation, error) {
- newBug := NewBug()
- createOp := NewCreateOp(author, unixTime, title, message, files)
-
- if err := createOp.Validate(); err != nil {
- return nil, createOp, err
+// Create is a convenience function to create a bug
+func Create(author identity.Interface, unixTime int64, title, message string, files []repository.Hash, metadata map[string]string) (*Bug, *CreateOperation, error) {
+ b := NewBug()
+ op := NewCreateOp(author, unixTime, title, message, files)
+ for key, val := range metadata {
+ op.SetMetadata(key, val)
}
-
- newBug.Append(createOp)
-
- return newBug, createOp, nil
+ if err := op.Validate(); err != nil {
+ return nil, op, err
+ }
+ b.Append(op)
+ return b, op, nil
}