       (git-root)
       (blocking-deref res))
     res))
-
-;; Last commit message: git log -n1 --pretty=format:%s
-;; Last commit hash: git rev-parse HEAD
 
 ;; Lock file I/O
 ;; --------------

    (inc-state ticket)
    ticket))

;(defn id-kw->pos
;  "Given a ticket's id keyword [ie :1], return its supposed position
;  DO NOT USE THIS
;  This is here only for historical reasons.  Ticket IDs are integer based"
;  [id-kw]
;  (-> id-kw name js/parseInt dec))

(defn id->pos
  "Given a ticket's integer ID, return its supposed position in the ticket vector"
  [id-int]
  (dec id-int))


    ;; We may have some hooks here, if not TODO remove the `let`
    ticket))

(defn append-ticket
  "Append a given ticket to the ticket vector/collection"
  [t-file-map ticket]
  (update-in t-file-map [:tickets] conj (assoc ticket
                                               :id (-> t-file-map :tickets count inc))))

(defn update-ticket
  "Update a ticket within the ticket vector/collection.
  The ticket passed must already have an :id"
  [t-file-map ticket]
  (update-in t-file-map [:tickets (-> ticket :id id->pos)] merge ticket))

(defn ticket-io!
  "This applies a function to the actual ticket file.
  All functions should take two args: the ticket file map and a ticket.
  You should never lock the ticket file by hand, use this function."
  ([f ticket]
   (ticket-io! f ticket default-ticket-path))
