Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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

This comment has been minimized.

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