Last active
November 29, 2016 19:41
-
-
Save sterpe/f94ff110ce4e7a41fc0613361196d744 to your computer and use it in GitHub Desktop.
Overcommit Pre-commit hook: Editorconfig
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Overcommit::Hook::PreCommit | |
| # Runs `editorconfig-tools check` against any modified files | |
| # | |
| # @see https://github.com/slang800/editorconfig-tools | |
| class Editorconfig < Base | |
| # There is no consistent message format unfortunately | |
| MESSAGE_REGEX =/^.*$/ | |
| def run | |
| result = execute(command, args: applicable_files) | |
| output = result.stdout.chomp | |
| return :pass if result.success? && output.empty? | |
| # example message: | |
| # message formats are all over the place | |
| extract_messages( | |
| output.split("\n").grep(MESSAGE_REGEX), | |
| MESSAGE_REGEX | |
| ) | |
| end | |
| end | |
| end | |
| # | |
| # .overcommit.yml | |
| # | |
| # PreCommit: | |
| # Editorconfig: | |
| # enabled: true | |
| # required_executable: "./bin/editorconfig-tools.sh" | |
| # command: [ | |
| # "./bin/editorconfig-tools.sh", | |
| # "check" | |
| # ] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment