Skip to content

Instantly share code, notes, and snippets.

@richardhsu
Created April 9, 2014 09:30
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save richardhsu/10247078 to your computer and use it in GitHub Desktop.
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.
#!/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