]> git.bundesbrandschatzamt.de Git - emacsconfig.git/commitdiff
added githooks. Thanks to https://github.com/NateEag/.emacs.d.git
authorAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 13 Jan 2015 17:28:30 +0000 (18:28 +0100)
committerAndreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
Tue, 13 Jan 2015 17:28:30 +0000 (18:28 +0100)
Signed-off-by: Andreas Gerler <baronNOSPAMbundesbrandschatzamt.de>
githooks/compile-changed-elisp.sh [new file with mode: 0755]
githooks/install.sh [new file with mode: 0755]
githooks/load-changed-elisp.sh [new file with mode: 0755]
githooks/post-commit.sh [new file with mode: 0644]
githooks/post-merge.sh [new file with mode: 0755]
githooks/rm-stale-bytecode-files.sh [new file with mode: 0755]

diff --git a/githooks/compile-changed-elisp.sh b/githooks/compile-changed-elisp.sh
new file mode 100755 (executable)
index 0000000..0d67c5f
--- /dev/null
@@ -0,0 +1,11 @@
+#! /bin/bash
+
+file_list=$(git diff --name-only --diff-filter=ACM "$1" "$2" | grep '\.el$')
+updated_files=''
+for file in $file_list
+do
+    updated_files+=$(echo "~/.emacs.d/$file")' '
+done
+
+# emacs -batch -l site-lisp/bootstrap.el -f batch-byte-compile $updated_files
+emacs -batch -f batch-byte-compile $updated_files
diff --git a/githooks/install.sh b/githooks/install.sh
new file mode 100755 (executable)
index 0000000..b295f71
--- /dev/null
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+githooks_dir=$(dirname $0)
+git_dir=$githooks_dir/../.git
+
+cp $githooks_dir/post-merge.sh $git_dir/hooks/post-merge
+chmod +x $git_dir/hooks/post-merge
+
+cp $githooks_dir/post-commit.sh $git_dir/hooks/post-commit
+chmod +x $git_dir/hooks/post-commit
+
+cp $githooks_dir/load-changed-elisp.sh $git_dir/hooks/load-changed-elisp.sh
+chmod +x $git_dir/hooks/load-changed-elisp.sh
+
+cp $githooks_dir/compile-changed-elisp.sh $git_dir/hooks/compile-changed-elisp.sh
+chmod +x $git_dir/hooks/compile-changed-elisp.sh
+
+cp $githooks_dir/rm-stale-bytecode-files.sh $git_dir/hooks/rm-stale-bytecode-files.sh
+chmod +x $git_dir/hooks/rm-stale-bytecode-files.sh
diff --git a/githooks/load-changed-elisp.sh b/githooks/load-changed-elisp.sh
new file mode 100755 (executable)
index 0000000..deaa6f5
--- /dev/null
@@ -0,0 +1,19 @@
+#! /bin/bash
+
+# If passed a pair of commit identifiers, this shell script will use emacsclient
+# to load any new or updated files in the existing emacs daemon.
+
+# This is probably only useful after git pull, to load latest config changes
+# into a long-running instance.
+
+emacs --batch --eval "(require 'server)" \
+    --eval "(if (not (eq (server-running-p) t)) (kill-emacs 1))"
+is_server_running=$?
+if [ $is_server_running -eq 0 ]; then
+    updated_files=$(git diff --name-only --diff-filter=ACM "$1" "$2" | grep '\.el$')
+    for file in $updated_files
+    do
+        emacsclient --eval \
+            "(if (server-running-p) (load-file \"~/.emacs.d/$file\"))"
+    done
+fi
diff --git a/githooks/post-commit.sh b/githooks/post-commit.sh
new file mode 100644 (file)
index 0000000..1fbca9f
--- /dev/null
@@ -0,0 +1,6 @@
+#! /bin/bash
+
+hooks_dir=$(dirname $0)
+
+$hooks_dir/compile-changed-elisp.sh HEAD^ HEAD
+$hooks_dir/rm-stale-bytecode-files.sh HEAD^ HEAD
diff --git a/githooks/post-merge.sh b/githooks/post-merge.sh
new file mode 100755 (executable)
index 0000000..e0815d9
--- /dev/null
@@ -0,0 +1,12 @@
+#! /bin/bash
+
+# My post-merge hook.
+
+hooks_dir=$(dirname $0)
+
+$hooks_dir/compile-changed-elisp.sh ORIG_HEAD HEAD
+$hooks_dir/load-changed-elisp.sh ORIG_HEAD HEAD
+$hooks_dir/rm-stale-bytecode-files.sh ORIG_HEAD HEAD
+
+# Clean out any untracked/unignored files.
+# git clean -fd elpa/
diff --git a/githooks/rm-stale-bytecode-files.sh b/githooks/rm-stale-bytecode-files.sh
new file mode 100755 (executable)
index 0000000..0f740d8
--- /dev/null
@@ -0,0 +1,14 @@
+#! /bin/bash
+
+# Delete any .elc files whose corresponding .el files were deleted or renamed
+# between commit $1 and $2.
+
+file_list=$(git diff --name-only --diff-filter=DR "$1" "$2" | grep '\.el$')
+for file in $file_list
+do
+    bytecode_file=${file}c
+    if [ -f "$bytecode_file" ]; then
+        rm "$bytecode_file"
+        echo "Deleted $bytecode_file"
+    fi
+done