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

: "prepare a package with a carefully simulated upstream tarball"

t-archive-none example
t-git-none
t-worktree 1.0

cd $p
git rm -rf debian
git checkout --orphan upstream
git commit -m 'Fresh upstream for testing'
git tag v1.0

git checkout master
git merge -s ours --allow-unrelated-histories upstream

mkdir -p debian/source
echo 1.0 debian/source/format
echo "-sk" >debian/source/options
git add debian/source
git commit -m 'Set source format 1.0 to non-native'

v=1.0-1
t-dch-commit -D unstable -v $v -m Upload

# We generate a "strange" orig, so if we accidentally regenerate it
# the tests will fail.
GZIP=-2 ${DGIT_DEBORIG_TEST-git deborig}

# And we make an upstream signature to check that it gets plumbed through
cd ..
origtar=${p}_${v%-*}.orig.tar.gz
gpg -u Hannibal --detach-sign --armor $origtar

t-setup-done 'v origtar' "git mirror aq $p $origtar $origtar.asc" "
	t-select-package $p
"
