Sha256: 040a7790ebe072179f89425005bf0789979e13524c928cbf17b9ee6a264800dc

Contents?: true

Size: 1.46 KB

Versions: 8

Compression:

Stored size: 1.46 KB

Contents

#!/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)

# http://www.brynary.com/2008/9/1/setting-the-git-commit-author-to-pair-programmers-names

#######################################################################
## Configuration

# Do not use a valid github account email here.
PAIR_EMAIL = "developers@weplay.com"

AUTHORS = {
  "bh" => "Bryan Helmkamp",
  "lm" => "Luke Melia"
  # ...
}

## 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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
git-precommit-1.3.0 bin/setpairs
git-precommit-1.2.6 bin/setpairs
git-precommit-1.2.5 bin/setpairs
git-precommit-1.2.4 bin/setpairs
git-precommit-1.2.3 bin/setpairs
git-precommit-1.2.2 bin/setpairs
git-precommit-1.2.1 bin/setpairs
git-precommit-1.2.0 bin/setpairs