diff options
author | Michael Muré <batolettre@gmail.com> | 2018-09-28 20:39:39 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-09-29 00:51:54 +0200 |
commit | 1bf268cebc84a9de1e538cbb54bcc0f434022192 (patch) | |
tree | daeb92cd6b15d56a7a7102f95b73756e5b9597d0 /operations/set_status.go | |
parent | 8af6f7d98f2fd98f85d6a17bcda49983c272cf48 (diff) | |
download | git-bug-1bf268cebc84a9de1e538cbb54bcc0f434022192.tar.gz |
merge package operations into bug, they are tightly coupled anyway
Diffstat (limited to 'operations/set_status.go')
-rw-r--r-- | operations/set_status.go | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/operations/set_status.go b/operations/set_status.go deleted file mode 100644 index 3e7eae4a..00000000 --- a/operations/set_status.go +++ /dev/null @@ -1,60 +0,0 @@ -package operations - -import ( - "github.com/MichaelMure/git-bug/bug" - "github.com/pkg/errors" -) - -// SetStatusOperation will change the status of a bug - -var _ bug.Operation = SetStatusOperation{} - -type SetStatusOperation struct { - *bug.OpBase - Status bug.Status `json:"status"` -} - -func (op SetStatusOperation) Apply(snapshot bug.Snapshot) bug.Snapshot { - snapshot.Status = op.Status - - return snapshot -} - -func (op SetStatusOperation) Validate() error { - if err := bug.OpBaseValidate(op, bug.SetStatusOp); err != nil { - return err - } - - if err := op.Status.Validate(); err != nil { - return errors.Wrap(err, "status") - } - - return nil -} - -func NewSetStatusOp(author bug.Person, unixTime int64, status bug.Status) SetStatusOperation { - return SetStatusOperation{ - OpBase: bug.NewOpBase(bug.SetStatusOp, author, unixTime), - Status: status, - } -} - -// Convenience function to apply the operation -func Open(b bug.Interface, author bug.Person, unixTime int64) error { - op := NewSetStatusOp(author, unixTime, bug.OpenStatus) - if err := op.Validate(); err != nil { - return err - } - b.Append(op) - return nil -} - -// Convenience function to apply the operation -func Close(b bug.Interface, author bug.Person, unixTime int64) error { - op := NewSetStatusOp(author, unixTime, bug.ClosedStatus) - if err := op.Validate(); err != nil { - return err - } - b.Append(op) - return nil -} |