Skip to content

Instantly share code, notes, and snippets.

@gerhard
Created April 20, 2010 08:46
Show Gist options
  • Save gerhard/372205 to your computer and use it in GitHub Desktop.
Save gerhard/372205 to your computer and use it in GitHub Desktop.
Pairing script, by Bryan Helmkamp
#!/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 = "we.write@papercavalier.com"
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