Created
October 10, 2009 00:38
-
-
Save samg/206474 to your computer and use it in GitHub Desktop.
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 ruby | |
# | |
# Git pre-commit hook: | |
# Install at .git/hooks/pre-commit and set as executable | |
# | |
# Interactively sets git commit author for pair programming | |
# | |
################################################### | |
# Configuration | |
me = "Sam Goldstein" | |
my_email = 'sam@aboutus.org' | |
pair_email = 'developers@aboutus.org' | |
developers = [ | |
"Stephen Judkins", | |
"Quin Hoxie", | |
"Didip Kerabat", | |
"Jason Watkins", | |
"Brandon CS Sanders" | |
] | |
################################################### | |
puts "Pairing? (enter number):" | |
developers.each_with_index do |name, index| | |
puts " #{index + 1}: #{name}" | |
end | |
choice = File.new("/dev/tty").readline.chomp | |
unless choice =~ /\A\d*\Z/ | |
puts "Bad input `#{choice}'" | |
exit 1 | |
end | |
commit_name = me | |
commit_name += ' & ' + developers[choice.to_i - 1] unless choice == '' | |
commit_email = choice == '' ? my_email : pair_email | |
puts "...setting *commit author* to `#{commit_name}'" | |
puts "...setting *commit email* to `#{commit_email}'" | |
`export GIT_AUTHOR_COMMIT='#{commit_name}'` | |
`export GIT_AUTHOR_EMAIL='#{commit_email}'` | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment