bummr 0.4.0 → 0.5.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: de386c3a0c041b1dc02b6fc5d75f2b6f3b473624
4
- data.tar.gz: 1dc533f03683112f7604c8fb80ad236ebd55ce4e
3
+ metadata.gz: 389815b5180dc129c7eabe7f2d2a4652c0266a7e
4
+ data.tar.gz: 55dea3cebd0100b8a484a8994ef4657765a27b84
5
5
  SHA512:
6
- metadata.gz: a837b59236235d1733ad24a770f63cf2b2b6c48739a1c538fc0ee2de807bf10c37824ebef30a5dc718b8e3d0cc9c57a75d7de273873824a36e395fdebbe6ecc1
7
- data.tar.gz: 437a0facee5cf00915827b57604f3202a82104beccc07b867459b677856e0d10cc1edbeb6c0dfaa036723b343bb35844c1471969b474aee1eb5d3140724eacc8
6
+ metadata.gz: 47ac269d5bffa3e9f45d83eabe2befb31f5ad932e18aa5cdd3cf817b3bca3153c15166e12f2f5489682d3c058bbce77579fe68e4e7a3126a0b21acf7885182de
7
+ data.tar.gz: f953d5673838a0c6f00f6785ec65745fbac5f550285796d061fdf2221c4a8baff9d40bfda5d8c877d3530a34fcc6cd0e44da6e5db0bae9d9929aa8f3bf698a8d
data/README.md CHANGED
@@ -15,7 +15,7 @@ build in separate commits, and logs the name and sha of each gem that fails.
15
15
  Bummr assumes you have good test coverage and follow a [pull-request workflow]
16
16
  with `master` as your default branch.
17
17
 
18
- Please note that this gem is *alpha* stage and may have bugs.
18
+ Please note that this gem is _alpha_ stage and may have bugs.
19
19
 
20
20
  ## Installation
21
21
 
@@ -23,6 +23,9 @@ Please note that this gem is *alpha* stage and may have bugs.
23
23
  $ gem install bummr
24
24
  ```
25
25
 
26
+ To run headless (skip interactive rebasing/confirmation), use
27
+ `BUMMR_HEADLESS=true bundle exec bummr update`.
28
+
26
29
  By default, bummr will use `bundle exec rake` to run your build.
27
30
 
28
31
  To customize your build command, `export BUMMR_TEST="./bummr-build.sh"`
@@ -52,15 +55,16 @@ instructions in the Installation section of this README.
52
55
  before running the tests. Careful.
53
56
  - At this point, you can leave `bummr` to work for some time.
54
57
  - If your build fails, `bummr` will notify you of failures, logging the failures to
55
- `log/bummr.log`. At this point it is recommended that you lock that gem version in
56
- your Gemfile and start the process over from the top. Alternatively, you may wish
58
+ `log/bummr.log`. At this point it is recommended that you lock that gem version in
59
+ your Gemfile and start the process over from the top. Alternatively, you may wish
57
60
  to implement code changes which fix the problem.
58
61
  - Once your build passes, open a pull-request and merge it to your `master` branch.
59
62
 
60
63
  ##### `bummr update`
61
64
 
62
65
  - Finds all your outdated gems
63
- - Updates them each individually, using `bundle update --source #{gemname}`
66
+ - Updates them each individually, using `bundle update --source #{gemname}`. To use a less
67
+ conservative update strategy, start `bummr update` with the `--all` option.
64
68
  - Commits each gem update separately, with a commit message like:
65
69
  - Options:
66
70
  - `--all` to include indirect dependencies (`bummr` defaults to direct dependencies only)
@@ -79,9 +83,9 @@ instructions in the Installation section of this README.
79
83
  ##### `bummr bisect`
80
84
 
81
85
  - `git bisect`s against master.
82
- - Finds the bad commit and attempts to remove it.
86
+ - Upon finding the bad commit, runs `git bisect reset` and notifies the developer on
87
+ how best to proceed.
83
88
  - Logs the bad commit in `log/bummr.log`.
84
- - Runs `bummr test`.
85
89
 
86
90
  ## Notes
87
91
 
@@ -90,12 +94,6 @@ instructions in the Installation section of this README.
90
94
  - Once the build passes, you can push your branch and create a pull-request!
91
95
  - You may wish to `tail -f log/bummr.log` in a separate terminal window so you
92
96
  can see which commits are being removed.
93
- - Bummr conservatively updates gems using `bundle update --source gemname`
94
- - Bummr automatically rebases out commits which fail the build using an "ours"
95
- merge strategy.
96
- - Bummr may not be able to remove the bad commit due to a merge conflict, in
97
- which case you will have to remove it manually, continue the rebase, and
98
- run `bummr test` again.
99
97
 
100
98
  ## License
101
99
 
@@ -110,9 +108,9 @@ wish to use it with.
110
108
 
111
109
  `rake` will run the suite of unit tests.
112
110
 
113
- I'd like to create feature tests, but because Bummr relies on command line
114
- manipulations which need to be doubled, I'm waiting on [this
115
- issue](https://github.com/bjoernalbers/aruba-doubles/issues/5)
111
+ The suite relies on Oliver Peate's [jet
112
+ black](https://github.com/odlp/jet_black) testing library for command line feature
113
+ tests.
116
114
 
117
115
  ## Thank you!
118
116
 
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "bundler"
29
29
  spec.add_development_dependency "rake"
30
30
  spec.add_development_dependency "guard"
31
+ spec.add_development_dependency "jet_black", "~> 0.3"
31
32
  spec.add_development_dependency "pry"
32
33
  spec.add_development_dependency "pry-remote"
33
34
  spec.add_development_dependency "pry-nav"
@@ -1,5 +1,6 @@
1
1
  # grouped by dependency order than alpha
2
2
  require 'bummr/log'
3
+ require 'bummr/prompt'
3
4
  require "bummr/scm"
4
5
  require 'rainbow/ext/string'
5
6
  require 'open3'
@@ -1,6 +1,7 @@
1
1
  module Bummr
2
2
  class Check < Thor
3
3
  include Singleton
4
+ include Bummr::Prompt
4
5
 
5
6
  desc "check", "Run automated checks to see if bummr can be run"
6
7
  def check(fullcheck=true)
@@ -1,9 +1,11 @@
1
1
  TEST_COMMAND = ENV["BUMMR_TEST"] || "bundle exec rake"
2
2
  BASE_BRANCH = ENV["BASE_BRANCH"] || "master"
3
+ HEADLESS = ENV["BUMMR_HEADLESS"] || false
3
4
 
4
5
  module Bummr
5
6
  class CLI < Thor
6
7
  include Bummr::Log
8
+ include Bummr::Prompt
7
9
  include Bummr::Scm
8
10
 
9
11
  desc "check", "Run automated checks to see if bummr can be run"
@@ -23,7 +25,7 @@ module Bummr
23
25
 
24
26
  def update
25
27
  system("bundle install")
26
- ask_questions
28
+ display_info
27
29
 
28
30
  if yes? "Are you ready to use Bummr? (y/n)"
29
31
  check
@@ -80,7 +82,7 @@ module Bummr
80
82
 
81
83
  private
82
84
 
83
- def ask_questions
85
+ def display_info
84
86
  puts "Bummr #{VERSION}"
85
87
  puts "To run Bummr, you must:"
86
88
  puts "- Be in the root path of a clean git branch off of " + "#{BASE_BRANCH}".color(:yellow)
@@ -17,7 +17,7 @@ module Bummr
17
17
  end
18
18
 
19
19
  def rebase_interactive(sha)
20
- system("git rebase -i #{BASE_BRANCH}")
20
+ system("git rebase -i #{BASE_BRANCH}") unless HEADLESS
21
21
  end
22
22
 
23
23
  def message(sha)
@@ -0,0 +1,14 @@
1
+ module Bummr
2
+ module Prompt
3
+ def yes?(*args)
4
+ headless? || super
5
+ end
6
+
7
+ private
8
+
9
+ def headless?
10
+ HEADLESS == true ||
11
+ HEADLESS == "true"
12
+ end
13
+ end
14
+ end
@@ -18,8 +18,7 @@ module Bummr
18
18
  " - `git reset --hard master`\n" +
19
19
  " - Lock the version of this Gem in your Gemfile.\n" +
20
20
  " - Commit the changes.\n" +
21
- " - Run `bummr update` again.\n\n" +
22
- "Lord Bummr\n\n"
21
+ " - Run `bummr update` again.\n\n"
23
22
 
24
23
  puts message.color(:yellow)
25
24
  end
@@ -36,7 +36,9 @@ module Bummr
36
36
  log("#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}")
37
37
  end
38
38
 
39
- git.add("Gemfile Gemfile.lock vendor/cache")
39
+ git.add("Gemfile")
40
+ git.add("Gemfile.lock")
41
+ git.add("vendor/cache")
40
42
  git.commit(message)
41
43
  end
42
44
 
@@ -1,3 +1,3 @@
1
1
  module Bummr
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
@@ -0,0 +1,59 @@
1
+ require "spec_helper"
2
+ require "jet_black"
3
+
4
+ describe "bummr update command" do
5
+ let(:session) { JetBlack::Session.new(options: { clean_bundler_env: true }) }
6
+ let(:bummr_gem_path) { File.expand_path("../../", __dir__) }
7
+
8
+ it "updates outdated gems" do
9
+ session.create_file "Gemfile", <<~RUBY
10
+ source "https://rubygems.org"
11
+ gem "rake", "~> 10.0"
12
+ gem "bummr", path: "#{bummr_gem_path}"
13
+ RUBY
14
+
15
+ session.create_file "Rakefile", <<~RUBY
16
+ task :default do
17
+ puts "Hello from the Rakefile"
18
+ end
19
+ RUBY
20
+
21
+ expect(session.run("bundle install --retry 3")).
22
+ to be_a_success.and have_stdout(/bummr .* from source/)
23
+
24
+ # Now allow newer versions of Rake to be installed
25
+ session.run("sed -i.bak 's/, \"~> 10.0\"//' Gemfile")
26
+
27
+ session.run("mkdir -p log")
28
+
29
+ expect(session.run("git init .")).
30
+ to be_a_success.and have_stdout("Initialized empty Git repository")
31
+
32
+ session.run("git config user.name 'Bummr Test'")
33
+ session.run("git config user.email 'test@example.com'")
34
+
35
+ expect(session.run("git add . && git commit -m 'Initial commit'")).
36
+ to be_a_success.and have_stdout("Initial commit")
37
+
38
+ session.run("git checkout -b bummr-branch")
39
+
40
+ update_result = session.run(
41
+ "bundle exec bummr update",
42
+ stdin: "y\ny\ny\n",
43
+ env: { EDITOR: nil, BUMMR_HEADLESS: "true" },
44
+ )
45
+
46
+ rake_gem_updated = /Update rake from 10\.\d\.\d to 1[1-9]\.\d\.\d/
47
+
48
+ expect(update_result).
49
+ to be_a_success.and have_stdout(rake_gem_updated)
50
+
51
+ expect(update_result).to have_stdout("Passed the build!")
52
+
53
+ expect(session.run("git log")).
54
+ to be_a_success.and have_stdout(rake_gem_updated)
55
+
56
+ expect(session.run("bundle show")).
57
+ to be_a_success.and have_stdout(/rake\s\(1[1-9]/)
58
+ end
59
+ end
@@ -30,7 +30,7 @@ describe Bummr::CLI do
30
30
  updater = double
31
31
  allow(updater).to receive(:update_gems)
32
32
 
33
- expect(cli).to receive(:ask_questions)
33
+ expect(cli).to receive(:display_info)
34
34
  expect(cli).to receive(:yes?).and_return(true)
35
35
  expect(cli).to receive(:check)
36
36
  expect(cli).to receive(:log)
@@ -45,7 +45,7 @@ describe Bummr::CLI do
45
45
  allow_any_instance_of(Bummr::Outdated).to receive(:outdated_gems)
46
46
  .and_return []
47
47
 
48
- expect(cli).to receive(:ask_questions)
48
+ expect(cli).to receive(:display_info)
49
49
  expect(cli).to receive(:yes?).and_return(true)
50
50
  expect(cli).to receive(:check)
51
51
  expect(cli).to receive(:log)
@@ -95,6 +95,24 @@ describe Bummr::CLI do
95
95
  end
96
96
  end
97
97
  end
98
+
99
+ context "when in headless mode" do
100
+ context "and there are no outdated gems" do
101
+ it "informs that there are no outdated gems" do
102
+ stub_const("HEADLESS", true)
103
+ allow_any_instance_of(Bummr::Outdated).to receive(:outdated_gems)
104
+ .and_return []
105
+
106
+ expect(cli).to receive(:display_info)
107
+ expect(cli).to receive(:check)
108
+ expect(cli).to receive(:log)
109
+ expect(cli).to receive(:system).with("bundle install")
110
+ expect(cli).to receive(:puts).with("No outdated gems to update".color(:green))
111
+
112
+ cli.update
113
+ end
114
+ end
115
+ end
98
116
  end
99
117
 
100
118
  describe "#test" do
@@ -0,0 +1,49 @@
1
+ require "spec_helper"
2
+
3
+ describe Bummr::Prompt do
4
+ let(:parent_class) do
5
+ Class.new do
6
+ def yes?(message)
7
+ "called parent with #{message}"
8
+ end
9
+ end
10
+ end
11
+ let(:object_class) { Class.new(parent_class) }
12
+ let(:object) { object_class.new }
13
+
14
+ before do
15
+ object.extend(Bummr::Prompt)
16
+ end
17
+
18
+ describe "#yes?" do
19
+ context "when HEADLESS is false" do
20
+ it "calls super" do
21
+ stub_const("HEADLESS", false)
22
+
23
+ expect(
24
+ object.yes?("foo")
25
+ ).to eq "called parent with foo"
26
+ end
27
+ end
28
+
29
+ context "when HEADLESS is nil" do
30
+ it "calls super" do
31
+ stub_const("HEADLESS", nil)
32
+
33
+ expect(
34
+ object.yes?("foo")
35
+ ).to eq "called parent with foo"
36
+ end
37
+ end
38
+
39
+ context "when HEADLESS is true" do
40
+ it "returns true and skips asking for user input" do
41
+ stub_const("HEADLESS", true)
42
+
43
+ expect(
44
+ object.yes?("foo")
45
+ ).to eq true
46
+ end
47
+ end
48
+ end
49
+ end
@@ -91,7 +91,9 @@ describe Bummr::Updater do
91
91
 
92
92
  updater.update_gem(gem, 0)
93
93
 
94
- expect(git).to have_received(:add).with("Gemfile Gemfile.lock vendor/cache")
94
+ expect(git).to have_received(:add).with("Gemfile")
95
+ expect(git).to have_received(:add).with("Gemfile.lock")
96
+ expect(git).to have_received(:add).with("vendor/cache")
95
97
  expect(git).to have_received(:commit).with(commit_message)
96
98
  end
97
99
  end
@@ -111,7 +113,9 @@ describe Bummr::Updater do
111
113
 
112
114
  updater.update_gem(gem, 0)
113
115
 
114
- expect(git).to have_received(:add).with("Gemfile Gemfile.lock vendor/cache")
116
+ expect(git).to have_received(:add).with("Gemfile")
117
+ expect(git).to have_received(:add).with("Gemfile.lock")
118
+ expect(git).to have_received(:add).with("vendor/cache")
115
119
  expect(git).to have_received(:commit).with(commit_message)
116
120
  end
117
121
  end
@@ -4,3 +4,4 @@ SimpleCov.start
4
4
  require 'pry'
5
5
  require 'bummr'
6
6
  require 'rainbow/ext/string'
7
+ require 'jet_black/rspec'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bummr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lee Pender
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-11-30 00:00:00.000000000 Z
11
+ date: 2019-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: jet_black
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.3'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.3'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: pry
141
155
  requirement: !ruby/object:Gem::Requirement
@@ -216,16 +230,19 @@ files:
216
230
  - lib/bummr/git.rb
217
231
  - lib/bummr/log.rb
218
232
  - lib/bummr/outdated.rb
233
+ - lib/bummr/prompt.rb
219
234
  - lib/bummr/remover.rb
220
235
  - lib/bummr/scm.rb
221
236
  - lib/bummr/updater.rb
222
237
  - lib/bummr/version.rb
238
+ - spec/black_box/bummr_update_spec.rb
223
239
  - spec/check_spec.rb
224
240
  - spec/lib/bisecter_spec.rb
225
241
  - spec/lib/cli_spec.rb
226
242
  - spec/lib/git_spec.rb
227
243
  - spec/lib/log_spec.rb
228
244
  - spec/lib/outdated_spec.rb
245
+ - spec/lib/prompt_spec.rb
229
246
  - spec/lib/remover_spec.rb
230
247
  - spec/lib/updater_spec.rb
231
248
  - spec/spec_helper.rb
@@ -254,12 +271,14 @@ signing_key:
254
271
  specification_version: 4
255
272
  summary: Helper script to intelligently update your Gemfile
256
273
  test_files:
274
+ - spec/black_box/bummr_update_spec.rb
257
275
  - spec/check_spec.rb
258
276
  - spec/lib/bisecter_spec.rb
259
277
  - spec/lib/cli_spec.rb
260
278
  - spec/lib/git_spec.rb
261
279
  - spec/lib/log_spec.rb
262
280
  - spec/lib/outdated_spec.rb
281
+ - spec/lib/prompt_spec.rb
263
282
  - spec/lib/remover_spec.rb
264
283
  - spec/lib/updater_spec.rb
265
284
  - spec/spec_helper.rb