marcin marcin - 2 months ago 19
Git Question

Average date of last line edit

git blame gives me date of last edit of every line in file.
It is possible to get average (or something similar) line edit date from whole file?

In other words I want have tool to evaluate how old is particular file. It can be helpful to decide which file potentially require some of refactor.

Answer
git blame --line-porcelain | grep "committer-time" | awk '{ sum += $2; n++ } END { if (n > 0) printf "%f\n", sum / n; }'

This works for me. Prints the average of commit timestamps.