class Overcommit::Hook::PreCommit::RstLint

Runs ‘rst-lint` against any modified reStructuredText files

@see github.com/twolfson/restructuredtext-lint

Constants

MESSAGE_REGEX

Public Instance Methods

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

  return :pass if result.success?
  return [:fail, result.stderr] unless result.stderr.empty?

  # example message:
  # WARNING README.rst:7 Title underline too short.
  extract_messages(
    output.split("\n"),
    MESSAGE_REGEX
  )
end