(define salmonella-full-version (let* ((head (handle-exceptions exn #f (with-input-from-file ".git/HEAD" read-line)))) (if head (let* ((rev-file (if (string-prefix? "ref: " head) (make-pathname ".git" (substring head 5)) ;; remove "ref: " #f)) (rev (if rev-file (handle-exceptions exn #f (with-input-from-file rev-file read-line)) head))) (if rev (sprintf "~a (rev ~a, branch ~a)" salmonella-version (substring rev 0 10) (if (and rev-file ;; slashes can be mixed up on Windows. ;; make-pathname will use Windows' separator ;; and git may use Unix's separator. (or (string-prefix? ".git/refs/heads/" rev-file) (string-prefix? ".git\\refs/heads/" rev-file) (string-prefix? ".git\\refs\\heads\\" rev-file))) (substring rev-file 16) "")) salmonella-version)) salmonella-version)))