The following scripts that you can find here, allows you to send diffs of repositories that you follow. The bash scripts below allows you to update your git/svn/hg repository and keep a diff in a plain and html format (using ansi2html).
git_diff() { cd $repo_url/$1 git_repo_url=`git remote show origin | grep "Fetch URL" | cut -d ' ' -f 5-` echo "GIT Diff $1 ($2) - $git_repo_url" git fetch git diff --color HEAD origin/HEAD | $ansi2html > $diff_dir/$2.html git diff HEAD origin/HEAD > $diff_dir/$2.diff git merge origin/HEAD } hg_diff() { cd $repo_url/$1 hg_repo_url=`hg showconfig | grep paths\.default | cut -d '=' -f 2-` echo "HG Diff $1 ($2) - $hg_repo_url" hg incoming --patch --git | $ansi2html > $diff_dir/$2.html hg incoming --patch --git > $diff_dir/$2.diff hg pull -u } svn_diff() { cd $repo_url/$1 svn_repo_url=`svn info | grep URL | cut -d ' ' -f 2-` svn_repo_rev=`svn info | grep "Last Changed Rev" | cut -d ' ' -f 4-` echo "SVN Diff $1 ($2) - $svn_repo_url" svn di $svn_repo_url -r$svn_repo_rev | $ansi2html > $diff_dir/$2.html svn di $svn_repo_url -r$svn_repo_rev > $diff_dir/$2.diff svn up } # Fetch my repos (xxx_diff repo_path diff_name) git_diff "linux/linux-2.6" "linux-2.6" svn_diff "apache/lucene" "lucene" hg_diff "java/jdk" "hotspot-jdk7"
After running repo-diff script that allows you to update your favorites repositories and saving diff files, you can send them using he send-mail script.
diff_dir="~/.repo-diffs" mail_address="th30z@localhost" for html_file in `ls -1 $diff_dir/*.html` ; do repo_name=`basename $html_file | sed 's/\.html$//g'` diff_file=`echo $html_file | sed 's/\.html$/\.diff/g'` boundary="==`echo $repo_name | md5sum | cut -d ' ' -f -1`" alt_boundary="==`echo $boundary | md5sum | cut -d ' ' -f -1`" echo "Send Repo Diff $repo_name - $html_file" ( echo "MIME-Version: 1.0" echo "Subject: Repo-Diff: $repo_name" echo "To: $mail_address" echo "Content-Type: multipart/mixed; boundary=$boundary" echo "--$boundary" echo "Content-Type: multipart/alternative; boundary=$alt_boundary" echo echo "--$alt_boundary" echo "Content-Type: text/plain" echo cat $diff_file echo "--$alt_boundary" echo "Content-Type: text/html" echo cat $html_file echo echo "--$alt_boundary--" echo "--$boundary" echo "Content-Type: Application/Binary_Attachment; name=\"`basename $diff_file`\"" echo "Content-Disposition: attachment; filename=\"`basename $diff_file`\"" echo "Content-Transfer-Encoding: uuencode" echo uuencode $diff_file $diff_file ) | sendmail $mail_address done
This script, for each file generated from the repo-diff script sends you a mail with the diff as body and attachment.
Scripts are available on my github repository under blog-code/repo-mail-diff.
No comments:
Post a Comment