Created
November 7, 2018 22:55
-
-
Save sheck/8131302233ffb5ce44a746bd81be59e6 to your computer and use it in GitHub Desktop.
Generate csv of historical file counts in folders in a git repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# rubocop:disable all | |
require 'date' | |
`touch stats.csv` | |
`echo 'date,base file count,comparison file count' > stats.csv` | |
def run(date) | |
sha = `git rev-list -n 1 --before="#{date.to_s}" master`.chomp | |
base_file_count = `git ls-tree -r --name-only #{sha} app/assets/javascripts/sprockets | wc -l`.strip | |
comparison_and_base = `git ls-tree -r --name-only #{sha} app/assets/javascripts | wc -l` | |
compare_1_count = comparison_and_base.strip.to_i - base_file_count.strip.to_i | |
compare_2_count = `git ls-tree -r --name-only #{sha} app/javascript | wc -l`.strip.to_i | |
compare_file_count = compare_1_count + compare_2_count | |
data = [date.to_s, base_file_count, compare_file_count] | |
row = data.join(",") | |
`echo '#{row}' >> stats.csv` | |
end | |
current_date = Date.today | |
until current_date <= Date.new(2017,2,14) | |
run(current_date) | |
current_date = current_date - 30 | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment