fix: validate fd --version output

Ref: https://discourse.doomemacs.org/t/3144
This commit is contained in:
Henrik Lissner 2022-09-07 01:45:54 +02:00
parent 71e0190618
commit e87fd8ac13
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -177,22 +177,20 @@ And if it's a function, evaluate it."
;; program that is significantly faster than git ls-files or find, and
;; it respects .gitignore. This is recommended in the projectile docs.
(cond
((when-let
(bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd"))
doom-projectile-fd-binary))
;; REVIEW Temporary fix for #6618. Improve me later.
(let ((version (or doom-projects--fd-version
(cadr (split-string (cdr (doom-call-process bin "--version"))
" " t)))))
(when version
(setq doom-projects--fd-version version))
((when-let*
((bin (if (ignore-errors (file-remote-p default-directory nil t))
(cl-find-if (doom-rpartial #'executable-find t)
(list "fdfind" "fd"))
doom-projectile-fd-binary))
;; REVIEW Temporary fix for #6618. Improve me later.
(version (with-memoization doom-projects--fd-version
(cadr (split-string (cdr (doom-call-process bin "--version"))
" " t))))
((ignore-errors (version-to-list 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"))
bin (if (version< version "8.3.0")
"" "--strip-cwd-prefix"))
(if IS-WINDOWS " --path-separator=/")))))
(if IS-WINDOWS " --path-separator=/"))))
;; Otherwise, resort to ripgrep, which is also faster than find
((executable-find "rg" t)
(concat "rg -0 --files --follow --color=never --hidden -g!.git"