fix: use --strip-cwd-prefix only if fd >=8.3.0

Since fd 8.3.0 has low availability across distros (see repology link
below), I don't want to make it Doom's minimum supported version.
Instead, I do a quick version check and adjust accordingly. I'll think
up a more elegant solution after v3.

Ref: https://repology.org/project/fd-find/versions
Fix: #6618
Fix: #6600
Close: #6597
This commit is contained in:
Henrik Lissner 2022-08-08 17:15:33 +02:00
parent 08eb6b555b
commit 232e9d4b91
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -15,6 +15,8 @@ Emacs.")
"The filename of the `fd' executable. On some distros it's 'fdfind' (ubuntu, "The filename of the `fd' executable. On some distros it's 'fdfind' (ubuntu,
debian, and derivatives). On most it's 'fd'.") debian, and derivatives). On most it's 'fd'.")
(defvar doom-projects--fd-version nil)
;; ;;
;;; Packages ;;; Packages
@ -174,9 +176,17 @@ And if it's a function, evaluate it."
(cl-find-if (doom-rpartial #'executable-find t) (cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd")) (list "fdfind" "fd"))
doom-projectile-fd-binary)) doom-projectile-fd-binary))
(concat (format "%s . -0 -H --color=never --type file --type symlink --follow --exclude .git --strip-cwd-prefix" ;; REVIEW Temporary fix for #6618. Improve me later.
bin) (let ((version (or doom-projects--fd-version
(if IS-WINDOWS " --path-separator=/")))) (cadr (split-string (cdr (doom-call-process bin "--version"))
" " t)))))
(when version
(setq doom-projects--fd-version version))
(concat (format "%s . -0 -H --color=never --type file --type symlink --follow --exclude .git %s"
bin (if (and (stringp version)
(version< version "8.3.0"))
"" "--strip-cwd-prefix"))
(if IS-WINDOWS " --path-separator=/")))))
;; Otherwise, resort to ripgrep, which is also faster than find ;; Otherwise, resort to ripgrep, which is also faster than find
((executable-find "rg" t) ((executable-find "rg" t)
(concat "rg -0 --files --follow --color=never --hidden -g!.git" (concat "rg -0 --files --follow --color=never --hidden -g!.git"