5 ms·
Intuition is great but we often forget that we can use churn stats too. find . -name "*.rb" |xargs -n1 -I file sh -c 'echo `git log --oneline file | wc -l`: fi
by michaelfeathers 11y ago
Intuition is great but we often forget that we can use churn stats too.
find . -name "*.rb" |xargs -n1 -I file sh -c 'echo `git log --oneline file | wc -l`: file'|sort -nr
Applying a time period window is good too as some parts of code churn for a while and them reach stability.
- voltagex_ 11y agoWhat does that command do?
- chairleader 11y agoBy my read, it prints a list of all Ruby files in your project sorted by number of commits against them. It may take a long time to complete depending on number of files and number of commits. YMMV, I am not a BASH shell.
- voltagex_ 11y agohttp://explainshell.com/explain?cmd=find+.+-name+%22*.rb%22+%7Cxargs+-n1+-I+file+sh+-c+%27echo+%60git+log+--oneline+file+%7C+wc+-l%60%3A+file%27%7Csort+-nr http://explainshell.com/explain?cmd=find+.+-name+%22*.rb%22+... doesn't quite get it either, but I think you're right. I'm not near a machine with Bash to check.
- chris_wot 11y agoActually, it finds all Ruby .rb files, then prints out that file every time a change was made to the file. It then does a count of each of the times the file is output, and then sorts the list with those files that were modified the most frequently being at the top, and those modified least frequently being at the bottom. In other words, it shows (as the poster says) file churn in a Ruby codebase.
- michaelfeathers 11y agoWe put a variation of the script to music also. Seriously. It's on iTunes and Bandcamp: https://itunes.apple.com/us/album/snippets-programming-episode/id918038224 https://itunes.apple.com/us/album/snippets-programming-episo... https://fowlerandfeathers.bandcamp.com/releases https://fowlerandfeathers.bandcamp.com/releases
- pg_is_a_butt 11y agoit looks for ruby files on your computer, then creates a new file on your desktop and explains why ruby is lame.
- reportingsjr 11y agoIt finds all of the files with the .rb extension in a directory, then feeds that in to git log --oneline. wc -l then counts how many lines resulted from git log, which basically tells you how many times each file has been modified. Lastly these numbers are sorted from largest number to lowest. The gist of it is that you figure out which files get modified the most. This lets you know where your most frequently changed code is.