#!/bin/bash
#
# Simple script to generate a CHANGELOG between two tags. This is usually invoked automatically during
# Debian package generation.
#
# Russell Michell 2017 <russellmichell@catalyst.net.nz>

from=$( git tag | grep -E '\.' | sort -r | head -2 | tail -1 )
to=$( git tag | grep -E '\.' | sort -r | head -1 )

echo -e "# Changelog for: $from : $to\n\n" > .deb/CHANGELOG.md
git log --no-merges $from...$to --pretty=format:'* %s [view commit](https://gitlab.catalyst.net.nz/SilverStripe/niwa-clidesc/commit/%H"]' --reverse >> .deb/CHANGELOG.md
