download: 'uri-abbreviation' can abbreviate the URI's basename.

* guix/build/download.scm (uri-abbreviation): Use 'ellipsis' instead of
"...".  Abbreviate the basename of PATH if needed.
master
Ludovic Courtès 2016-04-20 22:52:35 +02:00
parent b3129f2b76
commit 3e31ec827a
1 changed files with 10 additions and 5 deletions

View File

@ -202,13 +202,18 @@ abbreviation of URI showing the scheme, host, and basename of the file."
(uri->string uri))
(define (elide-path)
(let ((path (uri-path uri)))
(string-append (symbol->string (uri-scheme uri)) "://"
(let* ((path (uri-path uri))
(base (basename path))
(prefix (string-append (symbol->string (uri-scheme uri)) "://"
;; `file' URIs have no host part.
(or (uri-host uri) "")
;; `file' URIs have no host part.
(or (uri-host uri) "")
(string-append "/.../" (basename path)))))
(string-append "/" (ellipsis) "/"))))
(if (> (+ (string-length prefix) (string-length base)) max-length)
(string-append prefix (ellipsis)
(string-drop base (quotient (string-length base) 2)))
(string-append prefix base))))
(if (> (string-length uri-as-string) max-length)
(let ((short (elide-path)))