-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchangelog-burster
executable file
·103 lines (91 loc) · 2.33 KB
/
changelog-burster
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
#!/bin/ksh
#
# changelog-burster
#
#
# Utility to take an OpenBSD Changelog from an OpenBSD mirror
# and separate it into a bunch of commit-* files in dated directories
#
# Also slaps the date ranges into the file daterange
#
# It will purge cvs modules not applicable to making plus.html
# (ports and www)
#
# Optionally, it will purge commits that have a date listed in the
# file purgedate. This is to help with an in-progress plus.html
#
# Created 2019-02-05
#
if [ x${PURGE_MODULES} = x ]; then
PURGE_MODULES="www ports"
fi
if [ x${DATE_FILE} = x ]; then
DATE_FILE="daterange"
fi
if [ x${PURGEDATE_FILE} = x ]; then
PURGEDATE_FILE="purgedate"
fi
if [ x${CHANGELOG} = x ]; then
CHANGELOG="ChangeLog"
fi
if [ x${SPLIT_PREFIX} = x ]; then
SPLIT_PREFIX="commit-"
fi
# Make sure the changelog exists
if [ ! -f $CHANGELOG ]; then
echo No such file $CHANGELOG
exit 1
fi
# Harvest the dates into DATE_FILE
echo -n "Noting dates: "
grep "Changes by:" $CHANGELOG | awk '{ print $4 }' | uniq > $DATE_FILE
echo done
# Split the Changelog into thousands of pieces
# Mwa ha ha ha
echo -n "Wielding chainsaw: "
split -a 3 -p "CVSROOT: /cvs" $CHANGELOG $SPLIT_PREFIX
echo done
# Get rid of modules not documented in plus.html
echo -n "Purging unworthy modules: "
for module in $PURGE_MODULES;
do
echo -n "${module} "
grep -l "Module name: ${module}" ${SPLIT_PREFIX}* | xargs -r rm
done
echo done
# Get rid of modules that are only "sync"
echo -n "Forcing out of sync: "
grep -l '^sync$' ${SPLIT_PREFIX}* | xargs -r rm
echo done
# Get rid of modules that are only "regen"
echo -n "Applying flame: "
grep -l '^regen$' ${SPLIT_PREFIX}* | xargs -r rm
echo done
# Remove regress-test-only commits
echo -n "Caution will not save you"
for file in $( grep -l "^ regress/" ${SPLIT_PREFIX}* );
do
if [ ! $( grep -v regress $file | grep -q "^ .*/.*$" ) ]; then
rm $file
fi
done
echo !!!
# Create per-day directory tree for commits
echo -n "Creating directories: "
for day in $( cat $DATE_FILE );
do
mkdir -p $( echo ${day} | sed 's/\//-/g' )
done
echo done
# Shove commit files in correct directory
echo -n "Filing commits: "
for day in $( cat $DATE_FILE );
do
daydir=$( echo ${day} | sed 's/\//-/g' )
grep -l "${day}" ${SPLIT_PREFIX}* | xargs -r -J % mv % ${daydir}/
done
echo done
echo -n "Victims remaining: "
grep CVSROOT 2*/* | wc -l
echo -n "Let's play."
echo