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
|
#!/bin/bash
# Generate old-style ChangeLog files from the GIT log. Ultimately we may
# wish to insert this into ChangeLog
footer=false
printdate=true
directory=.
modules=true
quiet=false
moduleoptions=
[ -z "$level" ] && level="="
if [ $(uname) = Darwin ]; then
FMT="fmt"
else
FMT="fmt -ut"
fi
export level
help()
{ echo "Usage: `basename $0` option ... [version][..version] [path ...]"
echo "Options:"
echo " --footer"
echo " --nodate"
echo " --nomodules"
echo " --dir=<dir>"
}
done=false
while [ $done = false ]; do
case "$1" in
--help)
help
exit 0
;;
--footer)
footer=true
shift
;;
--nodate)
printdate=false
shift
moduleoptions+="--nodate"
;;
--quiet)
quiet=true
shift
;;
--wiki)
shift
;;
--nomodules)
modules=false
shift
;;
--dir=*)
directory="`echo $1 | sed 's/--dir=//'`"
shift
modules=false
;;
*) done=true
;;
esac
done
tag="$1"
if [ -z "$tag" ]; then
tag=$(cat VERSION)
fi
# Ensure case-sensitive matching
LANG=C
case "$tag" in
[0-9].[0-9]*.[0-9]*..[0-9].[0-9]*.[0-9]*)
vfrom="$(echo $tag | sed 's/\.\..*//')"
vto="$(echo $tag | sed 's/.*\.\.//')"
;;
V[0-9].[0-9]*.[0-9]*..V[0-9].[0-9]*.[0-9]*)
vfrom="$(echo $tag | sed -e s/V//g -e 's/\.\..*//')"
vto="$(echo $tag | sed -e s/V//g -e 's/.*\.\.//')"
;;
[0-9].[0-9]*.[0-9]*)
vfrom="$tag"
vto=
;;
V[0-9].[0-9]*.[0-9]*)
vfrom="$(echo $tag | sed s/V//)"
vto=
;;
*..*)
vfrom="$(echo $tag | sed 's/\.\..*//')"
vto="$(echo $tag | sed 's/.*\.\.//')"
;;
[0-9a-f]*)
vfrom=$tag
vto=
;;
esac
shift
vvtag()
{ case $1 in
[0-9].[0-9]*.[0-9]*)
echo V$1
;;
*)
echo $1
;;
esac
}
if [ -z "$vto" ]; then
opt=$(vvtag $vfrom)..
else
opt="$(vvtag $vfrom)..$(vvtag $vto)"
fi
cd $directory
if [ "$quiet" = true ]; then
git log "$opt" --pretty=format:"PATCH[%ad]%n%s%n%b" $* | \
grep -q '^[A-Z][A-Z]*:'
exit $?
fi
header ()
{ hdr="$*"
hdr="$*"
eq=`echo $hdr | sed "s/./$level/g"`
echo $hdr
echo $eq
echo
}
(
if [ "$directory" = "." ]; then
if [ -z "$vto" ]; then
header "SWI-Prolog Changelog since version $vfrom"
else
header "SWI-Prolog Changelog from version $vfrom to $vto"
fi
else
header "Package `basename $directory`"
fi
git log "$opt" --pretty=format:"PATCH[%ad]%n%s%n%b" --date-order --simplify-merges $* | awk '
BEGIN { doprint="false";
dateprinted="";
}
/^PATCH[[]/ { date="[" $2 " " $3 " " $5 "]";
doprint="false";
next;
}
/^[A-Z][A-Z]*:/ { if ( dateprinted != date )
{ if ( "'$printdate'" == "true" )
{ printf("%s\n\n", date);
}
dateprinted = date;
}
printf(" * %s\n", $0);
doprint="true";
next;
}
/.*/ { if ( doprint == "true" )
{ if ( $0 != "<unknown>" )
{ printf(" %s\n", $0);
} else
{ printf("\n");
}
}
next;
}
' ) | $FMT
# Include submodules
mtag()
{ git ls-tree $1 $2 | awk '{print $3}'
}
if [ "$modules" = true ]; then
level="-"
echo
for d in `git submodule -q foreach pwd`; do
mfrom=$(mtag $(vvtag $vfrom) $d)
if [ ! -z "$vto" ]; then
mto=$(mtag $(vvtag $vto) $d)
else
mto=$(mtag HEAD $d)
fi
if [ ! -z "$mfrom" -a ! -z "$mto" ]; then
subopts=$mfrom..$mto
if $0 --dir="$d" --quiet "$subopts"; then
echo
$0 --dir="$d" $moduleoptions "$subopts"
# else
# echo "Package `basename $d`: no changes"
fi
fi
done
fi
if [ "$footer" = true ]; then
header VERSION $tag
fi
|