maintainer="Michał Polański <michal@polanski.me>"
pkgname=git-warp-time
pkgver=0.8.5
pkgrel=0
pkgdesc="Reset timestamps of Git repository files to the time of the last modifying commit"
url="https://github.com/alerque/git-warp-time"
license="GPL-3.0-only"
arch="all"
makedepends="cargo cargo-auditable libgit2-dev"
subpackages="$pkgname-bash-completion $pkgname-fish-completion $pkgname-zsh-completion"
source="https://github.com/alerque/git-warp-time/archive/v$pkgver/git-warp-time-$pkgver.tar.gz"
options="net" # cargo fetch

export LIBGIT2_NO_VENDOR=1  # use system libgit2

prepare() {
	default_prepare

	# Doc-tests from README.md expect to be ran in a Git repository
	git init -q .
	git config --local user.name "example"
	git config --local user.email "example@example.com"
	git add .
	git commit -q -m "init"

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/$pkgname -t "$pkgdir"/usr/bin/

	# shell completions
	find target/release -name $pkgname.bash \
		-exec install -Dm644 {} "$pkgdir"/usr/share/bash-completion/completions/$pkgname \;
	find target/release -name $pkgname.fish \
		-exec install -Dm644 {} "$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish \;
	find target/release -name _$pkgname \
		-exec install -Dm644 {} "$pkgdir"/usr/share/zsh/site-functions/_$pkgname \;
}

sha512sums="
99c2dbd211e48163c37d9fe190f9440b67cede3cc431d58a6841cb509ee9bce402175fae6d1e19f5e3401bdcbd4294a3e1f6825e56e5ff2cafc152a9740f164c  git-warp-time-0.8.5.tar.gz
"
