diff options
author | Michael Muré <batolettre@gmail.com> | 2018-10-01 23:31:16 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2018-10-01 23:31:16 +0200 |
commit | 6ea6f3614e46a62f4a37c6afb488547a3d548191 (patch) | |
tree | 8a32431ce90dd8b169aac858b99a761b8f76c95f /bug | |
parent | f026f61aaaa7b9e579e99f171f7fefb38c4c6181 (diff) | |
download | git-bug-6ea6f3614e46a62f4a37c6afb488547a3d548191.tar.gz |
bug: in op convenience function, return the new op to be able to set metadata later
Diffstat (limited to 'bug')
-rw-r--r-- | bug/bug_actions_test.go | 70 | ||||
-rw-r--r-- | bug/op_add_comment.go | 8 | ||||
-rw-r--r-- | bug/op_create.go | 8 | ||||
-rw-r--r-- | bug/op_edit_comment.go | 8 | ||||
-rw-r--r-- | bug/op_label_change.go | 8 | ||||
-rw-r--r-- | bug/op_set_status.go | 12 | ||||
-rw-r--r-- | bug/op_set_title.go | 6 |
7 files changed, 60 insertions, 60 deletions
diff --git a/bug/bug_actions_test.go b/bug/bug_actions_test.go index ee9fbd72..e68132fc 100644 --- a/bug/bug_actions_test.go +++ b/bug/bug_actions_test.go @@ -70,7 +70,7 @@ func TestPushPull(t *testing.T) { repoA, repoB, remote := setupRepos(t) defer cleanupRepos(repoA, repoB, remote) - bug1, err := Create(rene, unix, "bug1", "message") + bug1, _, err := Create(rene, unix, "bug1", "message") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) @@ -89,7 +89,7 @@ func TestPushPull(t *testing.T) { } // B --> remote --> A - bug2, err := Create(rene, unix, "bug2", "message") + bug2, _, err := Create(rene, unix, "bug2", "message") assert.Nil(t, err) err = bug2.Commit(repoB) assert.Nil(t, err) @@ -132,7 +132,7 @@ func _RebaseTheirs(t testing.TB) { repoA, repoB, remote := setupRepos(t) defer cleanupRepos(repoA, repoB, remote) - bug1, err := Create(rene, unix, "bug1", "message") + bug1, _, err := Create(rene, unix, "bug1", "message") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) @@ -148,11 +148,11 @@ func _RebaseTheirs(t testing.TB) { bug2, err := ReadLocalBug(repoB, bug1.Id()) assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message2") + _, err = AddComment(bug2, rene, unix, "message2") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message3") + _, err = AddComment(bug2, rene, unix, "message3") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message4") + _, err = AddComment(bug2, rene, unix, "message4") assert.Nil(t, err) err = bug2.Commit(repoB) assert.Nil(t, err) @@ -193,7 +193,7 @@ func _RebaseOurs(t testing.TB) { repoA, repoB, remote := setupRepos(t) defer cleanupRepos(repoA, repoB, remote) - bug1, err := Create(rene, unix, "bug1", "message") + bug1, _, err := Create(rene, unix, "bug1", "message") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) @@ -206,29 +206,29 @@ func _RebaseOurs(t testing.TB) { err = Pull(repoB, "origin") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message2") + _, err = AddComment(bug1, rene, unix, "message2") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message3") + _, err = AddComment(bug1, rene, unix, "message3") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message4") + _, err = AddComment(bug1, rene, unix, "message4") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message5") + _, err = AddComment(bug1, rene, unix, "message5") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message6") + _, err = AddComment(bug1, rene, unix, "message6") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message7") + _, err = AddComment(bug1, rene, unix, "message7") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message8") + _, err = AddComment(bug1, rene, unix, "message8") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message9") + _, err = AddComment(bug1, rene, unix, "message9") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message10") + _, err = AddComment(bug1, rene, unix, "message10") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) @@ -274,7 +274,7 @@ func _RebaseConflict(t testing.TB) { repoA, repoB, remote := setupRepos(t) defer cleanupRepos(repoA, repoB, remote) - bug1, err := Create(rene, unix, "bug1", "message") + bug1, _, err := Create(rene, unix, "bug1", "message") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) @@ -287,29 +287,29 @@ func _RebaseConflict(t testing.TB) { err = Pull(repoB, "origin") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message2") + _, err = AddComment(bug1, rene, unix, "message2") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message3") + _, err = AddComment(bug1, rene, unix, "message3") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message4") + _, err = AddComment(bug1, rene, unix, "message4") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message5") + _, err = AddComment(bug1, rene, unix, "message5") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message6") + _, err = AddComment(bug1, rene, unix, "message6") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message7") + _, err = AddComment(bug1, rene, unix, "message7") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message8") + _, err = AddComment(bug1, rene, unix, "message8") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message9") + _, err = AddComment(bug1, rene, unix, "message9") assert.Nil(t, err) - err = AddComment(bug1, rene, unix, "message10") + _, err = AddComment(bug1, rene, unix, "message10") assert.Nil(t, err) err = bug1.Commit(repoA) assert.Nil(t, err) @@ -317,29 +317,29 @@ func _RebaseConflict(t testing.TB) { bug2, err := ReadLocalBug(repoB, bug1.Id()) assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message11") + _, err = AddComment(bug2, rene, unix, "message11") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message12") + _, err = AddComment(bug2, rene, unix, "message12") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message13") + _, err = AddComment(bug2, rene, unix, "message13") assert.Nil(t, err) err = bug2.Commit(repoB) assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message14") + _, err = AddComment(bug2, rene, unix, "message14") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message15") + _, err = AddComment(bug2, rene, unix, "message15") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message16") + _, err = AddComment(bug2, rene, unix, "message16") assert.Nil(t, err) err = bug2.Commit(repoB) assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message17") + _, err = AddComment(bug2, rene, unix, "message17") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message18") + _, err = AddComment(bug2, rene, unix, "message18") assert.Nil(t, err) - err = AddComment(bug2, rene, unix, "message19") + _, err = AddComment(bug2, rene, unix, "message19") assert.Nil(t, err) err = bug2.Commit(repoB) assert.Nil(t, err) diff --git a/bug/op_add_comment.go b/bug/op_add_comment.go index 3b2c2b76..e304a6ef 100644 --- a/bug/op_add_comment.go +++ b/bug/op_add_comment.go @@ -83,15 +83,15 @@ type AddCommentTimelineItem struct { } // Convenience function to apply the operation -func AddComment(b Interface, author Person, unixTime int64, message string) error { +func AddComment(b Interface, author Person, unixTime int64, message string) (*AddCommentOperation, error) { return AddCommentWithFiles(b, author, unixTime, message, nil) } -func AddCommentWithFiles(b Interface, author Person, unixTime int64, message string, files []git.Hash) error { +func AddCommentWithFiles(b Interface, author Person, unixTime int64, message string, files []git.Hash) (*AddCommentOperation, error) { addCommentOp := NewAddCommentOp(author, unixTime, message, files) if err := addCommentOp.Validate(); err != nil { - return err + return nil, err } b.Append(addCommentOp) - return nil + return addCommentOp, nil } diff --git a/bug/op_create.go b/bug/op_create.go index 2ac85ee1..45387d19 100644 --- a/bug/op_create.go +++ b/bug/op_create.go @@ -96,19 +96,19 @@ type CreateTimelineItem struct { } // Convenience function to apply the operation -func Create(author Person, unixTime int64, title, message string) (*Bug, error) { +func Create(author Person, unixTime int64, title, message string) (*Bug, *CreateOperation, error) { return CreateWithFiles(author, unixTime, title, message, nil) } -func CreateWithFiles(author Person, unixTime int64, title, message string, files []git.Hash) (*Bug, error) { +func CreateWithFiles(author Person, unixTime int64, title, message string, files []git.Hash) (*Bug, *CreateOperation, error) { newBug := NewBug() createOp := NewCreateOp(author, unixTime, title, message, files) if err := createOp.Validate(); err != nil { - return nil, err + return nil, createOp, err } newBug.Append(createOp) - return newBug, nil + return newBug, createOp, nil } diff --git a/bug/op_edit_comment.go b/bug/op_edit_comment.go index ec767ed4..f9f94f91 100644 --- a/bug/op_edit_comment.go +++ b/bug/op_edit_comment.go @@ -106,15 +106,15 @@ func NewEditCommentOp(author Person, unixTime int64, target git.Hash, message st } // Convenience function to apply the operation -func EditComment(b Interface, author Person, unixTime int64, target git.Hash, message string) error { +func EditComment(b Interface, author Person, unixTime int64, target git.Hash, message string) (*EditCommentOperation, error) { return EditCommentWithFiles(b, author, unixTime, target, message, nil) } -func EditCommentWithFiles(b Interface, author Person, unixTime int64, target git.Hash, message string, files []git.Hash) error { +func EditCommentWithFiles(b Interface, author Person, unixTime int64, target git.Hash, message string, files []git.Hash) (*EditCommentOperation, error) { editCommentOp := NewEditCommentOp(author, unixTime, target, message, files) if err := editCommentOp.Validate(); err != nil { - return err + return nil, err } b.Append(editCommentOp) - return nil + return editCommentOp, nil } diff --git a/bug/op_label_change.go b/bug/op_label_change.go index 006afd88..b7957b86 100644 --- a/bug/op_label_change.go +++ b/bug/op_label_change.go @@ -118,7 +118,7 @@ func (l LabelChangeTimelineItem) Hash() git.Hash { } // ChangeLabels is a convenience function to apply the operation -func ChangeLabels(b Interface, author Person, unixTime int64, add, remove []string) ([]LabelChangeResult, error) { +func ChangeLabels(b Interface, author Person, unixTime int64, add, remove []string) ([]LabelChangeResult, *LabelChangeOperation, error) { var added, removed []Label var results []LabelChangeResult @@ -163,18 +163,18 @@ func ChangeLabels(b Interface, author Person, unixTime int64, add, remove []stri } if len(added) == 0 && len(removed) == 0 { - return results, fmt.Errorf("no label added or removed") + return results, nil, fmt.Errorf("no label added or removed") } labelOp := NewLabelChangeOperation(author, unixTime, added, removed) if err := labelOp.Validate(); err != nil { - return nil, err + return nil, nil, err } b.Append(labelOp) - return results, nil + return results, labelOp, nil } func labelExist(labels []Label, label Label) bool { diff --git a/bug/op_set_status.go b/bug/op_set_status.go index e40d349d..62f373ec 100644 --- a/bug/op_set_status.go +++ b/bug/op_set_status.go @@ -72,21 +72,21 @@ func (s SetStatusTimelineItem) Hash() git.Hash { } // Convenience function to apply the operation -func Open(b Interface, author Person, unixTime int64) error { +func Open(b Interface, author Person, unixTime int64) (*SetStatusOperation, error) { op := NewSetStatusOp(author, unixTime, OpenStatus) if err := op.Validate(); err != nil { - return err + return nil, err } b.Append(op) - return nil + return op, nil } // Convenience function to apply the operation -func Close(b Interface, author Person, unixTime int64) error { +func Close(b Interface, author Person, unixTime int64) (*SetStatusOperation, error) { op := NewSetStatusOp(author, unixTime, ClosedStatus) if err := op.Validate(); err != nil { - return err + return nil, err } b.Append(op) - return nil + return op, nil } diff --git a/bug/op_set_title.go b/bug/op_set_title.go index 9c523a2c..9b7d1533 100644 --- a/bug/op_set_title.go +++ b/bug/op_set_title.go @@ -95,7 +95,7 @@ func (s SetTitleTimelineItem) Hash() git.Hash { } // Convenience function to apply the operation -func SetTitle(b Interface, author Person, unixTime int64, title string) error { +func SetTitle(b Interface, author Person, unixTime int64, title string) (*SetTitleOperation, error) { it := NewOperationIterator(b) var lastTitleOp Operation @@ -116,9 +116,9 @@ func SetTitle(b Interface, author Person, unixTime int64, title string) error { setTitleOp := NewSetTitleOp(author, unixTime, title, was) if err := setTitleOp.Validate(); err != nil { - return err + return nil, err } b.Append(setTitleOp) - return nil + return setTitleOp, nil } |