git_tracker 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,19 +1,12 @@
1
1
  *.gem
2
- *.rbc
3
2
  .bundle
4
- .config
5
- .yardoc
6
3
  Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
4
  coverage
10
5
  doc/
11
6
  lib/bundler/man
7
+ /git-tracker
12
8
  pkg
13
9
  rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
10
  tmp
18
11
  tags
19
12
  .rvmrc
data/.rspec CHANGED
@@ -1,4 +1,3 @@
1
1
  --colour
2
2
  -I spec/support
3
3
  -r rspec-spies
4
- -r pry
data/CHANGELOG.md CHANGED
@@ -1,19 +1,30 @@
1
1
  ### dev
2
- [full changelog](https://github.com/highgroove/git_tracker/compare/v1.3.0...master)
2
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.5.0...master)
3
+
4
+ ### 1.5.0 / 2013-02-02
5
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.4.0...v1.5.0)
6
+
7
+ Enhancements
8
+
9
+ * Support installing via Homebrew: `brew install git-tracker`
10
+ * Generate standalone binary via `rake standalone:build`
11
+
12
+ ### 1.4.0 / 2012-06-11
13
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.3.1...v1.4.0)
14
+
3
15
  Enhancements
4
16
 
5
17
  * Support Ruby 1.8.7
6
- * Generate standalone binary via `rake git-tracker`
7
18
 
8
19
  ### 1.3.1 / 2012-04-23
9
- [full changelog](https://github.com/highgroove/git_tracker/compare/v1.3.0...v1.3.1)
20
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.3.0...v1.3.1)
10
21
 
11
22
  Bug fixes
12
23
 
13
24
  * Bring back fourth Pivotal Tracker keyword, `delivered`
14
25
 
15
26
  ### 1.3.0 / 2012-04-23
16
- [full changelog](https://github.com/highgroove/git_tracker/compare/v1.2.0...v1.3.0)
27
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.2.0...v1.3.0)
17
28
 
18
29
  Enhancements
19
30
 
@@ -24,7 +35,7 @@ Bug fixes
24
35
  * Pivotal Tracker keywords are case-insensitive
25
36
 
26
37
  ### 1.2.0 / 2012-04-21
27
- [full changelog](https://github.com/highgroove/git_tracker/compare/v1.1.0...v1.2.0)
38
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.1.0...v1.2.0)
28
39
 
29
40
  Enhancements
30
41
 
@@ -33,11 +44,11 @@ Enhancements
33
44
  Bug fixes
34
45
 
35
46
  * Exit with non-zero status code when a commit exists [issue
36
- #3](https://github.com/highgroove/git_tracker/issues/3)
47
+ #3](https://github.com/stevenharman/git_tracker/issues/3)
37
48
  * Exit with non-zero status code with not in a Git repository
38
49
 
39
50
  ### 1.1.0 / 2012-04-03
40
- [full changelog](https://github.com/highgroove/git_tracker/compare/v1.0.0...v1.1.0)
51
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v1.0.0...v1.1.0)
41
52
 
42
53
  Enhancements
43
54
 
@@ -47,16 +58,16 @@ Bug fixes
47
58
 
48
59
  * Fix case-sensitivity issue w/English library
49
60
  * Exit with non-zero status code with not in a Git repository [issue
50
- #1](https://github.com/highgroove/git_tracker/issues/1)
61
+ #1](https://github.com/stevenharman/git_tracker/issues/1)
51
62
 
52
63
  ### 1.0.0 / 2012-03-31
53
- [full changelog](https://github.com/highgroove/git_tracker/compare/v0.0.1...v1.0.0)
64
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/v0.0.1...v1.0.0)
54
65
 
55
66
  Enhancements
56
67
 
57
68
  * Hook can install itself in a Git repository
58
69
 
59
70
  ### 0.0.1 / 2012-03-23
60
- [full changelog](https://github.com/highgroove/git_tracker/compare/5fbbe061e721c1f86fdd5d78a4bfb4c61a0eaf5c...v0.0.1)
71
+ [full changelog](https://github.com/stevenharman/git_tracker/compare/5fbbe061e721c1f86fdd5d78a4bfb4c61a0eaf5c...v0.0.1)
61
72
 
62
73
  * Initial release
data/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # GitTracker [![Build Status](https://secure.travis-ci.org/highgroove/git_tracker.png)](http://travis-ci.org/highgroove/git_tracker)
1
+ # GitTracker
2
+
3
+ [![Build Status](https://secure.travis-ci.org/stevenharman/git_tracker.png)](http://travis-ci.org/stevenharman/git_tracker)
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)
2
6
 
3
7
  *GitTracker*, or *git-tracker*, is a Git hook that will scan your current
4
8
  branch name looking for something it recognizes as a [Pivotal Tracker][pt]
@@ -7,30 +11,38 @@ format][pt-format], to your commit message.
7
11
 
8
12
  ## Installation
9
13
 
10
- You need to get the `git-tracker` executable on your system.
14
+ ### 1) Install the `git-tracker` executable
11
15
 
12
- ### RubyGems
16
+ You need to get the `git-tracker` executable on your system, and then you need
17
+ to install the *git hook* into your local Git repository.
13
18
 
14
- Currently, this is the only option, but I plan to have a standalone version
15
- ready soon.
19
+ - via [Homebrew][homebrew] (preferred)
16
20
 
17
- ```bash
18
- $ gem install git_tracker
19
- ```
21
+ ```bash
22
+ $ brew install git-tracker
23
+ ```
24
+
25
+ - via [RubyGems][rubygems] (if you must)
26
+
27
+ ```bash
28
+ $ gem install git_tracker
29
+ ```
30
+
31
+ ### 2) Install the hook
20
32
 
21
- Once you have the `git-tracker` executable on your system you need to install
22
- the hook into your local Git repository.
33
+ You need to add the hook into each repository where you want to use it.
23
34
 
24
35
  ```bash
25
36
  # from inside a local Git repository
37
+ # for example: /path/to/repo/
26
38
  $ git-tracker install
27
39
  ```
28
40
 
29
41
  This will put the `prepare-commit-msg` hook in the `/path/to/repo/.git/hooks`
30
42
  directory and make it executable.
31
43
 
32
- **NOTE:** This will need to be done for each repository that you wish to use
33
- the hook.
44
+ **NOTE:** The hook needs to be installed just once for each repository in which
45
+ you will use it.
34
46
 
35
47
  ## Usage
36
48
 
@@ -38,7 +50,7 @@ With the hook installed in a repository, create branches being sure to include
38
50
  the Pivotal Tracker story number in the branch name.
39
51
 
40
52
  ```bash
41
- $ git checkout -b a_useful_and_helpful_name_#8675309
53
+ $ git checkout -b a_useful_and_helpful_name_8675309
42
54
  ```
43
55
 
44
56
  When you commit, Git will fire the hook which will find the story number in the
@@ -46,7 +58,7 @@ branch name and prepare your commit message so that it include the story number
46
58
  in the special Pivotal Tracker syntax.
47
59
 
48
60
  ```bash
49
- # on branch named `best_feature_ever-#8675309`
61
+ # on branch named `best_feature_ever-8675309`
50
62
  $ git commit
51
63
  ```
52
64
 
@@ -59,7 +71,7 @@ the top)*
59
71
  [#8675309]
60
72
  # Please enter the commit message for your changes. Lines starting
61
73
  # with '#' will be ignored, and an empty message aborts the commit.
62
- # On branch best_feature_ever-#8675309
74
+ # On branch best_feature_ever-8675309
63
75
  # Changes to be committed:
64
76
  # (use "git reset HEAD <file>..." to unstage)
65
77
  #
@@ -76,7 +88,7 @@ If you pass a commit message on the command line the hook will still add the
76
88
  story number, preceded by an empty line, to the end of your message.
77
89
 
78
90
  ```bash
79
- # on branch named `best_feature_ever-#8675309`
91
+ # on branch named `best_feature_ever-8675309`
80
92
  $ git commit -m'Look at this rad code, yo!'
81
93
  ```
82
94
 
@@ -92,7 +104,7 @@ However, if you include the story number in the Pivotal Tracker format in your
92
104
  commit message, the hook will do nothing.
93
105
 
94
106
  ```bash
95
- # on branch named `best_feature_ever-#8675309`
107
+ # on branch named `best_feature_ever-8675309`
96
108
  $ git commit -m'[#8675309] Look at this rad code, yo!'
97
109
  ```
98
110
 
@@ -100,7 +112,7 @@ Results in this commit message:
100
112
 
101
113
 
102
114
  ```
103
- [#12356] Look at this rad code, yo!
115
+ [#8675309] Look at this rad code, yo!
104
116
  ```
105
117
 
106
118
  ### Keywords
@@ -116,7 +128,7 @@ to the story ID in the commit message.
116
128
  For example:
117
129
 
118
130
  ```bash
119
- # on branch named `bug/redis_connection_not_initializing_#8675309`
131
+ # on branch named `bug/redis_connection_not_initializing_8675309`
120
132
  $ git commit -am "Change the redis connection string [Fixes]"
121
133
  ```
122
134
 
@@ -134,21 +146,23 @@ Change the redis connection string [Fixes]
134
146
  name, optionally prefixing it with a hash (`#`). Examples:
135
147
 
136
148
  - `best_feature_ever_#8675309`
137
- - `best_feature_ever_8675309`
149
+ - `best-feature-ever-8675309`
138
150
  - `8675309_best_feature_ever`
139
- - `#8675309_best_feature_ever`
151
+ - `#8675309-best-feature-ever`
140
152
  - `your_name/8675309_best_feature_ever`
141
153
  - `your_name/#8675309_best_feature_ever`
142
154
 
143
155
  ## Contributing :octocat:
144
156
 
145
157
  1. Fork it
146
- 2. Create your feature branch (`git checkout -b my-new-feature`)
158
+ 2. Create your feature branch (`git checkout -b my_new_feature`)
147
159
  3. Commit your changes (`git commit -am 'Added some feature'`)
148
- 4. Push to the branch (`git push origin my-new-feature`)
160
+ 4. Push to the branch (`git push origin my_new_feature`)
149
161
  5. Create new Pull Request
150
162
 
151
163
 
152
164
  [pt]: https://www.pivotaltracker.com/
153
165
  [pt-format]: https://www.pivotaltracker.com/help/api?version=v3#scm_post_commit_message_syntax
154
166
  [tpope]: http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html
167
+ [homebrew]: http://mxcl.github.com/homebrew
168
+ [rubygems]: http://rubygems.org/gems/git_tracker
data/Rakefile CHANGED
@@ -1,12 +1,65 @@
1
1
  #!/usr/bin/env rake
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
2
+ require File.expand_path('../lib/git_tracker/version', __FILE__)
4
3
 
5
- RSpec::Core::RakeTask.new(:spec)
6
- task :default => :spec
4
+ # Skip these tasks when being installed by Homebrew
5
+ unless ENV['HOMEBREW_BREW_FILE']
7
6
 
8
- file 'git-tracker' => FileList.new('lib/git_tracker.rb, lib/git_tracker/*.rb') do |task|
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec)
9
+ task :default => :spec
10
+
11
+ # Rubygems tasks
12
+ namespace :gem do
13
+ require 'bundler/gem_tasks'
14
+ end
15
+
16
+ desc "Create tag v#{GitTracker::VERSION}, build, and push to GitHub, Rubygems, and Homebrew"
17
+ task :release => ['gem:release', 'standalone:homebrew']
18
+
19
+ end
20
+
21
+ # standalone and Homebrew
22
+ file 'git-tracker' => FileList.new('lib/git_tracker.rb', 'lib/git_tracker/*.rb') do |task|
9
23
  $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
10
24
  require 'git_tracker/standalone'
11
25
  GitTracker::Standalone.save(task.name)
12
26
  end
27
+
28
+ namespace :standalone do
29
+
30
+ desc 'Build standalone script'
31
+ task :build => 'git-tracker'
32
+
33
+ desc 'Build and install standalone script'
34
+ task :install => 'standalone:build' do
35
+ prefix = ENV['PREFIX'] || ENV['prefix'] || '/usr/local'
36
+
37
+ FileUtils.mkdir_p "#{prefix}/bin"
38
+ FileUtils.cp 'git-tracker', "#{prefix}/bin", :preserve => true
39
+ end
40
+
41
+ task :homebrew do
42
+ Dir.chdir `brew --prefix`.chomp do
43
+ sh 'git checkout -q master'
44
+ sh 'git pull -q origin master'
45
+
46
+ formula_file = 'Library/Formula/git-tracker.rb'
47
+ sha = `curl -#L https://github.com/stevenharman/git_tracker/tarball/v#{GitTracker::VERSION} | shasum`.split(/\s+/).first
48
+ abort unless $?.success? and sha.length == 40
49
+
50
+ formula = File.read formula_file
51
+ formula.sub! /\bv\d+(\.\d+)*/, "v#{GitTracker::VERSION}"
52
+ formula.sub! /\b[0-9a-f]{40}\b/, sha
53
+ File.open(formula_file, 'w') {|f| f << formula }
54
+
55
+ branch = "git_tracker-v#{GitTracker::VERSION}"
56
+ sh "git checkout -q -B #{branch}"
57
+ sh "git commit -m 'upgrade git-tracker to v#{GitTracker::VERSION}' -- #{formula_file}"
58
+ sh "git push -u stevenharman #{branch}"
59
+ sh "hub pull-request 'upgrade git-tracker to v#{GitTracker::VERSION}'"
60
+
61
+ sh "git checkout -q master"
62
+ end
63
+ end
64
+ end
65
+
data/git_tracker.gemspec CHANGED
@@ -6,16 +6,15 @@ Gem::Specification.new do |gem|
6
6
  gem.version = GitTracker::VERSION
7
7
  gem.authors = ["Steven Harman"]
8
8
  gem.email = ["steveharman@gmail.com"]
9
- gem.homepage = "https://github.com/highgroove/git_tracker"
9
+ gem.homepage = "https://github.com/stevenharman/git_tracker"
10
10
  gem.summary = %q{Teaching Git about Pivotal Tracker.}
11
11
  gem.description = <<-EOF
12
12
  Some simple tricks that make working with Pivotal Tracker even
13
13
  better... and easier... um, besier!
14
14
  EOF
15
15
 
16
- gem.add_development_dependency "rspec", "~> 2.9"
16
+ gem.add_development_dependency "rspec", "~> 2.12"
17
17
  gem.add_development_dependency "rspec-spies", "~> 2.0"
18
- gem.add_development_dependency "pry", "~> 0.9"
19
18
  gem.add_development_dependency "activesupport", "~> 3.2"
20
19
  gem.add_development_dependency "rake"
21
20
 
data/lib/git_tracker.rb CHANGED
@@ -1,8 +1,7 @@
1
+ require 'git_tracker/version'
1
2
  require 'git_tracker/hook'
2
3
  require 'git_tracker/repository'
3
4
  require 'git_tracker/prepare_commit_message'
4
5
  require 'git_tracker/runner'
5
6
  require 'git_tracker/branch'
6
7
  require 'git_tracker/commit_message'
7
- require 'git_tracker/version'
8
-
@@ -17,6 +17,10 @@ module GitTracker
17
17
  def self.install
18
18
  Hook.install
19
19
  end
20
+
21
+ def self.test_command
22
+ puts 'git-tracker is here. How are you?'
23
+ end
20
24
  end
21
25
 
22
26
  end
@@ -8,7 +8,7 @@ module GitTracker
8
8
  # This file is generated code. DO NOT send patches for it.
9
9
  #
10
10
  # Original source files with comments are at:
11
- # https://github.com/highgroove/git_tracker
11
+ # https://github.com/stevenharman/git_tracker
12
12
  #
13
13
 
14
14
  preamble
@@ -1,3 +1,3 @@
1
1
  module GitTracker
2
- VERSION = '1.4.0'
2
+ VERSION = '1.5.0'
3
3
  end
@@ -29,31 +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
- subject.story_number.should == '8675309'
32
+ expect(subject.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
- subject.story_number.should == '1235309'
37
+ expect(subject.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
- subject.story_number.should == '8675309'
42
+ expect(subject.story_number).to eq('8675309')
43
+ end
44
+
45
+ it 'finds the story in a branch with hyphens' do
46
+ stub_branch('refs/heads/stevenharman/got-her-number-8675309')
47
+ expect(subject.story_number).to eq('8675309')
43
48
  end
44
49
  end
45
50
 
46
51
  context 'The current branch does not have a story number' do
47
52
  it 'finds no story' do
48
- stub_branch('refs/heads/a_very_descriptive_name_without_a_#number')
49
- subject.story_number.should_not be
53
+ stub_branch('refs/heads/a_very_descriptive_name-without_a_#number')
54
+ expect(subject.story_number).to_not be
50
55
  end
51
56
  end
52
57
 
53
58
  context 'Not on a branch (HEAD does not exist)' do
54
59
  it 'finds no story' do
55
60
  stub_branch('')
56
- subject.story_number.should_not be
61
+ expect(subject.story_number).to_not be
57
62
  end
58
63
  end
59
64
  end
@@ -9,7 +9,7 @@ describe GitTracker::CommitMessage do
9
9
  let(:file) { 'COMMIT_EDITMSG' }
10
10
 
11
11
  it 'requires path to the temporary commit message file' do
12
- lambda { GitTracker::CommitMessage.new }.should raise_error ArgumentError
12
+ expect { GitTracker::CommitMessage.new }.to raise_error ArgumentError
13
13
  end
14
14
 
15
15
  def stub_commit_message(story_text)
@@ -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
- subject.keyword.should == keyword
23
+ expect(subject.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
- subject.keyword.should_not be
29
+ expect(subject.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
- subject.should be_mentions_story('8675309')
37
+ expect(subject).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
- subject.should be_mentions_story('99')
43
- subject.should be_mentions_story('777')
44
- subject.should be_mentions_story('8675309')
45
- subject.should be_mentions_story('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')
46
46
  end
47
47
 
48
48
  it 'allows state change before number' do
49
49
  stub_commit_message('[Fixes #8675309]')
50
- subject.should be_mentions_story('8675309')
50
+ expect(subject).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
- subject.should be_mentions_story('8675309')
55
+ expect(subject).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
- subject.should be_mentions_story('8675309')
60
+ expect(subject).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
- subject.should_not be_mentions_story('8675309')
67
+ expect(subject).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
- subject.should_not be_mentions_story('8675309')
72
+ expect(subject).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
- subject.should_not be_mentions_story('8675309')
77
+ expect(subject).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
- subject.should_not be_mentions_story('8675309')
82
+ expect(subject).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
- subject.should_not be_mentions_story('8675309')
87
+ expect(subject).to_not be_mentions_story('8675309')
88
88
  end
89
89
  end
90
90
  end
@@ -99,22 +99,21 @@ describe GitTracker::CommitMessage do
99
99
  end
100
100
 
101
101
  it 'handles no existing message' do
102
- stub_original_commit_message("\n\n# some other comments\n")
103
- subject.append('[#8675309]')
104
-
105
- fake_file.content.should == <<-COMMIT_MESSAGE.strip_heredoc
102
+ commit_message = <<-COMMIT_MESSAGE.strip_heredoc
106
103
 
107
104
 
108
105
  [#8675309]
109
106
  # some other comments
110
107
  COMMIT_MESSAGE
111
- end
112
108
 
113
- it 'preserves existing messages' do
114
- stub_original_commit_message("A first line\n\nWith more here\n# other comments\n")
109
+ stub_original_commit_message("\n\n# some other comments\n")
115
110
  subject.append('[#8675309]')
116
111
 
117
- fake_file.content.should == <<-COMMIT_MESSAGE.strip_heredoc
112
+ expect(fake_file.content).to eq(commit_message)
113
+ end
114
+
115
+ it 'preserves existing messages' do
116
+ commit_message = <<-COMMIT_MESSAGE.strip_heredoc
118
117
  A first line
119
118
 
120
119
  With more here
@@ -122,13 +121,15 @@ describe GitTracker::CommitMessage do
122
121
  [#8675309]
123
122
  # other comments
124
123
  COMMIT_MESSAGE
125
- end
126
124
 
127
- it 'preserves line breaks in comments' do
128
- stub_original_commit_message("# comment #1\n# comment B\n# comment III")
125
+ stub_original_commit_message("A first line\n\nWith more here\n# other comments\n")
129
126
  subject.append('[#8675309]')
130
127
 
131
- fake_file.content.should == <<-COMMIT_MESSAGE.strip_heredoc
128
+ expect(fake_file.content).to eq(commit_message)
129
+ end
130
+
131
+ it 'preserves line breaks in comments' do
132
+ commit_message = <<-COMMIT_MESSAGE.strip_heredoc
132
133
 
133
134
 
134
135
  [#8675309]
@@ -136,6 +137,11 @@ describe GitTracker::CommitMessage do
136
137
  # comment B
137
138
  # comment III
138
139
  COMMIT_MESSAGE
140
+
141
+ stub_original_commit_message("# comment #1\n# comment B\n# comment III")
142
+ subject.append('[#8675309]')
143
+
144
+ expect(fake_file.content).to eq(commit_message)
139
145
  end
140
146
  end
141
147
  end
@@ -3,7 +3,7 @@ require 'git_tracker/hook'
3
3
  require 'active_support/core_ext/string/strip'
4
4
 
5
5
  describe GitTracker::Hook do
6
- subject { described_class }
6
+ subject(:hook) { described_class }
7
7
  let(:root) { '/path/to/git/repo/toplevel' }
8
8
  let(:hook_path) { File.join(root, '.git', 'hooks', 'prepare-commit-msg') }
9
9
 
@@ -13,8 +13,8 @@ describe GitTracker::Hook do
13
13
  end
14
14
 
15
15
  it 'installs to the root of the Git repository' do
16
- subject.should_receive(:install_at).with(root)
17
- subject.install
16
+ hook.should_receive(:install_at).with(root)
17
+ hook.install
18
18
  end
19
19
  end
20
20
 
@@ -26,22 +26,24 @@ describe GitTracker::Hook do
26
26
 
27
27
  it 'writes the hook into the hooks directory' do
28
28
  File.should_receive(:open).with(hook_path, 'w')
29
- subject.install_at(root)
29
+ hook.install_at(root)
30
30
  end
31
31
 
32
32
  it 'makes the hook executable' do
33
- subject.install_at(root)
34
- fake_file.mode.should == 0755
33
+ hook.install_at(root)
34
+ expect(fake_file.mode).to eq(0755)
35
35
  end
36
36
 
37
37
  it 'writes the hook code in the hook file' do
38
- subject.install_at(root)
39
- fake_file.content.should == <<-HOOK_CODE.strip_heredoc
38
+ hook_code = <<-HOOK_CODE.strip_heredoc
40
39
  #!/usr/bin/env bash
41
40
 
42
41
  git-tracker prepare-commit-msg "$@"
43
42
 
44
43
  HOOK_CODE
44
+
45
+ hook.install_at(root)
46
+ expect(fake_file.content).to eq(hook_code)
45
47
  end
46
48
  end
47
49
 
@@ -19,19 +19,19 @@ describe GitTracker::PrepareCommitMessage do
19
19
  describe '.new' do
20
20
 
21
21
  it 'requires the name of the commit message file' do
22
- lambda { subject.new }.should raise_error(ArgumentError)
22
+ expect { subject.new }.to raise_error(ArgumentError)
23
23
  end
24
24
 
25
25
  it 'remembers the name of the commit message file' do
26
- subject.new('FILE1').file.should == 'FILE1'
26
+ expect(subject.new('FILE1').file).to eq('FILE1')
27
27
  end
28
28
 
29
29
  it 'optionally accepts a message source' do
30
- hook = subject.new('FILE1', 'merge').source.should == 'merge'
30
+ expect(hook = subject.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
- hook = subject.new('FILE1', 'commit', 'abc1234').commit_sha.should == 'abc1234'
34
+ expect(hook = subject.new('FILE1', 'commit', 'abc1234').commit_sha).to eq('abc1234')
35
35
  end
36
36
  end
37
37
 
@@ -45,7 +45,7 @@ describe GitTracker::PrepareCommitMessage do
45
45
  let(:hook) { described_class.new('FILE2', 'commit', '60a086f3') }
46
46
 
47
47
  it 'exits with status code 0' do
48
- lambda { hook.run }.should succeed
48
+ expect { hook.run }.to succeed
49
49
  end
50
50
  end
51
51
 
@@ -53,7 +53,7 @@ describe GitTracker::PrepareCommitMessage do
53
53
  let(:story) { nil }
54
54
 
55
55
  it 'exits without updating the commit message' do
56
- lambda { hook.run }.should succeed
56
+ expect { hook.run }.to succeed
57
57
  GitTracker::CommitMessage.should_not have_received(:append)
58
58
  end
59
59
  end
@@ -90,7 +90,7 @@ describe GitTracker::PrepareCommitMessage do
90
90
  end
91
91
 
92
92
  it 'exits without updating the commit message' do
93
- lambda { hook.run }.should succeed
93
+ expect { hook.run }.to succeed
94
94
  GitTracker::CommitMessage.should_not have_received(:append)
95
95
  end
96
96
  end
@@ -13,19 +13,19 @@ describe GitTracker::Repository 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
- subject.root.should == '/path/to/git/repo/root'
16
+ expect(subject.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
- lambda { subject.root }.should_not succeed
21
+ expect { subject.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
- lambda { subject.root }.should_not succeed
28
+ expect { subject.root }.to_not succeed
29
29
  end
30
30
  end
31
31
 
@@ -2,37 +2,42 @@ require 'spec_helper'
2
2
  require 'git_tracker/runner'
3
3
 
4
4
  describe GitTracker::Runner do
5
- subject { described_class }
5
+ subject(:runner) { described_class }
6
6
  let(:args) { ['a_file', 'the_source', 'sha1234'] }
7
7
 
8
8
  describe '.execute' do
9
9
  before do
10
- subject.stub(:prepare_commit_msg) { true }
10
+ runner.stub(:prepare_commit_msg) { true }
11
11
  end
12
12
 
13
13
  it 'runs the hook, passing the args' do
14
- subject.should_receive(:prepare_commit_msg).with(*args) { true }
15
- subject.execute('prepare-commit-msg', *args)
14
+ runner.should_receive(:prepare_commit_msg).with(*args) { true }
15
+ runner.execute('prepare-commit-msg', *args)
16
16
  end
17
17
 
18
18
  # TODO: stop the abort from writing to stderr during tests?
19
19
  it 'does not run hooks we do not know about' do
20
- lambda { subject.execute('non-existent-hook', *args) }.should_not succeed
20
+ expect { runner.execute('non-existent-hook', *args) }.to_not succeed
21
21
  end
22
22
  end
23
23
 
24
24
  describe '.prepare_commit_msg' do
25
25
  it 'runs the hook, passing the args' do
26
26
  GitTracker::PrepareCommitMessage.should_receive(:run).with(*args) { true }
27
- subject.prepare_commit_msg(*args)
27
+ runner.prepare_commit_msg(*args)
28
28
  end
29
29
  end
30
30
 
31
31
  describe '.install' do
32
32
  it 'tells the hook to install itself' do
33
33
  GitTracker::Hook.should_receive(:install)
34
- subject.install
34
+ runner.install
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')
41
+ end
42
+
38
43
  end
@@ -13,12 +13,12 @@ describe GitTracker::Standalone do
13
13
 
14
14
  it 'saves to the named file' do
15
15
  described_class.save('git-tracker')
16
- File.size('./git-tracker').should > 100
16
+ expect(File.size('./git-tracker')).to be > 100
17
17
  end
18
18
 
19
19
  it 'marks the binary as executable' do
20
20
  described_class.save('git-tracker')
21
- File.should be_executable('./git-tracker')
21
+ expect(File).to be_executable('./git-tracker')
22
22
  end
23
23
  end
24
24
 
@@ -28,33 +28,33 @@ describe GitTracker::Standalone do
28
28
  let(:standalone) { described_class.build(io).string }
29
29
 
30
30
  it 'declares a shebang' do
31
- subject.should =~ /#!.+/
31
+ expect(subject).to match(/#!.+/)
32
32
  end
33
33
 
34
34
  it 'includes generated code notice' do
35
- subject.should include('This file is generated')
35
+ expect(subject).to include('This file is generated')
36
36
  end
37
37
 
38
38
  it 'inlines the code' do
39
- subject.should include('Hook')
40
- subject.should include('Repository')
41
- subject.should include('PrepareCommitMessage')
42
- subject.should include('Runner')
43
- subject.should include('Branch')
44
- subject.should include('CommitMessage')
45
- subject.should include('VERSION')
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')
46
46
  end
47
47
 
48
48
  it 'does not inline the standalone code' do
49
- subject.should_not include('module Standalone')
49
+ expect(subject).to_not include('module Standalone')
50
50
  end
51
51
 
52
52
  it 'includes the call to execute the hook' do
53
- subject.should include('GitTracker::Runner.execute(*ARGV)')
53
+ expect(subject).to include('GitTracker::Runner.execute(*ARGV)')
54
54
  end
55
55
 
56
56
  it 'excludes requiring git_tracker code' do
57
- subject.should_not =~ /^require\s+["']git_tracker/
57
+ expect(subject).to_not match(/^require\s+["']git_tracker/)
58
58
  end
59
59
  end
60
60
 
@@ -67,12 +67,12 @@ describe GitTracker::Standalone do
67
67
 
68
68
  it 'uses user-level ruby binary when it is executable' do
69
69
  File.stub(:executable?).with('/usr/bin/ruby') { true }
70
- subject.ruby_executable.should == '/usr/bin/ruby'
70
+ expect(subject.ruby_executable).to eq('/usr/bin/ruby')
71
71
  end
72
72
 
73
73
  it 'uses rbconfig ruby when user-level ruby binary not executable' do
74
74
  File.stub(:executable?).with('/usr/bin/ruby') { false }
75
- subject.ruby_executable.should == '/some/other/bin/ruby'
75
+ expect(subject.ruby_executable).to eq('/some/other/bin/ruby')
76
76
  end
77
77
  end
78
78
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-12 00:00:00.000000000 Z
12
+ date: 2013-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: '2.9'
21
+ version: '2.12'
22
22
  type: :development
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ~>
28
28
  - !ruby/object:Gem::Version
29
- version: '2.9'
29
+ version: '2.12'
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: rspec-spies
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '2.0'
46
- - !ruby/object:Gem::Dependency
47
- name: pry
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: '0.9'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ~>
60
- - !ruby/object:Gem::Version
61
- version: '0.9'
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: activesupport
64
48
  requirement: !ruby/object:Gem::Requirement
@@ -131,7 +115,7 @@ files:
131
115
  - spec/support/commit_message_helper.rb
132
116
  - spec/support/fake_file.rb
133
117
  - spec/support/matchers/exit_code_matchers.rb
134
- homepage: https://github.com/highgroove/git_tracker
118
+ homepage: https://github.com/stevenharman/git_tracker
135
119
  licenses: []
136
120
  post_install_message:
137
121
  rdoc_options: []
@@ -167,3 +151,4 @@ test_files:
167
151
  - spec/support/commit_message_helper.rb
168
152
  - spec/support/fake_file.rb
169
153
  - spec/support/matchers/exit_code_matchers.rb
154
+ has_rdoc: