Last active
August 29, 2015 14:01
-
-
Save birgitta410/9828f7a116a7b5df5469 to your computer and use it in GitHub Desktop.
Simple script to generate JS static code analysis history for 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
#https://github.com/schacon/ruby-git | |
#https://github.com/es-analysis/plato | |
require 'git' | |
################################## | |
# root location of git repository | |
root_location = '/path/to/my/repo' | |
# JS scripts folder, relative to folder where script is started | |
scripts_folder = 'app/scripts' | |
# generate report for each nth commit | |
nth_commit = 100 | |
################################## | |
`git checkout master` | |
repo = Git.open(root_location) | |
repo.index | |
repo.index.readable? | |
repo.index.writable? | |
repo.repo | |
repo.dir | |
commits = repo.log(nil) | |
commits_array = commits.map { |l| l } | |
counter = 0 | |
current = '' | |
# commits are last (newest) first - want to go from oldest | |
commits_array.reverse.each do |l| | |
if counter % nth_commit == 0 && !current.empty? | |
`git checkout #{l.sha}` | |
`plato --exclude 'vendors|demo' --date #{l.date.to_i} -r -d reports #{scripts_folder}` | |
end | |
current = l.sha | |
counter = counter + 1 | |
end | |
puts 'DONE, opening report' | |
`open reports/index.html` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment