# Copyright 1999-2025 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit git-r3 go-module

DESCRIPTION="Environment variable manager for shell"
HOMEPAGE="https://github.com/direnv/direnv"
EGIT_REPO_URI="https://github.com/direnv/${PN}.git"

LICENSE="MIT"
SLOT="0"
IUSE="test"
RESTRICT="!test? ( test )"

BDEPEND="test? ( || ( dev-util/shellcheck-bin dev-util/shellcheck ) )"

DOCS=( {CHANGELOG,README}.md )

src_prepare() {
	default

	# remove tests require various shells
	sed -i  -e '/\tshellcheck /s|check |check -e SC2329 |' \
		-e '/test-go-lint /d' \
		-e '/test-elvish /d' \
		-e '/test-fish /d' \
		-e '/test-tcsh /d' \
		-e '/test-zsh /d' \
		-e '/test-pwsh /d' \
		-e '/test-mx$/d' GNUmakefile || die "sed failed for GNUmakefile"
}

src_install() {
	einstalldocs
	emake DESTDIR="${D}" PREFIX="/usr" install
}