Skip to content

Instantly share code, notes, and snippets.

@mtyurt
Last active February 28, 2017 12:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mtyurt/730cada4a0a28f5f32972a92351d3984 to your computer and use it in GitHub Desktop.
Save mtyurt/730cada4a0a28f5f32972a92351d3984 to your computer and use it in GitHub Desktop.
#!/bin/bash -ex
sendSlackMsg(){
curl -X POST --data-urlencode "payload={\"channel\": \"$1\", \"attachments\": [{\"title\":\"Merged branches report:\", \"text\":\"$2\",\"mrkdwn_in\":[\"text\"]}], \"icon_emoji\":\":shipit:\"}" https://hooks.slack.com/services/incoming-webhook-url
}
#user-defined
cd $REPO
git fetch -a --prune
declare -a textArray
git branch -r --merged origin/master | \
awk '{branch=substr($1,8); if(branch!="HEAD" && branch!="master") {print branch}}' | {
while read branch; do
git fetch origin $branch
author=$(git log origin/$branch --format="%an" -n 1)
branchTxt='*'$branch'*, last committer: *'$author'*'
textArray+=("$branchTxt")
done
printf '%s\n' "${textArray[@]}" > branchtmp.out
}
text=$(cat branchtmp.out)
rm branchtmp.out
sendSlackMsg "#engineering" "$text"
@mtyurt
Copy link
Author

mtyurt commented Feb 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment