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

Commit e99b3e4

Browse files
Jimmy Da and Matt RoyalMatt Royal
authored andcommitted
User can see help message with git pair-commit -h
[finishes #62492694]
1 parent 971d861 commit e99b3e4

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

lib/pivotal_git_scripts/git_pair.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,15 @@ def main(argv)
4848
end
4949

5050
def commit(argv)
51+
if argv[0] == '-h'
52+
puts 'Usage: git pair-commit [options_for_git_commit]'
53+
puts ''
54+
puts 'Commits changes to the repository using `git commit`, but randomly chooses the author email from the'
55+
puts 'member of the pair. In order for GitHub to assign credit for the commit activity, the user\'s email'
56+
puts 'must be linked in their GitHub account.'
57+
exit 0
58+
end
59+
5160
config = read_pairs_config
5261
_, email_ids = extract_author_names_and_email_ids_from_config(config, current_pair_initials)
5362
author_email = random_author_email(email_ids, config['email'])

spec/cli_spec.rb

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,8 @@ def git_config_value(name, global = false)
280280
end
281281
end
282282

283-
describe "pair-commit" do
284-
context "when a pair has been set" do
283+
describe 'pair-commit' do
284+
context 'when a pair has been set' do
285285
before do
286286
write ".pairs", <<-YAML.unindent
287287
pairs:
@@ -309,7 +309,7 @@ def git_config_value(name, global = false)
309309
end
310310

311311
it "randomly chooses from pair and set user.email" do
312-
emails = 4.times.map do
312+
emails = 6.times.map do
313313
git_pair_commit
314314
(run "git log -1 --pretty=%ae").strip
315315
end
@@ -328,9 +328,16 @@ def git_config_value(name, global = false)
328328
end
329329
end
330330

331-
context "when no pair has been set" do
332-
it "raises an exception" do
333-
git_pair_commit.should include("Error: No pair set")
331+
context 'when no pair has been set' do
332+
it 'raises an exception' do
333+
git_pair_commit.should include('Error: No pair set')
334+
end
335+
end
336+
337+
context 'when -h flag is passed' do
338+
it 'shows the help message' do
339+
results = run 'git pair-commit -h'
340+
results.should include('randomly chooses an email address from the pair to use for the commit')
334341
end
335342
end
336343

0 commit comments

Comments
 (0)