From 94c7990d578fea42c0b9b202e164f9a0460570b8 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Mon, 14 Sep 2020 13:10:41 -0400 Subject: [PATCH] feat(gs/emacs): Link created PR to clocked in item After creating a pull request link it to the currently clocked in org-mode headline if any. Change-Id: I75d7e70316494e355e11864496fdfc8b9e3009e1 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1979 Reviewed-by: glittershark Tested-by: BuildkiteCI --- users/glittershark/emacs.d/org-config.el | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/users/glittershark/emacs.d/org-config.el b/users/glittershark/emacs.d/org-config.el index 9885a8e3c..c72a7c968 100644 --- a/users/glittershark/emacs.d/org-config.el +++ b/users/glittershark/emacs.d/org-config.el @@ -144,3 +144,19 @@ ;;; TODO: this doesn't work? (define-auto-insert "\\.org?$" #'grfn/insert-org-template t) + +(defun forge--post-submit-around---link-pr-to-org-item + (orig) + (let ((cb (funcall orig))) + (lambda (value headers status req) + (prog1 (funcall cb value headers status req) + (grfn/at-org-clocked-in-item + (let ((url (alist-get 'url value)) + (number (alist-get 'number value))) + (org-set-property + "pull-request" + (org-make-link-string url (number-to-string number))))))))) + +(advice-add + #'forge--post-submit-callback + :around #'forge--post-submit-around---link-pr-to-org-item)