summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorp4bl0 <pablo@rauzy.name>2010-07-22 15:46:00 +0200
committerp4bl0 <pablo@rauzy.name>2010-07-22 15:46:00 +0200
commit01adb9a64d83cb49d0a53b0b003d50058a62d2d8 (patch)
treeef482ea62ebf026d32597851ad68d1ed2b567ed0
parent5e5f8031b9cbf8acf8292aa4255c0c23e1b0808e (diff)
added feedback info and fixed replace_var_by_file function
-rw-r--r--src/hooks/post-commit.sh24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/hooks/post-commit.sh b/src/hooks/post-commit.sh
index 4419672..32400d9 100644
--- a/src/hooks/post-commit.sh
+++ b/src/hooks/post-commit.sh
@@ -25,22 +25,30 @@ commit_time=`git log -1 --format="%ai" | cut -d' ' -f2`
commit_timestamp=`git log -1 --format="%at"`
commit_subject=`git log -1 --format="%s"`
commit_slug=`git log -1 --format="%f"`
-commit_body=`git log -1 --format="%b"`
+commit_body() {
+ tmp="/tmp/fugitive-$$.$RANDOM"
+ git log -1 --format="%b" > "$tmp"
+ (sleep 5 && rm -f "$tmp") & # this message will self-destruct in 5s
+ echo "$tmp"
+}
article_get_title() {
head -1 "$1"
}
article_get_content() {
- tail -n+2 "$1" > "/tmp/$$"
- (sleep 5 && rm -f "/tmp/$$") &
- echo "/tmp/$$"
+ tmp="/tmp/fugitive-$$.$RANDOM"
+ tail -n+2 "$1" > "$tmp"
+ (sleep 5 && rm -f "$tmp") & # this message will self-destruct in 5s
+ echo "$tmp"
}
replace_var_by_string() {
sed "s/<\!--$1-->/$2/"
}
replace_var_by_file() {
- sed "/<\!--$1-->/ { r $2; d }"
+ sed "/<\!--$1-->/ { \
+ r $2
+ d }"
}
replace_commit_info() {
replace_var_by_string "commit_Hash" "$commit_Hash" | \
@@ -50,22 +58,26 @@ replace_commit_info() {
replace_var_by_string "commit_date" "$commit_date" | \
replace_var_by_string "commit_subject" "$commit_subject" | \
replace_var_by_string "commit_slug" "$commit_slug" | \
- replace_var_by_string "commit_body" "$commit_body"
+ replace_var_by_file "commit_body" "`commit_body`"
}
for f in $deleted_files; do
if [ "$f" != "${f#$articles_dir}" ]; then
+ echo -n "Deleting $public_dir/${f#$articles_dir/}.html... "
rm $public_dir/${f#$articles_dir/}.html
+ echo "done."
fi
done
for f in $added_files $modified_files; do
if [ "$f" != "${f#$articles_dir}" ]; then
+ echo -n "Generating $public_dir/${f#$articles_dir/}.html from $f... "
cat $templates_dir/article.html | \
replace_commit_info | \
replace_var_by_string "article_title" "`article_get_title \"$f\"`" | \
replace_var_by_file "article_content" "`article_get_content \"$f\"`" | \
cat > $public_dir/${f#$articles_dir/}.html
+ echo "done."
fi
done