mirror of
https://github.com/MichaelMure/git-bug.git
synced 2024-12-14 17:51:44 +03:00
eb39c5c29b
a nice templace is now provided with explanations new: title and message can now be provided from the editor. Title will be the first non-empty line
46 lines
743 B
Go
46 lines
743 B
Go
package bug
|
|
|
|
import "time"
|
|
|
|
type OperationType int
|
|
|
|
const (
|
|
_ OperationType = iota
|
|
CreateOp
|
|
SetTitleOp
|
|
AddCommentOp
|
|
SetStatusOp
|
|
LabelChangeOp
|
|
)
|
|
|
|
type Operation interface {
|
|
OpType() OperationType
|
|
Time() time.Time
|
|
Apply(snapshot Snapshot) Snapshot
|
|
|
|
// TODO: data validation (ex: a title is a single line)
|
|
// Validate() bool
|
|
}
|
|
|
|
type OpBase struct {
|
|
OperationType OperationType
|
|
Author Person
|
|
UnixTime int64
|
|
}
|
|
|
|
func NewOpBase(opType OperationType, author Person) OpBase {
|
|
return OpBase{
|
|
OperationType: opType,
|
|
Author: author,
|
|
UnixTime: time.Now().Unix(),
|
|
}
|
|
}
|
|
|
|
func (op OpBase) OpType() OperationType {
|
|
return op.OperationType
|
|
}
|
|
|
|
func (op OpBase) Time() time.Time {
|
|
return time.Unix(op.UnixTime, 0)
|
|
}
|