├── README.md ├── gitmail.rb ├── gitmail_test.rb └── minitest_helper.rb /README.md: -------------------------------------------------------------------------------- 1 | # GitMail 2 | This is a simple ruby application that takes an input of a github repository and outputs all unique email addresses associated with the repo. It does this by cloning the repository, parsing through git logs to find email addresses and names, finding unique name/email combinations, sorting them, and outputting them to the terminal. After this, it will delete the temporary folder it made to clone the repo so as not to clutter up your computer. 3 | 4 | To use this application, simply run gitmail from your terminal with the argument of the repo you are trying to find the emails of. 5 | 6 | ### Example 7 | Run this command from your terminal - 8 | `ruby gitmail.rb kravinskylev/gitmail`. 9 | If you want to use a non Github repo, pass the base URL of the host you would like to use (`ruby gitmail.rb some_user/some_repo https://bitbucket.org/`) 10 | It doesn't matter what directory you're in when you run this command. 11 | That's basically all there is to it! 12 | 13 | ### Known Issues 14 | * *no email addresses are returned* 15 | * *email address is unused* 16 | 17 | If no email addresses are returned, this means that the github user set his email to private. Most emails are not private however - even when an email does not appear on a person's github profile, it still usually is public in their git logs. 18 | 19 | If the email address it returns is a bunk email, then this user either outsmarted or outstupided you. They outsmarted you if they want to associate a public email with their github commits in order to make their daily commits look impressive while still remaining un-contactable, and they outstupided you if they set their email to something not associated with their profile. 20 | 21 | **That's all there is to it!** 22 | -------------------------------------------------------------------------------- /gitmail.rb: -------------------------------------------------------------------------------- 1 | require 'tmpdir' 2 | 3 | class Finder 4 | def initialize(repo_name) 5 | Dir.mktmpdir("GitMail") do |dir| 6 | `git clone --bare #{ARGV[1] || "https://github.com/"}#{repo_name}.git #{dir}` 7 | Dir.chdir("#{dir}") do 8 | @emails = `git log --pretty=format:'%an %ae%n%cn %ce'` 9 | end 10 | end 11 | end 12 | 13 | def all_contributors 14 | @emails.split("\n").uniq.sort 15 | end 16 | end 17 | 18 | if $PROGRAM_NAME == __FILE__ 19 | repo_name = ARGV[0] 20 | puts Finder.new(repo_name).all_contributors 21 | end 22 | -------------------------------------------------------------------------------- /gitmail_test.rb: -------------------------------------------------------------------------------- 1 | require_relative "minitest_helper.rb" 2 | 3 | class GitMailTest < Minitest::Test 4 | def test_it_knows_its_own_contributor 5 | me = $this_project.all_contributors 6 | assert_equal me, ["Andrew Jorgensen andrew@andrewjorgensen.com", "Frank Hamand frankhamand@gmail.com", "Lev Kravinsky kravinskylev@gmail.com"] 7 | end 8 | 9 | def test_it_sorts_and_uniqs_contributors 10 | contributors = ["Clif Reeder clifreeder@gmail.com", 11 | "Corey Farwell coreyf@rwell.org", 12 | "Joshua Kerr joshkerr@gmail.com", 13 | "Nat Welch nat@natwelch.com"] 14 | 15 | assert_equal $nat_resume.all_contributors, contributors 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /minitest_helper.rb: -------------------------------------------------------------------------------- 1 | gem 'minitest', '~> 5.0' 2 | require "minitest/autorun" 3 | require "minitest/pride" 4 | require_relative "gitmail.rb" 5 | $this_project = Finder.new("kravinskylev/GitMail") 6 | $nat_resume = Finder.new("icco/Resume") 7 | 8 | --------------------------------------------------------------------------------