Skip to content

Instantly share code, notes, and snippets.

@antfroger
Last active August 22, 2017 09:25
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 antfroger/42a6bbe278e47ffe144c7a48eb2ea726 to your computer and use it in GitHub Desktop.
Save antfroger/42a6bbe278e47ffe144c7a48eb2ea726 to your computer and use it in GitHub Desktop.
Git grep in all merges/commits into the current branch since a specific date
#!/usr/bin/env bash
if [ $# -eq 0 ]
then
self=$(basename $0)
echo "Usage: $self pattern directory"
exit 1
fi
pattern=$1
since="--since=2015-12-01"
for revision in `git --no-pager log $since --first-parent --grep="Merge pull request" --format="%H"`
do
timestamp=`git --no-pager log --format='%at' -n 1 $revision`
count=`git --no-pager grep --extended-regexp $pattern $revision | wc -l | tr -d '[[:space:]]'`
echo $revision,$timestamp,$count
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment