This is an automated email from the git hooks/post-receive script.

niedzejkob pushed a commit to branch master
in repository guix.

The following commit(s) were added to refs/heads/master by this push:
     new bbf6bc1  git-version: Handle invalid arguments gracefully
bbf6bc1 is described below

commit bbf6bc1acc9bbdebf7ee7b68c0fa091733a5f6e1
Author: Jakub Kądziołka <[email protected]>
AuthorDate: Wed Apr 15 17:12:29 2020 +0200

    git-version: Handle invalid arguments gracefully
    
    * guix/git-download.scm (git-version): Add a check for commit ID length.
---
 guix/git-download.scm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/guix/git-download.scm b/guix/git-download.scm
index 1eae035..ef0bb2e 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès 
<[email protected]>
 ;;; Copyright © 2017 Mathieu Lirzin <[email protected]>
 ;;; Copyright © 2017 Christopher Baines <[email protected]>
+;;; Copyright © 2020 Jakub Kądziołka <[email protected]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -30,6 +31,8 @@
   #:use-module (ice-9 match)
   #:use-module (ice-9 vlist)
   #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-34)
+  #:use-module (srfi srfi-35)
   #:export (git-reference
             git-reference?
             git-reference-url
@@ -170,6 +173,13 @@ HASH-ALGO (a symbol).  Use NAME as the file name, or a 
generic name if #f."
 
 (define (git-version version revision commit)
   "Return the version string for packages using git-download."
+  ;; git-version is almost exclusively executed while modules are being loaded.
+  ;; This makes any errors hide their backtrace. Avoid the mysterious error
+  ;; "Value out of range 0 to N: 7" when the commit ID is too short, which
+  ;; can happen, for example, when the user swapped the revision and commit
+  ;; arguments by mistake.
+  (when (< (string-length commit) 7)
+    (error "git-version: commit ID unexpectedly short"))
   (string-append version "-" revision "." (string-take commit 7)))
 
 (define (git-file-name name version)

Reply via email to