#!/usr/bin/env bash
set -e
# this post commit git hook is based on the believe that obsolete automation
# is noise, but needed automation is lean - aka it provides the convinience
# for the developer to copy paste the hook produced message into the issue
# handling system
# in the this case the issue handling system is pivotal tracker
commit=$(git log -1 --pretty="%H%n%ci") # hash \n date
commit_hash=$(echo "$commit" | head -1)
commit_shash=$(git log -1 --pretty="%h")
commit_date=$(echo "$commit" | head -2 | tail -1) # 2017-11-28 02:16:23 +0300
commit_base_url="https://code.company.com/customer-case/project-name/commit"
branch_name=$(git branch -a | grep '*'| cut -c 3-)
# dump it
echo -e " to add the this commit as a pivotal tracker comment wih link : \n"
echo -e " START COPY FROM HERE \n"
echo -e "[git checkout $branch_name ; git show $commit_shash]($commit_base_url/$commit_hash)\n"
echo -e " STOP COPY TILL HERE"