Skip to content

Instantly share code, notes, and snippets.

@divmain
Created March 9, 2016 23:52
Show Gist options
  • Save divmain/144e9c18d3e5bfadd1e4 to your computer and use it in GitHub Desktop.
Save divmain/144e9c18d3e5bfadd1e4 to your computer and use it in GitHub Desktop.
Find commits where `package.json` version was bumped.
filename="package.json"
pattern=' "version": "([0-9]+\.[0-9]+\.[0-9]+).*'
git log --pretty="format:%H" -- package.json | {
while read current_hash; do
if [ -n "$previous_hash" ]; then
new_version=`git diff $previous_hash $current_hash -- $filename | sed -n -E -e "s/^\-$pattern/\1/p"`
if [ -n "$new_version" ]; then
echo version bumped to $new_version with $previous_hash
fi
fi
previous_hash="$current_hash"
done
new_version=`git diff $previous_hash $current_hash -- $filename | sed -n -E -e "s/^\-$pattern/\1/p"`
echo version bumped to $new_version with $previous_hash
original_version=`git show $current_hash:$filename | sed -n -E -e "s/^$pattern/\1/p"`
if [ -n "$original_version" ]; then
echo "original version was $original_version"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment