Created
April 11, 2022 12:09
-
-
Save cristobal/2a78398ec4e291070e4c7c9699860a2f to your computer and use it in GitHub Desktop.
Find git commit when a package was introduced in the package.json file in a git repo.
This file contains 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
prev_cmt="" | |
for cmt in $(git lg package.json | awk '{print $2}'); | |
do | |
git co $cmt >/dev/null 2>&1 | |
cat package.json | grep 'package-name' >/dev/null 2>&1 | |
# will fail if does not find the package-name in the current commit | |
if [ $? -ne 0 ] ; then | |
echo "cmt: $cmt" | |
echo "prev_cmt: $prev_cmt" | |
git co main | |
break; | |
fi | |
# store the last seen commit | |
prev_cmt=$cmt | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment