# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=gitui
pkgver=0.27.0
pkgrel=0
pkgdesc="Blazing fast terminal client for git"
url="https://github.com/extrawurst/gitui"
arch="all"
license="MIT"
makedepends="
	cargo
	cargo-auditable
	cmake
	libgit2-dev
	oniguruma-dev
	openssl-dev
	zlib-dev
	"
source="https://github.com/extrawurst/gitui/archive/v$pkgver/gitui-$pkgver.tar.gz"
options="net"  # cargo fetch

export LIBGIT2_NO_VENDOR=1  # use system libgit2
export LIBSSH2_SYS_USE_PKG_CONFIG=1  # use system libssh2
export RUSTONIG_DYNAMIC_LIBONIG=1  # use system libonig

# the p521 crate fails to compile with thread 'opt cgu.0' has overflowed its stack
# Unless the RUST_MIN_STACK is expanded
# https://github.com/RustCrypto/elliptic-curves/issues/1097
export RUST_MIN_STACK=$((16 * 1024 * 1024))

_cargo_opts="--frozen --no-default-features --features regex-onig"

prepare() {
	default_prepare

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

build() {
	cargo auditable build $_cargo_opts --release
}

check() {
	cargo test $_cargo_opts
}

package() {
	install -D -m755 target/release/gitui "$pkgdir"/usr/bin/gitui
}

sha512sums="
7e299b7045b116779eb3b0ee2cc71fb07664174d53c171a1c36a9cf0b5e1cb36143ec29417a39f462e46b3504d9952a4269aa08dc8643987966274401a831b5e  gitui-0.27.0.tar.gz
"
