Skip to content

Instantly share code, notes, and snippets.

View wytrych's full-sized avatar

Marcin Wolniewicz wytrych

View GitHub Profile
@wytrych
wytrych / pr-bot.sh
Last active February 12, 2018 14:07
A script finding merge commits between two latest tags and posting them to slack.
#!/bin/sh
HOOK_URL=<SLACK_HOOK_URL>
CHANNEL=<TARGET_CHANNEL>
REPO_NAME=`git config --get remote.origin.url | awk 'match($0,/\/([a-zA-Z1-9-]*)/) {print substr($0,RSTART+1,RLENGTH-1)}'`
REPO_URL=`git config remote.origin.url | sed 's/.*@\(.*\)\.git/\1/g' | sed 's/:/\//'`/pull
ESCAPED_REPO_URL=`echo $REPO_URL | sed 's/\//\\\\\//g'` #so many slashes!
read a b <<< $(git tag -l --sort=version:refname "v*" | tail -2)
read PULL_REQUESTS <<< $(git log --oneline $a...$b | grep "pull request" | awk 'match($0,/#[0-9]*/) {print substr($0,RSTART,RLENGTH)}')
PRS_WITH_LINKS=`echo $PULL_REQUESTS | sed -E "s/#([0-9]*)([ ]|$)/<https:\/\/$ESCAPED_REPO_URL\/\1|&> /g"`
https://giphy.com/gifs/rainbow-timelapse-fUDsTIDbCn2Vy