Skip to content

Commit

Permalink
Merge pull request #13 from cbartlett/master
Browse files Browse the repository at this point in the history
Join names of 3+ developers with commas
  • Loading branch information
Colin Bartlett and Joe Bilt authored and therubymug committed Jun 2, 2012
1 parent ffe6506 commit 8b0ee8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion lib/hitch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion spec/hitch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8b0ee8f

Please sign in to comment.