fix(vertico): consult-dir: don't guess user from containers

The tramp string used to connect to the container uses the first
`container-runtime ps` argument as a username, but the first argument
returned is the container ID, not a username.

Close: #7674
Co-authored-by: bergmannf <bergmannf@users.noreply.github.com>
Co-authored-by: elken <elken@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2024-03-20 03:09:05 -04:00 committed by Yann Esposito (Yogsototh)
parent 30bcf18397
commit baeb7838f6
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646

View file

@ -201,7 +201,8 @@ orderless."
("C-x C-j" . consult-dir-jump-file))
:config
(when (modulep! :tools docker)
;; TODO Replace with `tramp-container--completion-function' when we drop support for <29
;; TODO: Replace with `tramp-container--completion-function' when we drop
;; support for <29
(defun +vertico--consult-dir-container-hosts (host)
"Get a list of hosts from HOST."
(cl-loop for line in (cdr
@ -209,10 +210,7 @@ orderless."
(apply #'process-lines +vertico-consult-dir-container-executable
(append +vertico-consult-dir-container-args (list "ps")))))
for cand = (split-string line "[[:space:]]+" t)
collect (let ((user (unless (string-empty-p (car cand))
(concat (car cand) "@")))
(hostname (car (last cand))))
(format "/%s:%s%s:/" host user hostname))))
collect (format "/%s:%s:/" host (car (last cand)))))
(defun +vertico--consult-dir-podman-hosts ()
(let ((+vertico-consult-dir-container-executable "podman"))