Permalink
Browse files

support no_solo_prefix as suggested by zozi

  • Loading branch information...
Michael Grosser
Michael Grosser committed Mar 15, 2012
1 parent 11c43a0 commit e83f226d469cbd7336c3ddc028d314d1c9b50aa0
Showing with 20 additions and 1 deletion.
  1. +1 −0 README.md
  2. +3 −1 bin/git-pair
  3. +16 −0 spec/cli_spec.rb
View
@@ -34,6 +34,7 @@ Create a `.pairs` config file in project root or your home folder.
email:
prefix: pair
domain: pivotallabs.com
+ # no_solo_prefix: true
#global: true
View
@@ -25,6 +25,7 @@ Create a `.pairs` config file in project root or your home folder.
email:
prefix: pair
domain: pivotallabs.com
+ # no_solo_prefix: true
#global: true
@@ -90,7 +91,8 @@ end
def build_email(emails, config)
if config.is_a?(Hash)
- "#{([config['prefix']] + emails).compact.join('+')}@#{config['domain']}"
+ prefix = config['prefix'] if !config['no_solo_prefix'] or emails.size > 1
+ "#{([prefix] + emails).compact.join('+')}@#{config['domain']}"
else
config
end
View
@@ -189,6 +189,22 @@ def expect_config(result, name, initials, email, options={})
expect_config result, "Aa Bb", "ab", "aa@foo.com"
end
+ context "when no no_solo_prefix is given" do
+ before do
+ write ".pairs", File.read(".pairs").sub(/email:.*/m, "email:\n prefix: pairs\n no_solo_prefix: true\n domain: foo.com")
+ end
+
+ it "uses no email prefix for single developers" do
+ result = run "git pair ab"
+ expect_config result, "Aa Bb", "ab", "aa@foo.com"
+ end
+
+ it "uses email prefix for multiple developers" do
+ result = run "git pair ab bc"
+ expect_config result, "Aa Bb & Bb Cc", "ab bc", "pairs+aa+bb@foo.com"
+ end
+ end
+
it "fails with unknown initials" do
result = run "git pair xx", :fail => true
result.should include("Couldn't find author name for initials: xx")

0 comments on commit e83f226

Please sign in to comment.