Skip to content

Instantly share code, notes, and snippets.

@dafurman
Created February 4, 2024 02:45
Show Gist options
  • Save dafurman/04c318fe8735049e0a6949977c002a42 to your computer and use it in GitHub Desktop.
Save dafurman/04c318fe8735049e0a6949977c002a42 to your computer and use it in GitHub Desktop.
Count lines changed in PRs
#!/bin/zsh
# Put this the repo you want to examine
if [ $# -eq 0 ]; then
echo "Please provide PR numbers as arguments."
exit 1
fi
prs=("$@")
totalLines=0
for pr in "${prs[@]}"; do
lines=$(gh pr diff "$pr" | diffstat | awk '{ total += $4 + $6 } END { print total }')
echo "lines changed for $pr: $lines"
((totalLines += lines))
done
echo "Total lines changed for all prs: $totalLines"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment