-
Notifications
You must be signed in to change notification settings - Fork 183
/
update-venue.sh
executable file
·55 lines (48 loc) · 1.2 KB
/
update-venue.sh
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
#!/usr/bin/env bash
# Usage: $0 <user> <repo> [drafts...]
set -e
. "$(dirname "$0")/wg-meta.sh"
user="$1"
repo="$2"
shift 2
if [[ "$OSTYPE" =~ (darwin|bsd).* ]] ; then
function sed_no_backup() { sed -i '' "$@" ; }
else
function sed_no_backup() { sed -i "$@" ; }
fi
last_wg=
for d in "$@"; do
if ! head -1 "$d" | grep -q "^---"; then
# This only works for kramdown-rfc drafts
continue
fi
w="${d#draft-}"
w="${w#*-}"
w="${w%%-*}"
sed_no_backup -e '1,/^---/ {
/^venue:/,/^[^# ]/{
s,^[# ]*github: .*, github: "'"$user/$repo"'",
s,^[# ]*latest: .*, latest: "'"https://$user.github.io/$repo/${d%.*}.html"'",
}
}' "$d"
if [[ "$w" == "$last_wg" ]] || wgmeta "$w"; then
sed_no_backup -e '1,/^---/ {
s,^[# ]*area: .*,area: "'"$wg_area"'",
s,^[# ]*workgroup: .*,workgroup: "'"$wg_name"'",
/^venue:/,/^[^# ]/{
s,^[# ]*group: .*, group: "'"$wg_name"'",
s,^[# ]*type: .*, type: "'"$wg_type"'",
s,^[# ]*mail: .*, mail: "'"$wg_mail"'",
s,^[# ]*arch: .*, arch: "'"$wg_arch"'",
}
}' "$d"
last_wg="$w"
else
sed_no_backup -e '1,/^---/ {
s,^[# ]*\(area\|workgroup\):,# \1:,
/^venue:/,/^[^# ]/{
s,^[# ]*\(group\|type\|mail\|arch\):,# \1:,g
}
}' "$d"
fi
done