maintainer="Hoang Nguyen <folliekazetani@protonmail.com>"
pkgname=ghq
pkgver=1.8.0
pkgrel=1
pkgdesc="CLI to manage remote repository clones"
url="https://github.com/x-motemen/ghq"
arch="all"
license="MIT"
makedepends="asciidoctor go"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/x-motemen/ghq/archive/refs/tags/v$pkgver.tar.gz"

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

build() {
	go build -v -ldflags "-X main.revision=AlpineLinux"

	sed -i '1 s/^.*$/= ghq(1)/' README.adoc
	asciidoctor -b manpage README.adoc
}

check() {
	go test ./...
}

package() {
	install -Dm755 ghq -t "$pkgdir"/usr/bin/

	install -Dvm644 ghq.1 -t "$pkgdir"/usr/share/man/man1/
	install -Dvm644 LICENSE -t "$pkgdir"/usr/share/licenses/$pkgname/

	install -Dm644 misc/bash/_ghq \
		"$pkgdir"/usr/share/bash-completion/completions/ghq
	install -Dm644 misc/fish/ghq.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/ghq.fish
	install -Dm644 misc/zsh/_ghq \
		"$pkgdir"/usr/share/zsh/site-functions/_ghq
}

sha512sums="
807f3a06af8614561a604ae2c3a0f2a0a7565b26a7e76067e7efd3ce93fe112cadb1f36f054144bf4ed97a85a0d6a13d07baa3b74b264448a01f22f28161ad88  ghq-1.8.0.tar.gz
"
