# -*- 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           python 1.0

name                git-cola
version             4.18.2
revision            0

supported_archs     noarch
platforms           {darwin any}
categories-prepend  devel
maintainers         {raimue @raimue} \
                    openmaintainer
license             GPL-2+

description         The highly caffeinated Git GUI
long_description    git-cola is a powerful Git GUI with a slick and \
                    intuitive user interface.

distname            git_cola-${version}

checksums           rmd160  85a65fabc39e5f04720f5b8f40539e2be96d1e68 \
                    sha256  f1f1d9ddd33e6d319d2612b496b39cbf6ea300e5be0f305e1b4ae779236c6662 \
                    size    1391817

homepage            https://git-cola.github.io/

python.default_version 314

patchfiles          patch-pyqt-version.diff

variant qt5 conflicts qt6 description {Build with Qt 5} {
    post-patch {
        reinplace -W ${worksrcpath} -E "s/@@pyqt@@/pyqt5/" cola/app.py
    }

    depends_lib-append \
                    port:py${python.version}-pyqt5
}

variant qt6 conflicts qt5 description {Build with Qt 6} {
    post-patch {
        reinplace -W ${worksrcpath} -E "s/@@pyqt@@/pyqt6/" cola/app.py
    }

    depends_lib-append \
                    port:py${python.version}-pyqt6
}

if {${os.platform} eq "darwin" && ${os.major} < 18} {
    default_variants +qt5
} else {
    if {![variant_isset qt5]} {
        default_variants +qt6
    }
}

depends_build-append \
                    port:py${python.version}-setuptools_scm

depends_lib-append  port:git \
                    port:py${python.version}-qtpy \
                    port:py${python.version}-polib

post-destroot {
    xinstall -d ${destroot}${prefix}/share/bash-completion/completions
    xinstall -m 644 ${worksrcpath}/contrib/git-cola-completion.bash ${destroot}${prefix}/share/bash-completion/completions/${name}
}

notes "\
    If you want to use bash-completion for git-cola, you have to source the\
    completion files from your ~/.bashrc as it extends the git command\
    completion and cannot be loaded automatically:

      source ${prefix}/share/bash-completion/completions/git
      source ${prefix}/share/bash-completion/completions/git-cola
"
