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

github.setup            gitkraken gk-cli 3.1.42 v
name                    gk
github.tarball_from     releases

categories              devel
license                 CCBY-3
installs_libs           no
maintainers             {@sergiolms}\
                        openmaintainer

supported_archs         x86_64 arm64

description             Official CLI for GitKraken
long_description        ${name} is GitKraken on the command line. It makes working across multiple \
                        repos easier with Workspaces, provides access to pull requests and \
                        issues from multiple services (GitHub, GitLab, Bitbucket, etc.), \
                        and seamlessly connects with GitKraken Client and GitLens in VS Code \
                        to visualize git information when you need it.

if {${build_arch} eq "x86_64"} {
    # file name is "amd64" for x86_64
    set arch_filename   amd64
    checksums           rmd160  78d2e11ad9272c9bb4dbdb7c737d56b8ad1e8ad9 \
                        sha256  397f14b11b83f76fd21ccbbf45533459d20786cf7b6aa224e9c1c2d9d7ce94bf \
                        size    7616475
} else {
    # arm64
    set arch_filename ${build_arch}
    checksums           rmd160  1c96af52deede24b0d516b5f5ab5034e1f328406 \
                        sha256  a0dfd41e12309e658f05f6314d3b500e8b2dc81a1b39ee4976c90785aa35ec83 \
                        size    7067659
}

distfiles               ${name}_${version}_darwin_${arch_filename}.zip
extract.mkdir           yes
use_zip                 yes

use_configure           no
build                   {}

destroot {
    xinstall -m 0755 ${worksrcpath}/gk ${destroot}${prefix}/bin
    # All supported shells: bash, fish, powershell, zsh
    set comp_path(bash) ${destroot}${prefix}/share/bash-completion/completions/${name}
    set comp_path(fish) ${destroot}${prefix}/share/fish/completions/${name}.fish
    set comp_path(zsh)  ${destroot}${prefix}/share/zsh/site-functions/_${name}
    foreach shell {bash fish zsh} {
        xinstall -d [file dirname $comp_path(${shell})]
        system -W ${worksrcpath} "./${name} completion ${shell} > $comp_path(${shell})"
    }
}

github.livecheck.regex  {([0-9.]+)}
