Skip to content

Instantly share code, notes, and snippets.

@nyarly
Created August 27, 2014 22:57
Show Gist options
  • Save nyarly/0348b925ad1572777ba4 to your computer and use it in GitHub Desktop.
Save nyarly/0348b925ad1572777ba4 to your computer and use it in GitHub Desktop.
#!/bin/env bash
file=$1
source=$2
commit_sha=$3
echo $file
echo $source
#exit if source == 'commit'
if [ "${source}" == "commit" ]; then
exit 0
fi
path=$(git symbolic-ref HEAD)
if [ ! $? ]; then
exit 0
fi
current=$(echo $path | sed 's#refs/heads/##')
echo $current
numbers=$(echo $current | sed 's#[^0-9]\+# #')
echo $numbers
if echo $numbers | egrep -q '[0-9]'; then
echo -n ""
else
exit 0
fi
#if egrep "^[^#].*\[(\w+\s)?(#\d+\s)*#$number(\s#\d+)*(\s\w+)?\]" $file; then
# exit 0
#fi
keyword_re="\[(fix|fixes|fixed|complete|completes|completed|finish|finishes|finished|deliver|delivers|delivered)\]"
cat $file
keyword=$(egrep $keyword_re $file | sed "s#.*\($keyword_re\).*#\1#")
echo $keyword
pivotal_tag="["
for number in $keyword $numbers; do
pivotal_tag+=" #$number"
done
pivotal_tag+=" ]"
echo $pivotal_tag
awk "/^#/ && !x {print \"$pivotal_tag\"; x=1} 1" $file > $file.tmp
mv $file.tmp $file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment