views:

271

answers:

2

Hi,

I have successfully implemented the post-commit email notification for the post-commit hook. Now I'm looking at a bigger problem, I don't want the hook to send email for every commit. Is there a way to use the hook to maybe write the content of the email to a text file and maybe use another hook or something to send the text file?

I basically wnat to send an email with information of multiple commits.

thanks, Oded.

+3  A: 

First you have to decide when you actually want to send the email:

  1. Every tenth commit?
  2. At midnight?
  3. When tagging?

Then you should be able to easily implement a scheme working as you need it:

  1. in the post-commit hook: only send an email when revision number % 10 == 0
  2. create a cron job
  3. in the post-commit hook: detect when creating a tag

You can use svn log and svn diff with the -r FROM:TO option to gather the needed information by date or revision numbers. See the svnbook for more infos.

David Schmitt
The email I want to send need to contain all the information of all the commits... not the 5th or the 10th....
Oded
So write the contents out to a file on every commit and send the file on the 10th commit.
Jim T
Or use "svn log" and "svn diff" to get to the information you need.
David Schmitt
+1  A: 

You can modify the post-commit email sender script to send an email after some commits (e.g. the revision number is a multiple of 5)

To help write the script, you may use svnlook to fetch previous revision logs.

Here's part of a Python script I wrote to send SMS to developers:

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys, urllib, os
from subprocess import *

repo = sys.argv[2]
rev = sys.argv[3]

cmdlog = 'svnlook log -r %s %s'%(rev, repo)
cmdauthor = 'svnlook author -r %s %s'%(rev, repo)
log = Popen(cmdlog, stdout=PIPE, shell=True).stdout.read().strip()
author = Popen(cmdauthor, stdout=PIPE, shell=True).stdout.read().strip()

And in the post-commit file

#!/bin/bash

export LANG=en_US.utf8
REPOS="$1"
REV="$2"

./sms.py commit $REPOS $REV

You can refer to this example to fetch log information from svn repository by the command svnlook

ZelluX