summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Vanicat <vanicat@debian.org>2007-11-13 20:08:32 +0100
committerJoey Hess <joey@kodama.kitenet.net>2007-11-14 13:25:40 -0500
commit146c72298aea05c64df89d40f01c6136f70d3fda (patch)
tree0246e7dff8a0387db6e8fc6ebd26d07f24ac37f7
parent9346843fa6da3b598fc970238ff2b3a374bd80cd (diff)
Render option to git commit configurable
When etckeeper commit something it use a default message that can be configured, but not easily edited on a case by case basis. To make this possible, and to give other way to customize commit, I add a configuration file that contain for now only one option: GIT_COMMIT_OPTION that can contain option given to git commit when run by etckeeper
-rw-r--r--Makefile1
-rwxr-xr-xetckeeper8
-rw-r--r--etckeeper.conf5
-rwxr-xr-xpost-apt.d/50git-commit2
-rwxr-xr-xpre-apt.d/50uncommitted-changes2
5 files changed, 16 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 30a60b8..17b49b8 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,7 @@
install:
mkdir -p $(PREFIX)/etc/etckeeper/
cp -a *.d $(PREFIX)/etc/etckeeper/
+ cp etckeeper.conf $(PREFIX)/etc/etckeeper/
install -D etckeeper $(PREFIX)/usr/bin/etckeeper
install -m 0644 -D apt.conf $(PREFIX)/etc/apt/apt.conf.d/05etckeeper
install -m 0644 -D etckeeper.1 $(PREFIX)/usr/share/man/man1/etckeeper.1
diff --git a/etckeeper b/etckeeper
index 363f706..a9cf577 100755
--- a/etckeeper
+++ b/etckeeper
@@ -1,6 +1,14 @@
#!/bin/sh
set -e
+if [ -e /etc/etckeeper/etckeeper.conf ]; then
+ . /etc/etckeeper/etckeeper.conf
+fi
+
+if [ ! -z "$GIT_COMMIT_OPTION" ]; then
+ export GIT_COMMIT_OPTION
+fi
+
if [ -z "$1" ]; then
echo "usage: etckeeper command [directory]" >&2
exit 1
diff --git a/etckeeper.conf b/etckeeper.conf
new file mode 100644
index 0000000..6941e10
--- /dev/null
+++ b/etckeeper.conf
@@ -0,0 +1,5 @@
+# GIT_COMMIT_OPTION : option given to git commit when run by etckeeper
+# you could for exemple use GIT_COMMIT_OPTION="-e" if you want to edit
+# all commit message before commiting
+
+# GIT_COMMIT_OPTION=""
diff --git a/post-apt.d/50git-commit b/post-apt.d/50git-commit
index 6eb3434..fe5eb95 100755
--- a/post-apt.d/50git-commit
+++ b/post-apt.d/50git-commit
@@ -8,5 +8,5 @@ if [ -d .git ]; then
message="committing changes after apt run"
# ignore exit code since it exits nonzero if there is nothing to do
- git commit -m "$message" || true
+ git commit $GIT_COMMIT_OPTION -m "$message" || true
fi
diff --git a/pre-apt.d/50uncommitted-changes b/pre-apt.d/50uncommitted-changes
index dd8db13..eb3a64d 100755
--- a/pre-apt.d/50uncommitted-changes
+++ b/pre-apt.d/50uncommitted-changes
@@ -12,7 +12,7 @@ if [ -d .git ] && ! LANG=C git-status 2>&1 | grep -q "working directory clean";
db_get etckeeper/unclean
if [ "$RET" = true ]; then
git add .
- if ! git commit -m "saving uncommitted changes in /etc prior to apt run"; then
+ if ! git commit $GIT_COMMIT_OPTION -m "saving uncommitted changes in /etc prior to apt run"; then
db_input critical etckeeper/commit_failed || true
db_go || true
db_reset etckeeper/commit_failed || true