Created
August 20, 2018 11:35
-
-
Save CommodoreBeard/77c379c93afb6555e7211276a0df0737 to your computer and use it in GitHub Desktop.
Percent of Developers who Write Tests
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 bash | |
function getContributors() { | |
git ls-tree -r --name-only master $1 | while read file ; do | |
git log --follow --pretty=format:%an $file | sort | uniq | |
done | sort | uniq | |
return 0 | |
} | |
allContributors=() | |
while read -r user; do | |
allContributors+=("$user") | |
done <<< "$(getContributors ./)" | |
testContributorsRaw=$(getContributors) <<< $(find . -name '*test*' -o -name '*feature*' -o -name '*spec*') | |
testContributors=() | |
while read -r tester; do | |
testContributors+=("$tester") | |
done <<< "$testContributorsRaw" | |
htmlAllContributors="" | |
for contributor in "${allContributors[@]}"; do | |
htmlAllContributors+="<p>${contributor}</p>" | |
done | |
htmlTestContributors="" | |
for testContributor in "${testContributors[@]}"; do | |
htmlTestContributors+="<p>${testContributor}</p>" | |
done | |
numberOfContributors=${#allContributors[@]} | |
numberOfTesters=${#testContributors[@]} | |
scale=2 | |
percentageTesters=$(($numberOfTesters*100/$numberOfContributors | bc)) | |
IFS=$'\n' | |
cat << _EOF_ | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<title>Bootstrap Example</title> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | |
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> | |
</head> | |
<body> | |
<div class="container"> | |
<div class="jumbotron"> | |
<h1>👩⚕️ ${percentageTesters}% Contributors writing tests</h1> | |
</div> | |
<div class="row"> | |
<div class="col-sm-4"> | |
<h1>ALL Contributors</h1> | |
${htmlAllContributors} | |
</div> | |
<div class="col-sm-4"> | |
<h1>TEST Contributors</h1> | |
${htmlTestContributors} | |
<div> | |
</div> | |
</body> | |
</html> | |
_EOF_ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment