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_create.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_create.go')
-rw-r--r-- | bug/op_create.go | 26 |
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 } |