aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operation.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-09-28 20:39:39 +0200
committerMichael Muré <batolettre@gmail.com>2018-09-29 00:51:54 +0200
commit1bf268cebc84a9de1e538cbb54bcc0f434022192 (patch)
treedaeb92cd6b15d56a7a7102f95b73756e5b9597d0 /bug/operation.go
parent8af6f7d98f2fd98f85d6a17bcda49983c272cf48 (diff)
downloadgit-bug-1bf268cebc84a9de1e538cbb54bcc0f434022192.tar.gz
merge package operations into bug, they are tightly coupled anyway
Diffstat (limited to 'bug/operation.go')
-rw-r--r--bug/operation.go28
1 files changed, 8 insertions, 20 deletions
diff --git a/bug/operation.go b/bug/operation.go
index a408e167..cd4094dc 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -22,14 +22,12 @@ const (
// Operation define the interface to fulfill for an edit operation of a Bug
type Operation interface {
- // OpType return the type of operation
- OpType() OperationType
+ // base return the OpBase of the Operation, for package internal use
+ base() *OpBase
// Time return the time when the operation was added
Time() time.Time
// GetUnixTime return the unix timestamp when the operation was added
GetUnixTime() int64
- // GetAuthor return the author of the operation
- GetAuthor() Person
// GetFiles return the files needed by this operation
GetFiles() []git.Hash
// Apply the operation to a Snapshot to create the final state
@@ -50,8 +48,8 @@ type OpBase struct {
Metadata map[string]string `json:"metadata,omitempty"`
}
-// NewOpBase is the constructor for an OpBase
-func NewOpBase(opType OperationType, author Person, unixTime int64) *OpBase {
+// newOpBase is the constructor for an OpBase
+func newOpBase(opType OperationType, author Person, unixTime int64) *OpBase {
return &OpBase{
OperationType: opType,
Author: author,
@@ -59,11 +57,6 @@ func NewOpBase(opType OperationType, author Person, unixTime int64) *OpBase {
}
}
-// OpType return the type of operation
-func (op *OpBase) OpType() OperationType {
- return op.OperationType
-}
-
// Time return the time when the operation was added
func (op *OpBase) Time() time.Time {
return time.Unix(op.UnixTime, 0)
@@ -74,27 +67,22 @@ func (op *OpBase) GetUnixTime() int64 {
return op.UnixTime
}
-// GetAuthor return the author of the operation
-func (op *OpBase) GetAuthor() Person {
- return op.Author
-}
-
// GetFiles return the files needed by this operation
func (op *OpBase) GetFiles() []git.Hash {
return nil
}
// Validate check the OpBase for errors
-func OpBaseValidate(op Operation, opType OperationType) error {
- if op.OpType() != opType {
- return fmt.Errorf("incorrect operation type (expected: %v, actual: %v)", opType, op.OpType())
+func opBaseValidate(op Operation, opType OperationType) error {
+ if op.base().OperationType != opType {
+ return fmt.Errorf("incorrect operation type (expected: %v, actual: %v)", opType, op.base().OperationType)
}
if op.GetUnixTime() == 0 {
return fmt.Errorf("time not set")
}
- if err := op.GetAuthor().Validate(); err != nil {
+ if err := op.base().Author.Validate(); err != nil {
return errors.Wrap(err, "author")
}