#!/bin/bash

upstream=$(git describe --exclude 'debian/*' | cut -f1 -d-)
# try to get the non-tags out of the way; see
# https://stackoverflow.com/questions/9366960/limit-refs-shown-with-git-log-decorate
mkdir .git/backup-refs
mv .git/refs/{heads,remotes} .git/backup-refs/
git log --pretty=format:'%ad%d %s' --date=short "$upstream" > debian/upstream.changelog
mv .git/backup-refs/{heads,remotes} .git/refs/
rmdir .git/backup-refs