Created
April 9, 2014 09:30
-
-
Save richardhsu/10247078 to your computer and use it in GitHub Desktop.
Bash script to pull git repositories, clone them, view log and grab the first email address seen.
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 | |
# Set up a repos.txt file that contains a list of all the repos | |
# one repo per line. Then create an emails.txt file which is where | |
# all the emails will go. It'll be a CSV file so you can verify. | |
# This is a quick hacky way to get emails, not sure if I covered all | |
# valid characters in regex but didn't need precision. Feel free to | |
# make it better! | |
reponame="https://github.com/[a-zA-Z0-9._-]+/([a-zA-Z0-9._-]+)$" | |
email="<([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.\w+)>" | |
file="emails.txt" # Where emails go (CSV file) | |
while read p; do | |
echo "Working on $p" | |
git clone $p; | |
[[ $p =~ $reponame ]] | |
folder="${BASH_REMATCH[1]}" | |
echo "Folder: $folder" | |
cd $folder | |
var=`git log` | |
[[ $var =~ $email ]] | |
cd .. | |
echo "Add ${BASH_REMATCH[1]} to emails.txt" | |
printf "$p, ${BASH_REMATCH[1]}\n" >> $file | |
rm -rf $folder | |
done < repos.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment