Skip to content

Instantly share code, notes, and snippets.

@tarilabs
Created February 2, 2023 13:06
Show Gist options
  • Save tarilabs/61a49f4402c5ad7c8fa9c177e7a490f0 to your computer and use it in GitHub Desktop.
Save tarilabs/61a49f4402c5ad7c8fa9c177e7a490f0 to your computer and use it in GitHub Desktop.
Check in the last year commits, the one having a patch diff containing modified line starting with `+import javax`
#!/bin/bash
# Collect all the commits since the current date
commits=$(git rev-list --since="1 year ago" --date=iso main)
# Set the global counter to 0
counter=0
# Iterate over the commits
for commit in $commits; do
echo "Checking "$(git show "$commit" --no-patch --oneline)" dated "$(git show -s --format=%ci "$commit")
if [ $(git show "$commit" | grep "^[+]import javax" | wc -l) -gt 0 ]; then
echo " Commit $commit does contain the grep"
counter=$((counter+1))
fi
done
# Display the counter value
echo "Counter: $counter"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment