aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pearl.el31
-rw-r--r--tests/test-pearl-comment-editing.el4
-rw-r--r--tests/test-pearl-merge.el2
-rw-r--r--tests/test-pearl-refresh.el2
-rw-r--r--tests/test-pearl-save.el4
-rw-r--r--tests/test-pearl-sync.el12
6 files changed, 28 insertions, 27 deletions
diff --git a/pearl.el b/pearl.el
index 0c61e32..844b9f0 100644
--- a/pearl.el
+++ b/pearl.el
@@ -2177,11 +2177,12 @@ report the field as left in conflict."
pearl--conflict-backup-buffer)
(when cb (funcall cb))))
-(defun pearl--issue-body-at-point ()
- "Return the description body of the Linear issue subtree at point.
+(defun pearl--entry-body-at-point ()
+ "Return the body of the Org entry at point, before any child heading.
The body is the text after the property drawer and before the first child
-heading (so a Comments subtree is excluded), trimmed of surrounding
-whitespace. Returns the empty string when the entry has no body."
+heading (so an issue's Comments subtree is excluded), trimmed of surrounding
+whitespace. Returns the empty string when the entry has no body. Used for
+both issue descriptions and comment bodies -- hence \"entry\", not \"issue\"."
(save-excursion
(org-back-to-heading t)
;; Fix the body's end (the next heading: a Comments child or the next
@@ -2406,7 +2407,7 @@ proceeds and the subtree is replaced with Linear's version."
(when (pearl--subtree-dirty-p)
(pearl--stash-conflict-text
(format "%s description (pre-refresh)" issue-id)
- (pearl--org-to-md (pearl--issue-body-at-point))))
+ (pearl--org-to-md (pearl--entry-body-at-point))))
(pearl--progress "Refreshing %s from Linear..." issue-id)
(pearl--fetch-issue-async
issue-id
@@ -2542,7 +2543,7 @@ a dedicated buffer. Works from anywhere inside an issue subtree."
(pearl--compose-in-buffer
(format "description for %s" issue-id)
pearl--compose-description-instructions
- (org-with-point-at marker (pearl--issue-body-at-point))
+ (org-with-point-at marker (pearl--entry-body-at-point))
(lambda (org)
(org-with-point-at marker
(pearl--set-entry-body-at-point org)
@@ -3162,9 +3163,9 @@ fall back to the older markdown-round-trip comparison; those migrate to the
Org-baseline hash the next time the subtree is re-rendered."
(let ((org-hash (org-entry-get nil "LINEAR-DESC-ORG-SHA256")))
(if org-hash
- (not (string= (secure-hash 'sha256 (pearl--issue-body-at-point)) org-hash))
+ (not (string= (secure-hash 'sha256 (pearl--entry-body-at-point)) org-hash))
(let ((stored (org-entry-get nil "LINEAR-DESC-SHA256"))
- (local-md (pearl--org-to-md (pearl--issue-body-at-point))))
+ (local-md (pearl--org-to-md (pearl--entry-body-at-point))))
(not (string= (secure-hash 'sha256 local-md) (or stored "")))))))
(defun pearl--issue-subtree-markers ()
@@ -3207,7 +3208,7 @@ does). A candidate only means the body differs; ownership is decided later."
(when (and cid (not (string-empty-p cid)))
(let ((stored (or (org-entry-get nil "LINEAR-COMMENT-SHA256") ""))
(local (secure-hash 'sha256
- (pearl--org-to-md (pearl--issue-body-at-point)))))
+ (pearl--org-to-md (pearl--entry-body-at-point)))))
(unless (string= local stored)
(push (list :comment-id cid
:author-id (org-entry-get nil "LINEAR-COMMENT-AUTHOR-ID")
@@ -3338,7 +3339,7 @@ used by the local dirty scan), so the next scan sees the ticket as clean."
(org-with-point-at marker
(let* ((issue-id (org-entry-get nil "LINEAR-ID"))
(identifier (org-entry-get nil "LINEAR-IDENTIFIER"))
- (local (pearl--org-to-md (pearl--issue-body-at-point)))
+ (local (pearl--org-to-md (pearl--entry-body-at-point)))
(spec (list
:issue-id issue-id :identifier identifier :field 'description
:comment-id nil :marker marker :prop "LINEAR-DESC-SHA256"
@@ -3365,7 +3366,7 @@ used by the local dirty scan), so the next scan sees the ticket as clean."
(when (memq (plist-get outcome :status) '(pushed resolved-remote))
(org-with-point-at marker
(org-entry-put marker "LINEAR-DESC-ORG-SHA256"
- (secure-hash 'sha256 (pearl--issue-body-at-point)))))
+ (secure-hash 'sha256 (pearl--entry-body-at-point)))))
(funcall callback outcome))))))
(defun pearl--save-title-field (marker callback)
@@ -3405,7 +3406,7 @@ only the viewer's own comments are saved through the gate."
:issue-id (pearl--issue-id-at-point)
:identifier comment-id :field 'comment :comment-id comment-id
:marker marker :prop "LINEAR-COMMENT-SHA256"
- :local (pearl--org-to-md (pearl--issue-body-at-point))
+ :local (pearl--org-to-md (pearl--entry-body-at-point))
:stored (org-entry-get nil "LINEAR-COMMENT-SHA256")
:label (format "comment %s" comment-id)
:fetch (lambda (cb) (pearl--fetch-comment-body-async comment-id cb))
@@ -4195,10 +4196,10 @@ reported (refresh to reconcile)."
(unless comment-id
(user-error "Not on a Linear comment"))
;; No-op fast path before resolving the viewer: an unchanged comment
- ;; costs no viewer lookup. `pearl--issue-body-at-point' reads the text
+ ;; costs no viewer lookup. `pearl--entry-body-at-point' reads the text
;; after the drawer and before the first child heading -- a comment
;; subtree has that shape, so it serves the comment body unchanged.
- (let ((local-md (pearl--org-to-md (pearl--issue-body-at-point))))
+ (let ((local-md (pearl--org-to-md (pearl--entry-body-at-point))))
(if (string= (secure-hash 'sha256 local-md) (or stored ""))
(message "No comment changes to sync")
(pearl--viewer-async
@@ -4243,7 +4244,7 @@ body stay."
(string= (secure-hash 'sha256
(pearl--org-to-md
(org-with-point-at marker
- (pearl--issue-body-at-point))))
+ (pearl--entry-body-at-point))))
stored)))
(prompt (if clean
"Delete this comment from Linear and remove it here? "
diff --git a/tests/test-pearl-comment-editing.el b/tests/test-pearl-comment-editing.el
index be65aa3..ff1dff5 100644
--- a/tests/test-pearl-comment-editing.el
+++ b/tests/test-pearl-comment-editing.el
@@ -232,7 +232,7 @@
(goto-char (point-min))
(re-search-forward "^\\*\\*\\*\\*\\* Craig")
(should (string= stored (org-entry-get nil "LINEAR-COMMENT-SHA256")))
- (should (string= "new body" (pearl--issue-body-at-point)))))))
+ (should (string= "new body" (pearl--entry-body-at-point)))))))
;;; editability highlighting
@@ -282,7 +282,7 @@
"*** Comments\n**** Me — ts\n:PROPERTIES:\n:LINEAR-COMMENT-ID: c1\n:END:\n"
"see :note: below\nand more text\n")
(re-search-forward "see :note:")
- (should (string= "see :note: below\nand more text" (pearl--issue-body-at-point)))))
+ (should (string= "see :note: below\nand more text" (pearl--entry-body-at-point)))))
(provide 'test-pearl-comment-editing)
;;; test-pearl-comment-editing.el ends here
diff --git a/tests/test-pearl-merge.el b/tests/test-pearl-merge.el
index 180539e..e55127b 100644
--- a/tests/test-pearl-merge.el
+++ b/tests/test-pearl-merge.el
@@ -193,7 +193,7 @@ subtree, so every description-less issue read as a local edit."
(goto-char (point-min))
(re-search-forward "^\\*\\* ")
(beginning-of-line)
- (should (string= "" (pearl--issue-body-at-point)))
+ (should (string= "" (pearl--entry-body-at-point)))
(should-not (pearl--subtree-dirty-p))))
(ert-deftest test-pearl-subtree-dirty-p-edited-body-is-dirty ()
diff --git a/tests/test-pearl-refresh.el b/tests/test-pearl-refresh.el
index 6b8ba7b..ba17836 100644
--- a/tests/test-pearl-refresh.el
+++ b/tests/test-pearl-refresh.el
@@ -100,7 +100,7 @@
(should (string-match-p "Refreshed Title" (thing-at-point 'line t)))
(should (string= "In Progress" (org-entry-get nil "LINEAR-STATE-NAME")))
;; body is the remote description, and provenance matches it
- (should (string= "New remote desc." (pearl--issue-body-at-point)))
+ (should (string= "New remote desc." (pearl--entry-body-at-point)))
(should (string= (secure-hash 'sha256 "New remote desc.")
(org-entry-get nil "LINEAR-DESC-SHA256"))))))
diff --git a/tests/test-pearl-save.el b/tests/test-pearl-save.el
index 802535b..a8ae6af 100644
--- a/tests/test-pearl-save.el
+++ b/tests/test-pearl-save.el
@@ -247,9 +247,9 @@ so the next local dirty scan (which uses the Org hash) sees the ticket as clean.
(pearl--save-description-field marker (lambda (o) (setq outcome o))))
(should (eq 'pushed (plist-get outcome :status)))
(org-with-point-at marker
- (should (string= (secure-hash 'sha256 (pearl--issue-body-at-point))
+ (should (string= (secure-hash 'sha256 (pearl--entry-body-at-point))
(org-entry-get nil "LINEAR-DESC-ORG-SHA256")))
- (should (string= (secure-hash 'sha256 (pearl--org-to-md (pearl--issue-body-at-point)))
+ (should (string= (secure-hash 'sha256 (pearl--org-to-md (pearl--entry-body-at-point)))
(org-entry-get nil "LINEAR-DESC-SHA256")))
;; the push timestamp still lands via the after-push bookkeeping
(should (string= "t1" (org-entry-get nil "LINEAR-DESC-UPDATED-AT")))))))
diff --git a/tests/test-pearl-sync.el b/tests/test-pearl-sync.el
index 738e3ff..150944a 100644
--- a/tests/test-pearl-sync.el
+++ b/tests/test-pearl-sync.el
@@ -21,7 +21,7 @@
;; Tests for the explicit description sync-back: the pure conflict gate
;; (`pearl--sync-decision'), the org body extractor
-;; (`pearl--issue-body-at-point'), the two network helpers (fetch the
+;; (`pearl--entry-body-at-point'), the two network helpers (fetch the
;; remote description, push an updated description -- both stubbed at the HTTP
;; boundary), and the orchestrating command `pearl-sync-current-issue'
;; across its no-op / clean-push / conflict branches.
@@ -73,26 +73,26 @@
"*** TODO ENG-1 Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nThe body line.\nSecond line.\n"
(re-search-forward "Title")
(should (string= "The body line.\nSecond line."
- (pearl--issue-body-at-point)))))
+ (pearl--entry-body-at-point)))))
(ert-deftest test-pearl-issue-body-empty ()
"An entry with no body yields the empty string."
(test-pearl--in-org
"*** TODO ENG-1 Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\n"
- (should (string= "" (pearl--issue-body-at-point)))))
+ (should (string= "" (pearl--entry-body-at-point)))))
(ert-deftest test-pearl-issue-body-stops-before-comments ()
"The description body stops before a child Comments subtree."
(test-pearl--in-org
"*** TODO ENG-1 Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nDesc body.\n**** Comments\n***** bob -- ts\nhi\n"
- (should (string= "Desc body." (pearl--issue-body-at-point)))))
+ (should (string= "Desc body." (pearl--entry-body-at-point)))))
(ert-deftest test-pearl-issue-body-from-inside-body ()
"Extraction works with point already inside the body."
(test-pearl--in-org
"*** TODO ENG-1 Title\n:PROPERTIES:\n:LINEAR-ID: a\n:END:\nDesc body.\nmore.\n"
(goto-char (point-max))
- (should (string= "Desc body.\nmore." (pearl--issue-body-at-point)))))
+ (should (string= "Desc body.\nmore." (pearl--entry-body-at-point)))))
;;; network helpers (stubbed at the HTTP boundary)
@@ -219,7 +219,7 @@ helper (nil when never called); the update helper reports success."
;; ... but provenance is not advanced and the edit stays for retry.
(should (string= stored (org-entry-get nil "LINEAR-DESC-SHA256")))
(should (string= "old" (org-entry-get nil "LINEAR-DESC-UPDATED-AT")))
- (should (string= "Edited body now." (pearl--issue-body-at-point)))))))
+ (should (string= "Edited body now." (pearl--entry-body-at-point)))))))
(provide 'test-pearl-sync)
;;; test-pearl-sync.el ends here