git_tracker 1.5.1 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba4c5a465dbf21ac90a472ff068b3fc10db9dd59
4
+ data.tar.gz: 5abcc2a8a8712397c99db750e6c306f4bbd5d1ae
5
+ SHA512:
6
+ metadata.gz: 088927ac92d344094c3467f8af91f75fcd1505b02a3eaf413a667ab7d848e547d13c795177c21604352afda91952496092f8c83c44a96e12106cde4bf0d4e6cc
7
+ data.tar.gz: 473ebe902d93cb1eac40f44a93a5de68fbe08660548c98d45f58b104b53e1ab18812641c5e0674be0e91ca08e082c8810d3e992fe173ac3008b4c7c51726fef0
data/.rspec CHANGED
@@ -1,4 +1,3 @@
1
1
  --colour
2
2
  -I spec/support
3
- -r rspec-spies
4
3
  -r pry
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  ### dev
2
- [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.5.1...master)
2
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.6.0...master)
3
+
4
+ ### 1.6.0 / 2013-08-12
5
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.5.1...v1.6.0)
6
+
7
+ Enhancements
8
+
9
+ * Add and default to `help` command. [Issue
10
+ #15](https://github.com/stevenharman/git_tracker/issues/15)
11
+ * Deprecate `git-tracker install` in favor of `git-tracker init` [Issue
12
+ #13](https://github.com/stevenharman/git_tracker/issues/13)
3
13
 
4
14
  ### 1.5.1 / 2013-02-02
5
15
  [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.4.0...v1.5.1)
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://secure.travis-ci.org/stevenharman/git_tracker.png)](http://travis-ci.org/stevenharman/git_tracker)
4
4
  [![Dependency Status](https://gemnasium.com/stevenharman/git_tracker.png)](https://gemnasium.com/stevenharman/git_tracker)
5
- [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/stevenharman/git_tracker)
5
+ [![Code Climate](https://codeclimate.com/github/stevenharman/git_tracker.png)](https://codeclimate.com/github/stevenharman/git_tracker)
6
6
 
7
7
  *GitTracker*, or *git-tracker*, is a Git hook that will scan your current
8
8
  branch name looking for something it recognizes as a [Pivotal Tracker][pt]
@@ -13,8 +13,7 @@ format][pt-format], to your commit message.
13
13
 
14
14
  ### 1) Install the `git-tracker` binary
15
15
 
16
- You need to get the `git-tracker` binary onto your system, and then you need to
17
- install the *git hook* into your local Git repository.
16
+ You need to get the `git-tracker` binary onto your system.
18
17
 
19
18
  - via [Homebrew][homebrew] :beers: (preferred)
20
19
 
@@ -28,25 +27,26 @@ install the *git hook* into your local Git repository.
28
27
  $ gem install git_tracker
29
28
  ```
30
29
 
31
- ### 2) Install the hook
30
+ ### 2) Initialize the hook
32
31
 
33
- You need to add the hook into each repository where you want to use it.
32
+ Then you need to initialize the *git hook* into each local Git repository where
33
+ you want to use it.
34
34
 
35
35
  ```bash
36
36
  # from inside a local Git repository
37
37
  # for example: /path/to/repo/
38
- $ git tracker install
38
+ $ git tracker init
39
39
  ```
40
40
 
41
41
  This will put the `prepare-commit-msg` hook in the `/path/to/repo/.git/hooks`
42
42
  directory and make it executable.
43
43
 
44
- **NOTE:** The hook needs to be installed just once for each repository in which
45
- you will use it.
44
+ **NOTE:** The hook needs to be initialized just once for each repository in
45
+ which you will use it.
46
46
 
47
47
  ## Usage
48
48
 
49
- With the hook installed in a repository, create branches being sure to include
49
+ With the hook initialized in a repository, create branches being sure to include
50
50
  the Pivotal Tracker story number in the branch name.
51
51
 
52
52
  ```bash
data/git_tracker.gemspec CHANGED
@@ -13,8 +13,7 @@ Gem::Specification.new do |gem|
13
13
  better... and easier... um, besier!
14
14
  EOF
15
15
 
16
- gem.add_development_dependency "rspec", "~> 2.12"
17
- gem.add_development_dependency "rspec-spies", "~> 2.0"
16
+ gem.add_development_dependency "rspec", "~> 2.14"
18
17
  gem.add_development_dependency "activesupport", "~> 3.2"
19
18
  gem.add_development_dependency "pry", "~> 0.9.11"
20
19
  gem.add_development_dependency "rake"
@@ -2,30 +2,30 @@ require 'git_tracker/repository'
2
2
 
3
3
  module GitTracker
4
4
  class Hook
5
+ attr_reader :hook_file
5
6
 
6
- def self.install
7
- install_at(Repository.root)
7
+ def self.init
8
+ init_at(Repository.root)
8
9
  end
9
10
 
10
- def self.install_at(root)
11
- hook = hook_from(root)
12
- write(hook)
11
+ def self.init_at(root)
12
+ new(root).write
13
13
  end
14
14
 
15
- private
16
-
17
- def self.hook_from(root)
18
- File.join(root, '.git', 'hooks', 'prepare-commit-msg')
15
+ def initialize(root)
16
+ @hook_file = File.join(root, '.git', 'hooks', 'prepare-commit-msg')
19
17
  end
20
18
 
21
- def self.write(hook)
22
- File.open(hook, 'w') do |f|
19
+ def write
20
+ File.open(hook_file, 'w') do |f|
23
21
  f.write(hook_body)
24
22
  f.chmod(0755)
25
23
  end
26
24
  end
27
25
 
28
- def self.hook_body
26
+ private
27
+
28
+ def hook_body
29
29
  return <<-HOOK
30
30
  #!/usr/bin/env bash
31
31
 
@@ -4,7 +4,7 @@ require 'git_tracker/hook'
4
4
  module GitTracker
5
5
  module Runner
6
6
 
7
- def self.execute(cmd_arg, *args)
7
+ def self.execute(cmd_arg = 'help', *args)
8
8
  command = cmd_arg.gsub(/-/, '_')
9
9
  abort("[git_tracker] command: '#{cmd_arg}' does not exist.") unless respond_to?(command)
10
10
  send(command, *args)
@@ -14,12 +14,24 @@ module GitTracker
14
14
  PrepareCommitMessage.run(*args)
15
15
  end
16
16
 
17
+ def self.init
18
+ Hook.init
19
+ end
20
+
17
21
  def self.install
18
- Hook.install
22
+ puts "`git-tracker install` is deprecated. Please use `git-tracker init`"
23
+ self.init
19
24
  end
20
25
 
21
- def self.test_command
22
- puts 'git-tracker is here. How are you?'
26
+ def self.help
27
+ puts <<-HELP
28
+ git-tracker #{VERSION} is installed.
29
+
30
+ Remember, git-tracker is a hook which Git interacts with during its normal
31
+ lifecycle of committing, rebasing, merging, etc. You need to initialize this
32
+ hook by running `git-tracker init` from each repository in which you wish to
33
+ use it. Cheers!
34
+ HELP
23
35
  end
24
36
  end
25
37
 
@@ -1,3 +1,3 @@
1
1
  module GitTracker
2
- VERSION = '1.5.1'
2
+ VERSION = '1.6.0'
3
3
  end
@@ -2,26 +2,26 @@ require 'spec_helper'
2
2
  require 'git_tracker/branch'
3
3
 
4
4
  describe GitTracker::Branch do
5
- subject { described_class }
5
+ subject(:branch) { described_class }
6
6
 
7
7
  def stub_branch(ref, exit_status = 0)
8
8
  allow_message_expectations_on_nil
9
- subject.stub(:`) { ref }
9
+ branch.stub(:`) { ref }
10
10
  $?.stub(:exitstatus) { exit_status }
11
11
  end
12
12
 
13
13
  describe '.current' do
14
14
  it 'shells out to git, looking for the current HEAD' do
15
15
  stub_branch('refs/heads/herpty_derp_de')
16
- subject.should_receive('`').with('git symbolic-ref HEAD')
17
- subject.current
16
+ branch.should_receive('`').with('git symbolic-ref HEAD')
17
+ branch.current
18
18
  end
19
19
 
20
20
  it 'ensures in a Git repository when looking for HEAD exits with non-zero status' do
21
21
  stub_branch('', 128)
22
22
 
23
23
  GitTracker::Repository.should_receive(:ensure_exists)
24
- subject.current
24
+ branch.current
25
25
  end
26
26
  end
27
27
 
@@ -29,36 +29,36 @@ describe GitTracker::Branch do
29
29
  context 'Current branch has a story number' do
30
30
  it 'finds the story that starts with a hash' do
31
31
  stub_branch('refs/heads/a_very_descriptive_name_#8675309')
32
- expect(subject.story_number).to eq('8675309')
32
+ expect(branch.story_number).to eq('8675309')
33
33
  end
34
34
 
35
35
  it 'finds the story without a leading hash' do
36
36
  stub_branch('refs/heads/a_very_descriptive_name_1235309')
37
- expect(subject.story_number).to eq('1235309')
37
+ expect(branch.story_number).to eq('1235309')
38
38
  end
39
39
 
40
40
  it 'finds the story following a forward hash' do
41
41
  stub_branch('refs/heads/alindeman/8675309_got_her_number')
42
- expect(subject.story_number).to eq('8675309')
42
+ expect(branch.story_number).to eq('8675309')
43
43
  end
44
44
 
45
45
  it 'finds the story in a branch with hyphens' do
46
46
  stub_branch('refs/heads/stevenharman/got-her-number-8675309')
47
- expect(subject.story_number).to eq('8675309')
47
+ expect(branch.story_number).to eq('8675309')
48
48
  end
49
49
  end
50
50
 
51
51
  context 'The current branch does not have a story number' do
52
52
  it 'finds no story' do
53
53
  stub_branch('refs/heads/a_very_descriptive_name-without_a_#number')
54
- expect(subject.story_number).to_not be
54
+ expect(branch.story_number).to_not be
55
55
  end
56
56
  end
57
57
 
58
58
  context 'Not on a branch (HEAD does not exist)' do
59
59
  it 'finds no story' do
60
60
  stub_branch('')
61
- expect(subject.story_number).to_not be
61
+ expect(branch.story_number).to_not be
62
62
  end
63
63
  end
64
64
  end
@@ -5,7 +5,7 @@ require 'active_support/core_ext/string/strip'
5
5
  describe GitTracker::CommitMessage do
6
6
  include CommitMessageHelper
7
7
 
8
- subject { described_class.new(file) }
8
+ subject(:commit_message) { described_class.new(file) }
9
9
  let(:file) { 'COMMIT_EDITMSG' }
10
10
 
11
11
  it 'requires path to the temporary commit message file' do
@@ -20,13 +20,13 @@ describe GitTracker::CommitMessage do
20
20
  %w[fix Fixed FIXES Complete completed completes FINISH finished Finishes Deliver delivered DELIVERS].each do |keyword|
21
21
  it "detects the #{keyword} keyword" do
22
22
  stub_commit_message("Did the darn thing. [#{keyword}]")
23
- expect(subject.keyword).to eq(keyword)
23
+ expect(commit_message.keyword).to eq(keyword)
24
24
  end
25
25
  end
26
26
 
27
27
  it 'does not find the keyword when it does not exist' do
28
28
  stub_commit_message('Did the darn thing. [Something]')
29
- expect(subject.keyword).to_not be
29
+ expect(commit_message.keyword).to_not be
30
30
  end
31
31
  end
32
32
 
@@ -34,57 +34,57 @@ describe GitTracker::CommitMessage do
34
34
  context 'commit message contains the special Pivotal Tracker story syntax' do
35
35
  it 'allows just the number' do
36
36
  stub_commit_message('[#8675309]')
37
- expect(subject).to be_mentions_story('8675309')
37
+ expect(commit_message).to be_mentions_story('8675309')
38
38
  end
39
39
 
40
40
  it 'allows multiple numbers' do
41
41
  stub_commit_message('[#99 #777 #8675309 #111222]')
42
- expect(subject).to be_mentions_story('99')
43
- expect(subject).to be_mentions_story('777')
44
- expect(subject).to be_mentions_story('8675309')
45
- expect(subject).to be_mentions_story('111222')
42
+ expect(commit_message).to be_mentions_story('99')
43
+ expect(commit_message).to be_mentions_story('777')
44
+ expect(commit_message).to be_mentions_story('8675309')
45
+ expect(commit_message).to be_mentions_story('111222')
46
46
  end
47
47
 
48
48
  it 'allows state change before number' do
49
49
  stub_commit_message('[Fixes #8675309]')
50
- expect(subject).to be_mentions_story('8675309')
50
+ expect(commit_message).to be_mentions_story('8675309')
51
51
  end
52
52
 
53
53
  it 'allows state change after the number' do
54
54
  stub_commit_message('[#8675309 Delivered]')
55
- expect(subject).to be_mentions_story('8675309')
55
+ expect(commit_message).to be_mentions_story('8675309')
56
56
  end
57
57
 
58
58
  it 'allows surrounding text' do
59
59
  stub_commit_message('derp de #herp [Fixes #8675309] de herp-ity derp')
60
- expect(subject).to be_mentions_story('8675309')
60
+ expect(commit_message).to be_mentions_story('8675309')
61
61
  end
62
62
  end
63
63
 
64
64
  context 'commit message doesn not contain the special Pivotal Tracker story syntax' do
65
65
  it 'requires brackets' do
66
66
  stub_commit_message('#8675309')
67
- expect(subject).to_not be_mentions_story('8675309')
67
+ expect(commit_message).to_not be_mentions_story('8675309')
68
68
  end
69
69
 
70
70
  it 'requires a pound sign' do
71
71
  stub_commit_message('[8675309]')
72
- expect(subject).to_not be_mentions_story('8675309')
72
+ expect(commit_message).to_not be_mentions_story('8675309')
73
73
  end
74
74
 
75
75
  it 'does not allow the bare number' do
76
76
  stub_commit_message('8675309')
77
- expect(subject).to_not be_mentions_story('8675309')
77
+ expect(commit_message).to_not be_mentions_story('8675309')
78
78
  end
79
79
 
80
80
  it 'does not allow multiple state changes' do
81
81
  stub_commit_message('[Fixes Deploys #8675309]')
82
- expect(subject).to_not be_mentions_story('8675309')
82
+ expect(commit_message).to_not be_mentions_story('8675309')
83
83
  end
84
84
 
85
85
  it 'does not allow comments' do
86
86
  stub_commit_message('#[#8675309]')
87
- expect(subject).to_not be_mentions_story('8675309')
87
+ expect(commit_message).to_not be_mentions_story('8675309')
88
88
  end
89
89
  end
90
90
  end
@@ -99,7 +99,7 @@ describe GitTracker::CommitMessage do
99
99
  end
100
100
 
101
101
  it 'handles no existing message' do
102
- commit_message = <<-COMMIT_MESSAGE.strip_heredoc
102
+ commit_message_text = <<-COMMIT_MESSAGE.strip_heredoc
103
103
 
104
104
 
105
105
  [#8675309]
@@ -107,13 +107,13 @@ describe GitTracker::CommitMessage do
107
107
  COMMIT_MESSAGE
108
108
 
109
109
  stub_original_commit_message("\n\n# some other comments\n")
110
- subject.append('[#8675309]')
110
+ commit_message.append('[#8675309]')
111
111
 
112
- expect(fake_file.content).to eq(commit_message)
112
+ expect(fake_file.content).to eq(commit_message_text)
113
113
  end
114
114
 
115
115
  it 'preserves existing messages' do
116
- commit_message = <<-COMMIT_MESSAGE.strip_heredoc
116
+ commit_message_text = <<-COMMIT_MESSAGE.strip_heredoc
117
117
  A first line
118
118
 
119
119
  With more here
@@ -123,13 +123,13 @@ describe GitTracker::CommitMessage do
123
123
  COMMIT_MESSAGE
124
124
 
125
125
  stub_original_commit_message("A first line\n\nWith more here\n# other comments\n")
126
- subject.append('[#8675309]')
126
+ commit_message.append('[#8675309]')
127
127
 
128
- expect(fake_file.content).to eq(commit_message)
128
+ expect(fake_file.content).to eq(commit_message_text)
129
129
  end
130
130
 
131
131
  it 'preserves line breaks in comments' do
132
- commit_message = <<-COMMIT_MESSAGE.strip_heredoc
132
+ commit_message_text = <<-COMMIT_MESSAGE.strip_heredoc
133
133
 
134
134
 
135
135
  [#8675309]
@@ -139,9 +139,9 @@ describe GitTracker::CommitMessage do
139
139
  COMMIT_MESSAGE
140
140
 
141
141
  stub_original_commit_message("# comment #1\n# comment B\n# comment III")
142
- subject.append('[#8675309]')
142
+ commit_message.append('[#8675309]')
143
143
 
144
- expect(fake_file.content).to eq(commit_message)
144
+ expect(fake_file.content).to eq(commit_message_text)
145
145
  end
146
146
  end
147
147
  end
@@ -7,30 +7,31 @@ describe GitTracker::Hook do
7
7
  let(:root) { '/path/to/git/repo/toplevel' }
8
8
  let(:hook_path) { File.join(root, '.git', 'hooks', 'prepare-commit-msg') }
9
9
 
10
- describe '.install' do
10
+ describe '.init' do
11
11
  before do
12
12
  GitTracker::Repository.stub(:root) { root }
13
+ hook.stub(:init_at)
13
14
  end
14
15
 
15
- it 'installs to the root of the Git repository' do
16
- hook.should_receive(:install_at).with(root)
17
- hook.install
16
+ it 'initializes to the root of the Git repository' do
17
+ hook.init
18
+ expect(hook).to have_received(:init_at).with(root)
18
19
  end
19
20
  end
20
21
 
21
- describe '.install_at' do
22
+ describe '.init_at' do
22
23
  let(:fake_file) { GitTracker::FakeFile.new }
23
24
  before do
24
25
  File.stub(:open).and_yield(fake_file)
25
26
  end
26
27
 
27
28
  it 'writes the hook into the hooks directory' do
28
- File.should_receive(:open).with(hook_path, 'w')
29
- hook.install_at(root)
29
+ hook.init_at(root)
30
+ expect(File).to have_received(:open).with(hook_path, 'w')
30
31
  end
31
32
 
32
33
  it 'makes the hook executable' do
33
- hook.install_at(root)
34
+ hook.init_at(root)
34
35
  expect(fake_file.mode).to eq(0755)
35
36
  end
36
37
 
@@ -42,7 +43,7 @@ describe GitTracker::Hook do
42
43
 
43
44
  HOOK_CODE
44
45
 
45
- hook.install_at(root)
46
+ hook.init_at(root)
46
47
  expect(fake_file.content).to eq(hook_code)
47
48
  end
48
49
  end
@@ -2,43 +2,46 @@ require 'spec_helper'
2
2
  require 'git_tracker/prepare_commit_message'
3
3
 
4
4
  describe GitTracker::PrepareCommitMessage do
5
- subject { GitTracker::PrepareCommitMessage }
5
+ subject(:prepare_commit_message) { GitTracker::PrepareCommitMessage }
6
6
 
7
7
  describe '.run' do
8
- let(:hook) { stub('PrepareCommitMessage') }
8
+ let(:hook) { double('PrepareCommitMessage') }
9
9
  before do
10
- subject.stub(:new) { hook }
10
+ prepare_commit_message.stub(:new) { hook }
11
11
  end
12
12
 
13
13
  it 'runs the hook' do
14
14
  hook.should_receive(:run)
15
- subject.run('FILE1', 'hook_source', 'sha1234')
15
+ prepare_commit_message.run('FILE1', 'hook_source', 'sha1234')
16
16
  end
17
17
  end
18
18
 
19
19
  describe '.new' do
20
20
 
21
21
  it 'requires the name of the commit message file' do
22
- expect { subject.new }.to raise_error(ArgumentError)
22
+ expect { prepare_commit_message.new }.to raise_error(ArgumentError)
23
23
  end
24
24
 
25
25
  it 'remembers the name of the commit message file' do
26
- expect(subject.new('FILE1').file).to eq('FILE1')
26
+ expect(prepare_commit_message.new('FILE1').file).to eq('FILE1')
27
27
  end
28
28
 
29
29
  it 'optionally accepts a message source' do
30
- expect(hook = subject.new('FILE1', 'merge').source).to eq('merge')
30
+ expect(hook = prepare_commit_message.new('FILE1', 'merge').source).to eq('merge')
31
31
  end
32
32
 
33
33
  it 'optionally accepts the SHA-1 of a commit' do
34
- expect(hook = subject.new('FILE1', 'commit', 'abc1234').commit_sha).to eq('abc1234')
34
+ expect(hook = prepare_commit_message.new('FILE1', 'commit', 'abc1234').commit_sha).to eq('abc1234')
35
35
  end
36
36
  end
37
37
 
38
38
  describe '#run' do
39
39
  let(:hook) { GitTracker::PrepareCommitMessage.new('FILE1') }
40
+ let(:commit_message) { double('CommitMessage', append: nil) }
41
+
40
42
  before do
41
43
  GitTracker::Branch.stub(:story_number) { story }
44
+ GitTracker::CommitMessage.stub(:new) { commit_message }
42
45
  end
43
46
 
44
47
  context 'with an existing commit (via `-c`, `-C`, or `--amend` options)' do
@@ -54,33 +57,30 @@ describe GitTracker::PrepareCommitMessage do
54
57
 
55
58
  it 'exits without updating the commit message' do
56
59
  expect { hook.run }.to succeed
57
- GitTracker::CommitMessage.should_not have_received(:append)
60
+ expect(commit_message).to_not have_received(:append)
58
61
  end
59
62
  end
60
63
 
61
64
  context 'branch name with a Pivotal Tracker story number' do
62
65
  let(:story) { '8675309' }
63
- let(:commit_message) { stub('CommitMessage', :mentions_story? => false) }
64
-
65
66
  before do
67
+ commit_message.stub(:mentions_story?) { false }
66
68
  commit_message.stub(:keyword) { nil }
67
- GitTracker::CommitMessage.stub(:new) { commit_message }
68
69
  end
69
70
 
70
71
  it 'appends the number to the commit message' do
71
- commit_message.should_receive(:append).with('[#8675309]')
72
72
  hook.run
73
+ expect(commit_message).to have_received(:append).with('[#8675309]')
73
74
  end
74
75
 
75
76
  context 'keyword mentioned in the commit message' do
76
77
  before do
77
- commit_message.stub(:mentions_story?).with('8675309') { false }
78
78
  commit_message.stub(:keyword) { 'Delivers' }
79
79
  end
80
80
 
81
81
  it 'appends the keyword and the story number' do
82
- commit_message.should_receive(:append).with('[Delivers #8675309]')
83
82
  hook.run
83
+ expect(commit_message).to have_received(:append).with('[Delivers #8675309]')
84
84
  end
85
85
  end
86
86
 
@@ -91,7 +91,7 @@ describe GitTracker::PrepareCommitMessage do
91
91
 
92
92
  it 'exits without updating the commit message' do
93
93
  expect { hook.run }.to succeed
94
- GitTracker::CommitMessage.should_not have_received(:append)
94
+ expect(commit_message).to_not have_received(:append)
95
95
  end
96
96
  end
97
97
  end
@@ -2,30 +2,30 @@ require 'spec_helper'
2
2
  require 'git_tracker/repository'
3
3
 
4
4
  describe GitTracker::Repository do
5
- subject { described_class }
5
+ subject(:repository) { described_class }
6
6
  let(:git_command) { 'git rev-parse --show-toplevel' }
7
7
  before do
8
8
  allow_message_expectations_on_nil
9
- subject.stub(:`).with(git_command) { "/path/to/git/repo/root\n" }
9
+ repository.stub(:`).with(git_command) { "/path/to/git/repo/root\n" }
10
10
  end
11
11
 
12
12
  describe '.root' do
13
13
 
14
14
  it 'gets the path to the top-level directory of the local Repository' do
15
15
  $?.stub(:exitstatus) { 0 }
16
- expect(subject.root).to eq('/path/to/git/repo/root')
16
+ expect(repository.root).to eq('/path/to/git/repo/root')
17
17
  end
18
18
 
19
19
  it 'aborts when not in a git repository' do
20
20
  $?.stub(:exitstatus) { 128 }
21
- expect { subject.root }.to_not succeed
21
+ expect { repository.root }.to_not succeed
22
22
  end
23
23
  end
24
24
 
25
25
  describe '.ensure_exists' do
26
26
  it 'aborts when not in a git repository' do
27
27
  $?.stub(:exitstatus) { 128 }
28
- expect { subject.root }.to_not succeed
28
+ expect { repository.root }.to_not succeed
29
29
  end
30
30
  end
31
31
 
@@ -28,16 +28,16 @@ describe GitTracker::Runner do
28
28
  end
29
29
  end
30
30
 
31
- describe '.install' do
32
- it 'tells the hook to install itself' do
33
- GitTracker::Hook.should_receive(:install)
34
- runner.install
31
+ describe '.init' do
32
+ it 'tells the hook to initialize itself' do
33
+ GitTracker::Hook.should_receive(:init)
34
+ runner.init
35
35
  end
36
36
  end
37
37
 
38
- it '.test_command reports that it was run' do
39
- runner.should_receive(:puts).with('git-tracker is here. How are you?')
40
- runner.execute('test-command')
38
+ it '.help reports that it was run' do
39
+ runner.should_receive(:puts).with(/git-tracker #{GitTracker::VERSION} is installed\./)
40
+ runner.execute('help')
41
41
  end
42
42
 
43
43
  end
@@ -23,51 +23,50 @@ describe GitTracker::Standalone do
23
23
  end
24
24
 
25
25
  describe '#build' do
26
- subject { standalone }
26
+ subject(:standalone_script) { described_class.build(io).string }
27
27
  let(:io) { StringIO.new }
28
- let(:standalone) { described_class.build(io).string }
29
28
 
30
29
  it 'declares a shebang' do
31
- expect(subject).to match(/#!.+/)
30
+ expect(standalone_script).to match(/#!.+/)
32
31
  end
33
32
 
34
33
  it 'includes generated code notice' do
35
- expect(subject).to include('This file is generated')
34
+ expect(standalone_script).to include('This file is generated')
36
35
  end
37
36
 
38
37
  it 'inlines the code' do
39
- expect(subject).to include('Hook')
40
- expect(subject).to include('Repository')
41
- expect(subject).to include('PrepareCommitMessage')
42
- expect(subject).to include('Runner')
43
- expect(subject).to include('Branch')
44
- expect(subject).to include('CommitMessage')
45
- expect(subject).to include('VERSION')
38
+ expect(standalone_script).to include('Hook')
39
+ expect(standalone_script).to include('Repository')
40
+ expect(standalone_script).to include('PrepareCommitMessage')
41
+ expect(standalone_script).to include('Runner')
42
+ expect(standalone_script).to include('Branch')
43
+ expect(standalone_script).to include('CommitMessage')
44
+ expect(standalone_script).to include('VERSION')
46
45
  end
47
46
 
48
47
  it 'inlines the message HEREDOC' do
49
- expect(standalone).to include('#{preamble.strip}')
48
+ expect(standalone_script).to include('#{preamble.strip}')
50
49
  end
51
50
 
52
51
  it 'inlines the shebang for the hook' do
53
- expect(standalone).to include('#!/usr/bin/env bash')
52
+ expect(standalone_script).to include('#!/usr/bin/env bash')
54
53
  end
55
54
 
56
55
  it 'does not inline the standalone code' do
57
- expect(subject).to_not include('module Standalone')
56
+ expect(standalone_script).to_not include('module Standalone')
58
57
  end
59
58
 
60
59
  it 'includes the call to execute the hook' do
61
- expect(subject).to include('GitTracker::Runner.execute(*ARGV)')
60
+ expect(standalone_script).to include('GitTracker::Runner.execute(*ARGV)')
62
61
  end
63
62
 
64
63
  it 'excludes requiring git_tracker code' do
65
- expect(subject).to_not match(/^require\s+["']git_tracker/)
64
+ expect(standalone_script).to_not match(/^require\s+["']git_tracker/)
66
65
  end
67
66
  end
68
67
 
69
68
  describe '#ruby_executable' do
70
- subject { described_class }
69
+ subject(:standalone) { described_class }
71
70
  before do
72
71
  RbConfig::CONFIG.stub(:[]).with('bindir') { '/some/other/bin' }
73
72
  RbConfig::CONFIG.stub(:[]).with('ruby_install_name') { 'ruby' }
@@ -75,12 +74,12 @@ describe GitTracker::Standalone do
75
74
 
76
75
  it 'uses user-level ruby binary when it is executable' do
77
76
  File.stub(:executable?).with('/usr/bin/ruby') { true }
78
- expect(subject.ruby_executable).to eq('/usr/bin/ruby')
77
+ expect(standalone.ruby_executable).to eq('/usr/bin/ruby')
79
78
  end
80
79
 
81
80
  it 'uses rbconfig ruby when user-level ruby binary not executable' do
82
81
  File.stub(:executable?).with('/usr/bin/ruby') { false }
83
- expect(subject.ruby_executable).to eq('/some/other/bin/ruby')
82
+ expect(standalone.ruby_executable).to eq('/some/other/bin/ruby')
84
83
  end
85
84
  end
86
85
  end
metadata CHANGED
@@ -1,98 +1,74 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_tracker
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 1.5.1
4
+ version: 1.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Steven Harman
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-06 00:00:00.000000000 Z
11
+ date: 2013-08-12 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '2.12'
20
- none: false
21
14
  name: rspec
22
- type: :development
23
- prerelease: false
24
15
  requirement: !ruby/object:Gem::Requirement
25
16
  requirements:
26
17
  - - ~>
27
18
  - !ruby/object:Gem::Version
28
- version: '2.12'
29
- none: false
30
- - !ruby/object:Gem::Dependency
31
- version_requirements: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - ~>
34
- - !ruby/object:Gem::Version
35
- version: '2.0'
36
- none: false
37
- name: rspec-spies
19
+ version: '2.14'
38
20
  type: :development
39
21
  prerelease: false
40
- requirement: !ruby/object:Gem::Requirement
22
+ version_requirements: !ruby/object:Gem::Requirement
41
23
  requirements:
42
24
  - - ~>
43
25
  - !ruby/object:Gem::Version
44
- version: '2.0'
45
- none: false
26
+ version: '2.14'
46
27
  - !ruby/object:Gem::Dependency
47
- version_requirements: !ruby/object:Gem::Requirement
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
48
30
  requirements:
49
31
  - - ~>
50
32
  - !ruby/object:Gem::Version
51
33
  version: '3.2'
52
- none: false
53
- name: activesupport
54
34
  type: :development
55
35
  prerelease: false
56
- requirement: !ruby/object:Gem::Requirement
36
+ version_requirements: !ruby/object:Gem::Requirement
57
37
  requirements:
58
38
  - - ~>
59
39
  - !ruby/object:Gem::Version
60
40
  version: '3.2'
61
- none: false
62
41
  - !ruby/object:Gem::Dependency
63
- version_requirements: !ruby/object:Gem::Requirement
42
+ name: pry
43
+ requirement: !ruby/object:Gem::Requirement
64
44
  requirements:
65
45
  - - ~>
66
46
  - !ruby/object:Gem::Version
67
47
  version: 0.9.11
68
- none: false
69
- name: pry
70
48
  type: :development
71
49
  prerelease: false
72
- requirement: !ruby/object:Gem::Requirement
50
+ version_requirements: !ruby/object:Gem::Requirement
73
51
  requirements:
74
52
  - - ~>
75
53
  - !ruby/object:Gem::Version
76
54
  version: 0.9.11
77
- none: false
78
55
  - !ruby/object:Gem::Dependency
79
- version_requirements: !ruby/object:Gem::Requirement
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
80
58
  requirements:
81
- - - ! '>='
59
+ - - '>='
82
60
  - !ruby/object:Gem::Version
83
61
  version: '0'
84
- none: false
85
- name: rake
86
62
  type: :development
87
63
  prerelease: false
88
- requirement: !ruby/object:Gem::Requirement
64
+ version_requirements: !ruby/object:Gem::Requirement
89
65
  requirements:
90
- - - ! '>='
66
+ - - '>='
91
67
  - !ruby/object:Gem::Version
92
68
  version: '0'
93
- none: false
94
- description: ! " Some simple tricks that make working with Pivotal Tracker even\n
95
- \ better... and easier... um, besier!\n"
69
+ description: |2
70
+ Some simple tricks that make working with Pivotal Tracker even
71
+ better... and easier... um, besier!
96
72
  email:
97
73
  - steveharman@gmail.com
98
74
  executables:
@@ -133,27 +109,26 @@ files:
133
109
  - spec/support/matchers/exit_code_matchers.rb
134
110
  homepage: https://github.com/stevenharman/git_tracker
135
111
  licenses: []
112
+ metadata: {}
136
113
  post_install_message:
137
114
  rdoc_options: []
138
115
  require_paths:
139
116
  - lib
140
117
  required_ruby_version: !ruby/object:Gem::Requirement
141
118
  requirements:
142
- - - ! '>='
119
+ - - '>='
143
120
  - !ruby/object:Gem::Version
144
121
  version: '0'
145
- none: false
146
122
  required_rubygems_version: !ruby/object:Gem::Requirement
147
123
  requirements:
148
- - - ! '>='
124
+ - - '>='
149
125
  - !ruby/object:Gem::Version
150
126
  version: '0'
151
- none: false
152
127
  requirements: []
153
128
  rubyforge_project:
154
- rubygems_version: 1.8.23
129
+ rubygems_version: 2.0.5
155
130
  signing_key:
156
- specification_version: 3
131
+ specification_version: 4
157
132
  summary: Teaching Git about Pivotal Tracker.
158
133
  test_files:
159
134
  - spec/git_tracker/branch_spec.rb
@@ -167,4 +142,3 @@ test_files:
167
142
  - spec/support/commit_message_helper.rb
168
143
  - spec/support/fake_file.rb
169
144
  - spec/support/matchers/exit_code_matchers.rb
170
- has_rdoc: