Skip to content
This repository was archived by the owner on Mar 31, 2022. It is now read-only.

Commit d0ae3a4

Browse files
author
Matt Royal
committed
Merge branch 'master' into mark-rushakoff-specs
Conflicts: bin/git-pair
2 parents cfd991a + 68229dc commit d0ae3a4

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[![Build Status](https://travis-ci.org/pivotal/git_scripts.png)](https://travis-ci.org/pivotal/git_scripts)
2+
13
# Git Scripts
24

35
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`.

lib/pivotal_git_scripts/git_pair.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def main(argv)
2222
if initials.any?
2323
author_names, email_ids = extract_author_names_and_email_ids_from_config(config, initials)
2424
authors = [author_names[0..-2].join(", "), author_names.last].reject(&:empty?).join(" and ")
25-
git_config = {:name => authors, :initials => initials.join(" ")}
25+
git_config = {:name => authors, :initials => initials.sort.join(" ")}
2626
git_config[:email] = build_email(email_ids, config["email"]) unless no_email(config)
2727
set_git_config global, git_config
2828
else

spec/cli_spec.rb

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require "unindent"
2+
require 'open3'
23

34
describe "CLI" do
45
before :all do
@@ -7,9 +8,13 @@
78
end
89

910
def run(command, options={})
10-
result = `#{command}`
11-
raise "FAILED #{command} : #{result}" if $?.success? == !!options[:fail]
12-
result
11+
output = `#{command}`
12+
return output if $?.success?
13+
return output if options[:fail]
14+
15+
message = "Unable to run #{cmd.inspect} in #{Dir.pwd}.\n#{output}"
16+
warn "ERROR: #{message}"
17+
raise message
1318
end
1419

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

2833
Dir.chdir dir do
29-
run "touch a && git init && git add . && git commit -am 'initial'"
34+
run "touch a"
35+
run "git init"
36+
run "git add ."
37+
run "git config user.email 'rspec-tests@example.com'"
38+
run "git config user.name 'rspec test suite'"
39+
run "git commit -am 'initial'"
40+
run "git config --unset user.email"
41+
run "git config --unset user.name"
3042
example.run
3143
end
3244
end
@@ -149,6 +161,11 @@ def git_config_value(name, global = false)
149161
expect_config result, "Aa Bb, Bb Cc and Cc Dd", "ab bc cd", "the-pair+aa+bb+cc@the-host.com"
150162
end
151163

164+
it "prints names, email addresses, and initials in alphabetical order" do
165+
result = run "git pair ab cd bc"
166+
expect_config result, "Aa Bb, Bb Cc and Cc Dd", "ab bc cd", "the-pair+aa+bb+cc@the-host.com"
167+
end
168+
152169
it "can set a user with apostrophes as pair" do
153170
write ".pairs", File.read(".pairs").sub("Aa Bb", "Pete O'Connor")
154171
result = run "git pair ab"

0 commit comments

Comments
 (0)