git-autobisect 0.2.2 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Autobisect
3
- VERSION = Version = "0.2.2"
3
+ VERSION = Version = "0.3.0"
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ module Git
12
12
  return 1
13
13
  end
14
14
 
15
- command = "(bundle check || bundle) && (#{command})" if File.exist?("Gemfile")
15
+ command = "(bundle check || (test -f vendor/cache && bundle --local --quiet) || bundle --quiet) && (#{command})" if File.exist?("Gemfile")
16
16
 
17
17
  run_command(command, options) || 0
18
18
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-autobisect
3
3
  version: !ruby/object:Gem::Version
4
+ version: 0.3.0
4
5
  prerelease:
5
- version: 0.2.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Grosser
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-07 00:00:00.000000000 Z
12
+ date: 2013-07-03 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -18,16 +18,9 @@ executables:
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
- - .travis.yml
22
- - Gemfile
23
- - Gemfile.lock
24
- - Rakefile
25
- - Readme.md
26
21
  - bin/git-autobisect
27
- - git-autobisect.gemspec
28
22
  - lib/git/autobisect.rb
29
23
  - lib/git/autobisect/version.rb
30
- - spec/git-autobisect_spec.rb
31
24
  homepage: http://github.com/grosser/git-autobisect
32
25
  licenses:
33
26
  - MIT
@@ -36,26 +29,26 @@ rdoc_options: []
36
29
  require_paths:
37
30
  - lib
38
31
  required_ruby_version: !ruby/object:Gem::Requirement
32
+ none: false
39
33
  requirements:
40
34
  - - ! '>='
41
35
  - !ruby/object:Gem::Version
42
36
  version: '0'
43
37
  segments:
44
38
  - 0
45
- hash: 2309795783379412317
46
- none: false
39
+ hash: -4176001779097613862
47
40
  required_rubygems_version: !ruby/object:Gem::Requirement
41
+ none: false
48
42
  requirements:
49
43
  - - ! '>='
50
44
  - !ruby/object:Gem::Version
51
45
  version: '0'
52
46
  segments:
53
47
  - 0
54
- hash: 2309795783379412317
55
- none: false
48
+ hash: -4176001779097613862
56
49
  requirements: []
57
50
  rubyforge_project:
58
- rubygems_version: 1.8.24
51
+ rubygems_version: 1.8.25
59
52
  signing_key:
60
53
  specification_version: 3
61
54
  summary: Find the first broken commit without having to learn git bisect
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- rvm:
2
- - ree
3
- - 1.9.2
4
- - 1.9.3
data/Gemfile DELETED
@@ -1,6 +0,0 @@
1
- source :rubygems
2
- gemspec
3
-
4
- gem 'bump'
5
- gem 'rake'
6
- gem 'rspec', '~>2'
data/Gemfile.lock DELETED
@@ -1,28 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- git-autobisect (0.2.2)
5
-
6
- GEM
7
- remote: http://rubygems.org/
8
- specs:
9
- bump (0.3.5)
10
- diff-lcs (1.1.3)
11
- rake (0.9.2.2)
12
- rspec (2.11.0)
13
- rspec-core (~> 2.11.0)
14
- rspec-expectations (~> 2.11.0)
15
- rspec-mocks (~> 2.11.0)
16
- rspec-core (2.11.1)
17
- rspec-expectations (2.11.3)
18
- diff-lcs (~> 1.1.3)
19
- rspec-mocks (2.11.3)
20
-
21
- PLATFORMS
22
- ruby
23
-
24
- DEPENDENCIES
25
- bump
26
- git-autobisect!
27
- rake
28
- rspec (~> 2)
data/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'bump/tasks'
3
-
4
- task :default do
5
- sh "rspec spec/"
6
- end
data/Readme.md DELETED
@@ -1,47 +0,0 @@
1
- Find the first broken commit without having to learn git bisect.
2
-
3
- - automagically bundles if necessary
4
- - stops at first bad commit
5
- - takes binary steps (HEAD~1, HEAD~2, HEAD~4, HEAD~8)
6
-
7
- Install
8
- =======
9
-
10
- gem install git-autobisect
11
-
12
- Usage
13
- =====
14
-
15
- cd your project
16
- # run a test that has a non-0 exit status
17
- git-autobisect 'rspec spec/models/user_spec.rb'
18
- ... grab a coffee ...
19
- ---> The first bad commit is a4328fa
20
- git show
21
-
22
- ### Options
23
-
24
- -m, --max N Inspect commits between HEAD..HEAD~<max>
25
- -s, --start N Use N (instead of 1) as initial step and keep muliplying by 2
26
-
27
- TIPS
28
- ====
29
- - do not fail if test file is missing `[ ! -f spec/my_spec.rb ] || rspec spec/my_spec.rb`
30
-
31
- TODO
32
- ====
33
- - option for max-step-size so you can use a finer grained approach
34
- - option to disable `bundle check || bundle` injection
35
- - option to consider a build failed if it finishes faster then x seconds
36
-
37
- Development
38
- ===========
39
- - `bundle && bundle exec rake`
40
- - Tests run a lot faster without `bundle exec`
41
-
42
- Author
43
- ======
44
- [Michael Grosser](http://grosser.it)<br/>
45
- michael@grosser.it<br/>
46
- License: MIT<br/>
47
- [![Build Status](https://travis-ci.org/grosser/git-autobisect.png)](https://travis-ci.org/grosser/git-autobisect)
@@ -1,13 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
- name = "git-autobisect"
3
- require "git/autobisect/version"
4
-
5
- Gem::Specification.new name, Git::Autobisect::Version do |s|
6
- s.summary = "Find the first broken commit without having to learn git bisect"
7
- s.authors = ["Michael Grosser"]
8
- s.email = "michael@grosser.it"
9
- s.homepage = "http://github.com/grosser/#{name}"
10
- s.files = `git ls-files`.split("\n")
11
- s.executables = ["git-autobisect"]
12
- s.license = "MIT"
13
- end
@@ -1,169 +0,0 @@
1
- ROOT = File.expand_path('../../', __FILE__)
2
-
3
- describe "git-autobisect" do
4
- def run(command, options={})
5
- result = `#{command} 2>&1`
6
- message = (options[:fail] ? "SUCCESS BUT SHOULD FAIL" : "FAIL")
7
- raise "[#{message}] #{result} [#{command}]" if $?.success? == !!options[:fail]
8
- result
9
- end
10
-
11
- def autobisect(args, options={})
12
- run "#{ROOT}/bin/git-autobisect #{args}", options
13
- end
14
-
15
- def current_commit
16
- run "git log --oneline | head -1"
17
- end
18
-
19
- def add_irrelevant_commit(name="b")
20
- run "echo #{rand} >> #{name} && git add #{name} && git commit -m 'added #{name}'"
21
- end
22
-
23
- def remove_a
24
- run "git rm a && git commit -m 'remove a'"
25
- end
26
-
27
- before do
28
- Dir.chdir ROOT
29
- end
30
-
31
- describe "basics" do
32
- it "shows its usage without arguments" do
33
- autobisect("", :fail => true).should include("Usage")
34
- end
35
-
36
- it "shows its usage with -h" do
37
- autobisect("-h").should include("Usage")
38
- end
39
-
40
- it "shows its usage with --help" do
41
- autobisect("--help").should include("Usage")
42
- end
43
-
44
- it "shows its version with -v" do
45
- autobisect("-v").should =~ /^git-autobisect \d+\.\d+\.\d+$/
46
- end
47
-
48
- it "shows its version with --version" do
49
- autobisect("-v").should =~ /^git-autobisect \d+\.\d+\.\d+$/
50
- end
51
- end
52
-
53
- describe "bisecting" do
54
- before do
55
- run "rm -rf spec/tmp ; mkdir spec/tmp"
56
- Dir.chdir "spec/tmp"
57
- run "git init && touch a && git add a && git commit -m 'added a'"
58
- end
59
-
60
- it "stops when the first commit works" do
61
- autobisect("'test 1'", :fail => true).should include("HEAD is not broken")
62
- end
63
-
64
- it "stops when no commit works" do
65
- autobisect("test", :fail => true).should include("No good commit found")
66
- end
67
-
68
- context "--max" do
69
- let(:command){ "'test -e a' --max 5" }
70
-
71
- it "finds if a commit works inside of max range" do
72
- remove_a
73
- 3.times{ add_irrelevant_commit }
74
- autobisect(command).should_not include("No good commit found")
75
- end
76
-
77
- it "stops when no commit works inside of max range" do
78
- remove_a
79
- 5.times{ add_irrelevant_commit }
80
- autobisect(command, :fail => true).should include("No good commit found")
81
- end
82
- end
83
-
84
- context "--start" do
85
- let(:command){ "'test -e a' --start 5" }
86
-
87
- it "starts at given point" do
88
- remove_a
89
- 30.times{ add_irrelevant_commit }
90
- result = autobisect(command)
91
- result.scan(/HEAD~\d+/).should == ["HEAD~4", "HEAD~9", "HEAD~19", "HEAD~31"]
92
- end
93
- end
94
-
95
- it "finds the first broken commit for 1 commit" do
96
- remove_a
97
- result = autobisect("'test -e a'")
98
- result.should_not include("bisect run")
99
- result.should =~ /is the first bad commit.*remove a/m
100
- end
101
-
102
- it "finds the first broken commit for multiple commits" do
103
- remove_a
104
- result = autobisect("'test -e a'")
105
- result.should_not include("bisect run success")
106
- result.should =~ /is the first bad commit.*remove a/m
107
- end
108
-
109
- it "can run a complex command" do
110
- 10.times{ add_irrelevant_commit }
111
- remove_a
112
- 10.times{ add_irrelevant_commit }
113
- result = autobisect("'sleep 0.01 && test -e a'")
114
- result.should include("bisect run success")
115
- result.should =~ /is the first bad commit.*remove a/m
116
- end
117
-
118
- it "is fast for a large number of commits" do
119
- # build a ton of commits
120
- 40.times do |i|
121
- add_irrelevant_commit("#{i}_good")
122
- end
123
- run "git rm a && git commit -m 'remove a'"
124
- 40.times do |i|
125
- add_irrelevant_commit("#{i}_bad")
126
- end
127
-
128
- # ran successful ?
129
- result = autobisect("'echo a >> count && test -e a'")
130
- result.should include("bisect run success")
131
- result.should =~ /is the first bad commit.*remove a/m
132
-
133
- # ran fast?
134
- File.read('count').count('a').should < 20
135
- end
136
-
137
- it "stays at the first broken commit" do
138
- remove_a
139
- autobisect("'test -e a'")
140
- current_commit.should include("remove a")
141
- end
142
-
143
- context "with multiple good commits after broken commit" do
144
- before do
145
- add_irrelevant_commit "b"
146
- add_irrelevant_commit "c"
147
- add_irrelevant_commit "d"
148
- add_irrelevant_commit "e" # first good
149
- remove_a
150
- add_irrelevant_commit "f" # last bad
151
- add_irrelevant_commit "g"
152
- end
153
-
154
- it "finds the first broken commit for n commits" do
155
- result = autobisect("'test -e a'")
156
- result.should include("bisect run success")
157
- result.should =~ /is the first bad commit.*remove a/m
158
- current_commit.should include("remove a")
159
- end
160
-
161
- it "does not run test too often" do
162
- result = autobisect("'echo a >> count && test -e a'")
163
- result.should include("bisect run success")
164
- result.should include("added e")
165
- File.read('count').count('a').should == 4
166
- end
167
- end
168
- end
169
- end