Skip to content

Commit

Permalink
Merge branch 'master' into mark-rushakoff-specs
Browse files Browse the repository at this point in the history
Conflicts:
	bin/git-pair
  • Loading branch information
Matt Royal committed Oct 23, 2013
2 parents cfd991a + 68229dc commit d0ae3a4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
2 changes: 2 additions & 0 deletions README.md
@@ -1,3 +1,5 @@
[![Build Status](https://travis-ci.org/pivotal/git_scripts.png)](https://travis-ci.org/pivotal/git_scripts)

# Git Scripts

These scripts are helpers for managing developer workflow when using git repos hosted on GitHub. Install as a rubygem and they can be run as standard git commands like `git about`.
Expand Down
2 changes: 1 addition & 1 deletion lib/pivotal_git_scripts/git_pair.rb
Expand Up @@ -22,7 +22,7 @@ def main(argv)
if initials.any?
author_names, email_ids = extract_author_names_and_email_ids_from_config(config, initials)
authors = [author_names[0..-2].join(", "), author_names.last].reject(&:empty?).join(" and ")
git_config = {:name => authors, :initials => initials.join(" ")}
git_config = {:name => authors, :initials => initials.sort.join(" ")}
git_config[:email] = build_email(email_ids, config["email"]) unless no_email(config)
set_git_config global, git_config
else
Expand Down
25 changes: 21 additions & 4 deletions spec/cli_spec.rb
@@ -1,4 +1,5 @@
require "unindent"
require 'open3'

describe "CLI" do
before :all do
Expand All @@ -7,9 +8,13 @@
end

def run(command, options={})
result = `#{command}`
raise "FAILED #{command} : #{result}" if $?.success? == !!options[:fail]
result
output = `#{command}`
return output if $?.success?
return output if options[:fail]

message = "Unable to run #{cmd.inspect} in #{Dir.pwd}.\n#{output}"
warn "ERROR: #{message}"
raise message
end

def write(file, content)
Expand All @@ -26,7 +31,14 @@ def write(file, content)
ENV["HOME"] = File.expand_path("#{dir}/home")

Dir.chdir dir do
run "touch a && git init && git add . && git commit -am 'initial'"
run "touch a"
run "git init"
run "git add ."
run "git config user.email 'rspec-tests@example.com'"
run "git config user.name 'rspec test suite'"
run "git commit -am 'initial'"
run "git config --unset user.email"
run "git config --unset user.name"
example.run
end
end
Expand Down Expand Up @@ -149,6 +161,11 @@ def git_config_value(name, global = false)
expect_config result, "Aa Bb, Bb Cc and Cc Dd", "ab bc cd", "the-pair+aa+bb+cc@the-host.com"
end

it "prints names, email addresses, and initials in alphabetical order" do
result = run "git pair ab cd bc"
expect_config result, "Aa Bb, Bb Cc and Cc Dd", "ab bc cd", "the-pair+aa+bb+cc@the-host.com"
end

it "can set a user with apostrophes as pair" do
write ".pairs", File.read(".pairs").sub("Aa Bb", "Pete O'Connor")
result = run "git pair ab"
Expand Down

0 comments on commit d0ae3a4

Please sign in to comment.