bummr 0.3.2 → 0.4.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: 73ba0fef0427b0831920d37208c1a80827757d36
4
- data.tar.gz: 564bf9e76cfa61e7247f5261d3d5e0004eb6820d
3
+ metadata.gz: de386c3a0c041b1dc02b6fc5d75f2b6f3b473624
4
+ data.tar.gz: 1dc533f03683112f7604c8fb80ad236ebd55ce4e
5
5
  SHA512:
6
- metadata.gz: 3e1d9167c57e85513d41d1a988d93827855422612c790f16b24c2d04f3ba711c9f070e8666face7d0a875e28a506855efa4f0ec846fb18bcf024a964f53cf135
7
- data.tar.gz: 1223ef7d6a3c2fe2fd99909d1ab7e1d6d8a40ec267c633fb9071510d56316c0051d020f7514c84e2938e27c4f7149e3579835f969c87f73d30d30dfeeb430338
6
+ metadata.gz: a837b59236235d1733ad24a770f63cf2b2b6c48739a1c538fc0ee2de807bf10c37824ebef30a5dc718b8e3d0cc9c57a75d7de273873824a36e395fdebbe6ecc1
7
+ data.tar.gz: 437a0facee5cf00915827b57604f3202a82104beccc07b867459b677856e0d10cc1edbeb6c0dfaa036723b343bb35844c1471969b474aee1eb5d3140724eacc8
data/README.md CHANGED
@@ -49,11 +49,12 @@ instructions in the Installation section of this README.
49
49
  - After installing, create a new, clean branch off of your `master` branch.
50
50
  - Run `bummr update`. This may take some time.
51
51
  - `Bummr` will give you the opportunity to interactively rebase your branch
52
- before running the tests. Delete any commits for gems which you don't want
53
- to update and close the file.
52
+ before running the tests. Careful.
54
53
  - At this point, you can leave `bummr` to work for some time.
55
- - If your build fails, `bummr` will attempt to automatically remove breaking
56
- commits, until the build passes, logging any failures to `/log/bummr.log`.
54
+ - 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
57
+ to implement code changes which fix the problem.
57
58
  - Once your build passes, open a pull-request and merge it to your `master` branch.
58
59
 
59
60
  ##### `bummr update`
data/lib/bummr/cli.rb CHANGED
@@ -4,15 +4,23 @@ BASE_BRANCH = ENV["BASE_BRANCH"] || "master"
4
4
  module Bummr
5
5
  class CLI < Thor
6
6
  include Bummr::Log
7
+ include Bummr::Scm
7
8
 
8
9
  desc "check", "Run automated checks to see if bummr can be run"
9
10
  def check(fullcheck=true)
10
11
  Bummr::Check.instance.check(fullcheck)
11
12
  end
12
13
 
13
- desc "update", "Update outdated gems, run tests, bisect if tests fail"
14
+ desc "update",
15
+ "Update outdated gems, run tests, bisect if tests fail\n\n" +
16
+ "--all: Update indirect dependencies\n" +
17
+ "--group: Specify a group from the Gemfile to update\n" +
18
+ "\n"
19
+
20
+
14
21
  method_option :all, type: :boolean, default: false
15
22
  method_option :group, type: :string
23
+
16
24
  def update
17
25
  system("bundle install")
18
26
  ask_questions
@@ -30,7 +38,7 @@ module Bummr
30
38
  else
31
39
  Bummr::Updater.new(outdated_gems).update_gems
32
40
 
33
- system("git rebase -i #{BASE_BRANCH}")
41
+ git.rebase_interactive(BASE_BRANCH)
34
42
  test
35
43
  end
36
44
  else
@@ -75,13 +83,26 @@ module Bummr
75
83
  def ask_questions
76
84
  puts "Bummr #{VERSION}"
77
85
  puts "To run Bummr, you must:"
78
- puts "- Be in the root path of a clean git branch off of #{BASE_BRANCH}"
86
+ puts "- Be in the root path of a clean git branch off of " + "#{BASE_BRANCH}".color(:yellow)
79
87
  puts "- Have no commits or local changes"
80
88
  puts "- Have a 'log' directory, where we can place logs"
81
89
  puts "- Have your build configured to fail fast (recommended)"
82
90
  puts "- Have locked any Gem version that you don't wish to update in your Gemfile"
83
91
  puts "- It is recommended that you lock your versions of `ruby` and `rails` in your `Gemfile`"
84
- puts "Your test command is: '#{TEST_COMMAND}'"
92
+ puts "\n"
93
+ puts "Your test command is: " + "'#{TEST_COMMAND}'".color(:yellow)
94
+ puts "\n"
95
+ print_received_options
96
+ end
97
+
98
+ def print_received_options
99
+ puts "Bummr will run with the following options:"
100
+
101
+ options.each do |key, value|
102
+ puts "--#{key.color(:yellow)}: #{value}"
103
+ end
104
+
105
+ puts "\nRun `#{"bummr help update".color(:yellow)}` for more information.\n\n"
85
106
  end
86
107
  end
87
108
  end
data/lib/bummr/git.rb ADDED
@@ -0,0 +1,31 @@
1
+ module Bummr
2
+ class Git
3
+ include Singleton
4
+ include Log
5
+
6
+ def initialize
7
+ @git_commit = ENV.fetch("BUMMR_GIT_COMMIT") { "git commit" }
8
+ end
9
+
10
+ def add(files)
11
+ system("git add #{files}")
12
+ end
13
+
14
+ def commit(message)
15
+ log "Commit: #{message}".color(:green)
16
+ system("#{git_commit} -m '#{message}'")
17
+ end
18
+
19
+ def rebase_interactive(sha)
20
+ system("git rebase -i #{BASE_BRANCH}")
21
+ end
22
+
23
+ def message(sha)
24
+ `git log --pretty=format:'%s' -n 1 #{sha}`
25
+ end
26
+
27
+ private
28
+
29
+ attr_reader :git_commit
30
+ end
31
+ end
data/lib/bummr/remover.rb CHANGED
@@ -2,14 +2,15 @@ module Bummr
2
2
  class Remover < Thor
3
3
  include Singleton
4
4
  include Log
5
+ include Scm
5
6
 
6
7
  desc "remove_commit", "Remove a commit from the history"
7
8
  def remove_commit(sha)
8
- log "Bad commit: #{commit_message_for(sha)}, #{sha}".color(:red)
9
+ log "Bad commit: #{git.message(sha)}, #{sha}".color(:red)
9
10
  log "Resetting..."
10
11
  system("git bisect reset")
11
12
 
12
- message = "\nThe commit:\n\n `#{sha} #{commit_message_for(sha)}`\n\n" +
13
+ message = "\nThe commit:\n\n `#{sha} #{git.message(sha)}`\n\n" +
13
14
  "Is breaking the build.\n\n" +
14
15
  "Please do one of the following: \n\n" +
15
16
  " 1. Update your code to work with the latest version of this gem.\n\n" +
@@ -22,11 +23,5 @@ module Bummr
22
23
 
23
24
  puts message.color(:yellow)
24
25
  end
25
-
26
- private
27
-
28
- def commit_message_for(sha)
29
- `git log --pretty=format:'%s' -n 1 #{sha}`
30
- end
31
26
  end
32
27
  end
data/lib/bummr/scm.rb ADDED
@@ -0,0 +1,9 @@
1
+ module Bummr
2
+ module Scm
3
+ private
4
+
5
+ def git
6
+ Bummr::Git.instance
7
+ end
8
+ end
9
+ end
data/lib/bummr/updater.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  module Bummr
2
2
  class Updater
3
3
  include Log
4
+ include Scm
4
5
 
5
6
  def initialize(outdated_gems)
6
7
  @outdated_gems = outdated_gems
@@ -35,9 +36,8 @@ module Bummr
35
36
  log("#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}")
36
37
  end
37
38
 
38
- log "Commit: #{message}".color(:green)
39
- system("git add Gemfile Gemfile.lock")
40
- system("git commit -m '#{message}'")
39
+ git.add("Gemfile Gemfile.lock vendor/cache")
40
+ git.commit(message)
41
41
  end
42
42
 
43
43
  def updated_version_for(gem)
data/lib/bummr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Bummr
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/bummr.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # grouped by dependency order than alpha
2
2
  require 'bummr/log'
3
+ require "bummr/scm"
3
4
  require 'rainbow/ext/string'
4
5
  require 'open3'
5
6
  require 'singleton'
@@ -7,6 +8,7 @@ require 'thor'
7
8
 
8
9
  require "bummr/bisecter"
9
10
  require "bummr/check"
11
+ require "bummr/git"
10
12
  require "bummr/outdated"
11
13
  require "bummr/remover"
12
14
  require "bummr/updater"
data/spec/lib/cli_spec.rb CHANGED
@@ -6,6 +6,7 @@ describe Bummr::CLI do
6
6
  let(:options) { {} }
7
7
  let(:config) { { pretend: true } }
8
8
  let(:cli) { described_class.new(args, options, config) }
9
+ let(:git) { Bummr::Git.instance }
9
10
  let(:outdated_gems) {
10
11
  [
11
12
  { name: "myGem", installed: "0.3.2", newest: "0.3.5" },
@@ -35,8 +36,8 @@ describe Bummr::CLI do
35
36
  expect(cli).to receive(:log)
36
37
  expect(cli).to receive(:system).with("bundle install")
37
38
  expect(Bummr::Updater).to receive(:new).with(outdated_gems).and_return updater
38
- expect(cli).to receive(:system).with("git rebase -i #{BASE_BRANCH}")
39
39
  expect(cli).to receive(:test)
40
+ expect(git).to receive(:rebase_interactive).with(BASE_BRANCH)
40
41
  end
41
42
 
42
43
  context "and there are no outdated gems" do
@@ -0,0 +1,88 @@
1
+ require "spec_helper"
2
+
3
+ describe Bummr::Git do
4
+ describe "#add" do
5
+ it "stages specified files with git" do
6
+ git = stub_git
7
+ files = "Gemfile Gemfile.lock"
8
+
9
+ git.add(files)
10
+
11
+ expect(git).to have_received(:system).with(
12
+ "git add #{files}"
13
+ )
14
+ end
15
+ end
16
+
17
+ describe "#commit" do
18
+ it "logs the commit" do
19
+ git = stub_git
20
+ commit_message = "Update Foo from 0.0.1 to 0.0.2"
21
+
22
+ git.commit(commit_message)
23
+
24
+ expect(git).to have_received(:log).with(
25
+ /Commit: #{commit_message}/
26
+ )
27
+ end
28
+
29
+ it "commits with a message" do
30
+ git = stub_git
31
+ commit_message = "Update Foo from 0.0.1 to 0.0.2"
32
+
33
+ git.commit(commit_message)
34
+
35
+ expect(git).to have_received(:system).with(
36
+ "git commit -m '#{commit_message}'"
37
+ )
38
+ end
39
+
40
+ describe "when BUMMR_GIT_COMMIT is defined" do
41
+ it "commits using defined value" do
42
+ allow(ENV).to receive(:fetch).with("BUMMR_GIT_COMMIT").and_return("git commit --no-verify")
43
+ git = stub_git
44
+ commit_message = "Update Foo from 0.0.1 to 0.0.2"
45
+
46
+ git.commit(commit_message)
47
+
48
+ expect(git).to have_received(:system).with(
49
+ "git commit --no-verify -m '#{commit_message}'"
50
+ )
51
+ end
52
+ end
53
+ end
54
+
55
+ describe "#rebase_interactive" do
56
+ it "runs git interactive rebase to the given sha" do
57
+ git = stub_git
58
+ sha = "b39dcd8"
59
+
60
+ git.rebase_interactive(sha)
61
+
62
+ expect(git).to have_received(:system).with(
63
+ "git rebase -i #{BASE_BRANCH}"
64
+ )
65
+ end
66
+ end
67
+
68
+ describe "#message" do
69
+ it "displays the commit message for a given sha" do
70
+ git = stub_git
71
+ sha = "b39dcd8"
72
+
73
+ git.message(sha)
74
+
75
+ expect(git).to have_received(:`).with(
76
+ "git log --pretty=format:'%s' -n 1 #{sha}"
77
+ )
78
+ end
79
+ end
80
+
81
+ def stub_git
82
+ git = Bummr::Git.clone.instance
83
+ allow(git).to receive(:log)
84
+ allow(git).to receive(:system)
85
+ allow(git).to receive(:`)
86
+ git
87
+ end
88
+ end
@@ -1,13 +1,11 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Bummr::Remover do
4
- # let(:commit_message) { "test commit message" }
5
4
  let(:remover) { Bummr::Remover.instance }
5
+ let(:git) { Bummr::Git.instance }
6
6
  let(:sha) { "testsha" }
7
- let(:remove_command) { "git rebase -p --onto #{sha}^ #{sha}" }
8
7
 
9
8
  before do
10
- allow(remover).to receive(:commit_message_for).and_return "commit message"
11
9
  allow(remover).to receive(:log)
12
10
  allow(remover).to receive(:system)
13
11
  allow(remover).to receive(:yes?).and_return(true)
@@ -15,6 +13,8 @@ describe Bummr::Remover do
15
13
 
16
14
  describe "#remove_commit" do
17
15
  it "logs the bad commit" do
16
+ allow(git).to receive(:message).and_return("commit message")
17
+
18
18
  remover.remove_commit(sha)
19
19
 
20
20
  expect(remover).to have_received(:log).with(
@@ -14,6 +14,7 @@ describe Bummr::Updater do
14
14
  let(:installed) { outdated_gems[0][:installed] }
15
15
  let(:intermediate_version) { "0.3.4" }
16
16
  let(:update_cmd) { "bundle update #{gem[:name]}" }
17
+ let(:git) { Bummr::Git.instance }
17
18
 
18
19
  describe "#update_gems" do
19
20
  it "calls update_gem on each gem" do
@@ -32,6 +33,7 @@ describe Bummr::Updater do
32
33
  allow(updater).to receive(:system).with(update_cmd)
33
34
  allow(updater).to receive(:updated_version_for).with(gem).and_return installed
34
35
  allow(updater).to receive(:log)
36
+ allow(git).to receive(:commit)
35
37
 
36
38
  updater.update_gem(gem, 0)
37
39
  end
@@ -41,6 +43,7 @@ describe Bummr::Updater do
41
43
  allow(updater).to receive(:system).with(update_cmd)
42
44
  allow(updater).to receive(:updated_version_for).with(gem).and_return installed
43
45
  allow(updater).to receive(:log)
46
+ allow(git).to receive(:commit)
44
47
 
45
48
  updater.update_gem(gem, 0)
46
49
 
@@ -51,10 +54,11 @@ describe Bummr::Updater do
51
54
  allow(updater).to receive(:system).with(update_cmd)
52
55
  allow(updater).to receive(:updated_version_for).with(gem).and_return installed
53
56
  allow(updater).to receive(:log)
57
+ allow(git).to receive(:commit)
54
58
 
55
59
  updater.update_gem(gem, 0)
56
60
 
57
- expect(updater).to_not have_received(:system).with /git commit/
61
+ expect(git).to_not have_received(:commit)
58
62
  end
59
63
  end
60
64
 
@@ -70,6 +74,7 @@ describe Bummr::Updater do
70
74
  "#{gem[:name]} not updated from #{gem[:installed]} to latest: #{gem[:newest]}"
71
75
  allow(updater).to receive(:system)
72
76
  allow(updater).to receive(:log)
77
+ allow(git).to receive(:commit)
73
78
 
74
79
  updater.update_gem(gem, 0)
75
80
 
@@ -81,11 +86,13 @@ describe Bummr::Updater do
81
86
  "Update #{gem[:name]} from #{gem[:installed]} to #{intermediate_version}"
82
87
  allow(updater).to receive(:system)
83
88
  allow(updater).to receive(:log)
89
+ allow(git).to receive(:add)
90
+ allow(git).to receive(:commit)
84
91
 
85
92
  updater.update_gem(gem, 0)
86
93
 
87
- expect(updater).to have_received(:system).with("git add Gemfile Gemfile.lock")
88
- expect(updater).to have_received(:system).with("git commit -m '#{commit_message}'")
94
+ expect(git).to have_received(:add).with("Gemfile Gemfile.lock vendor/cache")
95
+ expect(git).to have_received(:commit).with(commit_message)
89
96
  end
90
97
  end
91
98
 
@@ -94,27 +101,18 @@ describe Bummr::Updater do
94
101
  allow(updater).to receive(:updated_version_for).and_return newest
95
102
  end
96
103
 
97
- it "logs the commit" do
98
- commit_message =
99
- "Commit: Update #{gem[:name]} from #{gem[:installed]} to #{gem[:newest]}".color(:green)
100
- allow(updater).to receive(:system)
101
- allow(updater).to receive(:log)
102
-
103
- updater.update_gem(gem, 0)
104
-
105
- expect(updater).to have_received(:log).with commit_message
106
- end
107
-
108
104
  it "commits" do
109
105
  commit_message =
110
106
  "Update #{gem[:name]} from #{gem[:installed]} to #{gem[:newest]}"
111
107
  allow(updater).to receive(:system)
112
108
  allow(updater).to receive(:log)
109
+ allow(git).to receive(:add)
110
+ allow(git).to receive(:commit)
113
111
 
114
112
  updater.update_gem(gem, 0)
115
113
 
116
- expect(updater).to have_received(:system).with("git add Gemfile Gemfile.lock")
117
- expect(updater).to have_received(:system).with("git commit -m '#{commit_message}'")
114
+ expect(git).to have_received(:add).with("Gemfile Gemfile.lock vendor/cache")
115
+ expect(git).to have_received(:commit).with(commit_message)
118
116
  end
119
117
  end
120
118
  end
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.3.2
4
+ version: 0.4.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-04-19 00:00:00.000000000 Z
11
+ date: 2018-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -213,14 +213,17 @@ files:
213
213
  - lib/bummr/bisecter.rb
214
214
  - lib/bummr/check.rb
215
215
  - lib/bummr/cli.rb
216
+ - lib/bummr/git.rb
216
217
  - lib/bummr/log.rb
217
218
  - lib/bummr/outdated.rb
218
219
  - lib/bummr/remover.rb
220
+ - lib/bummr/scm.rb
219
221
  - lib/bummr/updater.rb
220
222
  - lib/bummr/version.rb
221
223
  - spec/check_spec.rb
222
224
  - spec/lib/bisecter_spec.rb
223
225
  - spec/lib/cli_spec.rb
226
+ - spec/lib/git_spec.rb
224
227
  - spec/lib/log_spec.rb
225
228
  - spec/lib/outdated_spec.rb
226
229
  - spec/lib/remover_spec.rb
@@ -254,6 +257,7 @@ test_files:
254
257
  - spec/check_spec.rb
255
258
  - spec/lib/bisecter_spec.rb
256
259
  - spec/lib/cli_spec.rb
260
+ - spec/lib/git_spec.rb
257
261
  - spec/lib/log_spec.rb
258
262
  - spec/lib/outdated_spec.rb
259
263
  - spec/lib/remover_spec.rb