Created
December 28, 2015 15:16
-
-
Save davidkuster/8732c227448c74a09c12 to your computer and use it in GitHub Desktop.
Poor man's code contributions scratchpad
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
import groovy.io.FileType | |
def files = [] | |
def extensions = ['.groovy', '.md', '.yml', '.gradle', '.json', '.html', '.puml', '.properties'] | |
def foldersToExclude = ['/.gradle/', '/.idea/', '/build/'] | |
def dir = new File("/path/to/checked/out/git/repo") | |
println "dir = $dir" | |
dir.eachFileRecurse (FileType.FILES) { file -> | |
def filename = file.toString() | |
if (extensions.find { filename.endsWith(it) } && ! foldersToExclude.find { filename.contains(it) }) { | |
files << file | |
} | |
} | |
println "found ${files.size()} files" | |
Map contributors = [:] | |
files.each { file -> | |
println "blaming $file" | |
"git blame ${file}".execute().text.eachLine { | |
def tokens = it.tokenize() | |
println "tokens = $tokens" | |
def name = tokens[2] | |
if (name =~ '-') name = tokens[1] | |
if (name =~ '-') println "name = $name, tokens = $tokens" | |
def count = contributors[name] ?: 0 | |
contributors[name] = ++count | |
} | |
} | |
contributors | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment