Last Updated: February 25, 2016
·
842
· andrewdotnich

Code coverage for your current git branch using simplecov

Use git to find the ancestor commit you & master have in common, then collect all the files changed between then and now:

base_commit = `git merge-base master HEAD`.chomp
add_group 'This Branch' do |source_file|
  %x[ git diff #{base_commit}..HEAD --name-only].split("\n").detect do |filename|
    source_file.filename.ends_with?(filename)
  end
end