Skip to content

Commit

Permalink
intrgrate git diff into script
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladislav Moskovets committed May 14, 2009
1 parent c384195 commit 7ee0c72
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.swp
18 changes: 16 additions & 2 deletions gitnotify
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ DATE="`date`"

usage() {
echo "usage: $0 [-g] [-m] [-s] [-a] [-r]"
exit 1
}

start_html() {
Expand Down Expand Up @@ -207,6 +208,19 @@ send_mail() {
rm $tempfile
}

prepare_git() {
[ -x `which tempfile` ] && gitdiff=`tempfile` || tempfile="/tmp/.gitnotify-gitdiff-$$-`date +%N`"
git-rev-parse --verify HEAD 2>/dev/null || return 1

git-diff-index -p -M --cached HEAD^ -- >$gitdiff
exec 7<&0
exec < $gitdiff
}

post_git() {
exec 0<&7 7<&-
rm $gitdiff
}

main() {
[ `basename $0` = 'gitnotify' ] && gitmode=1 || gitmode=0
Expand All @@ -220,21 +234,21 @@ main() {
s) SUBJECT=${OPTARG} ;;
g) gitmode=1 ;;
*) usage
exit 1
;;
\? ) usage
exit 1
;;
esac
done

[ $mailmode ] && prepare_mail
[ $gitmode ] && prepare_git || usage

start_html
summary
htmlizediff
end_html

[ $gitmode ] && post_git
[ $mailmode ] && send_mail
}

Expand Down

0 comments on commit 7ee0c72

Please sign in to comment.