mirror of
https://github.com/org-roam/org-roam
synced 2025-08-01 12:17:21 -05:00
Node titles with special characters (single quotes, dollar signs, etc.) break the ripgrep command because the regex pattern is passed through the shell. This causes silent failures that show up as unlinked references not being present for a given node. This change writes the regex pattern to a temp file and uses ripgrep's --file option instead of shell command line. `shell-quote-argument` is replaced with `regexp-quote` since we're no longer passing through shell. Wrapped in unwind-protect for cleanup. Fix: #2407 Close: #2408
40 lines
1.4 KiB
EmacsLisp
40 lines
1.4 KiB
EmacsLisp
;;; test-org-roam-mode.el --- Tests for Org-roam -*- lexical-binding: t; -*-
|
|
|
|
;; Copyright (C) 2020 Jethro Kuan
|
|
|
|
;; Author: Jethro Kuan <jethrokuan95@gmail.com>
|
|
;; Package-Requires: ((buttercup))
|
|
|
|
;; This program is free software; you can redistribute it and/or modify
|
|
;; it under the terms of the GNU General Public License as published by
|
|
;; the Free Software Foundation, either version 3 of the License, or
|
|
;; (at your option) any later version.
|
|
|
|
;; This program is distributed in the hope that it will be useful,
|
|
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
;; GNU General Public License for more details.
|
|
|
|
;; You should have received a copy of the GNU General Public License
|
|
;; along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
;;; Commentary:
|
|
;;; Code:
|
|
|
|
(require 'buttercup)
|
|
(require 'org-roam)
|
|
|
|
(describe "org-roam-unlinked-references--rg-command"
|
|
(before-each
|
|
;; the space in the directory is on purpose
|
|
(setq org-roam-directory "/tmp/org roam"))
|
|
|
|
(it "returns the correct rg command for unlinked references"
|
|
(expect (org-roam-unlinked-references--rg-command '("foo" "bar") "/tmp/regex")
|
|
:to-equal
|
|
"rg --follow --only-matching --vimgrep --pcre2 --ignore-case --glob \"*.org\" --glob \"*.org.gpg\" --glob \"*.org.age\" --file /tmp/regex /tmp/org\\ roam")))
|
|
|
|
(provide 'test-org-roam-mode)
|
|
|
|
;;; test-org-roam-mode.el ends here
|