#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.31.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  c6f38e0d77013d1b5dcf1af28b741e2a71ff635d \
                    sha256  7f3a04e19381b00cde566627382b4cc0fcf9c5fc08722ea6b965d9fb3b0be7ed \
                    size    1999185

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'
"
