# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=gitui
pkgver=0.26.3
pkgrel=1
pkgdesc="Blazing fast terminal client for git"
url="https://github.com/extrawurst/gitui"
arch="all"
license="MIT"
makedepends="
	cargo
	cargo-auditable
	libgit2-dev
	oniguruma-dev
	openssl-dev
	zlib-dev
	"
source="https://github.com/extrawurst/gitui/archive/v$pkgver/gitui-$pkgver.tar.gz
	libgit2-0.18.patch
	"
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="
9cf160bf9f85211797096c0b18247d9ff1ac774b234d4c3622964b2ca7c856d5190a7a391824d7a431e4bfb15fe28a6ae84e3d44fcdb6889effc014e8ecfc8c0  gitui-0.26.3.tar.gz
5a19b5f863ff678ed2dc9f77f80b2b5fd9592ee7cd995e123089cf8eacefc3b0b949bacf08555daacac70d3c54c156e469dbb8ab743cb8fdd63f2edc479137f9  libgit2-0.18.patch
"
