Skip to content

Commit 8813bc8

Browse files
committed
Tweaked the mkdevbranch utility script to be able to make a branch for one specific developer on request.
- Legacy-Id: 10924
1 parent 661d89e commit 8813bc8

1 file changed

Lines changed: 162 additions & 68 deletions

File tree

bin/mkdevbranch

Lines changed: 162 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,104 +1,198 @@
11
#!/bin/bash
22

3-
version=0.23
3+
version=0.24
44
program=${0##*/}
55
progdir=${0%/*}
66
if [ "$progdir" = "$program" ]; then progdir="."; fi
77

8-
function die() {
9-
echo -e "\n$program: Error: ${1:0:160} ..." >&2
8+
# ----------------------------------------------------------------------
9+
function usage() {
10+
cat <<EOF
11+
NAME
12+
$program - make new dev branches for the IETF sprint
13+
14+
SYNOPSIS
15+
$program [OPTIONS] [DEVELOPER [BRANCHNAME]]
16+
17+
DESCRIPTION
18+
Make new dev branches for sprint participants based on the
19+
content of the sprint registration page. If given a specific
20+
developer name and optionally a branch name as arguments, make a
21+
new branch for the specified developer instead. If run without
22+
arguments, the script assumes that it's being run on the host that
23+
holds the Trac wiki with the sprint signup pages.
24+
25+
EOF
26+
echo -e "OPTIONS"
27+
if [ "$(uname)" = "Linux" ]; then
28+
egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | tr -s "\t|" "\t," | sed -r -e 's/\)[ \t]+([A-Z]+)=\$2[^#]*#/=\1\t/' -e 's/\)[^#]*#/\t/'
29+
else
30+
egrep "^[ ]+[-][A-Za-z| -]+\*?\)[ ]+[A-Za-z].+#" $0 | sed 's/\|.*\$2[^#]*#/ /'| sed -E 's/\|.*\)[^#]*#/ /'
31+
fi
32+
cat <<EOF
33+
34+
FILES
35+
36+
AUTHOR
37+
Written by Henrik Levkowetz, <henrik@zinfandel.tools.ietf.org>
38+
39+
COPYRIGHT
40+
Copyright 2016 Henrik Levkowetz.
41+
42+
This program is free software; you can redistribute it and/or modify
43+
it under the terms of the GNU General Public License as published by
44+
the Free Software Foundation; either version 2 of the License, or (at
45+
your option) any later version. There is NO WARRANTY; not even the
46+
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
47+
PURPOSE. See the GNU General Public License for more details.
48+
49+
EOF
50+
51+
}
52+
53+
# ----------------------------------------------------------------------
54+
function die() {
55+
echo -e "\n$program: error: $*" > /dev/stderr
1056
exit 1
1157
}
1258

1359
function warn() {
14-
logger -i -p user.warn -t $program "$*"
15-
echo "$program: Warning: $*" 1>&2;
60+
echo "$program: Warning: $*" 1>&2;
1661
}
1762

63+
1864
function note() {
19-
logger -i -p user.notice -t $program "$*"
20-
if [ -n "$OPT_VERBOSE" ]; then echo -e "$*"; fi
65+
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
2166
}
2267

23-
function version() {
24-
echo -e "$program: v$version\n\nRunning as $(id -urn) on $(date +'%Y-%m-%d %H:%M')"
68+
# ----------------------------------------------------------------------
69+
function version() {
70+
echo -e "$program $version"
2571
}
2672

27-
#[ "$#" -gt 0 ] || die "Expected the ietf number as argument on the command line, but found nothing"
28-
#[ $1 -gt 70 ] || die "Expected the ietf number as argument on the command line, but found '$1'"
73+
# ----------------------------------------------------------------------
74+
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] $0 $*)"; exit 1' ERR
75+
76+
77+
# ----------------------------------------------------------------------
78+
# Option parsing
2979

30-
#if [ "$1" ]; then arg=$1; else arg=$(svn info http://svn.tools.ietf.org/svn/tools/ietfdb/trunk/ | egrep "^Last Changed Rev" | awk '{print $4}'); fi
80+
# Options
81+
shortopts=hnvV
82+
longopts=help,verbose,number,version
3183

32-
if [ "$1" ]; then arg=$1; else arg=$(svn ls http://svn.tools.ietf.org/svn/tools/ietfdb/tags/ | grep '^[1-9]' | tail -n 1 | sed -r 's/^(.*)\/$/v\1/' ); fi
84+
# Default values
85+
num=""
3386

34-
if [ "${arg:0:1}" = "v" ]; then
35-
source="tags/${arg:1}"
36-
target="$arg"
37-
rev="release $arg"
87+
if [ "$(uname)" = "Linux" ]; then
88+
args=$(getopt -o "$shortopts" --long "$longopts" -n '$program' -- $SV "$@")
89+
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
90+
eval set -- "$args"
91+
sed="sed -r"
3892
else
39-
source="trunk@$arg"
40-
target="r$arg"
41-
rev="repository rev r$arg"
93+
# Darwin, BSDs
94+
args=$(getopt -o$shortopts $SV $*)
95+
if [ $? != 0 ] ; then die "Terminating..." >&2 ; exit 1 ; fi
96+
set -- $args
97+
sed="sed -E"
4298
fi
4399

100+
while true ; do
101+
case "$1" in
102+
-h| --help) usage; exit;; # Show this help, then exit
103+
-m| --meeting) num=$2; shift;; # Specify the IETF meeting number
104+
-v| --verbose) VERBOSE=1;; # Be more talkative
105+
-V| --version) version; exit;; # Show program version, then exit
106+
--) shift; break;;
107+
*) die "Internal error, inconsistent option specification: '$1'";;
108+
esac
109+
shift
110+
done
111+
112+
# ----------------------------------------------------------------------
113+
# The program itself
114+
115+
who=""
116+
tag=$(svn log -v https://svn.tools.ietf.org/svn/tools/ietfdb/tags/dev/ --limit 1 | grep '/tags/' | awk '{print $2}')
117+
118+
source="${tag:1}"
119+
target="${tag##*/}"
120+
rev="dev tag $target"
121+
122+
[ "$1" ] && who="$1"
123+
[ "$2" ] && target="${target%.dev*}-$2"
124+
44125
function mksvndir() {
45126
who=$1
46127
if [ "$2" ]; then dir=$2; else dir=$who; fi
47-
if ! svn info http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$dir >/dev/null 2>&1 ; then
128+
if ! svn info https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$dir >/dev/null 2>&1 ; then
48129
echo "Creating personal directory area for IETF datatracker coding: /personal/$dir"
49-
svn mkdir http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$dir -m "Personal SVN dir for $who, for IETF datatracker code"
130+
svn mkdir https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$dir -m "Personal SVN dir for $who, for IETF datatracker code"
50131
else
51132
echo "Repository area personal/$dir is already in place."
52133
fi
53134
}
54135

55-
cd $progdir
56-
57-
num=$( < /www/tools.ietf.org/meta/current-ietf-number.txt)
58-
for n in $(seq $((num-3)) $num); do
59-
trac-admin /www/tools.ietf.org/tools/ietfdb wiki export IETF${n}SprintSignUp \
60-
| egrep "^\|\|" | tail -n +2 | python -c '
61-
import sys, re
62-
afile = open("aliases")
63-
aliases = dict([ line.strip().split(None,1) for line in afile.read().splitlines() ])
64-
for line in sys.stdin:
65-
blank, name, email, rest = line.strip().split("||", 3)
66-
login, dummy = re.split("[@.]", email, 1)
67-
if login in aliases:
68-
login = aliases[login]
69-
print "\t".join((login.strip().lower(), email.strip().lower(), name.strip())) ' \
70-
| update $progdir/sprint$n.txt
71-
done
72-
73-
cat $(ls $progdir/sprint*.txt | tail -n 2) $progdir/extras.txt | sed 's/[ \t]*$//' | sort | uniq | while read login email name; do
74-
echo ""
75-
echo "$login ($name <$email>):"
76-
mksvndir $login
77-
if ! svn info http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target >/dev/null 2>&1 ; then
78-
echo " creating $target branch for $login ($name)."
79-
svn cp http://svn.tools.ietf.org/svn/tools/ietfdb/$source http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target/ -m "New IETF datatracker coding branch for $name" \
80-
&& mail "$name <$email>" -s "A new SVN branch for you for IETF datatracker coding${rev:+, based on $rev}." -b henrik@levkowetz.com <<-EOF
81-
Hi,
82-
83-
This mail has been automatically generated by the $program script.
84-
85-
A new SVN branch has been set up for you for IETF datatracker coding, at
86-
http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target
87-
${rev:+This branch is based on $rev. }You can check it out by doing
88-
svn co http://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target
136+
# dump="ietf_utf8.sql.gz"
137+
# echo "Copying a database dump to www.ietf.org/lib/dt/sprint/$dump"
138+
# scp /www/tools.ietf.org/tools/$dump ietfa:/a/www/www6s/lib/dt/sprint/
89139

90-
Please read the instructions about sprint coder setup at
91-
http://trac.tools.ietf.org/tools/ietfdb/wiki/SprintCoderSetup
92-
-- both the workflow description and the details of setting up your
93-
environment.
94-
95-
96-
Best regards,
140+
cd $progdir
97141

98-
Henrik (via the $program script)
142+
if [ "$who" ]; then
143+
mksvndir $who
144+
svn cp https://svn.tools.ietf.org/svn/tools/ietfdb/$source https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$who/$target/ -m "New branch for $target"
145+
else
146+
[ "$num" ] || num=$( < /www/tools.ietf.org/meta/current-ietf-number.txt)
147+
for n in $(seq $((num-3)) $num); do
148+
trac-admin /www/tools.ietf.org/tools/ietfdb wiki export IETF${n}SprintSignUp \
149+
| egrep "^\|\|" | tail -n +2 | python -c '
150+
import sys, re
151+
afile = open("aliases")
152+
aliases = dict([ line.strip().split(None,1) for line in afile.read().splitlines() ])
153+
for line in sys.stdin:
154+
blank, name, email, rest = line.strip().split("||", 3)
155+
login, dummy = re.split("[@.]", email, 1)
156+
if login in aliases:
157+
login = aliases[login]
158+
print "\t".join((login.strip().lower(), email.strip().lower(), name.strip())) ' \
159+
| update $progdir/sprint$n.txt
160+
done
161+
162+
cat $(ls $progdir/sprint*.txt | tail -n 2) $progdir/extras.txt | sed 's/[ \t]*$//' | sort | uniq | while read login email name; do
163+
echo ""
164+
echo "$login ($name <$email>):"
165+
mksvndir $login
166+
if ! svn info https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target >/dev/null 2>&1 ; then
167+
echo " creating $target branch for $login ($name)."
168+
svn cp https://svn.tools.ietf.org/svn/tools/ietfdb/$source https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target/ -m "New IETF datatracker coding branch for $name" \
169+
&& mail "$name <$email>" -s "A new SVN branch for you for IETF datatracker coding${rev:+, based on $rev}." -b henrik@levkowetz.com <<-EOF
170+
Hi,
171+
172+
This mail has been automatically generated by the $program script.
173+
174+
A new SVN branch has been set up for you for IETF datatracker coding, at
175+
https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target
176+
${rev:+This branch is based on $rev. }You can check it out by doing
177+
svn co https://svn.tools.ietf.org/svn/tools/ietfdb/personal/$login/$target
178+
179+
There's also a new database dump available at
180+
https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz -- this dump is served
181+
via CDN, and should hopefully be swifter to download than the alternatives.
182+
183+
Please read the instructions about sprint coder setup at
184+
https://trac.tools.ietf.org/tools/ietfdb/wiki/SprintCoderSetup
185+
-- both the workflow description and the details of setting up your
186+
environment.
187+
188+
189+
Best regards,
190+
191+
Henrik (via the $program script)
99192
100193
EOF
101-
else
102-
echo " branch personal/$login/$target already exists."
103-
fi
104-
done
194+
else
195+
echo " branch personal/$login/$target already exists."
196+
fi
197+
done
198+
fi

0 commit comments

Comments
 (0)