git_tracker 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/.travis.yml +1 -0
- data/CHANGELOG.md +4 -0
- data/Rakefile +6 -0
- data/bin/git-tracker +1 -1
- data/git_tracker.gemspec +2 -2
- data/lib/git_tracker/branch.rb +2 -2
- data/lib/git_tracker/runner.rb +22 -0
- data/lib/git_tracker/standalone.rb +72 -0
- data/lib/git_tracker/version.rb +1 -1
- data/lib/git_tracker.rb +4 -15
- data/spec/git_tracker/prepare_commit_message_spec.rb +1 -1
- data/spec/{git_tracker_spec.rb → git_tracker/runner_spec.rb} +2 -2
- data/spec/git_tracker/standalone_spec.rb +78 -0
- data/spec/spec_helper.rb +1 -1
- metadata +13 -9
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
### dev
|
|
2
2
|
[full changelog](https://github.com/highgroove/git_tracker/compare/v1.3.0...master)
|
|
3
|
+
Enhancements
|
|
4
|
+
|
|
5
|
+
* Support Ruby 1.8.7
|
|
6
|
+
* Generate standalone binary via `rake git-tracker`
|
|
3
7
|
|
|
4
8
|
### 1.3.1 / 2012-04-23
|
|
5
9
|
[full changelog](https://github.com/highgroove/git_tracker/compare/v1.3.0...v1.3.1)
|
data/Rakefile
CHANGED
|
@@ -4,3 +4,9 @@ require 'rspec/core/rake_task'
|
|
|
4
4
|
|
|
5
5
|
RSpec::Core::RakeTask.new(:spec)
|
|
6
6
|
task :default => :spec
|
|
7
|
+
|
|
8
|
+
file 'git-tracker' => FileList.new('lib/git_tracker.rb, lib/git_tracker/*.rb') do |task|
|
|
9
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
|
10
|
+
require 'git_tracker/standalone'
|
|
11
|
+
GitTracker::Standalone.save(task.name)
|
|
12
|
+
end
|
data/bin/git-tracker
CHANGED
data/git_tracker.gemspec
CHANGED
|
@@ -13,9 +13,9 @@ Gem::Specification.new do |gem|
|
|
|
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.9"
|
|
17
17
|
gem.add_development_dependency "rspec-spies", "~> 2.0"
|
|
18
|
-
gem.add_development_dependency "pry", "~> 0.9
|
|
18
|
+
gem.add_development_dependency "pry", "~> 0.9"
|
|
19
19
|
gem.add_development_dependency "activesupport", "~> 3.2"
|
|
20
20
|
gem.add_development_dependency "rake"
|
|
21
21
|
|
data/lib/git_tracker/branch.rb
CHANGED
|
@@ -4,7 +4,7 @@ require 'git_tracker/repository'
|
|
|
4
4
|
module GitTracker
|
|
5
5
|
module Branch
|
|
6
6
|
def self.story_number
|
|
7
|
-
current[/#?(
|
|
7
|
+
current[/#?(\d+)/, 1]
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def self.current
|
|
@@ -12,7 +12,7 @@ module GitTracker
|
|
|
12
12
|
|
|
13
13
|
Repository.ensure_exists unless exit_successful?
|
|
14
14
|
|
|
15
|
-
branch_path[%r{refs/heads/(
|
|
15
|
+
branch_path[%r{refs/heads/(.+)}, 1] || ''
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
private
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
require 'git_tracker/prepare_commit_message'
|
|
2
|
+
require 'git_tracker/hook'
|
|
3
|
+
|
|
4
|
+
module GitTracker
|
|
5
|
+
module Runner
|
|
6
|
+
|
|
7
|
+
def self.execute(cmd_arg, *args)
|
|
8
|
+
command = cmd_arg.gsub(/-/, '_')
|
|
9
|
+
abort("[git_tracker] command: '#{cmd_arg}' does not exist.") unless respond_to?(command)
|
|
10
|
+
send(command, *args)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.prepare_commit_msg(*args)
|
|
14
|
+
PrepareCommitMessage.run(*args)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def self.install
|
|
18
|
+
Hook.install
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
module GitTracker
|
|
2
|
+
module Standalone
|
|
3
|
+
extend self
|
|
4
|
+
|
|
5
|
+
GIT_TRACKER_ROOT = File.expand_path('../../..', __FILE__)
|
|
6
|
+
PREAMBLE = <<-preamble
|
|
7
|
+
#
|
|
8
|
+
# This file is generated code. DO NOT send patches for it.
|
|
9
|
+
#
|
|
10
|
+
# Original source files with comments are at:
|
|
11
|
+
# https://github.com/highgroove/git_tracker
|
|
12
|
+
#
|
|
13
|
+
|
|
14
|
+
preamble
|
|
15
|
+
|
|
16
|
+
def save(filename, path = '.')
|
|
17
|
+
dest = File.join(File.expand_path(path), filename)
|
|
18
|
+
File.open(dest, 'w') do |f|
|
|
19
|
+
build(f)
|
|
20
|
+
f.chmod(0755)
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def build(io)
|
|
25
|
+
io.puts "#!#{ruby_executable}"
|
|
26
|
+
io << PREAMBLE
|
|
27
|
+
|
|
28
|
+
each_source_file do |filename|
|
|
29
|
+
File.open(filename, 'r') do |source|
|
|
30
|
+
inline_source(source, io)
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
io.puts 'GitTracker::Runner.execute(*ARGV)'
|
|
35
|
+
io
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def inline_source(code, io)
|
|
39
|
+
code.each_line do |line|
|
|
40
|
+
io << line unless comment?(line) || require_own_file?(line)
|
|
41
|
+
end
|
|
42
|
+
io.puts ''
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def comment?(line)
|
|
46
|
+
line =~ /^\s*#/
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def require_own_file?(line)
|
|
50
|
+
line =~ /^\s*require\s+["']git_tracker\//
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def each_source_file
|
|
54
|
+
File.open(File.join(GIT_TRACKER_ROOT, 'lib/git_tracker.rb'), 'r') do |main|
|
|
55
|
+
main.each_line do |req|
|
|
56
|
+
if req =~ /^require\s+["'](.+)["']/
|
|
57
|
+
yield File.join(GIT_TRACKER_ROOT, 'lib', "#{$1}.rb")
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def ruby_executable
|
|
64
|
+
if File.executable? '/usr/bin/ruby' then '/usr/bin/ruby'
|
|
65
|
+
else
|
|
66
|
+
require 'rbconfig'
|
|
67
|
+
File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
end
|
data/lib/git_tracker/version.rb
CHANGED
data/lib/git_tracker.rb
CHANGED
|
@@ -1,19 +1,8 @@
|
|
|
1
1
|
require 'git_tracker/hook'
|
|
2
|
+
require 'git_tracker/repository'
|
|
2
3
|
require 'git_tracker/prepare_commit_message'
|
|
4
|
+
require 'git_tracker/runner'
|
|
5
|
+
require 'git_tracker/branch'
|
|
6
|
+
require 'git_tracker/commit_message'
|
|
3
7
|
require 'git_tracker/version'
|
|
4
8
|
|
|
5
|
-
module GitTracker
|
|
6
|
-
def self.execute(cmd_arg, *args)
|
|
7
|
-
command = cmd_arg.gsub(/-/, '_')
|
|
8
|
-
abort("[git_tracker] command: '#{cmd_arg}' does not exist.") unless respond_to?(command)
|
|
9
|
-
send(command, *args)
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.prepare_commit_msg(*args)
|
|
13
|
-
PrepareCommitMessage.run(*args)
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
def self.install
|
|
17
|
-
Hook.install
|
|
18
|
-
end
|
|
19
|
-
end
|
|
@@ -60,7 +60,7 @@ describe GitTracker::PrepareCommitMessage do
|
|
|
60
60
|
|
|
61
61
|
context 'branch name with a Pivotal Tracker story number' do
|
|
62
62
|
let(:story) { '8675309' }
|
|
63
|
-
let(:commit_message) { stub('CommitMessage', mentions_story
|
|
63
|
+
let(:commit_message) { stub('CommitMessage', :mentions_story? => false) }
|
|
64
64
|
|
|
65
65
|
before do
|
|
66
66
|
commit_message.stub(:keyword) { nil }
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
require 'git_tracker/standalone'
|
|
2
|
+
|
|
3
|
+
describe GitTracker::Standalone do
|
|
4
|
+
|
|
5
|
+
describe '#save' do
|
|
6
|
+
before do
|
|
7
|
+
File.delete 'git-tracker' if File.exists? 'git-tracker'
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
after do
|
|
11
|
+
File.delete 'git-tracker' if File.exists? 'git-tracker'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'saves to the named file' do
|
|
15
|
+
described_class.save('git-tracker')
|
|
16
|
+
File.size('./git-tracker').should > 100
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it 'marks the binary as executable' do
|
|
20
|
+
described_class.save('git-tracker')
|
|
21
|
+
File.should be_executable('./git-tracker')
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#build' do
|
|
26
|
+
subject { standalone }
|
|
27
|
+
let(:io) { StringIO.new }
|
|
28
|
+
let(:standalone) { described_class.build(io).string }
|
|
29
|
+
|
|
30
|
+
it 'declares a shebang' do
|
|
31
|
+
subject.should =~ /#!.+/
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it 'includes generated code notice' do
|
|
35
|
+
subject.should include('This file is generated')
|
|
36
|
+
end
|
|
37
|
+
|
|
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')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it 'does not inline the standalone code' do
|
|
49
|
+
subject.should_not include('module Standalone')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
it 'includes the call to execute the hook' do
|
|
53
|
+
subject.should include('GitTracker::Runner.execute(*ARGV)')
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
it 'excludes requiring git_tracker code' do
|
|
57
|
+
subject.should_not =~ /^require\s+["']git_tracker/
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
describe '#ruby_executable' do
|
|
62
|
+
subject { described_class }
|
|
63
|
+
before do
|
|
64
|
+
RbConfig::CONFIG.stub(:[]).with('bindir') { '/some/other/bin' }
|
|
65
|
+
RbConfig::CONFIG.stub(:[]).with('ruby_install_name') { 'ruby' }
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
it 'uses user-level ruby binary when it is executable' do
|
|
69
|
+
File.stub(:executable?).with('/usr/bin/ruby') { true }
|
|
70
|
+
subject.ruby_executable.should == '/usr/bin/ruby'
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
it 'uses rbconfig ruby when user-level ruby binary not executable' do
|
|
74
|
+
File.stub(:executable?).with('/usr/bin/ruby') { false }
|
|
75
|
+
subject.ruby_executable.should == '/some/other/bin/ruby'
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
data/spec/spec_helper.rb
CHANGED
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
|
+
version: 1.4.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-
|
|
12
|
+
date: 2012-06-12 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.9'
|
|
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.9'
|
|
30
30
|
- !ruby/object:Gem::Dependency
|
|
31
31
|
name: rspec-spies
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -50,7 +50,7 @@ dependencies:
|
|
|
50
50
|
requirements:
|
|
51
51
|
- - ~>
|
|
52
52
|
- !ruby/object:Gem::Version
|
|
53
|
-
version: 0.9
|
|
53
|
+
version: '0.9'
|
|
54
54
|
type: :development
|
|
55
55
|
prerelease: false
|
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -58,7 +58,7 @@ dependencies:
|
|
|
58
58
|
requirements:
|
|
59
59
|
- - ~>
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.9
|
|
61
|
+
version: '0.9'
|
|
62
62
|
- !ruby/object:Gem::Dependency
|
|
63
63
|
name: activesupport
|
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -116,6 +116,8 @@ files:
|
|
|
116
116
|
- lib/git_tracker/hook.rb
|
|
117
117
|
- lib/git_tracker/prepare_commit_message.rb
|
|
118
118
|
- lib/git_tracker/repository.rb
|
|
119
|
+
- lib/git_tracker/runner.rb
|
|
120
|
+
- lib/git_tracker/standalone.rb
|
|
119
121
|
- lib/git_tracker/version.rb
|
|
120
122
|
- prepare-commit-msg.example
|
|
121
123
|
- spec/git_tracker/branch_spec.rb
|
|
@@ -123,7 +125,8 @@ files:
|
|
|
123
125
|
- spec/git_tracker/hook_spec.rb
|
|
124
126
|
- spec/git_tracker/prepare_commit_message_spec.rb
|
|
125
127
|
- spec/git_tracker/repository_spec.rb
|
|
126
|
-
- spec/
|
|
128
|
+
- spec/git_tracker/runner_spec.rb
|
|
129
|
+
- spec/git_tracker/standalone_spec.rb
|
|
127
130
|
- spec/spec_helper.rb
|
|
128
131
|
- spec/support/commit_message_helper.rb
|
|
129
132
|
- spec/support/fake_file.rb
|
|
@@ -148,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
148
151
|
version: '0'
|
|
149
152
|
requirements: []
|
|
150
153
|
rubyforge_project:
|
|
151
|
-
rubygems_version: 1.8.
|
|
154
|
+
rubygems_version: 1.8.24
|
|
152
155
|
signing_key:
|
|
153
156
|
specification_version: 3
|
|
154
157
|
summary: Teaching Git about Pivotal Tracker.
|
|
@@ -158,7 +161,8 @@ test_files:
|
|
|
158
161
|
- spec/git_tracker/hook_spec.rb
|
|
159
162
|
- spec/git_tracker/prepare_commit_message_spec.rb
|
|
160
163
|
- spec/git_tracker/repository_spec.rb
|
|
161
|
-
- spec/
|
|
164
|
+
- spec/git_tracker/runner_spec.rb
|
|
165
|
+
- spec/git_tracker/standalone_spec.rb
|
|
162
166
|
- spec/spec_helper.rb
|
|
163
167
|
- spec/support/commit_message_helper.rb
|
|
164
168
|
- spec/support/fake_file.rb
|