#!/usr/bin/make -f

export PYBUILD_NAME=semantic-release
export PYBUILD_TEST_PYTEST=1
export PYBUILD_BEFORE_TEST=cd {build_dir}; git -c init.defaultBranch=master init
export PYBUILD_AFTER_TEST=rm -rf {build_dir}/.git/

%:
	dh $@ --buildsystem=pybuild

override_dh_auto_build:
	dh_auto_build $@ --buildsystem=pybuild
	cd docs; PYTHONPATH=.. make man; PYTHONPATH=.. LC_ALL=C.UTF-8 LANGUAGE=C.UTF-8 sphinx-build -bhtml . _build/html

execute_after_dh_auto_install:
	mv -v debian/python3-semantic-release/usr/bin/semantic-release debian/python3-semantic-release/usr/bin/python-semantic-release

override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	$(eval BUILD_DIR=$(shell pybuild --print '{build_dir}'))
	for dir in $(BUILD_DIR); do \
		cp -r tests $$dir ; \
	done
	dh_auto_test
	for dir in $(BUILD_DIR); do \
		rm -r $$dir/tests ; \
	done
endif
