Skip to content

Commit

Permalink
v4.4.1 Fixes for the really strange propertly block accessor
Browse files Browse the repository at this point in the history
fix: ahungry#319
fix: ahungry#296
fix: ahungry#316

I think this should fix it - for future readers, left the particulars
of this issue as an inline comment in the impacted function.
  • Loading branch information
ahungry committed Mar 23, 2023
1 parent 1345775 commit fce9f8f
Showing 1 changed file with 59 additions and 36 deletions.
95 changes: 59 additions & 36 deletions org-jira.el
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@

;;; News:

;;;; Changes in 4.4.1
;; - Fix tag (4.3.3 was out of order - we had a 4.4.0 on repo)
;; - Fix for some crazy scoping issue in the org-jira-get-issue-val-from-org function

;;;; Changes in 4.3.3:
;; - Address issue with assignee property being removed when Unassigned

Expand Down Expand Up @@ -1851,42 +1855,61 @@ that should be bound to an issue."

(defun org-jira-get-issue-val-from-org (key)
"Return the requested value by KEY from the current issue."
(ensure-on-issue
(cond ((eq key 'description)
(org-goto-first-child)
(forward-thing 'whitespace)
(if (looking-at "description: ")
(org-trim (org-get-entry))
(error "Can not find description field for this issue")))

((eq key 'summary)
(ensure-on-issue
(org-get-heading t t)))

;; org returns a time tuple, we need to convert it
((eq key 'deadline)
(let ((encoded-time (org-get-deadline-time (point))))
(when encoded-time
(cl-reduce (lambda (carry segment)
(format "%s-%s" carry segment))
(reverse (cl-subseq (decode-time encoded-time) 3 6))))))

;; default case, just grab the value in the properties block
(t
(when (symbolp key)
(setq key (symbol-name key)))
(setq key (or (assoc-default key org-jira-property-overrides)
key))
(when (string= key "key")
(setq key "ID"))
;; The variable `org-special-properties' will mess this up
;; if our search, such as 'priority' is within there, so
;; don't bother with it for this (since we only ever care
;; about the local properties, not any hierarchal or special
;; ones).
(let ((org-special-properties nil))
(or (org-entry-get (point) key t)
""))))))
;; There is some odd issue when not using any let-scoping, where myself
;; and an array of users are hitting a snag circa 2023-03-01 time frame
;; in which the setq portion of a when clause is being hit even when it
;; evaluates to false - the bug only manifests on a first launch of Emacs - it
;; doesn't occur when re-evaluating this function. However, wrapping it "fixes"
;; the issue.
;;
;; The first link has the most troubleshooting/diagnosis around the particulars of
;; this bug.
;;
;; See: https://github.com/ahungry/org-jira/issues/319
;; See: https://github.com/ahungry/org-jira/issues/296
;; See: https://github.com/ahungry/org-jira/issues/316
(lexical-let ((my-key key))
(ensure-on-issue
(cond ((eq my-key 'description)
(org-goto-first-child)
(forward-thing 'whitespace)
(if (looking-at "description: ")
(org-trim (org-get-entry))
(error "Can not find description field for this issue")))

((eq my-key 'summary)
(ensure-on-issue
(org-get-heading t t)))

;; org returns a time tuple, we need to convert it
((eq my-key 'deadline)
(let ((encoded-time (org-get-deadline-time (point))))
(when encoded-time
(cl-reduce (lambda (carry segment)
(format "%s-%s" carry segment))
(reverse (cl-subseq (decode-time encoded-time) 3 6))))))

;; default case, just grab the value in the properties block
(t
(when (symbolp my-key)
(setq my-key (symbol-name my-key)))

(setq my-key (or (assoc-default my-key org-jira-property-overrides)
my-key))

;; This is the "impossible" to hit setq that somehow gets hit without the let
;; wrapper around the function input args.
(when (string= my-key "key")
(setq my-key "ID"))

;; The variable `org-special-properties' will mess this up
;; if our search, such as 'priority' is within there, so
;; don't bother with it for this (since we only ever care
;; about the local properties, not any hierarchal or special
;; ones).
(let ((org-special-properties nil))
(or (org-entry-get (point) my-key t)
"")))))))

(defun org-jira-read-action (actions)
"Read issue workflow progress ACTIONS."
Expand Down

0 comments on commit fce9f8f

Please sign in to comment.