bummr 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25ae2fed8478c1b44bd75fdb39aa01d2c7baa196
4
- data.tar.gz: f01bf40b1efb8b489d7724f8411dd6f48d8655dd
3
+ metadata.gz: cd6d2b3e86b89fd5ebe4bdc256646fd98a7d4ef7
4
+ data.tar.gz: d2479e96779e929066df0596652d2c5786c863d4
5
5
  SHA512:
6
- metadata.gz: ff5beb79273d4ccedd442f83e620e4f81df35f544ae4fb452d3c381dda7930e222d35468f9ad990d5afa2eb7c3889cc01c6f37062a14c1237d315aab906bbe67
7
- data.tar.gz: 72925d9a0abff30b1c7fb1ead19ddeae96177029e0c61622d7303619fcda4da281ecfcc72f0588b6d690e0c4de5566198f83fdd2f4bd46c3b4646d4c35af6c88
6
+ metadata.gz: 3775a716d8e1331f713f05164646bbb7f443e5faa950b5b090d5ee93dc57f540747dcddd9df7b0bae5e6097cae099dfc6a53c23146bfcc718a2a7b54e043b488
7
+ data.tar.gz: 261a954cfe05dc78af6d90662cbe6e50dca3fa6b726f8e6c6d218832fdbdcdd72baa9f88639f2090db6f659048482c412c42901247760c344766f5c17f12d524
data/README.md CHANGED
@@ -29,7 +29,7 @@ brittle tests and false positives.
29
29
 
30
30
  ## Usage:
31
31
 
32
- Using bummr can take anywhere from a few minutes to several hours, depending
32
+ Using bummr can take anywhere from a few minutes to several hours, depending
33
33
  on the number of outdated gems you have and the number of tests in your test
34
34
  suite.
35
35
 
@@ -74,6 +74,9 @@ suite.
74
74
  - Once the build passes, you can push your branch and create a pull-request!
75
75
  - You may wish to `tail -f log/bummr.log` in a separate terminal window so you
76
76
  can see which commits are being removed.
77
+ - Bummr conservatively updates gems using `bundle update --source gemname`
78
+ - Bummr automatically rebases out commits which fail the build using an "ours"
79
+ merge strategy.
77
80
  - Bummr may not be able to remove the bad commit due to a merge conflict, in
78
81
  which case you will have to remove it manually, continue the rebase, and
79
82
  run `bummr test` again.
data/lib/bummr/cli.rb CHANGED
@@ -70,24 +70,23 @@ module Bummr
70
70
  check
71
71
  `bundle`
72
72
 
73
- if outdated_gems_to_update.empty?
73
+ if outdated_gems.empty?
74
74
  say "No outdated gems to update".green
75
75
  else
76
- say "Updating outdated gems:"
77
- say outdated_gems_to_update.map { |g| "* #{g}" }.join("\n")
76
+ say "Updating outdated gems".green
78
77
 
79
- outdated_gems_to_update.each_with_index do |gem, index|
80
- say "Updating #{gem[:name]}: #{index+1} of #{outdated_gems_to_update.count}"
78
+ outdated_gems.each_with_index do |gem, index|
79
+ say "Updating #{gem[:name]}: #{index+1} of #{outdated_gems.count}"
81
80
 
82
81
  system("bundle update --source #{gem[:name]}")
83
82
  updated_version = `bundle list | grep " #{gem[:name]} "`.split('(')[1].split(')')[0]
84
- message = "Update #{gem[:name]} from #{gem[:current_version]} to #{updated_version}"
83
+ message = "Update #{gem[:name]} from #{gem[:installed]} to #{updated_version}"
85
84
 
86
- if gem[:spec_version] != updated_version
87
- log("#{gem[:name]} not updated from #{gem[:current_version]} to latest: #{gem[:spec_version]}")
85
+ if gem[:newest] != updated_version
86
+ log("#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}")
88
87
  end
89
88
 
90
- unless gem[:current_version] == updated_version
89
+ unless gem[:installed] == updated_version
91
90
  say message.green
92
91
  system("git commit -am '#{message}'")
93
92
  else
@@ -152,34 +151,6 @@ module Bummr
152
151
  system("touch log/bummr.log && echo '#{message}' >> log/bummr.log")
153
152
  end
154
153
 
155
- # see bundler/lib/bundler/cli/outdated.rb
156
- def outdated_gems_to_update
157
- @gems_to_update ||= begin
158
- say 'Scanning for outdated gems...'
159
- gems_to_update = []
160
-
161
- all_gem_specs.each do |current_spec|
162
- active_spec = bundle_spec(current_spec)
163
- next if active_spec.nil?
164
-
165
- if spec_outdated?(current_spec, active_spec)
166
- spec_version = "#{active_spec.version}#{active_spec.git_version}"
167
- current_version = "#{current_spec.version}#{current_spec.git_version}"
168
-
169
- gem_to_update = { name: active_spec.name, spec_version: spec_version, current_version: current_version }
170
-
171
- say "Adding #{gem_to_update[:name]} version: #{gem_to_update[:current_version]} to update list"
172
-
173
- gems_to_update << gem_to_update
174
- end
175
- end
176
-
177
- gems_to_update.sort_by do |gem|
178
- gem[:name]
179
- end
180
- end
181
- end
182
-
183
154
  def remove_commit(sha)
184
155
  commit_message = `git log --pretty=format:'%s' -n 1 #{sha}`
185
156
  message = "Could not apply: #{commit_message}, #{sha}"
@@ -203,35 +174,23 @@ module Bummr
203
174
  end
204
175
  end
205
176
 
206
- def spec_outdated?(current_spec, active_spec)
207
- gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version)
208
- git_outdated = current_spec.git_version != active_spec.git_version
177
+ def outdated_gems
178
+ @outdated_gems ||= begin
179
+ results = []
209
180
 
210
- gem_outdated || git_outdated
211
- end
212
-
213
- def bundle_spec(current_spec)
214
- active_spec = bundle_definition.index[current_spec.name].sort_by { |b| b.version }
215
- if !current_spec.version.prerelease? && !options[:pre] && active_spec.size > 1
216
- active_spec = active_spec.delete_if { |b| b.respond_to?(:version) && b.version.prerelease? }
217
- end
218
- active_spec.last
219
- end
181
+ Open3.popen2("bundle outdated --strict") do |std_in, std_out|
182
+ while line = std_out.gets
183
+ puts line
220
184
 
221
- def all_gem_specs
222
- current_specs = Bundler.ui.silence { Bundler.load.specs }
223
- current_dependencies = {}
224
- Bundler.ui.silence { Bundler.load.dependencies.each { |dep| current_dependencies[dep.name] = dep } }
225
- gemfile_specs, dependency_specs = current_specs.partition { |spec| current_dependencies.has_key? spec.name }
226
- [gemfile_specs, dependency_specs].flatten.sort_by(&:name)
227
- end
185
+ regex = / \* (.*) \(newest (\d\.\d\.\d), installed (\d\.\d\.\d)/.match line
186
+ unless regex.nil?
187
+ gem = { name: regex[1], newest: regex[2], installed: regex[3] }
188
+ results.push gem
189
+ end
190
+ end
191
+ end
228
192
 
229
- def bundle_definition
230
- @definition ||= begin
231
- Bundler.definition.validate_ruby!
232
- definition = Bundler.definition(true)
233
- definition.resolve_remotely!
234
- definition
193
+ results
235
194
  end
236
195
  end
237
196
  end
data/lib/bummr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bummr
2
- VERSION = "0.0.7"
2
+ VERSION = "0.1.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bummr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Pender