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

# Autogenerated by pycargoebuild 0.15.1

EAPI=8

CRATES="
"

declare -A GIT_CRATES=(
	[gpui-ce-macros]='https://github.com/Havunen/gpui-ce;1679dc543d880e6562d84afe316a1b192a064b08;gpui-ce-%commit%/tooling/macros'
	[gpui-ce]='https://github.com/Havunen/gpui-ce;1679dc543d880e6562d84afe316a1b192a064b08;gpui-ce-%commit%'
	[libmimalloc-sys]='https://github.com/eduDorus/mimalloc_rust;262fb407466952bf6ebaf4a5d586c3010396cb2f;mimalloc_rust-%commit%/libmimalloc-sys'
	[mimalloc]='https://github.com/eduDorus/mimalloc_rust;262fb407466952bf6ebaf4a5d586c3010396cb2f;mimalloc_rust-%commit%'
	[naga]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/naga'
	[tree-sitter-gitcommit]='https://github.com/zed-industries/tree-sitter-git-commit;88309716a69dd13ab83443721ba6e0b491d37ee9;tree-sitter-git-commit-%commit%'
	[tree-sitter-gomod]='https://github.com/camdencheek/tree-sitter-go-mod;2e886870578eeba1927a2dc4bd2e2b3f598c5f9a;tree-sitter-go-mod-%commit%'
	[tree-sitter-gowork]='https://github.com/zed-industries/tree-sitter-go-work;acb0617bf7f4fda02c6217676cc64acb89536dc7;tree-sitter-go-work-%commit%'
	[tree-sitter-md]='https://github.com/tree-sitter-grammars/tree-sitter-markdown;9a23c1a96c0513d8fc6520972beedd419a973539;tree-sitter-markdown-%commit%'
	[wgpu-core-deps-apple]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-core/platform-deps/apple'
	[wgpu-core-deps-emscripten]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-core/platform-deps/emscripten'
	[wgpu-core-deps-windows-linux-android]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-core/platform-deps/windows-linux-android'
	[wgpu-core]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-core'
	[wgpu-hal]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-hal'
	[wgpu-naga-bridge]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-naga-bridge'
	[wgpu-types]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu-types'
	[wgpu]='https://github.com/zed-industries/wgpu;a466bc382ea747f8e1ac810efdb6dcd49a514575;wgpu-%commit%/wgpu'
	[xim-ctext]='https://github.com/zed-industries/xim-rs;16f35a2c881b815a2b6cdfd6687988e84f8447d8;xim-rs-%commit%/xim-ctext'
	[xim-parser]='https://github.com/zed-industries/xim-rs;16f35a2c881b815a2b6cdfd6687988e84f8447d8;xim-rs-%commit%/xim-parser'
	[zed-font-kit]='https://github.com/zed-industries/font-kit;110523127440aefb11ce0cf280ae7c5071337ec5;font-kit-%commit%'
	[zed-xim]='https://github.com/zed-industries/xim-rs;16f35a2c881b815a2b6cdfd6687988e84f8447d8;xim-rs-%commit%'
)

RUST_MIN_VER="1.94.0"

inherit cargo desktop wrapper xdg

MY_PN="GitComet"
MY_P=${MY_PN}-${PV}

DESCRIPTION="GitComet is user interface for GIT workflows"
HOMEPAGE="
	https://gitcomet.dev/
	https://github.com/Auto-Explore/GitComet
"
SRC_URI="
	https://github.com/Auto-Explore/GitComet/archive/refs/tags/v${PV}.tar.gz -> ${P}.tar.gz
	https://github.com/dsafxP/gentoo-distfiles/releases/download/${P}/${P}-crates.tar.xz
	${CARGO_CRATE_URIS}
"

S="${WORKDIR}/${MY_P}/crates/${PN}"

LICENSE="AGPL-3"
# Dependent crate licenses
LICENSE+="
	Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD Boost-1.0
	CC0-1.0 ISC MIT MPL-2.0 UoI-NCSA Unicode-3.0 ZLIB
"
SLOT="0"
KEYWORDS="~amd64"

DEPEND="dev-libs/libgit2:="
RDEPEND=">=dev-vcs/git-2.50.1"

src_prepare() {
	default

	local MIMALLOC_COMMIT="262fb407466952bf6ebaf4a5d586c3010396cb2f"
	local WORKSPACE="${WORKDIR}/mimalloc_rust-${MIMALLOC_COMMIT}"
	local VENDOR="${ECARGO_VENDOR}/libmimalloc-sys"

	# overwrite the broken c_src in the workspace
	rm -rf "${WORKSPACE}/libmimalloc-sys/c_src/mimalloc/v3" || die
	cp -r "${VENDOR}/c_src/mimalloc/v3" "${WORKSPACE}/libmimalloc-sys/c_src/mimalloc/v3" || die
}

src_configure() {
	export LIBGIT2_NO_VENDOR=1
	local myfeatures=(
		ui
		gix
	)
	cargo_src_configure --bin gitcomet # gitcomet-launcher unsupported in linux
}

src_install() {
	cargo_src_install

	dodir /usr/libexec/${PN}

	mv "${ED}/usr/bin/${PN}" "${ED}/usr/libexec/${PN}/" || die

	# prevents auto install of desktop & icons locally
	make_wrapper ${PN} "env GITCOMET_NO_DESKTOP_INSTALL=1 ${EPREFIX}/usr/libexec/${PN}/${PN}"

	cd "${WORKDIR}/${MY_P}" || die

	local DOCS=(
		README.md
		CONTRIBUTING.md
		NOTICE
		docs
	)

	einstalldocs

	domenu assets/linux/${PN}.desktop

	local x
	for x in 32 48 128 256 512; do
		doicon -s ${x} assets/linux/hicolor/${x}*/apps/*
	done

	newicon -s scalable assets/${PN}_logo.svg ${PN}.svg
}