safe_update 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e95adcf65e5d5aa163064c2172366ce50f852b0b
4
- data.tar.gz: 366a3554dfd2ca55f796946a1a1997402a608309
3
+ metadata.gz: fe337285cafce984750adbc2cdebe202bb84ff56
4
+ data.tar.gz: 706d441b2c670f325203e6064ab940bbe1fe4b51
5
5
  SHA512:
6
- metadata.gz: dc1b7b38c84282724216b0eaf24c469acb4fc9e93720d464d5f8d0cb75cd73014f3d7651e6b500fd6c939619b472b526fa338f561fb3f4f3f4527eb01cb83b37
7
- data.tar.gz: b60ad414fcf497af52f900269e5ede3f2875dea2692312e1290377772c1e6891d8ba8007183c233d2d28fafa9cbdc75295dd885c3bf0d07fccc2ce6589cfad0c
6
+ metadata.gz: a45361991a9bb4872aa331e258a0963259a136d5c7bbd7eec9c962974c6a3cf09059dc70d4ab38ae4ffbbae31bab885ceccf09af875ef4792ee61296085a7224
7
+ data.tar.gz: eeb43295a21a4ef7c050a69f1e46d6873ce5ac3b79cdaacf38ca94cdd1492c99d0d49df2ba2b2ed9746adaee61110df7f9c9dcbd029bc95cf97fbe14b1a96bce
data/README.md CHANGED
@@ -7,7 +7,7 @@ When I first started ruby, I was told 'Never run `bundle update`'. The reality i
7
7
  This gem does `bundle update` in a safer way. It takes the output of `bundle outdated`, and, for each outdated gem, it:
8
8
 
9
9
  - runs `bundle update <gem_name>`
10
- - commits to git with the message: `ran: bundle update <gem_name>`
10
+ - commits to git with the message: `update gem: <gem_name>`
11
11
 
12
12
  Once you've got each gem updated, with one commit per gem, you can run your tests, and check everything is working. If something is broken, you can use `git bisect` to easily figure out the problem gem.
13
13
 
data/exe/safe_update CHANGED
@@ -1,4 +1,21 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require_relative "../lib/safe_update"
4
- SafeUpdate::Updater.new.run
3
+ require 'optparse'
4
+ require_relative '../lib/safe_update'
5
+ options = {}
6
+ OptionParser.new do |opts|
7
+ opts.banner = 'Usage: safe_update [options]'
8
+
9
+ opts.on('-v', '--version', 'Show version') do |v|
10
+ options[:version] = v
11
+ end
12
+ opts.on('-p', '--push N', 'git push every N commits') do |p|
13
+ options[:push] = p
14
+ end
15
+ end.parse!
16
+
17
+ if options[:version]
18
+ puts "safe_update version #{SafeUpdate::VERSION}"
19
+ else
20
+ SafeUpdate::Updater.new.run(options)
21
+ end
@@ -1,12 +1,18 @@
1
1
  module SafeUpdate
2
2
  class Updater
3
- def run
3
+ def run(options = {})
4
+ options[:push] = options[:push].to_i if options[:push]
4
5
  check_for_staged_changes
5
6
  check_for_gemfile_lock_changes
6
7
  output_array = bundle_outdated_parseable.split(/\n+/)
7
- output_array.each do |line|
8
- OutdatedGem.new(line).update
8
+ output_array.to_enum.with_index(1) do |line, index|
9
+ update_gem(line)
10
+ `git push` if options[:push] && index % options[:push] == 0
9
11
  end
12
+
13
+ # run it once at the very end, so the final commit can be tested in CI
14
+ `git push` if options[:push]
15
+
10
16
  puts '-------------'
11
17
  puts '-------------'
12
18
  puts 'FINISHED'
@@ -14,6 +20,10 @@ module SafeUpdate
14
20
 
15
21
  private
16
22
 
23
+ def update_gem(line)
24
+ OutdatedGem.new(line).update
25
+ end
26
+
17
27
  def bundle_outdated_parseable
18
28
  output = `bundle outdated --parseable`
19
29
  if output.strip == "Unknown switches '--parseable'"
@@ -1,3 +1,3 @@
1
1
  module SafeUpdate
2
- VERSION = '0.1.1'
2
+ VERSION = '0.2.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: safe_update
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Paling
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-10 00:00:00.000000000 Z
11
+ date: 2016-04-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler