rabbitt-githooks 1.3.0 → 1.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +5 -13
  2. data/Gemfile.lock +29 -19
  3. data/Rakefile +20 -0
  4. data/bin/githooks +2 -1
  5. data/bin/githooks-runner +10 -2
  6. data/lib/githooks.rb +11 -7
  7. data/lib/githooks/action.rb +67 -53
  8. data/lib/githooks/cli.rb +9 -6
  9. data/lib/githooks/commands/config.rb +26 -19
  10. data/lib/githooks/core_ext.rb +2 -1
  11. data/lib/githooks/core_ext/array/extract_options.rb +5 -1
  12. data/lib/githooks/core_ext/array/min_max.rb +4 -4
  13. data/lib/githooks/core_ext/array/select_with_index.rb +1 -1
  14. data/lib/githooks/core_ext/colorize.rb +30 -0
  15. data/lib/githooks/core_ext/object.rb +8 -0
  16. data/lib/githooks/core_ext/pathname.rb +7 -6
  17. data/lib/githooks/core_ext/string.rb +1 -1
  18. data/lib/githooks/core_ext/string/sanitize.rb +51 -0
  19. data/lib/githooks/error.rb +1 -0
  20. data/lib/githooks/hook.rb +21 -26
  21. data/lib/githooks/repository.rb +31 -35
  22. data/lib/githooks/repository/config.rb +16 -24
  23. data/lib/githooks/repository/diff_index_entry.rb +3 -2
  24. data/lib/githooks/repository/file.rb +14 -7
  25. data/lib/githooks/runner.rb +38 -36
  26. data/lib/githooks/section.rb +13 -19
  27. data/lib/githooks/system_utils.rb +132 -47
  28. data/lib/githooks/version.rb +1 -1
  29. data/lib/tasks/dev.task +14 -0
  30. data/rabbitt-githooks.gemspec +18 -15
  31. metadata +58 -33
  32. data/.gitignore +0 -34
  33. data/.hooks/commit-messages.rb +0 -29
  34. data/.hooks/formatting.rb +0 -44
  35. data/.rubocop.yml +0 -87
  36. data/lib/githooks/core_ext/process.rb +0 -9
  37. data/lib/githooks/core_ext/string/strip_empty_lines.rb +0 -9
  38. data/lib/githooks/terminal_colors.rb +0 -62
  39. data/thoughts.txt +0 -56
@@ -1,9 +0,0 @@
1
- module Process
2
- class Status
3
- def failed?
4
- !success?
5
- end
6
- alias_method :fail?, :failed?
7
- alias_method :failure?, :failed?
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class String
2
- def strip_empty_lines!
3
- replace(split(/\n/).reject(&:empty?).join("\n"))
4
- end
5
-
6
- def strip_empty_lines
7
- dup.strip_empty_lines!
8
- end
9
- end
@@ -1,62 +0,0 @@
1
- # encoding: utf-8
2
- =begin
3
- Copyright (C) 2013 Carl P. Corliss
4
-
5
- This program is free software; you can redistribute it and/or modify
6
- it under the terms of the GNU General Public License as published by
7
- the Free Software Foundation; either version 2 of the License, or
8
- (at your option) any later version.
9
-
10
- This program is distributed in the hope that it will be useful,
11
- but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- GNU General Public License for more details.
14
-
15
- You should have received a copy of the GNU General Public License along
16
- with this program; if not, write to the Free Software Foundation, Inc.,
17
- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
- =end
19
-
20
- module GitHooks
21
- module TerminalColors
22
- NORMAL = "\033[0;0"
23
-
24
- REGEX_COLOR_MAP = {
25
- /(black|gr[ae]y)/ => 30,
26
- /red/ => 31,
27
- /green/ => 32,
28
- /yellow/ => 33,
29
- /blue/ => 34,
30
- /(magenta|purple)/ => 35,
31
- /cyan/ => 36,
32
- /white/ => 37
33
- }
34
-
35
- def color(name)
36
- return '' unless $stdout.tty? && $stderr.tty?
37
- light = !!name.match(/(light|bright)/) ? '1' : '0'
38
- blink = !!name.match(/blink/) ? ';5' : ''
39
-
40
- color_code = REGEX_COLOR_MAP.find { |key, _| name =~ key }
41
- color_code = color_code ? color_code.last : NORMAL
42
-
43
- "\033[#{light}#{blink};#{color_code}m"
44
- end
45
- module_function :color
46
-
47
- ['light', 'bright', 'dark', ''].each do |shade|
48
- ['blinking', ''].each do |style|
49
- %w(black gray red green yellow blue magenta purple cyan white).each do |color|
50
- name1 = "color_#{style}_#{shade}_#{color}".gsub(/(^_+|_+$)/, '').gsub(/_{2,}/, '_')
51
- name2 = "color_#{style}_#{shade}#{color}".gsub(/(^_+|_+$)/, '').gsub(/_{2,}/, '_')
52
- [name1, name2].each do |name|
53
- next if const_defined? name.upcase
54
- const_set(name.upcase, color(name))
55
- define_method(name) { |text| "#{color(name)}#{text}#{color(:normal)}" }
56
- module_function name.to_sym
57
- end
58
- end
59
- end
60
- end
61
- end
62
- end
data/thoughts.txt DELETED
@@ -1,56 +0,0 @@
1
-
2
- githook config [--global] [--hook <hookname>] get <var>
3
- githook config [--global] [--hook <hookname>] set <var> <value>
4
- githook config [--global] [--hook <hookname>] unset <var> [<value>]
5
-
6
- variables:
7
- path: <path string>
8
- - the path to the tests to load for the given repository or globally. Can not be set if script is set.
9
-
10
- script: <path string>
11
- - the path to the script to execute when the given hook(s) are run.
12
-
13
- pre-run-execute: Array<path string>
14
- - a list of executables to run before the tests run
15
-
16
- post-run-execute: Array<path string>
17
- - a list of executables to run after the tests run
18
-
19
- githook config [--global] show
20
- - show the current githook configuration (global or repository)
21
-
22
- githook list [--hook <hook1,hook2,hookN>]
23
- -- lists tests for the given hook(s), or all hooks if none specified
24
-
25
- githook attach [--hook <hook1,hookN>] [--script <path> | --path <path>]
26
- -- attaches the listed hooks (or all if none specified) to the githook runner
27
- optionally sets the script XOR path
28
-
29
- githook dettach [--hook <hook1,hookN>]
30
- -- detaches the listed hooks, or all hooks if none specified
31
-
32
- githooks run [--hook <hook1,hookN>] [--[un]staged] [--args -- one two three ... fifty]
33
- -- runs the selected hooks (or pre-commit, if none specified) passing
34
- the argument list to the script
35
-
36
-
37
- ----
38
-
39
- GitHook::Hook.register 'pre-commit' do
40
- command ruby, path: /usr/local/bin/ruby
41
-
42
- section 'Syntax Checks' do
43
- test 'Ruby Syntax' do
44
- limit(:type).to :modified, :added
45
- limit(:path).to %r{\.rb$}
46
-
47
- on_each_file { |file| ruby '-c', file.path }
48
- end
49
- end
50
- end
51
-
52
- -- repository's .git/config file --
53
-
54
- [githooks]
55
- tests_path = /foo/lib
56
- loader_path = /foo/bin/runner.sh