git-autobisect 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -1,5 +1,6 @@
1
1
  source :rubygems
2
2
  gemspec
3
3
 
4
+ gem 'bump'
4
5
  gem 'rake'
5
6
  gem 'rspec', '~>2'
data/Gemfile.lock CHANGED
@@ -1,11 +1,12 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git-autobisect (0.2.0)
4
+ git-autobisect (0.2.1)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
+ bump (0.3.5)
9
10
  diff-lcs (1.1.3)
10
11
  rake (0.9.2.2)
11
12
  rspec (2.11.0)
@@ -21,6 +22,7 @@ PLATFORMS
21
22
  ruby
22
23
 
23
24
  DEPENDENCIES
25
+ bump
24
26
  git-autobisect!
25
27
  rake
26
28
  rspec (~> 2)
data/Rakefile CHANGED
@@ -1,22 +1,6 @@
1
1
  require 'bundler/gem_tasks'
2
+ require 'bump/tasks'
2
3
 
3
4
  task :default do
4
5
  sh "rspec spec/"
5
6
  end
6
-
7
- # extracted from https://github.com/grosser/project_template
8
- rule /^version:bump:.*/ do |t|
9
- sh "git status | grep 'nothing to commit'" # ensure we are not dirty
10
- index = ['major', 'minor','patch'].index(t.name.split(':').last)
11
- file = 'lib/git/autobisect/version.rb'
12
-
13
- version_file = File.read(file)
14
- old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
15
- version_parts[index] = version_parts[index].to_i + 1
16
- version_parts[2] = 0 if index < 2 # remove patch for minor
17
- version_parts[1] = 0 if index < 1 # remove minor for major
18
- new_version = version_parts * '.'
19
- File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
20
-
21
- sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
22
- end
data/Readme.md CHANGED
@@ -21,7 +21,12 @@ Usage
21
21
 
22
22
  ### Options
23
23
 
24
- -m, --max [N] Inspect commits between HEAD..HEAD~<max>
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`
25
30
 
26
31
  TODO
27
32
  ====
@@ -19,7 +19,7 @@ module Git
19
19
 
20
20
  def run_command(command, options)
21
21
  commits = `git log --pretty=format:'%h' | head -n #{options[:max]}`.split("\n")
22
- good, bad = find_good_and_bad_commit(commits, command)
22
+ good, bad = find_good_and_bad_commit(commits, command, options)
23
23
 
24
24
  if good == commits.first
25
25
  puts " ---> HEAD is not broken"
@@ -57,7 +57,8 @@ module Git
57
57
  BANNER
58
58
  opts.on("-h", "--help", "Show this.") { puts opts; exit }
59
59
  opts.on("-v", "--version", "Show Version"){ puts "git-autobisect #{Version}"; exit }
60
- opts.on("-m", "--max [N]", Integer, "Inspect commits between HEAD..HEAD~<max>"){|max| options[:max] = max }
60
+ opts.on("-m", "--max N", Integer, "Inspect commits between HEAD..HEAD~<max>"){|max| options[:max] = max }
61
+ opts.on("-s", "--start N", Integer, "Use N (instead of 1) as initial step and keep muliplying by 2"){|start| options[:start] = start }
61
62
  end.parse!(argv)
62
63
  options
63
64
  end
@@ -78,21 +79,22 @@ module Git
78
79
  raise "Command failed #{command}" unless run(command).first
79
80
  end
80
81
 
81
- def find_good_and_bad_commit(commits, command)
82
- i = 0
82
+ def find_good_and_bad_commit(commits, command, options)
83
+ initial = 1
84
+ i = options[:start] || initial
83
85
  maybe_good = commits.first
84
86
 
85
87
  loop do
86
88
  # scan backwards through commits to find a good
87
- offset = [2**i - 1, commits.size-1].min
89
+ offset = [i - 1, commits.size-1].min
88
90
  maybe_good, bad = commits[offset], maybe_good
89
- return if i > 0 and bad == maybe_good # we reached the end
91
+ return if i > initial and bad == maybe_good # we reached the end
90
92
 
91
93
  # see if it works
92
94
  puts " ---> Now trying #{maybe_good} (HEAD~#{offset})"
93
95
  run!("git checkout #{maybe_good}")
94
96
  return [maybe_good, bad] if run(command).first
95
- i += 1
97
+ i *= 2
96
98
  end
97
99
  end
98
100
 
@@ -1,5 +1,5 @@
1
1
  module Git
2
2
  module Autobisect
3
- VERSION = Version = "0.2.0"
3
+ VERSION = Version = "0.2.1"
4
4
  end
5
5
  end
@@ -81,6 +81,17 @@ describe "git-autobisect" do
81
81
  end
82
82
  end
83
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
+
84
95
  it "finds the first broken commit for 1 commit" do
85
96
  remove_a
86
97
  result = autobisect("'test -e a'")
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git-autobisect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
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-10-06 00:00:00.000000000 Z
12
+ date: 2012-11-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: michael@grosser.it
@@ -43,7 +43,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
43
43
  version: '0'
44
44
  segments:
45
45
  - 0
46
- hash: -1063815506089341293
46
+ hash: 1643035677456387071
47
47
  required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  none: false
49
49
  requirements:
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  version: '0'
53
53
  segments:
54
54
  - 0
55
- hash: -1063815506089341293
55
+ hash: 1643035677456387071
56
56
  requirements: []
57
57
  rubyforge_project:
58
58
  rubygems_version: 1.8.24