Last active
January 16, 2016 17:33
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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