aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bug/bug.go2
-rw-r--r--bug/op_add_comment.go4
-rw-r--r--bug/op_create.go3
-rw-r--r--bug/op_create_test.go2
-rw-r--r--bug/op_label_change.go4
-rw-r--r--bug/op_set_status.go4
-rw-r--r--bug/op_set_title.go4
-rw-r--r--bug/operation.go2
-rw-r--r--bug/with_snapshot.go6
9 files changed, 10 insertions, 21 deletions
diff --git a/bug/bug.go b/bug/bug.go
index b252b176..f29c04b4 100644
--- a/bug/bug.go
+++ b/bug/bug.go
@@ -641,7 +641,7 @@ func (bug *Bug) Compile() Snapshot {
for it.Next() {
op := it.Value()
- snap = op.Apply(snap)
+ op.Apply(&snap)
snap.Operations = append(snap.Operations, op)
}
diff --git a/bug/op_add_comment.go b/bug/op_add_comment.go
index 300609fb..e5622073 100644
--- a/bug/op_add_comment.go
+++ b/bug/op_add_comment.go
@@ -26,7 +26,7 @@ func (op AddCommentOperation) Hash() (git.Hash, error) {
return hashOperation(op)
}
-func (op AddCommentOperation) Apply(snapshot Snapshot) Snapshot {
+func (op AddCommentOperation) Apply(snapshot *Snapshot) {
comment := Comment{
Message: op.Message,
Author: op.Author,
@@ -35,8 +35,6 @@ func (op AddCommentOperation) Apply(snapshot Snapshot) Snapshot {
}
snapshot.Comments = append(snapshot.Comments, comment)
-
- return snapshot
}
func (op AddCommentOperation) GetFiles() []git.Hash {
diff --git a/bug/op_create.go b/bug/op_create.go
index c65b3bd8..70ca7242 100644
--- a/bug/op_create.go
+++ b/bug/op_create.go
@@ -27,7 +27,7 @@ func (op CreateOperation) Hash() (git.Hash, error) {
return hashOperation(op)
}
-func (op CreateOperation) Apply(snapshot Snapshot) Snapshot {
+func (op CreateOperation) Apply(snapshot *Snapshot) {
snapshot.Title = op.Title
snapshot.Comments = []Comment{
{
@@ -38,7 +38,6 @@ func (op CreateOperation) Apply(snapshot Snapshot) Snapshot {
}
snapshot.Author = op.Author
snapshot.CreatedAt = op.Time()
- return snapshot
}
func (op CreateOperation) GetFiles() []git.Hash {
diff --git a/bug/op_create_test.go b/bug/op_create_test.go
index 338067aa..2c5ae35b 100644
--- a/bug/op_create_test.go
+++ b/bug/op_create_test.go
@@ -18,7 +18,7 @@ func TestCreate(t *testing.T) {
create := NewCreateOp(rene, unix, "title", "message", nil)
- snapshot = create.Apply(snapshot)
+ create.Apply(&snapshot)
expected := Snapshot{
Title: "title",
diff --git a/bug/op_label_change.go b/bug/op_label_change.go
index c245d1a5..8909cf56 100644
--- a/bug/op_label_change.go
+++ b/bug/op_label_change.go
@@ -26,7 +26,7 @@ func (op LabelChangeOperation) Hash() (git.Hash, error) {
}
// Apply apply the operation
-func (op LabelChangeOperation) Apply(snapshot Snapshot) Snapshot {
+func (op LabelChangeOperation) Apply(snapshot *Snapshot) {
// Add in the set
AddLoop:
for _, added := range op.Added {
@@ -54,8 +54,6 @@ AddLoop:
sort.Slice(snapshot.Labels, func(i, j int) bool {
return string(snapshot.Labels[i]) < string(snapshot.Labels[j])
})
-
- return snapshot
}
func (op LabelChangeOperation) Validate() error {
diff --git a/bug/op_set_status.go b/bug/op_set_status.go
index 19af46c2..1fb9cab6 100644
--- a/bug/op_set_status.go
+++ b/bug/op_set_status.go
@@ -22,10 +22,8 @@ func (op SetStatusOperation) Hash() (git.Hash, error) {
return hashOperation(op)
}
-func (op SetStatusOperation) Apply(snapshot Snapshot) Snapshot {
+func (op SetStatusOperation) Apply(snapshot *Snapshot) {
snapshot.Status = op.Status
-
- return snapshot
}
func (op SetStatusOperation) Validate() error {
diff --git a/bug/op_set_title.go b/bug/op_set_title.go
index a4912143..6049ebd0 100644
--- a/bug/op_set_title.go
+++ b/bug/op_set_title.go
@@ -26,10 +26,8 @@ func (op SetTitleOperation) Hash() (git.Hash, error) {
return hashOperation(op)
}
-func (op SetTitleOperation) Apply(snapshot Snapshot) Snapshot {
+func (op SetTitleOperation) Apply(snapshot *Snapshot) {
snapshot.Title = op.Title
-
- return snapshot
}
func (op SetTitleOperation) Validate() error {
diff --git a/bug/operation.go b/bug/operation.go
index 4c6f2e5a..d7d5af51 100644
--- a/bug/operation.go
+++ b/bug/operation.go
@@ -35,7 +35,7 @@ type Operation interface {
// GetFiles return the files needed by this operation
GetFiles() []git.Hash
// Apply the operation to a Snapshot to create the final state
- Apply(snapshot Snapshot) Snapshot
+ Apply(snapshot *Snapshot)
// Validate check if the operation is valid (ex: a title is a single line)
Validate() error
// SetMetadata store arbitrary metadata about the operation
diff --git a/bug/with_snapshot.go b/bug/with_snapshot.go
index 48274ed5..2b2439df 100644
--- a/bug/with_snapshot.go
+++ b/bug/with_snapshot.go
@@ -27,10 +27,8 @@ func (b *WithSnapshot) Append(op Operation) {
return
}
- snap := op.Apply(*b.snap)
- snap.Operations = append(snap.Operations, op)
-
- b.snap = &snap
+ op.Apply(b.snap)
+ b.snap.Operations = append(b.snap.Operations, op)
}
// Commit intercept Bug.Commit() to update the snapshot efficiently