1 |
#!/bin/sh |
2 |
# |
3 |
# This is a CIA bot client script for Subversion repositories, |
4 |
# delivering via email. See below for usage and customization information. |
5 |
# |
6 |
# -------------------------------------------------------------------------- |
7 |
# |
8 |
# Copyright (c) 2004-2005, Micah Dowty |
9 |
# All rights reserved. |
10 |
# |
11 |
# Redistribution and use in source and binary forms, with or without |
12 |
# modification, are permitted provided that the following conditions are met: |
13 |
# |
14 |
# * Redistributions of source code must retain the above copyright notice, |
15 |
# this list of conditions and the following disclaimer. |
16 |
# * Redistributions in binary form must reproduce the above copyright |
17 |
# notice, this list of conditions and the following disclaimer in the |
18 |
# documentation and/or other materials provided with the distribution. |
19 |
# * The name of the author may not be used to endorse or promote products |
20 |
# derived from this software without specific prior written permission. |
21 |
# |
22 |
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
23 |
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
24 |
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
25 |
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
26 |
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
27 |
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
28 |
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
29 |
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
30 |
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
31 |
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
32 |
# POSSIBILITY OF SUCH DAMAGE. |
33 |
# |
34 |
# -------------------------------------------------------------------------- |
35 |
# |
36 |
# See http://cia.vc for more information on what the CIA bot |
37 |
# is and how it works, and links to other client scripts. |
38 |
# |
39 |
# To use the CIA bot in your Subversion repository... |
40 |
# |
41 |
# 1. Customize the parameters below, specifically the ones under |
42 |
# the "Project information" section |
43 |
# |
44 |
# 2. This script should be called from your repository's post-commit |
45 |
# hook with the repository and revision as arguments. For example, |
46 |
# you could copy this script into your repository's "hooks" directory |
47 |
# and add something like the following to the "post-commit" script, |
48 |
# also in the repository's "hooks" directory: |
49 |
# |
50 |
# REPOS="$1" |
51 |
# REV="$2" |
52 |
# $REPOS/hooks/ciabot_svn.sh "$REPOS" "$REV"& |
53 |
# |
54 |
# ------ There are some parameters for this script that you can customize: |
55 |
|
56 |
# Project information |
57 |
# |
58 |
# NOTE: This shouldn't be a long description of your project. Ideally |
59 |
# it is a short identifier with no spaces, punctuation, or |
60 |
# unnecessary capitalization. This will be used in URLs related |
61 |
# to your project, as an internal identifier, and in IRC messages. |
62 |
# If you want a longer name shown for your project on the web |
63 |
# interface, please use the "title" metadata key rather than |
64 |
# putting that here. |
65 |
# |
66 |
project_name="Mageia" |
67 |
module_name="<%= cia_module %>" |
68 |
return_address="root@<%= domain %>" |
69 |
ignore_author="<%= cia_ignore_author %>" |
70 |
|
71 |
# System |
72 |
sendmail_command="/usr/sbin/sendmail -t" |
73 |
|
74 |
############# Below this line you shouldn't have to change anything |
75 |
|
76 |
# Script arguments |
77 |
REPOS="$1" |
78 |
REV="$2" |
79 |
|
80 |
# The email address CIA lives at |
81 |
cia_address="cia@cia.vc" |
82 |
|
83 |
author=`svnlook author -r "$REV" "$REPOS" | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'` |
84 |
if test -n "$ignore_author" && echo "$author" | grep -q "$ignore_author" |
85 |
then |
86 |
exit 0 |
87 |
fi |
88 |
log=`svnlook log -r "$REV" "$REPOS" | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'` |
89 |
diff_lines=`svnlook diff -r "$REV" "$REPOS" | wc -l` |
90 |
for file in `svnlook changed -r "$REV" "$REPOS" | cut -c 3- | sed 's/\&/\&/g;s/</\</g;s/>/\>/g'`; do |
91 |
files="$files<file>$file</file>" |
92 |
done |
93 |
|
94 |
url="http://svnweb.<%= domain%>/${REPOS/\/svn\//}?view=revision&revision=$REV" |
95 |
|
96 |
# Send an email with the final XML message |
97 |
(cat <<EOF |
98 |
From: $return_address |
99 |
To: $cia_address |
100 |
Subject: DeliverXML |
101 |
|
102 |
<message> |
103 |
<generator> |
104 |
<name>Subversion CIA Bot client shell script</name> |
105 |
<version>1.1</version> |
106 |
</generator> |
107 |
<source> |
108 |
<project>$project_name</project> |
109 |
<module>$module_name</module> |
110 |
</source> |
111 |
<body> |
112 |
<commit> |
113 |
<revision>$REV</revision> |
114 |
<author>$author</author> |
115 |
<files>$files</files> |
116 |
<log>$log</log> |
117 |
<url>$url</url> |
118 |
<diffLines>$diff_lines</diffLines> |
119 |
</commit> |
120 |
</body> |
121 |
</message> |
122 |
EOF |
123 |
) | $sendmail_command |
124 |
|
125 |
### The End ### |