Skip to content

Commit 256df65

Browse files
cxxxrclaude
andcommitted
Fix git hash retrieval during Nix builds
- Skip git operations when :nix-build feature is set - Run git command in repository root instead of .git/ directory - Add error handling to prevent build failures when git command fails 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 4d4b4b4 commit 256df65

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

src/version.lisp

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@
22

33
(defun get-git-hash ()
44
"Return lem's git hash."
5+
;; Skip git operations during Nix build
6+
#-nix-build
57
(let ((path (asdf:system-relative-pathname :lem ".git/")))
68
(when (uiop:directory-exists-p path)
7-
(uiop:with-current-directory (path)
8-
(string-trim
9-
(list #\Newline #\Space)
10-
#+sbcl
11-
(with-output-to-string (stream)
12-
(uiop:run-program "git rev-parse --short HEAD"
13-
:output stream))
14-
#-sbcl
15-
""
16-
)))))
9+
(let ((repo-root (uiop:pathname-directory-pathname path)))
10+
(uiop:with-current-directory (repo-root)
11+
(handler-case
12+
(string-trim
13+
(list #\Newline #\Space)
14+
#+sbcl
15+
(with-output-to-string (stream)
16+
(uiop:run-program "git rev-parse --short HEAD"
17+
:output stream
18+
:ignore-error-status nil))
19+
#-sbcl
20+
"")
21+
(error () nil)))))))
1722

1823
(defvar *git-revision* (get-git-hash)
1924
"Stores lem's git revision; this is treated as a cache.")

0 commit comments

Comments
 (0)