Skip to content

Instantly share code, notes, and snippets.

@schlick
Last active January 16, 2016 17:33
Show Gist options
  • Save schlick/023d1ef6508026c2cfe7 to your computer and use it in GitHub Desktop.
Save schlick/023d1ef6508026c2cfe7 to your computer and use it in GitHub Desktop.
SimpleCov config to add groups for tracking changed files in a commit and a branch. Originally from an email by @fredwu.
if ENV['COV']
require 'simplecov'
SimpleCov.start 'rails' do
add_group 'This Commit' do |source_file|
`git ls-files --exclude-standard --others \
&& git diff --name-only \
&& git diff --name-only --cached`.split("\n").detect do |filename|
source_file.filename.ends_with?(filename)
end
end
base_commit = `git merge-base master HEAD`.chomp
add_group 'This Branch' do |source_file|
`git diff #{base_commit}..HEAD --name-only`.split("\n").detect do |filename|
source_file.filename.ends_with?(filename)
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment