diff --git a/config/default.yml b/config/default.yml index 233f77fc..02777c7e 100644 --- a/config/default.yml +++ b/config/default.yml @@ -330,6 +330,13 @@ PreCommit: quiet: true branch_patterns: ['master'] + GinkgoFocus: + enabled: false + description: 'Check for "focused" tests' + required_executable: 'grep' + flags: ['-IEHnw'] + keywords: ['FContext','FDescribe','FIt','FMeasure','FSpecify','FWhen'] + GoLint: enabled: false description: 'Analyze with golint' diff --git a/lib/overcommit/hook/pre_commit/ginkgo_focus.rb b/lib/overcommit/hook/pre_commit/ginkgo_focus.rb new file mode 100644 index 00000000..8528926e --- /dev/null +++ b/lib/overcommit/hook/pre_commit/ginkgo_focus.rb @@ -0,0 +1,23 @@ +# frozen_string_literal: true + +module Overcommit::Hook::PreCommit + # Check for "focused" tests + class GinkgoFocus < Base + def run + keywords = config['keywords'] + result = execute(command, args: [keywords.join('|')] + applicable_files) + + extract_messages( + result.stdout.split("\n"), + /^(?(?:\w:)?[^:]+):(?\d+)/, + lambda { |_type| :warning } + ) + end + + def applicable_test_files + applicable_files.select do |f| + f if f =~ /_test\.go/ + end + end + end +end