5a9f330
#!/bin/bash
5a9f330
5a9f330
# Copyright (C) 2022 Red Hat, Inc.
5a9f330
# Written by Andrew John Hughes <gnu.andrew@redhat.com>, 2012-2022
5a9f330
#
5a9f330
# This program is free software: you can redistribute it and/or modify
5a9f330
# it under the terms of the GNU Affero General Public License as
5a9f330
# published by the Free Software Foundation, either version 3 of the
5a9f330
# License, or (at your option) any later version.
5a9f330
#
5a9f330
# This program is distributed in the hope that it will be useful,
5a9f330
# but WITHOUT ANY WARRANTY; without even the implied warranty of
5a9f330
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
5a9f330
# GNU Affero General Public License for more details.
5a9f330
#
5a9f330
# You should have received a copy of the GNU Affero General Public License
5a9f330
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
5a9f330
5a9f330
OLD_RELEASE=$1
5a9f330
NEW_RELEASE=$2
5a9f330
SUBDIR=$3
5a9f330
REPO=$4
5a9f330
SCRIPT_DIR=$(dirname ${0})
5a9f330
5a9f330
if test "x${SUBDIR}" = "x"; then
5a9f330
    echo "No subdirectory specified; using .";
5a9f330
    SUBDIR=".";
5a9f330
fi
5a9f330
5a9f330
if test "x$REPO" = "x"; then
5a9f330
    echo "No repository specified; using ${PWD}"
5a9f330
    REPO=${PWD}
5a9f330
fi
5a9f330
5a9f330
if test x${TMPDIR} = x; then
5a9f330
    TMPDIR=/tmp;
5a9f330
fi
5a9f330
5a9f330
echo "Repository: ${REPO}"
5a9f330
5a9f330
if [ -e ${REPO}/.git ] ; then
5a9f330
    TYPE=git;
5a9f330
elif [ -e ${REPO}/.hg ] ; then
5a9f330
    TYPE=hg;
5a9f330
else
5a9f330
    echo "No Mercurial or Git repository detected.";
5a9f330
    exit 1;
5a9f330
fi
5a9f330
5a9f330
if test "x$OLD_RELEASE" = "x" || test "x$NEW_RELEASE" = "x"; then
5a9f330
    echo "ERROR: Need to specify old and new release";
5a9f330
    exit 2;
5a9f330
fi
5a9f330
5a9f330
echo "Listing fixes between $OLD_RELEASE and $NEW_RELEASE in $REPO"
5a9f330
rm -f ${TMPDIR}/fixes2 ${TMPDIR}/fixes3 ${TMPDIR}/fixes
5a9f330
for repos in . $(${SCRIPT_DIR}/discover_trees.sh ${REPO});
5a9f330
do
5a9f330
    if test "x$TYPE" = "xhg"; then
5a9f330
	hg log -r "tag('$NEW_RELEASE'):tag('$OLD_RELEASE') - tag('$OLD_RELEASE')" -R $REPO/$repos -G -M ${REPO}/${SUBDIR} | \
5a9f330
	    egrep '^[o:| ]*summary'|grep -v 'Added tag'|sed -r 's#^[o:| ]*summary:\W*([0-9])#  - JDK-\1#'| \
5a9f330
	    sed 's#^[o:| ]*summary:\W*#  - #' >> ${TMPDIR}/fixes2;
5a9f330
	hg log -v -r "tag('$NEW_RELEASE'):tag('$OLD_RELEASE') - tag('$OLD_RELEASE')" -R $REPO/$repos -G -M ${REPO}/${SUBDIR} | \
5a9f330
	    egrep '^[o:| ]*[0-9]{7}'|sed -r 's#^[o:| ]*([0-9]{7})#  - JDK-\1#' >> ${TMPDIR}/fixes3;
5a9f330
    else
5a9f330
	git -C ${REPO} log --no-merges --pretty=format:%B ${NEW_RELEASE}...${OLD_RELEASE} -- ${SUBDIR} |egrep '^[0-9]{7}' | \
5a9f330
	    sed -r 's#^([0-9])#  - JDK-\1#' >> ${TMPDIR}/fixes2;
5a9f330
	touch ${TMPDIR}/fixes3 ; # unused
5a9f330
    fi
5a9f330
done
5a9f330
5a9f330
sort ${TMPDIR}/fixes2 ${TMPDIR}/fixes3 | uniq > ${TMPDIR}/fixes
5a9f330
rm -f ${TMPDIR}/fixes2 ${TMPDIR}/fixes3
5a9f330
5a9f330
echo "In ${TMPDIR}/fixes:"
5a9f330
cat ${TMPDIR}/fixes