forked from adamlaska/datatracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmkdevbranch
More file actions
executable file
·282 lines (234 loc) · 7.9 KB
/
mkdevbranch
File metadata and controls
executable file
·282 lines (234 loc) · 7.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
#!/bin/bash
version=0.24
program=${0##*/}
progdir=${0%/*}
svn_url_base="https://svn.ietf.org/svn/tools/ietfdb"
if [ "$progdir" = "$program" ]; then progdir="."; fi
# ----------------------------------------------------------------------
function usage() {
cat <<EOF
NAME
$program - make new dev branches for the IETF sprint
SYNOPSIS
$program [OPTIONS] [DEVELOPER [BRANCHNAME]]
DESCRIPTION
Make new dev branches for sprint participants based on the
content of the sprint registration page. If given a specific
developer name and optionally a branch name as arguments, make a
new branch for the specified developer instead. If run without
arguments, the script assumes that it's being run on the host that
holds the Trac wiki with the sprint signup pages.
EOF
echo -e "OPTIONS"
if [ "$(uname)" = "Linux" ]; then
# shellcheck disable=SC2086
# shellcheck disable=SC2016
grep -E "^\s+[-][A-Za-z| -]+\*?\)\s+[A-Za-z].+#" "$0" | tr -s "\t|" "\t," | $sed -e 's/\)[ \t]+([A-Z]+)=\$2[^#]*#/=\1\t/' -e 's/\)[^#]*#/\t/'
else
# shellcheck disable=SC2086
# shellcheck disable=SC2016
grep -E "^\s+[-][A-Za-z| -]+\*?\)\s+[A-Za-z].+#" "$0" | $sed 's/\|.*\$2[^#]*#/ /' | $sed 's/\|.*\)[^#]*#/ /'
fi
cat <<EOF
FILES
AUTHOR
Written by Henrik Levkowetz, <henrik@zinfandel.tools.ietf.org>
COPYRIGHT
Copyright 2016 Henrik Levkowetz.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or (at
your option) any later version. There is NO WARRANTY; not even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.
EOF
}
# ----------------------------------------------------------------------
function die() {
echo -e "\n$program: error: $*" >/dev/stderr
exit 1
}
function warn() {
echo "$program: Warning: $*" 1>&2
}
function note() {
if [ -n "$VERBOSE" ]; then echo -e "$*"; fi
}
# ----------------------------------------------------------------------
function version() {
echo -e "$program $version"
}
# ----------------------------------------------------------------------
function check_svn_path_exists() {
local __resultvar=$1
local __path=$2
local myresult
svn info "${__path}" >/dev/null 2>&1
myresult=$?
# shellcheck disable=SC2086
eval $__resultvar="'$myresult'"
}
function mksvndir() {
who=$1
if [ "$2" ]; then dir=$2; else dir=$who; fi
check_svn_path_exists exists "${svn_url_base}/personal/$dir"
# shellcheck disable=SC2154
if [ "$exists" != "0" ]; then
$do echo "Creating personal directory area for IETF datatracker coding: /personal/$dir"
$do svn mkdir "${svn_url_base}/personal/$dir" -m "Personal SVN dir for $who, for IETF datatracker code"
else
echo "Repository area personal/$dir is already in place."
fi
}
function mksvntarget() {
local who=$1
local target=$2
local source=$3
local email=$4
local name=$5
check_svn_path_exists exists "${svn_url_base}/personal/$who/$target"
if [ "$exists" != "0" ]; then
$do echo " creating $target branch for $who ($name)."
$do svn cp "${svn_url_base}/$source" \
"${svn_url_base}/personal/$who/$target/" \
-m "New branch for $target"
$do echo "New branch: ^/personal/$who/$target"
if [ -n "$email" ]; then
notify_user "$who" "$target" "$email" "$name"
fi
else
$do echo " branch personal/$who/$target already exists."
fi
}
function notify_user() {
local login=$1
local target=$2
local email=$3
local name=$4
$do mail "$name <$email>" -s "A new SVN branch for you for IETF datatracker coding${rev:+, based on $rev}." -b rjsparks@nostrum.com <<-EOF
Hi,
$msg
This mail has been automatically generated by the $program script.
A new SVN branch has been set up for you for IETF datatracker coding, at
${svn_url_base}/personal/$login/$target
${rev:+This branch is based on $rev. }You can check it out by doing
svn co ${svn_url_base}/personal/$login/$target
There's also a database dump available at
https://www.ietf.org/lib/dt/sprint/ietf_utf8.sql.gz -- this dump is served
via CDN, and should hopefully be swifter to download than the alternatives.
Please read the instructions about sprint coder setup at
https://trac.ietf.org/tools/ietfdb/wiki/SprintCoderSetup
-- both the workflow description and the details of setting up your
environment.
Best regards,
The IETF tools team (via the $program script)
EOF
}
function get_sprinters_info() {
local n=$1
curl -L -s "https://trac.ietf.org/trac/ietfdb/wiki/IETF${n}SprintSignUp?format=txt" | \
grep -E "^\|\|" | \
grep -Ev "^\|\|\s+\|\|\s+" | \
tail -n +2 | \
python3 sprintcoders.py | \
update "$progdir/sprint${n}.txt"
}
# ----------------------------------------------------------------------
trap 'echo "$program($LINENO): Command failed with error code $? ([$$] "$0" $*)"; exit 1' ERR
# ----------------------------------------------------------------------
# Option parsing
# Options
short_options=hm:M:nsvV
long_options=help,meeting=,message=,dry-run,sprint,verbose,version
# Default values
num=""
msg=""
do=""
if [ "$(uname)" = "Linux" ]; then
# shellcheck disable=SC2086
# shellcheck disable=SC2048
if ! args=$(getopt -o $short_options --long $long_options -n $program -- $SV $*); then
die "Terminating..." >&2
exit 1
fi
# shellcheck disable=SC2086
eval set -- $args
sed="sed -r"
else
# Darwin, BSDs
# shellcheck disable=SC2086
# shellcheck disable=SC2048
if ! args=$(getopt -o$short_options $SV $*); then
die "Terminating..." >&2
exit 1
fi
# shellcheck disable=SC2086
set -- $args
sed="sed -E"
fi
while true; do
case "$1" in
-h | --help)
usage
exit
;; # Show this help, then exit
-m | --meeting)
num=$2
shift
;; # Specify the IETF meeting number
-M | --message)
msg=$2
shift
;; # Specify extra message text
-n | --dry-run) do="echo -- ==>" ;; # Only show what would be done
-s | --sprint) SPRINT=1 ;; # Make branches for sprint sign-ups
-v | --verbose) VERBOSE=1 ;; # Be more talkative
-V | --version)
version
exit
;; # Show program version, then exit
--)
shift
break
;;
*) die "Internal error, inconsistent option specification: '$1'" ;;
esac
shift
done
# ----------------------------------------------------------------------
# The program itself
who=""
tag=$(svn log -v ${svn_url_base}/tags/dev/ --limit 1 | grep '/tags/' | awk '{print $2}')
source="${tag:1}"
target="${tag##*/}"
rev="dev tag $target"
[ "$1" ] && who="$1"
[ "$2" ] && target="${target%.dev*}-$2"
if [ -z "${who}${SPRINT}" ]; then die "Specify either individual developer name or --sprint"; fi
cd $progdir || exit
if [ "$who" ]; then
mksvndir "$who"
mksvntarget "$who" "$target" "$source"
fi
if [ "$SPRINT" ]; then
[ "$msg" ] && msg="
$msg
"
[ "$num" ] || num=$(curl -L -s "https://tools.ietf.org/meta/current-ietf-number.txt")
for n in $(seq $((num - 3)) "$num"); do
get_sprinters_info "$n"
done
# shellcheck disable=SC2046
# shellcheck disable=SC2012
# shellcheck disable=SC2162
# sed -E (regexp extended) breaks this usage on MacOS 10.15, so back to regular sed.
cat $(ls $progdir/sprint*.txt | tail -n 2) $progdir/extras.txt | \
sed -e 's/[ \t]*$//' -e 's/[ \t]+/ /g' | \
sort | uniq | \
while read login email name; do
echo ""
echo "$login ($name <$email>):"
mksvndir "$login"
mksvntarget "$login" "$target" "$source" "$email" "$name"
done
fi