Sha256: f2b70ad51a9682d35a6ead257ca93c978178414a3faa142bb5b255722ffd97f8
Contents?: true
Size: 1.23 KB
Versions: 9
Compression:
Stored size: 1.23 KB
Contents
# frozen_string_literal: true require_relative "matcher" module Datadog module CI module Codeowners # Responsible for parsing a CODEOWNERS file class Parser DEFAULT_LOCATION = "CODEOWNERS" POSSIBLE_CODEOWNERS_LOCATIONS = [ "CODEOWNERS", ".github/CODEOWNERS", ".gitlab/CODEOWNERS", "docs/CODEOWNERS" ].freeze def initialize(root_file_path) @root_file_path = root_file_path || Dir.pwd end def parse default_path = File.join(@root_file_path, DEFAULT_LOCATION) # We are using the first codeowners file that we find or # default location if nothing is found # # Matcher handles it internally and creates a class with # an empty list of rules if the file is not found codeowners_file_path = POSSIBLE_CODEOWNERS_LOCATIONS.map do |codeowners_location| File.join(@root_file_path, codeowners_location) end.find do |path| File.exist?(path) end || default_path ::Datadog.logger.debug { "Using CODEOWNERS file from: #{codeowners_file_path}" } Matcher.new(codeowners_file_path) end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems