Last active
January 31, 2018 20:36
-
-
Save mark-sch/327d17f35424e6060713943f3a2756d8 to your computer and use it in GitHub Desktop.
Monitor GIT remote commits and send out pretty diff e-mails, e.g. for use as a daily cron to monitor fork parents on github. It uses https://github.com/git-commit-notifier/git-commit-notifier and feeds it with the wanted params.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| #my git clone to monitor with remote upstream | |
| cd /git/ediabaslib/ | |
| git fetch upstream | |
| #get all commits from this remote from the last 1 day | |
| git log upstream/master --pretty=format:"%h" --since="1 day ago" > commits.today | |
| #latest commit | |
| myhead="$(head -n 1 commits.today)" | |
| #first commit from last day | |
| mytail="$(tail -n 1 commits.today)" | |
| # we need the ancestor of mytail to get a proper commit range | |
| git rev-list --parents -n 2 $mytail --pretty=format:"%h" > commits.today | |
| mytail="$(tail -n 1 commits.today)" | |
| if [ "$myhead" != "" ]; then | |
| echo "Got new commits for today, processing..." | |
| source /usr/local/rvm/environments/ruby-2.4.1 | |
| /usr/local/rvm/gems/ruby-2.4.1/bin/git-commit-notifier /scripts/git-commit-notifier-config.yml $mytail $myhead refs/heads/master | |
| rm commits.today | |
| else | |
| echo "No new commits for today, skip notifications..." | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment