class Overcommit::Hook::PreCommit::YamlLint
Runs ‘YAMLLint` against any modified YAML files.
Constants
- MESSAGE_REGEX
Public Instance Methods
run()
click to toggle source
# File lib/overcommit/hook/pre_commit/yaml_lint.rb, line 16 def run result = execute(command, args: applicable_files) parse_messages(result.stdout) end
Private Instance Methods
parse_messages(output)
click to toggle source
# File lib/overcommit/hook/pre_commit/yaml_lint.rb, line 23 def parse_messages(output) repo_root = Overcommit::Utils.repo_root output.scan(MESSAGE_REGEX).map do |file, line, col, type, msg| line = line.to_i type = type.to_sym # Obtain the path relative to the root of the repository # for nicer output: relpath = file.dup relpath.slice!("#{repo_root}/") text = "#{relpath}:#{line}:#{col}:#{type} #{msg}" Overcommit::Hook::Message.new(type, file, line, text) end end