# Contributor: Thomas Kienlen <kommander@laposte.net>
# Maintainer: Thomas Kienlen <kommander@laposte.net>
pkgname=git-bug
pkgver=0.8.1
pkgrel=1
pkgdesc="Distributed, offline-first bug tracker embedded in git, with bridges"
url="https://github.com/MichaelMure/git-bug"
# loongarch64: blocked by bbolt
arch="all !loongarch64"
license="GPL-3.0-or-later"
makedepends="
	go
	npm
	"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	$pkgname-fish-completion
	"
source="
	git-bug-$pkgver.tar.gz::https://github.com/MichaelMure/git-bug/archive/v$pkgver.tar.gz
	"
options="net"

export GIT_COMMIT=v$pkgver
export GIT_LAST_TAG=v$pkgver
export GIT_EXACT_TAG=v$pkgver

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

prepare() {
	default_prepare

	npm ci --prefix webui
}

build() {
	make pack-webui
	make
}

check() {
	make test
	cd webui
	make test
}

package() {
	install -Dm755 git-bug "$pkgdir"/usr/bin/git-bug

	install -Dm 644 misc/completion/bash/git-bug "$pkgdir"/usr/share/bash-completion/completions/git-bug
	install -Dm 644 misc/completion/fish/git-bug "$pkgdir"/usr/share/fish/vendor_completions.d/git-bug.fish
	install -Dm 644 misc/completion/zsh/git-bug "$pkgdir"/usr/share/zsh/site-functions/_git-bug

	install -Dm 644 doc/man/*.1 -t "$pkgdir"/usr/share/man/man1
}

sha512sums="
d19d07f6827831c9e23de086201dd1cc39f4f4f2d45c728e7fa63a12d57498ef7bd879fda1a87117470d9d9d3c7b921ae2499877b48e6a8ef25e78ad140c85d4  git-bug-0.8.1.tar.gz
"
