class SkipList
Represents revisions to skip when analyzing authorship.
Definitions
def self.for(root)
Load the skip list from a directory.
Implementation
def self.for(root)
full_path = File.join(root, GIT_BLAME_IGNORE_REVS)
if File.exist?(full_path)
skip_list = self.new
skip_list.extract(full_path)
return skip_list
end
end
def initialize(revisions = [])
Create a new skip list with the given revisions.
Signature
-
parameter
revisions
Array(String)
The revisions to skip.
Implementation
def initialize(revisions = [])
@revisions = Set.new(revisions)
end
def extract(path)
Extract the revisions from the given path.
Implementation
def extract(path)
File.open(path, "r") do |file|
file.each_line do |line|
# Skip empty lines and comments
next if line =~ /^\s*(#|$)/
# Parse line
@revisions << line.strip
end
end
end
def ignore?(commit)
Check if the given commit should be ignored.
Implementation
def ignore?(commit)
@revisions.include?(commit.oid)
end