How to get total number of lines of code (added and deleted) of a github user's pull requests to a certain github repo (optionally within a period of time)? Is there an easy way without writing code (or a hard way anyway)?
https://ossinsight.io/ is cool but it does not seem to have a way to run custom SQL query on the website.
CodePudding user response:
A possible approach (to be refined) would be to use the GitHub CLI gh, from within a local clone:
C:\Users\vonc\git\git>gh pr diff --patch 1382 | grep -E "file.? changed, "
2 files changed, 29 insertions( ), 13 deletions(-)
Which refers to PR 1382 of the git/git
repository.
The other approach would be to use a GraphQL query (similar to this one) and start querying remote pull request that way.
The OP yijiem reports in the comments using the first approach with:
$ gh pr list --search "is:merged author:<name>" --json number --jq '.[].number' | \ awk '{ system("gh pr diff --patch " $0) }' | \ grep -E "file.? changed" | \ awk '{ i =$4; d =$6 } END { print i,d }'
The
--json
output format and--jq
query option ofgh
are really nice! 8 hours ago