[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Help with post-commit script

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Tue, 3 Dec 2013 20:13:50 +0200

Andrew Reedick wrote on Mon, Dec 02, 2013 at 16:07:52 -0600:
> #!/bin/bash
>
> set -o pipefail
>
> REPOS_PATH=$1
> REV=$2 # or is it the other way around?

It's this way around.

> RECIPIENT_LIST=$(svnlook propget ... my:email_list_prop)

Need to set PATH first for this to work.

> svnlook changed ... > $CHANGED_LIST || exit 1
> cat $CHANGED_LIST | sed 's/^....//g' | perl -ne 'print "$1$2\n" if /^(trunk)\/|^(branches\/[^\/]*)\//' | sort -u | xargs -n 1 -i svnlook propget $REPOS_PATH my:filelist_prop "{}" > $FILES_TO_REPORT_ON || exit 1
>
> cat $CHANGED_LIST | while read i

'read' splits on whitespace, so filenames that contain spaces won't DTRT.

> do
> grep -q "$i" "$FILES_TO_REPORT_ON"

Same for filenames that contain regex metacharacters.

> if [[ $? -eq 0 ]]
> then
> sendmail -s " $i was touched in an impure manner" $RECIPIENT_LIST < svnlook diff -r ...

There's an obvious semantic error here, you meant to use a pipe.

But I would suggest using mailer.py here. If nothing else, you can use
it in its "print the mail to stdout" mode and then pipe that to
sendmail. That'll take care of formatting the diff, log message, etc.

> Also, do NOT have any blank links in the "my:filelist_prop". Or does
> that only apply when using 'grep -v'?

Your perl invocation will DTRT on blank lines (that is: skip them
without printing them).
Received on 2013-12-03 19:14:27 CET

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.