#!/bin/bash
set -e
. tests/lib

t-tstunt-parsechangelog

t-debpolicy
t-prep-newpackage example 1.0

cd $p
revision=1
git tag start
t-dgit setup-mergechangelogs

: ---------- "initial upload"

t-dgit push-source --new

: ---------- "REJECT"

rm $tmp/incoming/*
t-archive-none example

touch -d 'now -1 day' $tmp/git/example*

t-policy-periodic

: ---------- "Fix and upload with dput"

t-dch-commit-bump 'edit after REJECT'

t-non-dgit-upload

: ---------- "Now upload with dgit again"

t-dch-commit-bump 'edit after dput'

t-expect-push-fail-tainted-new \
 'Reason:.* all previously pushed versions were found to have been removed from NEW' \
t-dgit push-source --trust-changelog

grep -P '^Probably, previous git-based .* into NEW was' ../t.output.precheck

# we need --force-reuse-version because t-expect-push-fail-tainted-new
# tries again with --force-push-tainted, making actual tags etc.
t-dgit push-source --trust-changelog --untaint-history \
       --force-reusing-version

t-ok
