#!/bin/sh

set -e

. ./helpers.sh

# Running pkgos-modernize a second time on an already modern package
# must do nothing at all.

set_stub_rmadison "" 0
make_fixture "1.0.0-1" unstable "openstack-pkg-tools" \
	"UPSTREAM_GIT := https://github.com/openstack/openstack-pkg-tools.git"

run_modernize
assert_eq "first run" "${MODERNIZE_RC}" "0"
HEAD1=$(git rev-parse HEAD)
CHANGELOG1=$(md5sum debian/changelog)

run_modernize
assert_eq "second run" "${MODERNIZE_RC}" "0"
assert_eq "no new commit" "$(git rev-parse HEAD)" "${HEAD1}"
assert_eq "changelog untouched" "$(md5sum debian/changelog)" "${CHANGELOG1}"
assert_eq "clean tree" "$(git status --porcelain | wc -l)" "0"
assert_contains "all done" "${OUT}" "All done."

exit 0
