#k_script -*- 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            github.com/thoughtworks/talisman 1.37.0 v
go.package          talisman
revision            0

homepage            https://thoughtworks.github.io/talisman

description         Git-hook utility to protect from committing sensitive \
                    information.

long_description    Talisman is a tool that installs a hook to your \
                    repository to ensure that potential secrets or sensitive \
                    information do not leave the developer's workstation. It \
                    validates the outgoing changeset for things that look \
                    suspicious - such as potential SSH keys, authorization \
                    tokens, private keys etc. Talisman can also be used as a \
                    repository history scanner to detect secrets that have \
                    already been checked in, so that you can take an informed \
                    decision to safeguard secrets.

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

build.pre_args-append \
    -ldflags=\"-s -w -X main.Version=v${version}\" \
    -o ${worksrcpath}/${name}_${goos}_${goarch}
build.args-append   ${name}/cmd

set tlsman_bin_path     ${prefix}/bin/${name}
set tlsman_hook_path    ${prefix}/libexec/${name}

patch {
    reinplace -E "s|^(shopt.*)|\\1\\\n\\\nTALISMAN_BINARY=\\\"${tlsman_bin_path}\\\"|" \
        ${worksrcpath}/global_install_scripts/talisman_hook_script.bash

    reinplace {s|^check_and_upgrade_talisman_binary|#check_and_upgrade_talisman_binary|g} \
        ${worksrcpath}/global_install_scripts/talisman_hook_script.bash
}

destroot {
    xinstall -m 0755 \
        ${worksrcpath}/${name}_${goos}_${goarch} ${destroot}${tlsman_bin_path}

    xinstall -d ${destroot}${tlsman_hook_path}
    xinstall -m 0755 \
        ${worksrcpath}/global_install_scripts/talisman_hook_script.bash \
        ${destroot}${tlsman_hook_path}/talisman_hook_script.bash
}

go.offline_build no

checksums           rmd160  46f83fb025c9c1845aeb94e80544907074fe2c35 \
                    sha256  40f9ab7d43fadf75abe7a4d71fac5ff083f71b63afada282146827725460d2d1 \
                    size    1998596

notes "
  To install Talisman to a given Git repo, you can do:

  $ cd <repo_dir>
  $ mkdir .git/hooks
  $ ln -s ${tlsman_hook_path}/talisman_hook_script.bash .git/hooks/<hook_type>

  ...where <hook_type> is either 'pre-push' or 'pre-commit'
"
