#!/usr/bin/make -f

include /usr/share/dpkg/pkg-info.mk

%:
	dh $@

# Upstream's t/run.sh only picks up test scripts whose mode is exactly
# 755, which silently skips everything when the tree is unpacked with a
# different umask, so run each test through a helper instead.
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
	debian/tests/run-upstream-tests $(CURDIR)/git-assembler
endif

override_dh_installchangelogs:
	dh_installchangelogs NEWS.rst

# Generate man page from the --help/--version output with help2man.
# Widen the terminal so that argparse does not wrap the usage line,
# which help2man would otherwise split into separate paragraphs.
ifeq (,$(filter nodoc,$(DEB_BUILD_PROFILES)))
execute_after_dh_auto_build:
	COLUMNS=1000 help2man \
		--no-info \
		--section=1 \
		--version-string=$(DEB_VERSION_UPSTREAM) \
		--name='update git branches using high-level instructions' \
		--include=debian/git-assembler.h2m \
		--output=debian/git-assembler.1 \
		./git-assembler
endif
