From 5ff38e903a9ada8938aa71695af44b8bdde29fa9 Mon Sep 17 00:00:00 2001 From: p4bl0 Date: Mon, 2 Aug 2010 13:49:17 +0200 Subject: post-receive now works :-) --- post-receive.sh | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'post-receive.sh') diff --git a/post-receive.sh b/post-receive.sh index ba901c5..acec2b6 100644 --- a/post-receive.sh +++ b/post-receive.sh @@ -1,3 +1,40 @@ #!/bin/sh -echo "hi!" +cd .. +export GIT_DIR=.git +git reset --hard + +refs=`cat - | head -1 | cut -d' ' -f1,2` +ref_begin=`echo $refs | cut -d' ' -f1` +ref_end=`echo $refs | cut -d' ' -f2` + +if [ "$ref_begin" = "0000000000000000000000000000000000000000" ]; then + range="" # first push, empty repos. +else + range="$ref_begin..$ref_end" +fi + +articles_dir=`git config --get fugitive.articles-dir` + +added_files=`git log $range --name-status --pretty="format:" | \ + grep -E '^A' | cut -f2 | sort | uniq` +modified_files=`git log $range --name-status --pretty="format:" | \ + grep -E '^M' | cut -f2 | sort | uniq` +deleted_files=`git log $range --name-status --pretty="format:" | \ + grep -E '^D' | cut -f2 | sort | uniq` + +tmpart=`mktemp --suffix "-fugitive"` +tmpadd=`mktemp --suffix "-fugitive"` +tmpmod=`mktemp --suffix "-fugitive"` +tmpdel=`mktemp --suffix "-fugitive"` +ls "$articles_dir"/* > "$tmpart" +echo "$added_files" | tr " " "\n" > "$tmpadd" +echo "$modified_files" | tr " " "\n" > "$tmpmod" +echo "$deleted_files" | tr " " "\n" > "$tmpdel" +deleted_files=`comm -23 --nocheck-order "$tmpdel" "$tmpart"` +echo "$deleted_files" | tr " " "\n" > "$tmpdel" +deleted_files=`comm -23 --nocheck-order "$tmpdel" "$tmpadd"` +added_files=`comm -12 --nocheck-order "$tmpadd" "$tmpart"` +echo "$added_files" | tr " " "\n" > "$tmpadd" +modified_files=`comm -23 --nocheck-order "$tmpmod" "$tmpadd"` +rm "$tmpart" "$tmpadd" "$tmpmod" "$tmpdel" -- cgit v1.2.3