Permalink
Browse files

Join names of 3+ developers with commas

  • Loading branch information...
1 parent 80147d5 commit 599abf2bcbeca6d9c64f1c19bc8b8fa532b6d19f Colin Bartlett and Joe Bilt committed with Jun 1, 2012
Showing with 17 additions and 2 deletions.
  1. +9 −1 lib/hitch.rb
  2. +8 −1 spec/hitch_spec.rb
View
@@ -63,7 +63,15 @@ def self.current_pair=(pairs)
end
def self.git_author_name
- current_pair.sort.map {|pair| Hitch::Author.find(pair)}.join(' and ')
+ devs = current_pair.sort.map {|pair| Hitch::Author.find(pair)}
+ case devs.length
+ when 1
+ devs[0]
+ when 2
+ "#{devs[0]} and #{devs[1]}"
+ else
+ "#{devs[0...-1].join(', ')}, and #{devs[-1]}"
+ end
end
def self.git_author_email
View
@@ -2,7 +2,7 @@
describe Hitch do
- let(:hitch_pairs) {{'leela' => 'Turanga Leela', 'fry' => 'Philip J. Fry'}}
+ let(:hitch_pairs) {{'leela' => 'Turanga Leela', 'fry' => 'Philip J. Fry', 'zoidberg' => 'John A. Zoidberg'}}
let(:hitch_config) do
{ :group_email => 'dev@hashrocket.com',
@@ -58,6 +58,13 @@
end
end
+ context 'with more than 2 developers' do
+ it "joins 3+ developers together with commas and an 'and'" do
+ Hitch.current_pair = ['leela', 'fry', 'zoidberg']
+ Hitch.author_command.should == "export GIT_AUTHOR_NAME='Philip J. Fry, Turanga Leela, and John A. Zoidberg' GIT_AUTHOR_EMAIL='dev+fry+leela+zoidberg@hashrocket.com'"
+ end
+ end
+
end
describe '.unhitch' do

0 comments on commit 599abf2

Please sign in to comment.