Skip to content
Advertisement

Is there a way to check contribution lines in a project in relevant files (such .java, .story, etc) and ignore other type of files?

I’m trying to check how many lines of code I contributed to the project I work, but only in relevant files such as .java and .story, not sure if there any other relevant types, and I want to ignore any other file types (I added some files for unit tests and don’t want to consider them in this counting).

I also want to know if there is a better way to get this information.

I used this command:

git log --shortstat --author "<author>" --since "<beginDate>" --until "<endDate>" 
| grep "files? changed" 
| awk '{files+=$1; inserted+=$4; deleted+=$6} END 
       {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'

Advertisement

Answer

log can get glob patterns as the last argument…. so you could say

git log whatever conditions -- '*.java' '*.txt'

Which will only consider logging those files (just make sure that bash doesn’t expand them…. that’s why I used quotes).

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement