Skip to content

Commit

Permalink
filesPlusMinus
Browse files Browse the repository at this point in the history
  • Loading branch information
adomani committed May 19, 2024
1 parent 29b57f4 commit d826a6e
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/mathlib_stats.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ printf -v today '%(%Y-%m-%d)T\n' -1
# }
# print -tot }')

# produce output `(+X -Y ~Z)` for the files added (+), deleted (-), modified (~)
filesPlusMinus="$(git diff --name-status "${oldCommit}"..."${currentCommit}" |
awk '/^A/ { added++ }
/^M/ { modified++}
/^D/ {deleted++} END{
printf("(+%d -%d ~%d)\n", added, deleted, modified)
}')"

net=$(git diff --shortstat "${oldCommit}"..."${currentCommit}" |
awk 'BEGIN{ con=0 }{
awk -v filesPlusMinus="${filesPlusMinus}" 'BEGIN{ con=0 }{
for(i=1; i<=NF; i++) {
if($i+0 == $i){ con++; nums[con]=$i } ## nums= [files changed, insertions, deletions]
}
if(con != 3) { print "Expected 3 fields from `git diff`" }
printf("%s files changed, %s lines changed (+%s -%s)\n",
nums[1], nums[2]-nums[3], nums[2], nums[3]) }')
printf("%s files changed %s, %s lines changed (+%s -%s)\n",
nums[1], filesPlusMinus, nums[2]-nums[3], nums[2], nums[3]) }')

######################
# Lean-based reports #
Expand Down

0 comments on commit d826a6e

Please sign in to comment.