Created
May 27, 2011 18:15
-
-
Save matthewmccullough/995813 to your computer and use it in GitHub Desktop.
Find unique contributors to a Git repo
This file contains hidden or 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
| #!/bin/bash | |
| #Ensure we have the quantity specified on the CLI | |
| if [ -z "$1" ]; then ARG_ERR=ERR; fi | |
| if [ -n "$ARG_ERR" ]; | |
| then | |
| echo "Usage: <portionofcommiter>" | |
| exit | |
| fi | |
| # Create an output directory if it doesn't exist | |
| if [ ! -d output ]; then mkdir output;fi | |
| # Delete existing count files | |
| if [ -e output/contributorlines.$1.* ]; then rm output/contributorlines.$1.* ;fi | |
| for f in book/chapter.*.asc; do git annotate $f | cut -c 11-15 | grep "$1" >> output/contributorlines.$1.rawcount; done; | |
| cat output/contributorlines.$1.rawcount | uniq -c >> output/contributorlines.$1.count | |
| rm output/contributorlines.$1.rawcount | |
| cat output/contributorlines.$1.count |
This file contains hidden or 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
| #!/bin/bash | |
| #Remove all existing files | |
| rm output/contributornames.* | |
| #Loop through all chapters | |
| for f in book/chapter.*.asc; do git annotate $f | cut -c 11-15 | sort | uniq >> output/contributornames.raw; done | |
| #Sort the combined results, trim strings, and unique them again | |
| sort output/contributornames.raw | sed 's/ //g' | uniq > output/contributornames.processed | |
| #Show the result file | |
| echo Contributors: | |
| cat output/contributornames.processed | |
| #Find the line counts for each | |
| cat output/contributornames.processed | while read line; do | |
| countcontribs $line | |
| done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment