【发布时间】:2015-12-09 19:26:21
【问题描述】:
我创建了 spec/lint/rubocop_spec.rb,它在当前分支和主分支之间更改的文件上运行 Rubocop 样式检查器。这在我本地测试时有效,但在构建服务器 Circle.ci 上运行时无效。
我怀疑是因为只下载了有问题的分支,所以它没有发现master之间的任何差异。有没有比git co master && git pull origin master 更好的方法?
我可以查询 Github API 以列出更改的文件吗?
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
【问题讨论】:
标签: ruby-on-rails git continuous-deployment circleci rubocop