# Contributor: Carlo Landmeter <clandmeter@alpinelinux.org>
# Maintainer: Carlo Landmeter <clandmeter@alpinelinux.org>
pkgname=lab
pkgver=0.25.1
pkgrel=21
pkgdesc="Git Wrapper for GitLab"
url="https://zaquestion.github.io/lab/"
arch="all"
license="CC0-1.0"
depends="git"
makedepends="go"
checkdepends="bash"
subpackages="
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="lab-$pkgver.tar.gz::https://github.com/zaquestion/lab/archive/v$pkgver.tar.gz
	update-go-mod.patch
	"
options="net !check chmod-clean" # Tests require configured GitLab account with SSH keys

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build -ldflags "-X main.version=$pkgver" -o bin/$pkgname
	./bin/lab completion bash > lab.bash
	./bin/lab completion zsh > _lab.zsh
	./bin/lab completion fish > lab.fish
}

package() {
	install -Dm755 "$builddir"/bin/$pkgname \
		"$pkgdir"/usr/bin/$pkgname
	install -Dm644 "$builddir"/lab.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 "$builddir"/_lab.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
	install -Dm644 "$builddir"/lab.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
}

sha512sums="
891605f0572c9deff27b5583782b59361fd99a2559f9ac84a77f9a9d323ba54b97ac79bfed4ea63e8a421e38a63b3ea713a67c42ecd45ca895d29b2f826e8859  lab-0.25.1.tar.gz
0fe48eab9285fd36f04cda639f2c81e0242778ba0d9e47563510140968d93e412e208af99ea54b0dcb3df9d72d15443a3bdd266acadeb84925910d10048b4339  update-go-mod.patch
"
