Skip to content

Commit

Permalink
fix for issue whitesmith#461
Browse files Browse the repository at this point in the history
  • Loading branch information
rishijain committed Oct 11, 2023
1 parent 1d20e4f commit e67418a
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rubycritic/source_control_systems/git/churn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def process_line(line)
when /^[RC]/
process_rename(*rest)
else
rest = filename_for_subdirectory(rest[0])
process_file(*rest)
end
end
Expand All @@ -86,6 +87,15 @@ def process_rename(from, to)
process_file(to)
end

def filename_for_subdirectory(filename)
git_path = Git.git('rev-parse --show-toplevel')
cd_path = Dir.pwd
if cd_path.length > git_path.length
filename = filename.sub(/^#{Regexp.escape("#{File.basename(cd_path)}/")}/, '')
end
[filename]
end

def process_file(filename)
record_commit(renames.current(filename), @date)
end
Expand Down

0 comments on commit e67418a

Please sign in to comment.