fix: pre-commit hook — handle non-lisp org files (no :tangle header)
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
Some checks failed
Deploy (Gitea) / deploy (push) Failing after 2s
The set -euo pipefail combined with grep returning non-zero on files without a :tangle header (like ROADMAP.org) caused the hook to abort silently, preventing commits. Added || true to the grep pipeline.
This commit is contained in:
@@ -35,7 +35,7 @@ for orgfile in $CHANGED; do
|
|||||||
[ -f "$orgfile" ] || continue
|
[ -f "$orgfile" ] || continue
|
||||||
|
|
||||||
# Determine the tangle target from the org file's PROPERTY line
|
# Determine the tangle target from the org file's PROPERTY line
|
||||||
TANGLE=$(grep 'header-args.*:tangle' "$orgfile" | sed "s/.*:tangle //" | head -1)
|
TANGLE=$(grep 'header-args.*:tangle' "$orgfile" | sed "s/.*:tangle //" | head -1 || true)
|
||||||
if [ -z "$TANGLE" ]; then
|
if [ -z "$TANGLE" ]; then
|
||||||
echo "SKIP: $orgfile — no :tangle header" >&2
|
echo "SKIP: $orgfile — no :tangle header" >&2
|
||||||
continue
|
continue
|
||||||
@@ -48,7 +48,7 @@ for orgfile in $CHANGED; do
|
|||||||
# Tangle the org file to lisp
|
# Tangle the org file to lisp
|
||||||
if ! emacs --batch -L "$PROJECT_DIR" --eval "(require 'ob-tangle)" \
|
if ! emacs --batch -L "$PROJECT_DIR" --eval "(require 'ob-tangle)" \
|
||||||
--eval "(org-babel-tangle-file \"$ORG_DIR/$(basename "$orgfile")\")" \
|
--eval "(org-babel-tangle-file \"$ORG_DIR/$(basename "$orgfile")\")" \
|
||||||
2>/dev/null; then
|
</dev/null 2>/dev/null; then
|
||||||
echo "FAIL: $orgfile — tangling failed" >&2
|
echo "FAIL: $orgfile — tangling failed" >&2
|
||||||
FAILED=1
|
FAILED=1
|
||||||
continue
|
continue
|
||||||
@@ -62,7 +62,7 @@ for orgfile in $CHANGED; do
|
|||||||
# Compile the lisp file in the daemon.
|
# Compile the lisp file in the daemon.
|
||||||
# We send a Lisp form that compiles the file and returns T or an error string.
|
# We send a Lisp form that compiles the file and returns T or an error string.
|
||||||
# Using format to avoid backquote/comma issues.
|
# Using format to avoid backquote/comma issues.
|
||||||
LISP_ABS=$(realpath "$LISP_FILE")
|
LISP_ABS=$(realpath "$LISP_FILE" 2>/dev/null || echo "$LISP_FILE")
|
||||||
CODE=$(cat <<-LISPEOF
|
CODE=$(cat <<-LISPEOF
|
||||||
(let ((*standard-output* (make-broadcast-stream))
|
(let ((*standard-output* (make-broadcast-stream))
|
||||||
(*error-output* (make-broadcast-stream)))
|
(*error-output* (make-broadcast-stream)))
|
||||||
|
|||||||
Reference in New Issue
Block a user