commit 2e7c482b15ce6e24fc80e3e2e12aec25024ac581
parent 3b29ea08fd17a8f0fe2f9c1847090bdf51d409e8
Author: Jack Mordaunt <jackmordaunt@gmail.com>
Date: Sat, 27 Feb 2021 16:35:46 +0800
fix: implicitly initialise a ticket when assigning it
Diffstat:
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/kanban.go b/kanban.go
@@ -140,14 +140,16 @@ type Stage struct {
}
// Assign appends a ticket to the stage with a unique ID.
-// Existing tickets will be duplicated, butwith different IDs.
+// Existing tickets will be duplicated, but with different IDs.
func (s *Stage) Assign(ticket Ticket) error {
- id, err := uuid.NewUUID()
- if err != nil {
- return fmt.Errorf("generating ID: %v", err)
+ if ticket.ID == uuid.Nil {
+ id, err := uuid.NewUUID()
+ if err != nil {
+ return fmt.Errorf("generating ID: %v", err)
+ }
+ ticket.ID = id
+ ticket.Created = time.Now()
}
- ticket.ID = id
- ticket.Created = time.Now()
s.Tickets = append(s.Tickets, ticket)
return nil
}