# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           golang 1.0

go.setup            gitea.com/gitea/tea 0.15.1 v
go.package          gitea.dev/tea
go.offline_build    no
go.toolchain_min    1.26
name                gitea-tea
revision            1

homepage            https://code.gitea.io/tea

description         A command line tool to interact with Gitea servers

long_description    {*}${description}. tea is the official CLI for Gitea. \
                    It can be used to manage most entities on one or multiple \
                    Gitea instances and provides local helpers like \'tea \
                    pull checkout\'. tea makes use of context provided by \
                    the repository in \$PWD if available, but is still usable \
                    independently of \$PWD.

categories          devel
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

checksums           rmd160  d5887447765734c450ec5042042b059e6b102a8f \
                    sha256  e242dd3589c31a36320d75e0de9eefa3fa429bd9b0af89d35af8585c7f514b9c \
                    size    843088

# Upstream's Makefile only wraps go build, so the portgroup drives it directly
# here. .goreleaser.yaml, which produces the release binaries, additionally
# passes -trimpath; the Makefile omits it.
#
# SDK is the gitea.dev/sdk version from go.mod, which the Makefile derives with
# `go list -m`. Recheck it on every update.
build.pre_args-append \
                    -trimpath \
                    -ldflags \" \
                        -X ${go.package}/modules/version.Version=${version} \
                        -X ${go.package}/modules/version.SDK=v1.2.0 \
                    \"

build.args-append   -o tea

destroot {
    xinstall -m 0755 ${worksrcpath}/tea ${destroot}${prefix}/bin/

    set zsh_comp_dir ${prefix}/share/zsh/site-functions
    xinstall -d ${destroot}/${zsh_comp_dir}
    xinstall -m 0644 ${worksrcpath}/contrib/autocomplete.zsh \
        ${destroot}${zsh_comp_dir}/_tea

    set bash_comp_dir ${prefix}/share/bash-completion/completions
    xinstall -d ${destroot}${bash_comp_dir}
    xinstall -m 0644 ${worksrcpath}/contrib/autocomplete.sh \
        ${destroot}${bash_comp_dir}/tea
}
