aboutsummaryrefslogtreecommitdiffstats
path: root/bug/operation.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-13 15:28:16 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-13 15:28:47 +0200
commitdf144e727a858ed07e3c9328d91efe052c4781e1 (patch)
treebfbfeea70f97ab3d4274c8e5add2c3aeeac1423b /bug/operation.go
parentf2f779c5a8b4efe67317bbffe110a9880c1f529a (diff)
downloadgit-bug-df144e727a858ed07e3c9328d91efe052c4781e1.tar.gz
fix some linting trouble
Diffstat (limited to 'bug/operation.go')
-rw-r--r--bug/operation.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/bug/operation.go b/bug/operation.go
index 3949ac7b..cdf87931 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -5,6 +5,7 @@ import (
"time"
)
+// OperationType is an identifier
type OperationType int
const (
@@ -16,22 +17,29 @@ const (
LabelChangeOp
)
+// Operation define the interface to fulfill for an edit operation of a Bug
type Operation interface {
+ // OpType return the type of operation
OpType() OperationType
+ // Time return the time when the operation was added
Time() time.Time
+ // Apply the operation to a Snapshot to create the final state
Apply(snapshot Snapshot) Snapshot
+ // Files return the files needed by this operation
Files() []util.Hash
// TODO: data validation (ex: a title is a single line)
// Validate() bool
}
+// OpBase implement the common code for all operations
type OpBase struct {
OperationType OperationType
Author Person
UnixTime int64
}
+// NewOpBase is the constructor for an OpBase
func NewOpBase(opType OperationType, author Person) OpBase {
return OpBase{
OperationType: opType,
@@ -40,14 +48,17 @@ func NewOpBase(opType OperationType, author Person) 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)
}
+// Files return the files needed by this operation
func (op OpBase) Files() []util.Hash {
return nil
}