about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAspen Smith <root@gws.fyi>2023-11-06T15·40-0500
committerclbot <clbot@tvl.fyi>2023-11-06T15·46+0000
commitf3dea2ffbc4255c64d01a80e2668b2060b676e9e (patch)
tree77d5f9c54ec3e822aec6d50752f7575a95fc52d7
parent81047cfcd7e527722a32dc7987cfb0e288ddd1eb (diff)
fix(grfn/emacs): Fix clocked-in-ticket-id for linear tickets r/6965
Change-Id: Id0e8883c1b621afb99edde3d256cccd057e89097
Reviewed-on: https://cl.tvl.fyi/c/depot/+/9972
Autosubmit: grfn <grfn@gws.fyi>
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
-rw-r--r--users/grfn/emacs.d/config.el31
-rw-r--r--users/grfn/emacs.d/org-query.el20
2 files changed, 33 insertions, 18 deletions
diff --git a/users/grfn/emacs.d/config.el b/users/grfn/emacs.d/config.el
index da2ef48cd8fd..5549a621dcc7 100644
--- a/users/grfn/emacs.d/config.el
+++ b/users/grfn/emacs.d/config.el
@@ -228,12 +228,13 @@
 (use-package! org-tracker
   :hook (org-mode . org-tracker-mode)
   :config
-  (setq org-tracker-state-alist '(("INBOX" . "Inbox")
+  (setq org-tracker-state-alist '(("INBOX" . "Triage")
                                   ("BACKLOG" . "Backlog")
-                                  ("TODO" . "Selected for Development")
+                                  ("TODO" . "Todo")
                                   ("ACTIVE" . "In Progress")
                                   ("PR" . "Code Review")
-                                  ("DONE" . "Done"))
+                                  ("DONE" . "Done")
+                                  ("CANCELLED" . "Canceled"))
         org-tracker-username "griffin@readyset.io"
         org-tracker-claim-ticket-on-status-update '("ACTIVE" "PR" "DONE")
         org-tracker-create-stories-with-labels 'existing)
@@ -467,21 +468,21 @@
 
 (setq projectile-create-missing-test-files 't)
 
-(setq grfn/jira-refs-re
+(setq grfn/tracker-refs-re
       (rx line-start
           (or "Refs" "Fixes")
           ": "
-          "ENG-" (one-or-more digit)
+          (one-or-more graph)
           line-end))
 
-(defun grfn/add-jira-reference-to-commit-message ()
+(defun grfn/add-tracker-reference-to-commit-message ()
   (interactive)
-  (when-let* ((jira-id (grfn/org-clocked-in-jira-ticket-id)))
+  (when-let* ((ticket-id (grfn/org-clocked-in-ticket-id)))
     (save-excursion
       (save-match-data
         (goto-char (point-min))
         ;; Don't add one if we've already got one
-        (unless (search-forward-regexp grfn/jira-refs-re nil t)
+        (unless (search-forward-regexp grfn/tracker-refs-re nil t)
           (or
            (and
             (search-forward-regexp (rx line-start "Change-Id:") nil t)
@@ -489,14 +490,14 @@
            (and
             (search-forward-regexp (rx line-start "# Please enter") nil t)
             (forward-line -2)))
-          (insert (format "\nRefs: %s" jira-id)))))))
+          (insert (format "\nRefs: %s" ticket-id)))))))
 
-(defun grfn/switch-jira-refs-fixes ()
+(defun grfn/switch-tracker-refs-fixes ()
   (interactive)
   (save-excursion
     (save-match-data
-      (if (not (search-forward-regexp grfn/jira-refs-re nil t))
-          (message "Could not find reference to JIRA ticket")
+      (if (not (search-forward-regexp grfn/tracker-refs-re nil t))
+          (message "Could not find reference to ticket")
         (goto-char (point-at-bol))
         (save-restriction
           (narrow-to-region (point-at-bol)
@@ -581,9 +582,9 @@
 
   )
 
-(add-hook 'git-commit-setup-hook #'grfn/add-jira-reference-to-commit-message)
+(add-hook 'git-commit-setup-hook #'grfn/add-tracker-reference-to-commit-message)
 (map! (:map git-commit-mode-map
-       "C-c C-f" #'grfn/switch-jira-refs-fixes))
+       "C-c C-f" #'grfn/switch-tracker-refs-fixes))
 
 ;; (defun grfn/split-window-more-sensibly (&optional window)
 ;;   (let ((window (or window (selected-window))))
@@ -1119,3 +1120,5 @@
 (set-popup-rule!
   "^\\*gud-"
   :quit nil)
+
+(setq elcord-editor-icon "emacs_icon")
diff --git a/users/grfn/emacs.d/org-query.el b/users/grfn/emacs.d/org-query.el
index e403c9e56fd3..9d3b3358a9d3 100644
--- a/users/grfn/emacs.d/org-query.el
+++ b/users/grfn/emacs.d/org-query.el
@@ -115,11 +115,22 @@
  (grfn/org-current-clocked-in-task-message)
  )
 
-(defun grfn/org-clocked-in-jira-ticket-id ()
+(cl-defgeneric grfn/org-tracker-ticket-id-label (backend elt)
+  (org-tracker-backend/extract-issue-id backend elt))
+(cl-defmethod grfn/org-tracker-ticket-id-label
+  ((backend org-tracker-linear-backend) elt)
+  (when-let* ((link (plist-get elt :LINEAR-KEY)))
+    (string-match
+     (rx "[[" (one-or-more anything) "]"
+         "[" (group (one-or-more anything)) "]]")
+     link)
+    (match-string 1 link)))
+
+(defun grfn/org-clocked-in-ticket-id ()
   (grfn/at-org-clocked-in-item
-   (when (org-tracker-current-backend t)
-     (org-tracker-backend/extract-issue-id
-      (org-tracker-current-backend)
+   (when-let* ((backend (org-tracker-current-backend t)))
+     (grfn/org-tracker-ticket-id-label
+      backend
       (cadr (org-element-at-point))))))
 
 (comment
@@ -128,4 +139,5 @@
    (org-tracker-current-backend)
    (cadr (org-element-at-point))))
 
+ (grfn/org-clocked-in-ticket-id)
  )