aboutsummaryrefslogtreecommitdiffstats
path: root/entities
diff options
context:
space:
mode:
Diffstat (limited to 'entities')
-rw-r--r--entities/bug/bug.go3
-rw-r--r--entities/bug/op_set_status.go11
-rw-r--r--entities/bug/op_set_status_test.go3
-rw-r--r--entities/bug/operation_test.go13
-rw-r--r--entities/bug/snapshot.go3
-rw-r--r--entities/common/status.go (renamed from entities/bug/status.go)2
6 files changed, 20 insertions, 15 deletions
diff --git a/entities/bug/bug.go b/entities/bug/bug.go
index 213a4ca4..4ce10c5b 100644
--- a/entities/bug/bug.go
+++ b/entities/bug/bug.go
@@ -4,6 +4,7 @@ package bug
import (
"fmt"
+ "github.com/MichaelMure/git-bug/entities/common"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/entity/dag"
@@ -149,7 +150,7 @@ func (bug *Bug) Operations() []Operation {
func (bug *Bug) Compile() *Snapshot {
snap := &Snapshot{
id: bug.Id(),
- Status: OpenStatus,
+ Status: common.OpenStatus,
}
for _, op := range bug.Operations() {
diff --git a/entities/bug/op_set_status.go b/entities/bug/op_set_status.go
index 5e73d982..cf17901a 100644
--- a/entities/bug/op_set_status.go
+++ b/entities/bug/op_set_status.go
@@ -3,6 +3,7 @@ package bug
import (
"github.com/pkg/errors"
+ "github.com/MichaelMure/git-bug/entities/common"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/entity/dag"
@@ -14,7 +15,7 @@ var _ Operation = &SetStatusOperation{}
// SetStatusOperation will change the status of a bug
type SetStatusOperation struct {
dag.OpBase
- Status Status `json:"status"`
+ Status common.Status `json:"status"`
}
func (op *SetStatusOperation) Id() entity.Id {
@@ -47,7 +48,7 @@ func (op *SetStatusOperation) Validate() error {
return nil
}
-func NewSetStatusOp(author identity.Interface, unixTime int64, status Status) *SetStatusOperation {
+func NewSetStatusOp(author identity.Interface, unixTime int64, status common.Status) *SetStatusOperation {
return &SetStatusOperation{
OpBase: dag.NewOpBase(SetStatusOp, author, unixTime),
Status: status,
@@ -58,7 +59,7 @@ type SetStatusTimelineItem struct {
id entity.Id
Author identity.Interface
UnixTime timestamp.Timestamp
- Status Status
+ Status common.Status
}
func (s SetStatusTimelineItem) Id() entity.Id {
@@ -70,7 +71,7 @@ func (s SetStatusTimelineItem) IsAuthored() {}
// Open is a convenience function to change a bugs state to Open
func Open(b Interface, author identity.Interface, unixTime int64, metadata map[string]string) (*SetStatusOperation, error) {
- op := NewSetStatusOp(author, unixTime, OpenStatus)
+ op := NewSetStatusOp(author, unixTime, common.OpenStatus)
for key, value := range metadata {
op.SetMetadata(key, value)
}
@@ -83,7 +84,7 @@ func Open(b Interface, author identity.Interface, unixTime int64, metadata map[s
// Close is a convenience function to change a bugs state to Close
func Close(b Interface, author identity.Interface, unixTime int64, metadata map[string]string) (*SetStatusOperation, error) {
- op := NewSetStatusOp(author, unixTime, ClosedStatus)
+ op := NewSetStatusOp(author, unixTime, common.ClosedStatus)
for key, value := range metadata {
op.SetMetadata(key, value)
}
diff --git a/entities/bug/op_set_status_test.go b/entities/bug/op_set_status_test.go
index 7ec78704..5bb30265 100644
--- a/entities/bug/op_set_status_test.go
+++ b/entities/bug/op_set_status_test.go
@@ -3,12 +3,13 @@ package bug
import (
"testing"
+ "github.com/MichaelMure/git-bug/entities/common"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity/dag"
)
func TestSetStatusSerialize(t *testing.T) {
dag.SerializeRoundTripTest(t, func(author identity.Interface, unixTime int64) *SetStatusOperation {
- return NewSetStatusOp(author, unixTime, ClosedStatus)
+ return NewSetStatusOp(author, unixTime, common.ClosedStatus)
})
}
diff --git a/entities/bug/operation_test.go b/entities/bug/operation_test.go
index fe8080c3..4bec49ae 100644
--- a/entities/bug/operation_test.go
+++ b/entities/bug/operation_test.go
@@ -6,6 +6,7 @@ import (
"github.com/stretchr/testify/require"
+ "github.com/MichaelMure/git-bug/entities/common"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity/dag"
"github.com/MichaelMure/git-bug/repository"
@@ -30,7 +31,7 @@ func TestValidate(t *testing.T) {
NewCreateOp(rene, unix, "title", "message", nil),
NewSetTitleOp(rene, unix, "title2", "title1"),
NewAddCommentOp(rene, unix, "message2", nil),
- NewSetStatusOp(rene, unix, ClosedStatus),
+ NewSetStatusOp(rene, unix, common.ClosedStatus),
NewLabelChangeOperation(rene, unix, []Label{"added"}, []Label{"removed"}),
}
@@ -42,11 +43,11 @@ func TestValidate(t *testing.T) {
bad := []Operation{
// opbase
- NewSetStatusOp(makeIdentity(t, "", "rene@descartes.fr"), unix, ClosedStatus),
- NewSetStatusOp(makeIdentity(t, "René Descartes\u001b", "rene@descartes.fr"), unix, ClosedStatus),
- NewSetStatusOp(makeIdentity(t, "René Descartes", "rene@descartes.fr\u001b"), unix, ClosedStatus),
- NewSetStatusOp(makeIdentity(t, "René \nDescartes", "rene@descartes.fr"), unix, ClosedStatus),
- NewSetStatusOp(makeIdentity(t, "René Descartes", "rene@\ndescartes.fr"), unix, ClosedStatus),
+ NewSetStatusOp(makeIdentity(t, "", "rene@descartes.fr"), unix, common.ClosedStatus),
+ NewSetStatusOp(makeIdentity(t, "René Descartes\u001b", "rene@descartes.fr"), unix, common.ClosedStatus),
+ NewSetStatusOp(makeIdentity(t, "René Descartes", "rene@descartes.fr\u001b"), unix, common.ClosedStatus),
+ NewSetStatusOp(makeIdentity(t, "René \nDescartes", "rene@descartes.fr"), unix, common.ClosedStatus),
+ NewSetStatusOp(makeIdentity(t, "René Descartes", "rene@\ndescartes.fr"), unix, common.ClosedStatus),
&CreateOperation{OpBase: dag.NewOpBase(CreateOp, rene, 0),
Title: "title",
Message: "message",
diff --git a/entities/bug/snapshot.go b/entities/bug/snapshot.go
index cece09b8..442496f7 100644
--- a/entities/bug/snapshot.go
+++ b/entities/bug/snapshot.go
@@ -4,6 +4,7 @@ import (
"fmt"
"time"
+ "github.com/MichaelMure/git-bug/entities/common"
"github.com/MichaelMure/git-bug/entities/identity"
"github.com/MichaelMure/git-bug/entity"
"github.com/MichaelMure/git-bug/entity/dag"
@@ -15,7 +16,7 @@ var _ dag.Snapshot = &Snapshot{}
type Snapshot struct {
id entity.Id
- Status Status
+ Status common.Status
Title string
Comments []Comment
Labels []Label
diff --git a/entities/bug/status.go b/entities/common/status.go
index b8fba609..6859891a 100644
--- a/entities/bug/status.go
+++ b/entities/common/status.go
@@ -1,4 +1,4 @@
-package bug
+package common
import (
"fmt"