class Overcommit::Hook::PreCommit::XmlLint

Runs ‘xmllint` against any modified XML files.

@see xmlsoft.org/xmllint.html

Constants

MESSAGE_REGEX

Public Instance Methods

run() click to toggle source
# File lib/overcommit/hook/pre_commit/xml_lint.rb, line 10
def run
  result = execute(command, args: applicable_files)
  output = result.stderr.chomp

  return :pass if result.success? && output.empty?

  # example message:
  #   path/to/file.xml:1: parser error : Error message
  extract_messages(
    output.split("\n").grep(MESSAGE_REGEX),
    MESSAGE_REGEX
  )
end