#!/usr/bin/make -f
# -*- makefile -*-

export HOME=$(CURDIR)/build/test

override_dh_installdocs:
	dh_installdocs -Xjquery.js -X_sources

%:
	dh $@ --with python2

override_dh_auto_test:
	: # run tests only if we can fetch original sources repository
	-mkdir -p build/test; cd build/test; \
         git config --global http.sslVerify false; git config --global user.name "TESTING"; git config --global user.email "TESTING@example.com"; \
         git clone git://github.com/gitpython-developers/GitPython; \
         cd GitPython; git submodule update --init --recursive; \
          for i in `seq 4`; do git reset --hard HEAD~1; done; git reset --hard origin/master; touch ../go
	[ ! -e build/test/go ] || \
     LC_ALL=C.UTF-8 \
     GIT_PYTHON_TEST_GIT_REPO_BASE=$(CURDIR)/build/test/GitPython \
	 nosetests -s -v git/test

override_dh_auto_clean:
	dh_auto_clean
	rm -f lib/GitPython.egg-info/SOURCES.txt
	rm -rf build

DOC_VERSION=$(shell dpkg-parsechangelog | sed -rne 's,^Version: ([^-]+).*,\1,p' | sed 's/~.*//')
UPSTREAM=$(shell dpkg-parsechangelog | sed -nr 's/Version: (.*)-[^-]*/\1/p')
get-orig-source:
	uscan --download-current-version
	wget -P get-orig-source http://packages.python.org/GitPython/$(DOC_VERSION)/docs_$(DOC_VERSION).zip
	mkdir get-orig-source/doc
	unzip -d get-orig-source/doc get-orig-source/docs_$(DOC_VERSION).zip
	tar -C get-orig-source -czvf python-git_$(UPSTREAM).orig-doc.tar.gz doc/
	rm -rf get-orig-source

