Created
April 20, 2010 08:46
-
-
Save gerhard/372205 to your computer and use it in GitHub Desktop.
Pairing script, by Bryan Helmkamp
This file contains hidden or 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 gl he (Sets the author to 'Gerhard Lazu, and Hakan Ensari') | |
# pair (Unsets the author so the git global config takes effect) | |
# | |
# Author: Bryan Helmkamp (http://brynary.com) | |
####################################################################### | |
## Configuration | |
PAIR_EMAIL = "[email protected]" | |
AUTHORS = { | |
"he" => "Hakan Ensari", | |
"gl" => "Gerhard Lazu", | |
"pl" => "Piotr Laszewski" | |
} | |
## 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 | |
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 | |
`git config user.name '#{authors}'` | |
`git config user.email '#{PAIR_EMAIL}'` | |
puts "user.name = #{authors}" | |
puts "user.email = #{PAIR_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