aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bug/operation.go4
-rw-r--r--cache/bug_cache.go38
-rw-r--r--cache/repo_cache.go14
-rw-r--r--misc/random_bugs/create_random_bugs.go32
-rw-r--r--operations/add_comment.go12
-rw-r--r--operations/create.go12
-rw-r--r--operations/create_test.go5
-rw-r--r--operations/label_change.go8
-rw-r--r--operations/operations_test.go53
-rw-r--r--operations/set_status.go12
-rw-r--r--operations/set_title.go8
-rw-r--r--tests/bug_actions_test.go70
-rw-r--r--tests/operation_iterator_test.go13
-rw-r--r--tests/operation_pack_test.go4
14 files changed, 170 insertions, 115 deletions
diff --git a/bug/operation.go b/bug/operation.go
index c57d46d3..a408e167 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -51,11 +51,11 @@ type OpBase struct {
}
// NewOpBase is the constructor for an OpBase
-func NewOpBase(opType OperationType, author Person) *OpBase {
+func NewOpBase(opType OperationType, author Person, unixTime int64) *OpBase {
return &OpBase{
OperationType: opType,
Author: author,
- UnixTime: time.Now().Unix(),
+ UnixTime: unixTime,
}
}
diff --git a/cache/bug_cache.go b/cache/bug_cache.go
index 4fdc7d62..92b4af95 100644
--- a/cache/bug_cache.go
+++ b/cache/bug_cache.go
@@ -1,6 +1,8 @@
package cache
import (
+ "time"
+
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/operations"
"github.com/MichaelMure/git-bug/util/git"
@@ -35,11 +37,7 @@ func (c *BugCache) notifyUpdated() error {
}
func (c *BugCache) AddComment(message string) error {
- if err := c.AddCommentWithFiles(message, nil); err != nil {
- return err
- }
-
- return c.notifyUpdated()
+ return c.AddCommentWithFiles(message, nil)
}
func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error {
@@ -48,7 +46,11 @@ func (c *BugCache) AddCommentWithFiles(message string, files []git.Hash) error {
return err
}
- err = operations.CommentWithFiles(c.bug, author, message, files)
+ return c.AddCommentRaw(author, time.Now().Unix(), message, files, nil)
+}
+
+func (c *BugCache) AddCommentRaw(author bug.Person, unixTime int64, message string, files []git.Hash, metadata map[string]string) error {
+ err := operations.CommentWithFiles(c.bug, author, unixTime, message, files)
if err != nil {
return err
}
@@ -62,7 +64,11 @@ func (c *BugCache) ChangeLabels(added []string, removed []string) ([]operations.
return nil, err
}
- changes, err := operations.ChangeLabels(c.bug, author, added, removed)
+ return c.ChangeLabelsRaw(author, time.Now().Unix(), added, removed)
+}
+
+func (c *BugCache) ChangeLabelsRaw(author bug.Person, unixTime int64, added []string, removed []string) ([]operations.LabelChangeResult, error) {
+ changes, err := operations.ChangeLabels(c.bug, author, unixTime, added, removed)
if err != nil {
return changes, err
}
@@ -81,7 +87,11 @@ func (c *BugCache) Open() error {
return err
}
- err = operations.Open(c.bug, author)
+ return c.OpenRaw(author, time.Now().Unix())
+}
+
+func (c *BugCache) OpenRaw(author bug.Person, unixTime int64) error {
+ err := operations.Open(c.bug, author, unixTime)
if err != nil {
return err
}
@@ -95,7 +105,11 @@ func (c *BugCache) Close() error {
return err
}
- err = operations.Close(c.bug, author)
+ return c.CloseRaw(author, time.Now().Unix())
+}
+
+func (c *BugCache) CloseRaw(author bug.Person, unixTime int64) error {
+ err := operations.Close(c.bug, author, unixTime)
if err != nil {
return err
}
@@ -109,7 +123,11 @@ func (c *BugCache) SetTitle(title string) error {
return err
}
- err = operations.SetTitle(c.bug, author, title)
+ return c.SetTitleRaw(author, time.Now().Unix(), title)
+}
+
+func (c *BugCache) SetTitleRaw(author bug.Person, unixTime int64, title string) error {
+ err := operations.SetTitle(c.bug, author, unixTime, title)
if err != nil {
return err
}
diff --git a/cache/repo_cache.go b/cache/repo_cache.go
index 4ca19150..2278b604 100644
--- a/cache/repo_cache.go
+++ b/cache/repo_cache.go
@@ -11,6 +11,7 @@ import (
"sort"
"strconv"
"strings"
+ "time"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/operations"
@@ -354,11 +355,22 @@ func (c *RepoCache) NewBugWithFiles(title string, message string, files []git.Ha
return nil, err
}
- b, err := operations.CreateWithFiles(author, title, message, files)
+ return c.NewBugRaw(author, time.Now().Unix(), title, message, files, nil)
+}
+
+// NewBugWithFilesMeta create a new bug with attached files for the message, as
+// well as metadata for the Create operation.
+// The new bug is written in the repository (commit)
+func (c *RepoCache) NewBugRaw(author bug.Person, unixTime int64, title string, message string, files []git.Hash, metadata map[string]string) (*BugCache, error) {
+ b, err := operations.CreateWithFiles(author, unixTime, title, message, files)
if err != nil {
return nil, err
}
+ for key, value := range metadata {
+ b.FirstOp().SetMetadata(key, value)
+ }
+
err = b.Commit(c.repo)
if err != nil {
return nil, err
diff --git a/misc/random_bugs/create_random_bugs.go b/misc/random_bugs/create_random_bugs.go
index dfef4e07..66ca18a9 100644
--- a/misc/random_bugs/create_random_bugs.go
+++ b/misc/random_bugs/create_random_bugs.go
@@ -66,7 +66,12 @@ func GenerateRandomBugsWithSeed(opts Options, seed int64) []*bug.Bug {
for i := 0; i < opts.BugNumber; i++ {
addedLabels = []string{}
- b, err := operations.Create(randomPerson(opts.PersonNumber), fake.Sentence(), paragraphs())
+ b, err := operations.Create(
+ randomPerson(opts.PersonNumber),
+ time.Now().Unix(),
+ fake.Sentence(),
+ paragraphs(),
+ )
if err != nil {
panic(err)
@@ -106,12 +111,23 @@ func GenerateRandomOperationPacksWithSeed(packNumber int, opNumber int, seed int
var op bug.Operation
- op = operations.NewCreateOp(randomPerson(5), fake.Sentence(), paragraphs(), nil)
+ op = operations.NewCreateOp(
+ randomPerson(5),
+ time.Now().Unix(),
+ fake.Sentence(),
+ paragraphs(),
+ nil,
+ )
opp.Append(op)
for j := 0; j < opNumber-1; j++ {
- op = operations.NewAddCommentOp(randomPerson(5), paragraphs(), nil)
+ op = operations.NewAddCommentOp(
+ randomPerson(5),
+ time.Now().Unix(),
+ paragraphs(),
+ nil,
+ )
opp.Append(op)
}
@@ -148,19 +164,19 @@ func paragraphs() string {
}
func comment(b bug.Interface, p bug.Person) {
- _ = operations.Comment(b, p, paragraphs())
+ _ = operations.Comment(b, p, time.Now().Unix(), paragraphs())
}
func title(b bug.Interface, p bug.Person) {
- _ = operations.SetTitle(b, p, fake.Sentence())
+ _ = operations.SetTitle(b, p, time.Now().Unix(), fake.Sentence())
}
func open(b bug.Interface, p bug.Person) {
- _ = operations.Open(b, p)
+ _ = operations.Open(b, p, time.Now().Unix())
}
func close(b bug.Interface, p bug.Person) {
- _ = operations.Close(b, p)
+ _ = operations.Close(b, p, time.Now().Unix())
}
var addedLabels []string
@@ -187,5 +203,5 @@ func labels(b bug.Interface, p bug.Person) {
// ignore error
// if the randomisation produce no changes, no op
// is added to the bug
- _, _ = operations.ChangeLabels(b, p, added, removed)
+ _, _ = operations.ChangeLabels(b, p, time.Now().Unix(), added, removed)
}
diff --git a/operations/add_comment.go b/operations/add_comment.go
index 65606d77..56a2c606 100644
--- a/operations/add_comment.go
+++ b/operations/add_comment.go
@@ -52,21 +52,21 @@ func (op AddCommentOperation) Validate() error {
return nil
}
-func NewAddCommentOp(author bug.Person, message string, files []git.Hash) AddCommentOperation {
+func NewAddCommentOp(author bug.Person, unixTime int64, message string, files []git.Hash) AddCommentOperation {
return AddCommentOperation{
- OpBase: bug.NewOpBase(bug.AddCommentOp, author),
+ OpBase: bug.NewOpBase(bug.AddCommentOp, author, unixTime),
Message: message,
Files: files,
}
}
// Convenience function to apply the operation
-func Comment(b bug.Interface, author bug.Person, message string) error {
- return CommentWithFiles(b, author, message, nil)
+func Comment(b bug.Interface, author bug.Person, unixTime int64, message string) error {
+ return CommentWithFiles(b, author, unixTime, message, nil)
}
-func CommentWithFiles(b bug.Interface, author bug.Person, message string, files []git.Hash) error {
- addCommentOp := NewAddCommentOp(author, message, files)
+func CommentWithFiles(b bug.Interface, author bug.Person, unixTime int64, message string, files []git.Hash) error {
+ addCommentOp := NewAddCommentOp(author, unixTime, message, files)
if err := addCommentOp.Validate(); err != nil {
return err
}
diff --git a/operations/create.go b/operations/create.go
index 49c69482..fd66e732 100644
--- a/operations/create.go
+++ b/operations/create.go
@@ -62,9 +62,9 @@ func (op CreateOperation) Validate() error {
return nil
}
-func NewCreateOp(author bug.Person, title, message string, files []git.Hash) CreateOperation {
+func NewCreateOp(author bug.Person, unixTime int64, title, message string, files []git.Hash) CreateOperation {
return CreateOperation{
- OpBase: bug.NewOpBase(bug.CreateOp, author),
+ OpBase: bug.NewOpBase(bug.CreateOp, author, unixTime),
Title: title,
Message: message,
Files: files,
@@ -72,13 +72,13 @@ func NewCreateOp(author bug.Person, title, message string, files []git.Hash) Cre
}
// Convenience function to apply the operation
-func Create(author bug.Person, title, message string) (*bug.Bug, error) {
- return CreateWithFiles(author, title, message, nil)
+func Create(author bug.Person, unixTime int64, title, message string) (*bug.Bug, error) {
+ return CreateWithFiles(author, unixTime, title, message, nil)
}
-func CreateWithFiles(author bug.Person, title, message string, files []git.Hash) (*bug.Bug, error) {
+func CreateWithFiles(author bug.Person, unixTime int64, title, message string, files []git.Hash) (*bug.Bug, error) {
newBug := bug.NewBug()
- createOp := NewCreateOp(author, title, message, files)
+ createOp := NewCreateOp(author, unixTime, title, message, files)
if err := createOp.Validate(); err != nil {
return nil, err
diff --git a/operations/create_test.go b/operations/create_test.go
index a20472d3..c32b2868 100644
--- a/operations/create_test.go
+++ b/operations/create_test.go
@@ -4,6 +4,7 @@ import (
"github.com/MichaelMure/git-bug/bug"
"reflect"
"testing"
+ "time"
)
func TestCreate(t *testing.T) {
@@ -14,7 +15,9 @@ func TestCreate(t *testing.T) {
Email: "rene@descartes.fr",
}
- create := NewCreateOp(rene, "title", "message", nil)
+ unix := time.Now().Unix()
+
+ create := NewCreateOp(rene, unix, "title", "message", nil)
snapshot = create.Apply(snapshot)
diff --git a/operations/label_change.go b/operations/label_change.go
index 478fbe30..83e3e692 100644
--- a/operations/label_change.go
+++ b/operations/label_change.go
@@ -74,16 +74,16 @@ func (op LabelChangeOperation) Validate() error {
return nil
}
-func NewLabelChangeOperation(author bug.Person, added, removed []bug.Label) LabelChangeOperation {
+func NewLabelChangeOperation(author bug.Person, unixTime int64, added, removed []bug.Label) LabelChangeOperation {
return LabelChangeOperation{
- OpBase: bug.NewOpBase(bug.LabelChangeOp, author),
+ OpBase: bug.NewOpBase(bug.LabelChangeOp, author, unixTime),
Added: added,
Removed: removed,
}
}
// ChangeLabels is a convenience function to apply the operation
-func ChangeLabels(b bug.Interface, author bug.Person, add, remove []string) ([]LabelChangeResult, error) {
+func ChangeLabels(b bug.Interface, author bug.Person, unixTime int64, add, remove []string) ([]LabelChangeResult, error) {
var added, removed []bug.Label
var results []LabelChangeResult
@@ -131,7 +131,7 @@ func ChangeLabels(b bug.Interface, author bug.Person, add, remove []string) ([]L
return results, fmt.Errorf("no label added or removed")
}
- labelOp := NewLabelChangeOperation(author, added, removed)
+ labelOp := NewLabelChangeOperation(author, unixTime, added, removed)
if err := labelOp.Validate(); err != nil {
return nil, err
diff --git a/operations/operations_test.go b/operations/operations_test.go
index b74dd8d1..b94c2c0c 100644
--- a/operations/operations_test.go
+++ b/operations/operations_test.go
@@ -2,6 +2,7 @@ package operations
import (
"testing"
+ "time"
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/util/git"
@@ -13,12 +14,14 @@ func TestValidate(t *testing.T) {
Email: "rene@descartes.fr",
}
+ unix := time.Now().Unix()
+
good := []bug.Operation{
- NewCreateOp(rene, "title", "message", nil),
- NewSetTitleOp(rene, "title2", "title1"),
- NewAddCommentOp(rene, "message2", nil),
- NewSetStatusOp(rene, bug.ClosedStatus),
- NewLabelChangeOperation(rene, []bug.Label{"added"}, []bug.Label{"removed"}),
+ NewCreateOp(rene, unix, "title", "message", nil),
+ NewSetTitleOp(rene, unix, "title2", "title1"),
+ NewAddCommentOp(rene, unix, "message2", nil),
+ NewSetStatusOp(rene, unix, bug.ClosedStatus),
+ NewLabelChangeOperation(rene, unix, []bug.Label{"added"}, []bug.Label{"removed"}),
}
for _, op := range good {
@@ -29,11 +32,11 @@ func TestValidate(t *testing.T) {
bad := []bug.Operation{
// opbase
- NewSetStatusOp(bug.Person{Name: "", Email: "rene@descartes.fr"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René Descartes\u001b", Email: "rene@descartes.fr"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@descartes.fr\u001b"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René \nDescartes", Email: "rene@descartes.fr"}, bug.ClosedStatus),
- NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@\ndescartes.fr"}, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "", Email: "rene@descartes.fr"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René Descartes\u001b", Email: "rene@descartes.fr"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@descartes.fr\u001b"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René \nDescartes", Email: "rene@descartes.fr"}, unix, bug.ClosedStatus),
+ NewSetStatusOp(bug.Person{Name: "René Descartes", Email: "rene@\ndescartes.fr"}, unix, bug.ClosedStatus),
CreateOperation{OpBase: &bug.OpBase{
Author: rene,
UnixTime: 0,
@@ -43,21 +46,21 @@ func TestValidate(t *testing.T) {
Message: "message",
},
- NewCreateOp(rene, "multi\nline", "message", nil),
- NewCreateOp(rene, "title", "message", []git.Hash{git.Hash("invalid")}),
- NewCreateOp(rene, "title\u001b", "message", nil),
- NewCreateOp(rene, "title", "message\u001b", nil),
- NewSetTitleOp(rene, "multi\nline", "title1"),
- NewSetTitleOp(rene, "title", "multi\nline"),
- NewSetTitleOp(rene, "title\u001b", "title2"),
- NewSetTitleOp(rene, "title", "title2\u001b"),
- NewAddCommentOp(rene, "", nil),
- NewAddCommentOp(rene, "message\u001b", nil),
- NewAddCommentOp(rene, "message", []git.Hash{git.Hash("invalid")}),
- NewSetStatusOp(rene, 1000),
- NewSetStatusOp(rene, 0),
- NewLabelChangeOperation(rene, []bug.Label{}, []bug.Label{}),
- NewLabelChangeOperation(rene, []bug.Label{"multi\nline"}, []bug.Label{}),
+ NewCreateOp(rene, unix, "multi\nline", "message", nil),
+ NewCreateOp(rene, unix, "title", "message", []git.Hash{git.Hash("invalid")}),
+ NewCreateOp(rene, unix, "title\u001b", "message", nil),
+ NewCreateOp(rene, unix, "title", "message\u001b", nil),
+ NewSetTitleOp(rene, unix, "multi\nline", "title1"),
+ NewSetTitleOp(rene, unix, "title", "multi\nline"),
+ NewSetTitleOp(rene, unix, "title\u001b", "title2"),
+ NewSetTitleOp(rene, unix, "title", "title2\u001b"),
+ NewAddCommentOp(rene, unix, "", nil),
+ NewAddCommentOp(rene, unix, "message\u001b", nil),
+ NewAddCommentOp(rene, unix, "message", []git.Hash{git.Hash("invalid")}),
+ NewSetStatusOp(rene, unix, 1000),
+ NewSetStatusOp(rene, unix, 0),
+ NewLabelChangeOperation(rene, unix, []bug.Label{}, []bug.Label{}),
+ NewLabelChangeOperation(rene, unix, []bug.Label{"multi\nline"}, []bug.Label{}),
}
for i, op := range bad {
diff --git a/operations/set_status.go b/operations/set_status.go
index 6ef95320..3e7eae4a 100644
--- a/operations/set_status.go
+++ b/operations/set_status.go
@@ -32,16 +32,16 @@ func (op SetStatusOperation) Validate() error {
return nil
}
-func NewSetStatusOp(author bug.Person, status bug.Status) SetStatusOperation {
+func NewSetStatusOp(author bug.Person, unixTime int64, status bug.Status) SetStatusOperation {
return SetStatusOperation{
- OpBase: bug.NewOpBase(bug.SetStatusOp, author),
+ OpBase: bug.NewOpBase(bug.SetStatusOp, author, unixTime),
Status: status,
}
}
// Convenience function to apply the operation
-func Open(b bug.Interface, author bug.Person) error {
- op := NewSetStatusOp(author, bug.OpenStatus)
+func Open(b bug.Interface, author bug.Person, unixTime int64) error {
+ op := NewSetStatusOp(author, unixTime, bug.OpenStatus)
if err := op.Validate(); err != nil {
return err
}
@@ -50,8 +50,8 @@ func Open(b bug.Interface, author bug.Person) error {
}
// Convenience function to apply the operation
-func Close(b bug.Interface, author bug.Person) error {
- op := NewSetStatusOp(author, bug.ClosedStatus)
+func Close(b bug.Interface, author bug.Person, unixTime int64) error {
+ op := NewSetStatusOp(author, unixTime, bug.ClosedStatus)
if err := op.Validate(); err != nil {
return err
}
diff --git a/operations/set_title.go b/operations/set_title.go
index 154998cf..e6964a65 100644
--- a/operations/set_title.go
+++ b/operations/set_title.go
@@ -52,16 +52,16 @@ func (op SetTitleOperation) Validate() error {
return nil
}
-func NewSetTitleOp(author bug.Person, title string, was string) SetTitleOperation {
+func NewSetTitleOp(author bug.Person, unixTime int64, title string, was string) SetTitleOperation {
return SetTitleOperation{
- OpBase: bug.NewOpBase(bug.SetTitleOp, author),
+ OpBase: bug.NewOpBase(bug.SetTitleOp, author, unixTime),
Title: title,
Was: was,
}
}
// Convenience function to apply the operation
-func SetTitle(b bug.Interface, author bug.Person, title string) error {
+func SetTitle(b bug.Interface, author bug.Person, unixTime int64, title string) error {
it := bug.NewOperationIterator(b)
var lastTitleOp bug.Operation
@@ -79,7 +79,7 @@ func SetTitle(b bug.Interface, author bug.Person, title string) error {
was = b.FirstOp().(CreateOperation).Title
}
- setTitleOp := NewSetTitleOp(author, title, was)
+ setTitleOp := NewSetTitleOp(author, unixTime, title, was)
if err := setTitleOp.Validate(); err != nil {
return err
diff --git a/tests/bug_actions_test.go b/tests/bug_actions_test.go
index b8720842..50333cd2 100644
--- a/tests/bug_actions_test.go
+++ b/tests/bug_actions_test.go
@@ -71,7 +71,7 @@ func TestPushPull(t *testing.T) {
repoA, repoB, remote := setupRepos(t)
defer cleanupRepos(repoA, repoB, remote)
- bug1, err := operations.Create(rene, "bug1", "message")
+ bug1, err := operations.Create(rene, unix, "bug1", "message")
checkErr(t, err)
err = bug1.Commit(repoA)
checkErr(t, err)
@@ -90,7 +90,7 @@ func TestPushPull(t *testing.T) {
}
// B --> remote --> A
- bug2, err := operations.Create(rene, "bug2", "message")
+ bug2, err := operations.Create(rene, unix, "bug2", "message")
checkErr(t, err)
err = bug2.Commit(repoB)
checkErr(t, err)
@@ -139,7 +139,7 @@ func _RebaseTheirs(t testing.TB) {
repoA, repoB, remote := setupRepos(t)
defer cleanupRepos(repoA, repoB, remote)
- bug1, err := operations.Create(rene, "bug1", "message")
+ bug1, err := operations.Create(rene, unix, "bug1", "message")
checkErr(t, err)
err = bug1.Commit(repoA)
checkErr(t, err)
@@ -155,9 +155,9 @@ func _RebaseTheirs(t testing.TB) {
bug2, err := bug.ReadLocalBug(repoB, bug1.Id())
checkErr(t, err)
- operations.Comment(bug2, rene, "message2")
- operations.Comment(bug2, rene, "message3")
- operations.Comment(bug2, rene, "message4")
+ operations.Comment(bug2, rene, unix, "message2")
+ operations.Comment(bug2, rene, unix, "message3")
+ operations.Comment(bug2, rene, unix, "message4")
err = bug2.Commit(repoB)
checkErr(t, err)
@@ -197,7 +197,7 @@ func _RebaseOurs(t testing.TB) {
repoA, repoB, remote := setupRepos(t)
defer cleanupRepos(repoA, repoB, remote)
- bug1, err := operations.Create(rene, "bug1", "message")
+ bug1, err := operations.Create(rene, unix, "bug1", "message")
checkErr(t, err)
err = bug1.Commit(repoA)
checkErr(t, err)
@@ -210,21 +210,21 @@ func _RebaseOurs(t testing.TB) {
err = bug.Pull(repoB, "origin")
checkErr(t, err)
- operations.Comment(bug1, rene, "message2")
- operations.Comment(bug1, rene, "message3")
- operations.Comment(bug1, rene, "message4")
+ operations.Comment(bug1, rene, unix, "message2")
+ operations.Comment(bug1, rene, unix, "message3")
+ operations.Comment(bug1, rene, unix, "message4")
err = bug1.Commit(repoA)
checkErr(t, err)
- operations.Comment(bug1, rene, "message5")
- operations.Comment(bug1, rene, "message6")
- operations.Comment(bug1, rene, "message7")
+ operations.Comment(bug1, rene, unix, "message5")
+ operations.Comment(bug1, rene, unix, "message6")
+ operations.Comment(bug1, rene, unix, "message7")
err = bug1.Commit(repoA)
checkErr(t, err)
- operations.Comment(bug1, rene, "message8")
- operations.Comment(bug1, rene, "message9")
- operations.Comment(bug1, rene, "message10")
+ operations.Comment(bug1, rene, unix, "message8")
+ operations.Comment(bug1, rene, unix, "message9")
+ operations.Comment(bug1, rene, unix, "message10")
err = bug1.Commit(repoA)
checkErr(t, err)
@@ -269,7 +269,7 @@ func _RebaseConflict(t testing.TB) {
repoA, repoB, remote := setupRepos(t)
defer cleanupRepos(repoA, repoB, remote)
- bug1, err := operations.Create(rene, "bug1", "message")
+ bug1, err := operations.Create(rene, unix, "bug1", "message")
checkErr(t, err)
err = bug1.Commit(repoA)
checkErr(t, err)
@@ -282,42 +282,42 @@ func _RebaseConflict(t testing.TB) {
err = bug.Pull(repoB, "origin")
checkErr(t, err)
- operations.Comment(bug1, rene, "message2")
- operations.Comment(bug1, rene, "message3")
- operations.Comment(bug1, rene, "message4")
+ operations.Comment(bug1, rene, unix, "message2")
+ operations.Comment(bug1, rene, unix, "message3")
+ operations.Comment(bug1, rene, unix, "message4")
err = bug1.Commit(repoA)
checkErr(t, err)
- operations.Comment(bug1, rene, "message5")
- operations.Comment(bug1, rene, "message6")
- operations.Comment(bug1, rene, "message7")
+ operations.Comment(bug1, rene, unix, "message5")
+ operations.Comment(bug1, rene, unix, "message6")
+ operations.Comment(bug1, rene, unix, "message7")
err = bug1.Commit(repoA)
checkErr(t, err)
- operations.Comment(bug1, rene, "message8")
- operations.Comment(bug1, rene, "message9")
- operations.Comment(bug1, rene, "message10")
+ operations.Comment(bug1, rene, unix, "message8")
+ operations.Comment(bug1, rene, unix, "message9")
+ operations.Comment(bug1, rene, unix, "message10")
err = bug1.Commit(repoA)
checkErr(t, err)
bug2, err := bug.ReadLocalBug(repoB, bug1.Id())
checkErr(t, err)
- operations.Comment(bug2, rene, "message11")
- operations.Comment(bug2, rene, "message12")
- operations.Comment(bug2, rene, "message13")
+ operations.Comment(bug2, rene, unix, "message11")
+ operations.Comment(bug2, rene, unix, "message12")
+ operations.Comment(bug2, rene, unix, "message13")
err = bug2.Commit(repoB)
checkErr(t, err)
- operations.Comment(bug2, rene, "message14")
- operations.Comment(bug2, rene, "message15")
- operations.Comment(bug2, rene, "message16")
+ operations.Comment(bug2, rene, unix, "message14")
+ operations.Comment(bug2, rene, unix, "message15")
+ operations.Comment(bug2, rene, unix, "message16")
err = bug2.Commit(repoB)
checkErr(t, err)
- operations.Comment(bug2, rene, "message17")
- operations.Comment(bug2, rene, "message18")
- operations.Comment(bug2, rene, "message19")
+ operations.Comment(bug2, rene, unix, "message17")
+ operations.Comment(bug2, rene, unix, "message18")
+ operations.Comment(bug2, rene, unix, "message19")
err = bug2.Commit(repoB)
checkErr(t, err)
diff --git a/tests/operation_iterator_test.go b/tests/operation_iterator_test.go
index 52778e71..524a639c 100644
--- a/tests/operation_iterator_test.go
+++ b/tests/operation_iterator_test.go
@@ -5,6 +5,7 @@ import (
"github.com/MichaelMure/git-bug/operations"
"github.com/MichaelMure/git-bug/repository"
"testing"
+ "time"
)
var (
@@ -13,11 +14,13 @@ var (
Email: "rene@descartes.fr",
}
- createOp = operations.NewCreateOp(rene, "title", "message", nil)
- setTitleOp = operations.NewSetTitleOp(rene, "title2", "title1")
- addCommentOp = operations.NewAddCommentOp(rene, "message2", nil)
- setStatusOp = operations.NewSetStatusOp(rene, bug.ClosedStatus)
- labelChangeOp = operations.NewLabelChangeOperation(rene, []bug.Label{"added"}, []bug.Label{"removed"})
+ unix = time.Now().Unix()
+
+ createOp = operations.NewCreateOp(rene, unix, "title", "message", nil)
+ setTitleOp = operations.NewSetTitleOp(rene, unix, "title2", "title1")
+ addCommentOp = operations.NewAddCommentOp(rene, unix, "message2", nil)
+ setStatusOp = operations.NewSetStatusOp(rene, unix, bug.ClosedStatus)
+ labelChangeOp = operations.NewLabelChangeOperation(rene, unix, []bug.Label{"added"}, []bug.Label{"removed"})
)
func TestOpIterator(t *testing.T) {
diff --git a/tests/operation_pack_test.go b/tests/operation_pack_test.go
index d7393c29..aab1f1c9 100644
--- a/tests/operation_pack_test.go
+++ b/tests/operation_pack_test.go
@@ -19,7 +19,7 @@ func TestOperationPackSerialize(t *testing.T) {
opp.Append(setStatusOp)
opp.Append(labelChangeOp)
- opMeta := operations.NewCreateOp(rene, "title", "message", nil)
+ opMeta := operations.NewCreateOp(rene, unix, "title", "message", nil)
opMeta.SetMetadata("key", "value")
opp.Append(opMeta)
@@ -27,7 +27,7 @@ func TestOperationPackSerialize(t *testing.T) {
t.Fatal()
}
- opFile := operations.NewCreateOp(rene, "title", "message", []git.Hash{
+ opFile := operations.NewCreateOp(rene, unix, "title", "message", []git.Hash{
"abcdef",
"ghijkl",
})