# Copyright 2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

CRATES="
"

RUST_MIN_VER="1.85.0"
inherit cargo shell-completion

DESCRIPTION="Real-time co-editing of local text files."
HOMEPAGE="https://teamtype.github.io/teamtype/"
SRC_URI="https://github.com/teamtype/teamtype/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz"
SRC_URI+=" https://raw.githubusercontent.com/PPN-SD/vendor/refs/tags/${P}/${P}-crates.tar.xz"
S="${WORKDIR}/${P}/daemon"

LICENSE="AGPL-3+"
# ring licenses
LICENSE+=" openssl"
# Autogenerated by pycargoebuild
# Dependent crate licenses
LICENSE+="
	Apache-2.0 BSD CC0-1.0 CDLA-Permissive-2.0 EUPL-1.2 GPL-3 ISC MIT
	MPL-2.0 Unicode-3.0 Unlicense ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

QA_FLAGS_IGNORED="usr/bin/teamtype"

DEPEND="dev-libs/libgit2:="
RDEPEND="${DEPEND}"

src_prepare() {
	default
	sed -i -e '/^lto =/d' -e 's/^strip = true$/strip = false/g' Cargo.toml || die "failed to sed Cargo.toml"
}

src_install() {
	cargo_src_install

	local DOCS=( "${WORKDIR}"/${P}/{CHANGELOG,README}.md )
	einstalldocs

	doman target/manpages/*.1

	dobashcomp target/completions/${PN}.bash
	dofishcomp target/completions/${PN}.fish
	dozshcomp target/completions/_${PN}
}