Skip to content

Commit

Permalink
support passing wildcards in rubycritic.yml paths
Browse files Browse the repository at this point in the history
  • Loading branch information
rishijain committed Oct 23, 2023
1 parent 052b777 commit baa6b9f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/rubycritic/source_control_systems/git/churn.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,20 @@ def exec_git_command(command)
.each { |line| process_line(line) }
end

def extract_path_from_wildcard(path)
if path.include?('**')
path.split('**').first
else
path
end
end

def git_log_commands
@paths.map { |path| git_log_command(path) }
end

def git_log_command(path)
path = extract_path_from_wildcard(path)
"log --all --date=iso --follow --format='format:date:%x09%ad' --name-status #{after_clause}#{path}"
end

Expand Down
3 changes: 3 additions & 0 deletions lib/rubycritic/source_locator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def expand_paths
path_list = @initial_paths.flat_map do |path|
if File.directory?(path)
Pathname.glob(File.join(path, RUBY_FILES))
elsif path.include?('**')
matches = Dir.glob(path + '/*.rb')
matches.map { |p| Pathname.new(p) if ruby_file?(p) }
elsif File.exist?(path) && ruby_file?(path)
Pathname.new(path)
end
Expand Down

0 comments on commit baa6b9f

Please sign in to comment.