bummr 0.3.1 → 0.3.2
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 +4 -4
- data/lib/bummr/bisecter.rb +1 -1
- data/lib/bummr/cli.rb +21 -10
- data/lib/bummr/remover.rb +32 -0
- data/lib/bummr/updater.rb +12 -3
- data/lib/bummr/version.rb +1 -1
- data/lib/bummr.rb +1 -1
- data/spec/lib/bisecter_spec.rb +3 -3
- data/spec/lib/cli_spec.rb +6 -4
- data/spec/lib/remover_spec.rb +31 -0
- data/spec/lib/updater_spec.rb +5 -7
- metadata +5 -5
- data/lib/bummr/rebaser.rb +0 -29
- data/spec/lib/rebaser_spec.rb +0 -64
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 73ba0fef0427b0831920d37208c1a80827757d36
         | 
| 4 | 
            +
              data.tar.gz: 564bf9e76cfa61e7247f5261d3d5e0004eb6820d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3e1d9167c57e85513d41d1a988d93827855422612c790f16b24c2d04f3ba711c9f070e8666face7d0a875e28a506855efa4f0ec846fb18bcf024a964f53cf135
         | 
| 7 | 
            +
              data.tar.gz: 1223ef7d6a3c2fe2fd99909d1ab7e1d6d8a40ec267c633fb9071510d56316c0051d020f7514c84e2938e27c4f7149e3579835f969c87f73d30d30dfeeb430338
         | 
    
        data/lib/bummr/bisecter.rb
    CHANGED
    
    
    
        data/lib/bummr/cli.rb
    CHANGED
    
    | @@ -14,12 +14,12 @@ module Bummr | |
| 14 14 | 
             
                method_option :all, type: :boolean, default: false
         | 
| 15 15 | 
             
                method_option :group, type: :string
         | 
| 16 16 | 
             
                def update
         | 
| 17 | 
            +
                  system("bundle install")
         | 
| 17 18 | 
             
                  ask_questions
         | 
| 18 19 |  | 
| 19 20 | 
             
                  if yes? "Are you ready to use Bummr? (y/n)"
         | 
| 20 21 | 
             
                    check
         | 
| 21 22 | 
             
                    log("Bummr update initiated #{Time.now}")
         | 
| 22 | 
            -
                    system("bundle")
         | 
| 23 23 |  | 
| 24 24 | 
             
                    outdated_gems = Bummr::Outdated.instance.outdated_gems(
         | 
| 25 25 | 
             
                      all_gems: options[:all], group: options[:group]
         | 
| @@ -41,15 +41,17 @@ module Bummr | |
| 41 41 | 
             
                desc "test", "Test for a successful build and bisect if necesssary"
         | 
| 42 42 | 
             
                def test
         | 
| 43 43 | 
             
                  check(false)
         | 
| 44 | 
            -
                  system "bundle"
         | 
| 45 | 
            -
                  puts "Testing the build!".color(:green)
         | 
| 46 44 |  | 
| 47 | 
            -
                  if  | 
| 48 | 
            -
                     | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
                     | 
| 52 | 
            -
             | 
| 45 | 
            +
                  if yes? "Do you want to test the build now?"
         | 
| 46 | 
            +
                    system "bundle install"
         | 
| 47 | 
            +
                    puts "Testing the build!".color(:green)
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                    if system(TEST_COMMAND) == false
         | 
| 50 | 
            +
                      bisect
         | 
| 51 | 
            +
                    else
         | 
| 52 | 
            +
                      puts "Passed the build!".color(:green)
         | 
| 53 | 
            +
                      puts "See log/bummr.log for details".color(:yellow)
         | 
| 54 | 
            +
                    end
         | 
| 53 55 | 
             
                  end
         | 
| 54 56 | 
             
                end
         | 
| 55 57 |  | 
| @@ -57,12 +59,21 @@ module Bummr | |
| 57 59 | 
             
                def bisect
         | 
| 58 60 | 
             
                  check(false)
         | 
| 59 61 |  | 
| 60 | 
            -
                   | 
| 62 | 
            +
                  if yes? "Would you like to bisect in order to find which gem is causing " +
         | 
| 63 | 
            +
                          "your build to break? (y/n)"
         | 
| 64 | 
            +
                    Bummr::Bisecter.instance.bisect
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
                end
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                desc "remove_commit", "Remove a commit from the history"
         | 
| 69 | 
            +
                def remove_commit(sha)
         | 
| 70 | 
            +
                  Bummr::Remover.instance.remove_commit(sha)
         | 
| 61 71 | 
             
                end
         | 
| 62 72 |  | 
| 63 73 | 
             
                private
         | 
| 64 74 |  | 
| 65 75 | 
             
                def ask_questions
         | 
| 76 | 
            +
                  puts "Bummr #{VERSION}"
         | 
| 66 77 | 
             
                  puts "To run Bummr, you must:"
         | 
| 67 78 | 
             
                  puts "- Be in the root path of a clean git branch off of #{BASE_BRANCH}"
         | 
| 68 79 | 
             
                  puts "- Have no commits or local changes"
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            module Bummr
         | 
| 2 | 
            +
              class Remover < Thor
         | 
| 3 | 
            +
                include Singleton
         | 
| 4 | 
            +
                include Log
         | 
| 5 | 
            +
             | 
| 6 | 
            +
                desc "remove_commit", "Remove a commit from the history"
         | 
| 7 | 
            +
                def remove_commit(sha)
         | 
| 8 | 
            +
                  log "Bad commit: #{commit_message_for(sha)}, #{sha}".color(:red)
         | 
| 9 | 
            +
                  log "Resetting..."
         | 
| 10 | 
            +
                  system("git bisect reset")
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  message = "\nThe commit:\n\n `#{sha} #{commit_message_for(sha)}`\n\n" +
         | 
| 13 | 
            +
                    "Is breaking the build.\n\n" +
         | 
| 14 | 
            +
                    "Please do one of the following: \n\n" +
         | 
| 15 | 
            +
                    " 1. Update your code to work with the latest version of this gem.\n\n" +
         | 
| 16 | 
            +
                    " 2. Perform the following steps to lock the gem version:\n\n" +
         | 
| 17 | 
            +
                    "    - `git reset --hard master`\n" +
         | 
| 18 | 
            +
                    "    - Lock the version of this Gem in your Gemfile.\n" +
         | 
| 19 | 
            +
                    "    - Commit the changes.\n" +
         | 
| 20 | 
            +
                    "    - Run `bummr update` again.\n\n" +
         | 
| 21 | 
            +
                    "Lord Bummr\n\n"
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  puts message.color(:yellow)
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                private
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                def commit_message_for(sha)
         | 
| 29 | 
            +
                  `git log --pretty=format:'%s' -n 1 #{sha}`
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
    
        data/lib/bummr/updater.rb
    CHANGED
    
    | @@ -19,7 +19,12 @@ module Bummr | |
| 19 19 | 
             
                  system("bundle update #{gem[:name]}")
         | 
| 20 20 |  | 
| 21 21 | 
             
                  updated_version = updated_version_for(gem)
         | 
| 22 | 
            -
             | 
| 22 | 
            +
             | 
| 23 | 
            +
                  if (updated_version)
         | 
| 24 | 
            +
                    message = "Update #{gem[:name]} from #{gem[:installed]} to #{updated_version}"
         | 
| 25 | 
            +
                  else
         | 
| 26 | 
            +
                    message = "Update dependencies for #{gem[:name]}"
         | 
| 27 | 
            +
                  end
         | 
| 23 28 |  | 
| 24 29 | 
             
                  if gem[:installed] == updated_version
         | 
| 25 30 | 
             
                    log("#{gem[:name]} not updated")
         | 
| @@ -31,11 +36,15 @@ module Bummr | |
| 31 36 | 
             
                  end
         | 
| 32 37 |  | 
| 33 38 | 
             
                  log "Commit: #{message}".color(:green)
         | 
| 34 | 
            -
                  system("git  | 
| 39 | 
            +
                  system("git add Gemfile Gemfile.lock")
         | 
| 40 | 
            +
                  system("git commit -m '#{message}'")
         | 
| 35 41 | 
             
                end
         | 
| 36 42 |  | 
| 37 43 | 
             
                def updated_version_for(gem)
         | 
| 38 | 
            -
                   | 
| 44 | 
            +
                  begin
         | 
| 45 | 
            +
                    `bundle list | grep " #{gem[:name]} "`.split('(')[1].split(')')[0]
         | 
| 46 | 
            +
                  rescue Error
         | 
| 47 | 
            +
                  end
         | 
| 39 48 | 
             
                end
         | 
| 40 49 | 
             
              end
         | 
| 41 50 | 
             
            end
         | 
    
        data/lib/bummr/version.rb
    CHANGED
    
    
    
        data/lib/bummr.rb
    CHANGED
    
    
    
        data/spec/lib/bisecter_spec.rb
    CHANGED
    
    | @@ -8,7 +8,7 @@ describe Bummr::Bisecter do | |
| 8 8 | 
             
                StringIO.new(output)
         | 
| 9 9 | 
             
              }
         | 
| 10 10 | 
             
              let(:bisecter) { described_class.instance }
         | 
| 11 | 
            -
              let(: | 
| 11 | 
            +
              let(:remover) { Bummr::Remover.instance }
         | 
| 12 12 |  | 
| 13 13 | 
             
              before do
         | 
| 14 14 | 
             
                allow(STDOUT).to receive(:puts)
         | 
| @@ -20,12 +20,12 @@ describe Bummr::Bisecter do | |
| 20 20 | 
             
                context "bad commit" do
         | 
| 21 21 | 
             
                  it "rebases it out" do
         | 
| 22 22 | 
             
                    allow(Open3).to receive(:popen2e).and_yield(nil, std_out_err_bad_commit)
         | 
| 23 | 
            -
                    allow( | 
| 23 | 
            +
                    allow(remover).to receive(:remove_commit)
         | 
| 24 24 | 
             
                      .with("mybadcommit")
         | 
| 25 25 |  | 
| 26 26 | 
             
                    bisecter.bisect
         | 
| 27 27 |  | 
| 28 | 
            -
                    expect( | 
| 28 | 
            +
                    expect(remover).to have_received(:remove_commit).with("mybadcommit")
         | 
| 29 29 | 
             
                  end
         | 
| 30 30 | 
             
                end
         | 
| 31 31 | 
             
              end
         | 
    
        data/spec/lib/cli_spec.rb
    CHANGED
    
    | @@ -33,7 +33,7 @@ describe Bummr::CLI do | |
| 33 33 | 
             
                    expect(cli).to receive(:yes?).and_return(true)
         | 
| 34 34 | 
             
                    expect(cli).to receive(:check)
         | 
| 35 35 | 
             
                    expect(cli).to receive(:log)
         | 
| 36 | 
            -
                    expect(cli).to receive(:system).with("bundle")
         | 
| 36 | 
            +
                    expect(cli).to receive(:system).with("bundle install")
         | 
| 37 37 | 
             
                    expect(Bummr::Updater).to receive(:new).with(outdated_gems).and_return updater
         | 
| 38 38 | 
             
                    expect(cli).to receive(:system).with("git rebase -i #{BASE_BRANCH}")
         | 
| 39 39 | 
             
                    expect(cli).to receive(:test)
         | 
| @@ -48,7 +48,7 @@ describe Bummr::CLI do | |
| 48 48 | 
             
                      expect(cli).to receive(:yes?).and_return(true)
         | 
| 49 49 | 
             
                      expect(cli).to receive(:check)
         | 
| 50 50 | 
             
                      expect(cli).to receive(:log)
         | 
| 51 | 
            -
                      expect(cli).to receive(:system).with("bundle")
         | 
| 51 | 
            +
                      expect(cli).to receive(:system).with("bundle install")
         | 
| 52 52 | 
             
                      expect(cli).to receive(:puts).with("No outdated gems to update".color(:green))
         | 
| 53 53 |  | 
| 54 54 | 
             
                      cli.update
         | 
| @@ -102,6 +102,7 @@ describe Bummr::CLI do | |
| 102 102 | 
             
                  allow(cli).to receive(:check)
         | 
| 103 103 | 
             
                  allow(cli).to receive(:system)
         | 
| 104 104 | 
             
                  allow(cli).to receive(:bisect)
         | 
| 105 | 
            +
                  allow(cli).to receive(:yes?).and_return true
         | 
| 105 106 | 
             
                end
         | 
| 106 107 |  | 
| 107 108 | 
             
                context "build passes" do
         | 
| @@ -111,7 +112,7 @@ describe Bummr::CLI do | |
| 111 112 | 
             
                    cli.test
         | 
| 112 113 |  | 
| 113 114 | 
             
                    expect(cli).to have_received(:check).with(false)
         | 
| 114 | 
            -
                    expect(cli).to have_received(:system).with("bundle")
         | 
| 115 | 
            +
                    expect(cli).to have_received(:system).with("bundle install")
         | 
| 115 116 | 
             
                    expect(cli).to have_received(:system).with("bundle exec rake")
         | 
| 116 117 | 
             
                    expect(cli).not_to have_received(:bisect)
         | 
| 117 118 | 
             
                  end
         | 
| @@ -124,7 +125,7 @@ describe Bummr::CLI do | |
| 124 125 | 
             
                    cli.test
         | 
| 125 126 |  | 
| 126 127 | 
             
                    expect(cli).to have_received(:check).with(false)
         | 
| 127 | 
            -
                    expect(cli).to have_received(:system).with("bundle")
         | 
| 128 | 
            +
                    expect(cli).to have_received(:system).with("bundle install")
         | 
| 128 129 | 
             
                    expect(cli).to have_received(:system).with("bundle exec rake")
         | 
| 129 130 | 
             
                    expect(cli).to have_received(:bisect)
         | 
| 130 131 | 
             
                  end
         | 
| @@ -134,6 +135,7 @@ describe Bummr::CLI do | |
| 134 135 | 
             
              describe "#bisect" do
         | 
| 135 136 | 
             
                it "calls Bummr:Bisecter.instance.bisect" do
         | 
| 136 137 | 
             
                  allow(cli).to receive(:check)
         | 
| 138 | 
            +
                  allow(cli).to receive(:yes?).and_return true
         | 
| 137 139 | 
             
                  allow_any_instance_of(Bummr::Bisecter).to receive(:bisect)
         | 
| 138 140 | 
             
                  bisecter = Bummr::Bisecter.instance
         | 
| 139 141 |  | 
| @@ -0,0 +1,31 @@ | |
| 1 | 
            +
            require "spec_helper"
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Bummr::Remover do
         | 
| 4 | 
            +
              # let(:commit_message) { "test commit message" }
         | 
| 5 | 
            +
              let(:remover) { Bummr::Remover.instance }
         | 
| 6 | 
            +
              let(:sha) { "testsha" }
         | 
| 7 | 
            +
              let(:remove_command) { "git rebase -p --onto #{sha}^ #{sha}" }
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              before do
         | 
| 10 | 
            +
                allow(remover).to receive(:commit_message_for).and_return "commit message"
         | 
| 11 | 
            +
                allow(remover).to receive(:log)
         | 
| 12 | 
            +
                allow(remover).to receive(:system)
         | 
| 13 | 
            +
                allow(remover).to receive(:yes?).and_return(true)
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              describe "#remove_commit" do
         | 
| 17 | 
            +
                it "logs the bad commit" do
         | 
| 18 | 
            +
                  remover.remove_commit(sha)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  expect(remover).to have_received(:log).with(
         | 
| 21 | 
            +
                    "Bad commit: commit message, #{sha}".color(:red)
         | 
| 22 | 
            +
                  )
         | 
| 23 | 
            +
                end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                it "resets the bisection" do
         | 
| 26 | 
            +
                  remover.remove_commit(sha)
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  expect(remover).to have_received(:system).with("git bisect reset")
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
              end
         | 
| 31 | 
            +
            end
         | 
    
        data/spec/lib/updater_spec.rb
    CHANGED
    
    | @@ -78,15 +78,14 @@ describe Bummr::Updater do | |
| 78 78 |  | 
| 79 79 | 
             
                  it "commits" do
         | 
| 80 80 | 
             
                    commit_message =
         | 
| 81 | 
            -
                      " | 
| 81 | 
            +
                      "Update #{gem[:name]} from #{gem[:installed]} to #{intermediate_version}"
         | 
| 82 82 | 
             
                    allow(updater).to receive(:system)
         | 
| 83 83 | 
             
                    allow(updater).to receive(:log)
         | 
| 84 84 |  | 
| 85 85 | 
             
                    updater.update_gem(gem, 0)
         | 
| 86 86 |  | 
| 87 | 
            -
                    expect(updater).to have_received(:system).with(
         | 
| 88 | 
            -
             | 
| 89 | 
            -
                    )
         | 
| 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}'")
         | 
| 90 89 | 
             
                  end
         | 
| 91 90 | 
             
                end
         | 
| 92 91 |  | 
| @@ -114,9 +113,8 @@ describe Bummr::Updater do | |
| 114 113 |  | 
| 115 114 | 
             
                    updater.update_gem(gem, 0)
         | 
| 116 115 |  | 
| 117 | 
            -
                    expect(updater).to have_received(:system).with(
         | 
| 118 | 
            -
             | 
| 119 | 
            -
                    )
         | 
| 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}'")
         | 
| 120 118 | 
             
                  end
         | 
| 121 119 | 
             
                end
         | 
| 122 120 | 
             
              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. | 
| 4 | 
            +
              version: 0.3.2
         | 
| 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- | 
| 11 | 
            +
            date: 2018-04-19 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: thor
         | 
| @@ -215,7 +215,7 @@ files: | |
| 215 215 | 
             
            - lib/bummr/cli.rb
         | 
| 216 216 | 
             
            - lib/bummr/log.rb
         | 
| 217 217 | 
             
            - lib/bummr/outdated.rb
         | 
| 218 | 
            -
            - lib/bummr/ | 
| 218 | 
            +
            - lib/bummr/remover.rb
         | 
| 219 219 | 
             
            - lib/bummr/updater.rb
         | 
| 220 220 | 
             
            - lib/bummr/version.rb
         | 
| 221 221 | 
             
            - spec/check_spec.rb
         | 
| @@ -223,7 +223,7 @@ files: | |
| 223 223 | 
             
            - spec/lib/cli_spec.rb
         | 
| 224 224 | 
             
            - spec/lib/log_spec.rb
         | 
| 225 225 | 
             
            - spec/lib/outdated_spec.rb
         | 
| 226 | 
            -
            - spec/lib/ | 
| 226 | 
            +
            - spec/lib/remover_spec.rb
         | 
| 227 227 | 
             
            - spec/lib/updater_spec.rb
         | 
| 228 228 | 
             
            - spec/spec_helper.rb
         | 
| 229 229 | 
             
            homepage: https://github.com/lpender/bummr
         | 
| @@ -256,6 +256,6 @@ test_files: | |
| 256 256 | 
             
            - spec/lib/cli_spec.rb
         | 
| 257 257 | 
             
            - spec/lib/log_spec.rb
         | 
| 258 258 | 
             
            - spec/lib/outdated_spec.rb
         | 
| 259 | 
            -
            - spec/lib/ | 
| 259 | 
            +
            - spec/lib/remover_spec.rb
         | 
| 260 260 | 
             
            - spec/lib/updater_spec.rb
         | 
| 261 261 | 
             
            - spec/spec_helper.rb
         | 
    
        data/lib/bummr/rebaser.rb
    DELETED
    
    | @@ -1,29 +0,0 @@ | |
| 1 | 
            -
            module Bummr
         | 
| 2 | 
            -
              class Rebaser
         | 
| 3 | 
            -
                include Singleton
         | 
| 4 | 
            -
                include Log
         | 
| 5 | 
            -
             | 
| 6 | 
            -
                def remove_commit(sha)
         | 
| 7 | 
            -
                  log "Bad commit: #{commit_message_for(sha)}, #{sha}".color(:red)
         | 
| 8 | 
            -
                  log "Resetting..."
         | 
| 9 | 
            -
                  system("git bisect reset")
         | 
| 10 | 
            -
             | 
| 11 | 
            -
                  log "Removing commit..."
         | 
| 12 | 
            -
                  if system("git rebase -X ours --onto #{sha}^ #{sha}")
         | 
| 13 | 
            -
                    log "Successfully removed bad commit...".color(:green)
         | 
| 14 | 
            -
                    log "Re-testing build...".color(:green)
         | 
| 15 | 
            -
                    system("bummr test")
         | 
| 16 | 
            -
                  else
         | 
| 17 | 
            -
                    log "Could not automatically remove this commit!".color(:red)
         | 
| 18 | 
            -
                    log "Please resolve conflicts, then 'git rebase --continue'."
         | 
| 19 | 
            -
                    log "Run 'bummr test' again once the rebase is complete"
         | 
| 20 | 
            -
                  end
         | 
| 21 | 
            -
                end
         | 
| 22 | 
            -
             | 
| 23 | 
            -
                private
         | 
| 24 | 
            -
             | 
| 25 | 
            -
                def commit_message_for(sha)
         | 
| 26 | 
            -
                  `git log --pretty=format:'%s' -n 1 #{sha}`
         | 
| 27 | 
            -
                end
         | 
| 28 | 
            -
              end
         | 
| 29 | 
            -
            end
         | 
    
        data/spec/lib/rebaser_spec.rb
    DELETED
    
    | @@ -1,64 +0,0 @@ | |
| 1 | 
            -
            require "spec_helper"
         | 
| 2 | 
            -
             | 
| 3 | 
            -
            describe Bummr::Rebaser do
         | 
| 4 | 
            -
              # let(:commit_message) { "test commit message" }
         | 
| 5 | 
            -
              let(:rebaser) { Bummr::Rebaser.instance }
         | 
| 6 | 
            -
              let(:sha) { "testsha" }
         | 
| 7 | 
            -
              let(:rebase_command) { "git rebase -X ours --onto #{sha}^ #{sha}" }
         | 
| 8 | 
            -
             | 
| 9 | 
            -
              before do
         | 
| 10 | 
            -
                allow(rebaser).to receive(:commit_message_for).and_return "commit message"
         | 
| 11 | 
            -
                allow(rebaser).to receive(:log)
         | 
| 12 | 
            -
                allow(rebaser).to receive(:system)
         | 
| 13 | 
            -
              end
         | 
| 14 | 
            -
             | 
| 15 | 
            -
              describe "#remove_commit" do
         | 
| 16 | 
            -
                it "logs the bad commit" do
         | 
| 17 | 
            -
                  rebaser.remove_commit(sha)
         | 
| 18 | 
            -
             | 
| 19 | 
            -
                  expect(rebaser).to have_received(:log).with(
         | 
| 20 | 
            -
                    "Bad commit: commit message, #{sha}".color(:red)
         | 
| 21 | 
            -
                  )
         | 
| 22 | 
            -
                end
         | 
| 23 | 
            -
             | 
| 24 | 
            -
                it "resets the bisection" do
         | 
| 25 | 
            -
                  rebaser.remove_commit(sha)
         | 
| 26 | 
            -
             | 
| 27 | 
            -
                  expect(rebaser).to have_received(:system).with("git bisect reset")
         | 
| 28 | 
            -
                end
         | 
| 29 | 
            -
             | 
| 30 | 
            -
                context "successfully rebases the commit out" do
         | 
| 31 | 
            -
                  before(:each) do
         | 
| 32 | 
            -
                    allow(rebaser).to receive(:system).with(rebase_command).and_return true
         | 
| 33 | 
            -
                  end
         | 
| 34 | 
            -
             | 
| 35 | 
            -
                  it "logs the successful result" do
         | 
| 36 | 
            -
                    rebaser.remove_commit(sha)
         | 
| 37 | 
            -
             | 
| 38 | 
            -
                    expect(rebaser).to have_received(:log).with(
         | 
| 39 | 
            -
                      "Successfully removed bad commit...".color(:green)
         | 
| 40 | 
            -
                    )
         | 
| 41 | 
            -
                  end
         | 
| 42 | 
            -
             | 
| 43 | 
            -
                  it "tests the build again" do
         | 
| 44 | 
            -
                    rebaser.remove_commit(sha)
         | 
| 45 | 
            -
             | 
| 46 | 
            -
                    expect(rebaser).to have_received(:system).with "bummr test"
         | 
| 47 | 
            -
                  end
         | 
| 48 | 
            -
                end
         | 
| 49 | 
            -
             | 
| 50 | 
            -
                context "fails to rebase the commit out" do
         | 
| 51 | 
            -
                  before(:each) do
         | 
| 52 | 
            -
                    allow(rebaser).to receive(:system).with(rebase_command).and_return false
         | 
| 53 | 
            -
                  end
         | 
| 54 | 
            -
             | 
| 55 | 
            -
                  it "logs the  failure to rebase" do
         | 
| 56 | 
            -
                    rebaser.remove_commit(sha)
         | 
| 57 | 
            -
             | 
| 58 | 
            -
                    expect(rebaser).to have_received(:log).with(
         | 
| 59 | 
            -
                      "Could not automatically remove this commit!".color(:red)
         | 
| 60 | 
            -
                    )
         | 
| 61 | 
            -
                  end
         | 
| 62 | 
            -
                end
         | 
| 63 | 
            -
              end
         | 
| 64 | 
            -
            end
         |