The method of git and vs2019 code volume statistics

git opens git bash under the project

//Replace username to view personal code volume

git log --author="username" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

 The effect is as follows: 

 If you don't look at the user, just put --author

git log --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

//If the project is developed by multiple people, count the number of rows added or deleted by each person

git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done

The effect is as follows:

Why do you need to look at the amount of code? Before, I found that an open source project had the functions I wanted. I wanted to separate the functions. I didn’t even look at the amount of code. , to strip the relevant function code has to be re-evaluated :(

In addition, the method of counting the amount of code in viual studio

press ctrl+shitf+f 

In the pop-up window, perform the following steps:

If it is a c# project file type, change it to:

 

*.cs;*.vb;*.resx;*.xsd;*.wsdl;*.htm;*.html;*.aspx;*.ascx;*.asmx;*.svc;*.asax;*.config;*.asp;*.asa;*.cshtml;*.vbhtml;*.razor;*.css;*.xml;*.xaml

If it is a c++ project file type, change it to:

*.c;*.cpp;*.cxx;*.cc;*.tli;*.tlh;*.h;*.hh;*.hpp;*.hxx;*.hh;*.inl;*.ipp;*.rc;*.resx;*.idl;*.asm;*.inc;*.vcxproj

enter search

^b*[^:b#/]+.*$


Select the search range to be the entire solution or the current project, or specify a directory.
Select the Use regular expression
setting to find the following file types as the file types contained in the project.
Click Find All to start counting.

Next, VS will search and count whether the regular expression is satisfied line by line. After completion, you can see the number of code lines of the project in the bottom matching line~

 Remember to look at the amount of project code before evaluating the workload, and evaluating without looking at the amount of code is asking for trouble!

 

おすすめ

転載: blog.csdn.net/babytiger/article/details/130199126