A quick and dirty script to check out each commit of a writing project and find the word count of each Markdown file at that point in time. You might want to use this on a clone of your writing repository. NO WARRANTY EXPRESS OR IMPLIED.
Last active
November 11, 2015 10:37
-
-
Save lmullen/117597e452ed73b4e157 to your computer and use it in GitHub Desktop.
Word count history
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 | |
require "git" | |
require "csv" | |
data = [] | |
repo = Git.open(Dir.pwd) | |
repo.log(10000).each do |commit| | |
repo.checkout(commit) | |
date = commit.date | |
message = commit.message | |
holder = [] | |
wc = `wc -w *.md` | |
wc.split("\n").each {|string| holder.push string.strip.split(" ",2)} | |
holder.each do |value| | |
value.push date | |
value.push message | |
data.push value | |
end | |
end | |
repo.checkout("master") | |
CSV.open("wordcounts.csv", "wb") do |csv| | |
csv << ["word_count", "file", "date_time", "commit_message"] | |
data.each do |row| | |
csv << row | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment