title: How to run Rubocop only on the changed files in a pull request?
body: <p>I have created <strong>spec/lint/rubocop_spec.rb</strong> which runs Rubocop style checker on the files changed between current branch and master. This works when I test locally but not when the test run on the build server Circle.ci.
  I suspect it is because only the branch in question is downloaded, so it does not find any differences between master. Is there a better way than <code>git co master &amp;&amp; git pull origin master</code>?
  Can I query the Github API perhaps to get the files changed listed?</p>
  
  <pre><code>require 'spec_helper'
  
  describe 'Check that the files we have changed have correct syntax' do
    before do
      current_sha = `git rev-parse --verify HEAD`.strip!
      files = `git diff master #{current_sha} --name-only | grep .rb`
      files.tr!("\n", ' ')
      @report = 'nada'
      if files.present?
        puts "Changed files: #{files}"
  
        @report = `rubocop #{files}`
        puts "Report: #{@report}"
      end
    end
  
    it { @report.match('Offenses').should_not be true }
  end
  </code></pre>