summaryrefslogtreecommitdiff
path: root/pre-commit.sh
diff options
context:
space:
mode:
authorp4bl0 <pablo@rauzy.name>2010-08-10 22:25:11 +0200
committerp4bl0 <pablo@rauzy.name>2010-08-10 22:25:11 +0200
commitf71626c7ecade5cf26baa9cb318cdd1c3d0c84c1 (patch)
treea894c4aebf28fd8577abb647a6bd97d54a62e478 /pre-commit.sh
parentd0618efb643f2dbec9b470a129946396315f60d5 (diff)
now preventing commit when zero article (for real ^^) and push when fugitive.blog-url not set
Diffstat (limited to 'pre-commit.sh')
-rw-r--r--pre-commit.sh20
1 files changed, 20 insertions, 0 deletions
diff --git a/pre-commit.sh b/pre-commit.sh
new file mode 100644
index 0000000..225c73e
--- /dev/null
+++ b/pre-commit.sh
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+articles_dir=`git config --get fugitive.articles-dir`
+
+article_exists=`mktemp --suffix "-fugitive"`
+for f in "$articles_dir"/*; do
+ ts=`git log --format="%at" -- "$f" | tail -1`
+ if [ "$ts" != "" ]; then
+ echo "1"
+ break
+ fi
+done > "$article_exists"
+article_exists=`cat $article_exists`
+non_tracked=`git status --porcelain | grep -E '^(A|R)' | grep "$articles_dir"`
+
+if [ "$article_exists" = "" -a "$non_tracked" = "" ]; then
+ echo -n "[fugitive] ERROR: need at least one article (you can use " >&2
+ echo '`git commit --no-verify` to bypass), aborting.' >&2
+ exit 1
+fi