]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/make-countdown-announcement.sh
Add `make-countdown-announcement.sh'.
[lilypond.git] / scripts / auxiliar / make-countdown-announcement.sh
1 #!/bin/bash
2
3 # convert a Google code CSV file into a countdown announcement
4 #
5 # USAGE:
6 #   make-countdown-announcement.sh NEXT_DEADLINE_DATE [PATCH-MEISTER]
7 #     OR
8 #   make-countdown-announcement.sh NEXT_DEADLINE_DATE [PATCH-MEISTER] > OUTPUT-FILE
9 #
10 # EXAMPLES:
11 #   make-countdown-announcement.sh "Jan 1, 2001" "John Doe"
12 #   make-countdown-announcement.sh "Jan 1, 2001" John
13 #   make-countdown-announcement.sh "Jan 1, 2001" > countdown.txt
14
15
16 CSV_FILE=lilypond-issues.csv # comma-separated values
17 TSV_FILE=lilypond-issues.tsv # tab-separated values
18 URL_BASE="http://code.google.com/p/lilypond/issues"
19 QUERY_STR="q=Patch%3Apush%2Ccountdown%2Creview%2Cnew%2Cwaiting&colspec=Patch%20Owner%20ID%20Summary&sort=patch"
20 DEADLINE=$1
21 PATCH_MEISTER=${2:-"The Patch Mister"}
22 MAILMAP='
23 "adam.spiers","Adam Spiers"
24 "aleksandr.andreev","Aleksandr Andreev"
25 "benko.pal","Benkő Pál"
26 "bordage.bertrand","Bertrand Bordage"
27 "brownian.box","Dmytro O. Redchuk"
28 "Carl.D.Sorensen","Carl Sorensen"
29 "carlopeterson","Carl Peterson"
30 "colinghall","Colin Hall"
31 "ColinPKCampbell","Colin Campbell"
32 "d8valily","Mark Mathias"
33 "dak@gnu.org","David Kastrup"
34 "david.nalesnik","David Nalesnik"
35 "dschudy","Devon Schudy"
36 "Eluzew","Eluze W"
37 "erlenda","Erlend Aasland"
38 "fedelogy","Federico Bruni"
39 "frederic.bron.1995@polytechnique.org","Frédéric Bron"
40 "graham@percival-music.ca","Graham Percival"
41 "hanwenn","Han-Wen Nienhuys"
42 "hjunes","Heikki Junes"
43 "ianhulin44","Ian Hulin"
44 "idragosani","Brett McCoy"
45 "jameselihubailey","James E. Bailey"
46 "janek.lilypond","Janek Warchoł"
47 "jan.nieuwenhuizen","Jan Nieuwenhuizen"
48 "joeneeman","Joe Neeman"
49 "john.mandereau","John Mandereau"
50 "joseph.wakeling","Joseph Wakeling"
51 "julien.rioux","Julien Rioux"
52 "kieren@alumni.rice.edu","Kieren MacMillan"
53 "k-ohara5a5a@oco.net","Keith OHara"
54 "lemzwerg","Werner Lemberg"
55 "lilyliska","Urs Liska"
56 "lilypond.patchy.graham","Graham Percival"
57 "mandolaerik","Erik Sandberg"
58 "marc@hohlart.de","Marc Hohl"
59 "marek@gregoriana.sk","Marek Klein"
60 "markpolesky","Mark Polesky"
61 "milimetr88","Łukasz Czerwiński"
62 "mtsolo","Mike Solomon"
63 "neziap","Janek Warchoł"
64 "nicolas.sceaux","Nicolas Sceaux"
65 "n.puttock","Neil Puttock"
66 "paconet.org","Francisco Vila"
67 "PhilEHolmes","Phil Holmes"
68 "pkx166h","James Lowe"
69 "plroskin","Pavel Roskin"
70 "pnorcks","Patrick McCarty"
71 "RalphBugList","Ralph Palmer"
72 "reinhold.kainhofer","Reinhold Kainhofer"
73 "rzedeler","Rune Zedeler"
74 "schilke.60","Derek Klinge"
75 "shingarov","Boris Shingarov"
76 "tdanielsmusic","Trevor Daniels"
77 "thomasmorley65","Thomas Morley"
78 "v.villenave","Valentin Villenave"
79 '
80
81
82 usage() {
83   cat << EOF >&2
84 USAGE:
85   `basename $0` NEXT_DEADLINE_DATE [PATCH-MEISTER]
86     OR
87   `basename $0` NEXT_DEADLINE_DATE [PATCH-MEISTER] > OUTPUT-FILE
88
89 EXAMPLES:
90   `basename $0` "Jan 1, 2001" "John Doe"
91   `basename $0` "Jan 1, 2001" John
92   `basename $0` "Jan 1, 2001" > countdown.txt
93 EOF
94   exit 1
95 }
96
97
98 # display USAGE
99 case $# in
100   1|2) case $1 in
101          -h|--help) usage ;;
102          *) ;;
103        esac ;;
104   *) usage ;;
105 esac
106
107
108 # clean up in case of a previous interrupt
109 remove-if-exists() {
110   if [ -e $1 ]; then rm $1; fi
111 }
112 remove-if-exists push.tmp
113 remove-if-exists countdown.tmp
114 remove-if-exists review.tmp
115 remove-if-exists new.tmp
116 remove-if-exists waiting.tmp
117 remove-if-exists $TSV_FILE
118
119
120 # show initial instructions
121 read -p "First, in your web browser, make sure you're logged in to:
122
123   $URL_BASE/list
124
125 Then save the following link as a file called \"$CSV_FILE\"
126 (save it to this directory -- $PWD/):
127
128   $URL_BASE/csv?$QUERY_STR
129
130 Then press enter"
131
132
133 if [ ! -e $CSV_FILE ]; then
134   echo -e "\nError: can't find \`$CSV_FILE': No such file or directory" >&2
135   exit 1
136 fi
137
138
139 # If the user wasn't logged in when downloading $CSV_FILE, the emails will
140 # appear truncated, e.g. "abc...@gmail.com", and won't be properly replaced by
141 # the author names later on.  This code block complains if the string "...@" is
142 # found anywhere in the email field.
143 if [ "`cut -d, -f2 $CSV_FILE | grep -o '\.\.\.@'`" ]; then
144     read -p "
145 It looks like you were not logged in to Google code when you downloaded
146 $CSV_FILE.  Continue anyway (y/n)? "
147   while :
148   do
149     case "$REPLY" in
150       y) break ;;
151       n) exit 1 ;;
152       *) read -p "Enter \`y' to continue; \`n' to quit and try again: "
153     esac
154   done
155 fi
156
157
158 # change the quoted, comma-separated file
159 # into an unquoted, tab-separated file
160 # and keep only the first 4 fields: Patch,Owner,ID,Summary
161 sed '{
162 1d
163 /^$/d
164 s/^"//
165 s/","/\t/g
166 s/",*$//
167 s/""/"/g
168 }' $CSV_FILE | cut -sf1-4 > $TSV_FILE
169
170
171 EMAILS_USED=`awk -F"\t" '{ print $2 }' $TSV_FILE | sort --unique`
172 KNOWN_EMAILS=`
173 IFS=$'\n'
174 for i in $MAILMAP; do
175   echo "$i" | sed 's/^"\(.*\)",".*/\1/'
176 done`
177 UNKNOWN_EMAILS=`comm -23 <(echo "$EMAILS_USED") <(echo "$KNOWN_EMAILS")`
178
179
180 # Unknown emails/usernames usually mean new contributors.
181 # If any are found, the user is prompted to add the new
182 # authors' names to the MAILMAP list above.
183 if [ "$UNKNOWN_EMAILS" ]; then
184   COUNT=`wc --lines <(echo "$UNKNOWN_EMAILS") | sed 's/ .*//'`
185   if [ $COUNT -eq 1 ]; then
186     echo -e "\nError: The following email/username needs to be associated with a name:" >&2
187     echo "$UNKNOWN_EMAILS" | sed 's/^/  /' >&2
188     echo -e "Please add it to the MAILMAP list in\n  $0" >&2
189   else
190     echo -e "\nError: The following emails/usernames need to be associated with names:" >&2
191     echo "$UNKNOWN_EMAILS" | sed 's/^/  /' >&2
192     echo -e "Please add them to the MAILMAP list in\n  $0" >&2
193   fi
194   echo "using the following form:" >&2
195   echo "$UNKNOWN_EMAILS" | sed 's/.*/  "&","author name"/' >&2
196   echo "and commit your changes to the main git repository." >&2
197   remove-if-exists $TSV_FILE
198   exit 1
199 fi
200
201
202 EMAIL_REPLACEMENTS=`
203 IFS=$'\n'
204 for i in $MAILMAP; do
205   echo "$i" | sed 's/^"\(.*\)","\(.*\)"$/s\/\1\/\2\/g/'
206 done`
207
208
209 # replace emails/usernames with author names
210 # and separate the issues by patch type
211 sed -n "{
212 $EMAIL_REPLACEMENTS
213 /^push/w push.tmp
214 /^countdown/w countdown.tmp
215 /^review/w review.tmp
216 /^new/w new.tmp
217 /^waiting/w waiting.tmp
218 }" $TSV_FILE
219
220
221 # clean up; $TSV_FILE is no longer needed
222 remove-if-exists $TSV_FILE
223
224
225 format-entry() {
226   TYPE=$1
227   FILE="$1.tmp"
228   if [ -s $FILE ]; then
229     echo -e "$TYPE:\n" | tr 'a-z' 'A-Z'
230     awk -v UB=$URL_BASE -F"\t" \
231       '{ printf("%s: %s\n%s/detail?id=%d\n\n"), $2, $4, UB, $3 }' $FILE
232     echo -e "____________________\n\n"
233   fi
234   remove-if-exists $FILE
235 }
236
237 echo >&2
238
239
240 # display the countdown announcement
241 echo "Hello,
242
243 Here is the current patch countdown list.
244 The next countdown will be on $DEADLINE.
245
246 You can always view the most current countdown list here:
247 $URL_BASE/list?$QUERY_STR
248
249 ____________________
250
251 "
252
253 format-entry push
254 format-entry countdown
255 format-entry review
256 format-entry new
257 format-entry waiting
258
259 echo -e "Thank you,\n$PATCH_MEISTER"