Skip to content

Instantly share code, notes, and snippets.

@davidkuster
Created December 28, 2015 15:16
Show Gist options
  • Save davidkuster/8732c227448c74a09c12 to your computer and use it in GitHub Desktop.
Save davidkuster/8732c227448c74a09c12 to your computer and use it in GitHub Desktop.
Poor man's code contributions scratchpad
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