Skip to content

Instantly share code, notes, and snippets.

@samg
Created October 10, 2009 00:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samg/206474 to your computer and use it in GitHub Desktop.
Save samg/206474 to your computer and use it in GitHub Desktop.
#!/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