Created
February 18, 2010 11:00
-
-
Save jzajpt/307578 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 | |
# Configures the git author to a list of developers when pair programming | |
# | |
# Usage: pair lm bh (Sets the author to 'Luke Melia and Bryan Helmkamp') | |
# pair (Unsets the author so the git global config takes effect) | |
# | |
# Author: Bryan Helmkamp (http://brynary.com) | |
####################################################################### | |
## Configuration | |
EMAIL_DOMAIN = "blueberryapps.com" | |
AUTHORS = { | |
"jz" => "Jiří Zajpt", | |
"mm" => "Martin Magnusek", | |
'mb' => 'Marek Bendík' | |
# ... | |
} | |
## End of configuration | |
####################################################################### | |
unless File.exists?(".git") | |
puts "This doesn't look like a git repository." | |
exit 1 | |
end | |
authors = ARGV.map do |initials| | |
if AUTHORS[initials.downcase] | |
AUTHORS[initials.downcase] | |
else | |
puts "Couldn't find author name for initials: #{initials}" | |
exit 1 | |
end | |
end | |
initials = ARGV | |
if authors.any? | |
if authors.size == 1 | |
authors = authors.first | |
elsif authors.size == 2 | |
authors = authors.join(" and ") | |
else | |
authors = authors[0..-2].join(", ") + " and " + authors.last | |
end | |
email = "devs-#{initials.join('+')}@#{EMAIL_DOMAIN}" | |
`git config user.name '#{authors}'` | |
`git config user.email '#{email}'` | |
puts "user.name = #{authors}" | |
puts "user.email = #{email}" | |
else | |
`git config --unset user.name` | |
`git config --unset user.email` | |
puts "Unset user.name and user.email" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment