From 3e31ec827a887eda2d13f5fb7b7f61e222b2169d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Wed, 20 Apr 2016 22:52:35 +0200
Subject: [PATCH] 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.
---
 guix/build/download.scm | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/guix/build/download.scm b/guix/build/download.scm
index e00fa04e358..fe7a453c89b 100644
--- a/guix/build/download.scm
+++ b/guix/build/download.scm
@@ -202,13 +202,18 @@ (define uri-as-string
     (uri->string uri))
 
   (define (elide-path)
-    (let ((path (uri-path uri)))
-      (string-append (symbol->string (uri-scheme uri)) "://"
-
-                     ;; `file' URIs have no host part.
-                     (or (uri-host uri) "")
-
-                     (string-append "/.../" (basename path)))))
+    (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) "")
+
+                                  (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)))
-- 
GitLab