Skip to content

Instantly share code, notes, and snippets.

@ignazioc
Created November 27, 2018 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ignazioc/200db191b80aba935cf146e1abccd9ec to your computer and use it in GitHub Desktop.
Save ignazioc/200db191b80aba935cf146e1abccd9ec to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'FileUtils'
require 'json'
require 'date'
Dir.chdir('ios-client') do
system("git checkout develop")
# Collect the commits
commit_list = []
result = []
dates = []
200.downto(1) { |i|
sha1 = %x[git rev-list -n 1 --before='#{i} weeks ago' develop]
date = %x[git show -s --format=%ci #{sha1}]
date = Date.parse(date)
commit_list << {SHA1: sha1, DATE: date.strftime("%d/%m/%Y") }
}
# Collect the CLOC
commit_list.each do | commit |
system("git checkout #{commit[:SHA1]}")
output = %x[cloc --fullpath --not-match-d="(vendor|ci-dependencies|Pods|DerivedData|Documentation|fastlane,lib,Provisioning,Screenshots)" --include-lang="Swift,Objective C" --json --ignore-whitespace --quiet .]
hash = JSON.parse(output)
objc = hash["Objective C"]["code"]
swift = 0
unless hash["Swift"].nil?
swift = hash["Swift"]["code"]
end
result << "#{commit[:SHA1].strip!},#{commit[:DATE]},#{objc},#{swift}"
end
puts result
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment