aboutsummaryrefslogtreecommitdiffstats
path: root/operations/set_status.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-11 22:04:16 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-11 22:14:46 +0200
commit3605887345792d2f981f971c6c4a2cb7f86a343e (patch)
treeafd525b6e3a638e4c619a5a986fcb2811c297444 /operations/set_status.go
parent7b05983c19af4da70f2a9a5062913f4e4f5d5faa (diff)
downloadgit-bug-3605887345792d2f981f971c6c4a2cb7f86a343e.tar.gz
reorganize package for a more idomatic go
Diffstat (limited to 'operations/set_status.go')
-rw-r--r--operations/set_status.go39
1 files changed, 39 insertions, 0 deletions
diff --git a/operations/set_status.go b/operations/set_status.go
new file mode 100644
index 00000000..bafcf5ee
--- /dev/null
+++ b/operations/set_status.go
@@ -0,0 +1,39 @@
+package operations
+
+import (
+ "github.com/MichaelMure/git-bug/bug"
+)
+
+// SetStatusOperation will change the status of a bug
+
+var _ bug.Operation = SetStatusOperation{}
+
+type SetStatusOperation struct {
+ bug.OpBase
+ Status bug.Status
+}
+
+func (op SetStatusOperation) Apply(snapshot bug.Snapshot) bug.Snapshot {
+ snapshot.Status = op.Status
+
+ return snapshot
+}
+
+func NewSetStatusOp(author bug.Person, status bug.Status) SetStatusOperation {
+ return SetStatusOperation{
+ OpBase: bug.NewOpBase(bug.SetStatusOp, author),
+ Status: status,
+ }
+}
+
+// Convenience function to apply the operation
+func Open(b bug.Interface, author bug.Person) {
+ op := NewSetStatusOp(author, bug.OpenStatus)
+ b.Append(op)
+}
+
+// Convenience function to apply the operation
+func Close(b bug.Interface, author bug.Person) {
+ op := NewSetStatusOp(author, bug.ClosedStatus)
+ b.Append(op)
+}