safe_update 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/exe/safe_update +19 -2
- data/lib/safe_update/updater.rb +13 -3
- data/lib/safe_update/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fe337285cafce984750adbc2cdebe202bb84ff56
|
4
|
+
data.tar.gz: 706d441b2c670f325203e6064ab940bbe1fe4b51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: `
|
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
|
-
|
4
|
-
|
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
|
data/lib/safe_update/updater.rb
CHANGED
@@ -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.
|
8
|
-
|
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'"
|
data/lib/safe_update/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2016-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|