overcommit 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,12 +9,12 @@ submodule_status.each_line do |line|
9
9
 
10
10
  if line.match(/^\+/)
11
11
  # The second word is the submodule directory.
12
- updated_submodules << line.split(" ")[1]
12
+ updated_submodules << line.split(' ')[1]
13
13
  end
14
14
  end
15
15
 
16
16
  if updated_submodules.length > 0
17
- puts "The following git submodules are out of date:"
17
+ puts 'The following git submodules are out of date:'
18
18
  updated_submodules.each do |submodule|
19
19
  puts "\t#{submodule}"
20
20
  end
@@ -24,7 +24,7 @@ module Overcommit
24
24
 
25
25
  opts.on('-l', '--list-templates', 'List built-in templates') do
26
26
  Overcommit.config.templates.each_pair do |name, configuration|
27
- bold name
27
+ log.bold name
28
28
  log.log YAML.dump(configuration), ''
29
29
  end
30
30
  exit 0
@@ -59,7 +59,7 @@ module Overcommit
59
59
  hook_name = Utils.underscorize(check.name).split('/').last
60
60
 
61
61
  check.skippable? && (skip_all || skip_checks.include?(hook_name))
62
- end
62
+ end.sort_by(&:name)
63
63
  end
64
64
  end
65
65
 
@@ -28,6 +28,10 @@ module Overcommit
28
28
  def skippable?
29
29
  !required
30
30
  end
31
+
32
+ def friendly_name
33
+ Overcommit::Utils.underscorize name.to_s.split('::').last
34
+ end
31
35
  end
32
36
 
33
37
  def initialize(*args)
@@ -35,7 +39,7 @@ module Overcommit
35
39
  end
36
40
 
37
41
  def name
38
- Overcommit::Utils.underscorize self.class.name.to_s.split('::').last
42
+ self.class.friendly_name
39
43
  end
40
44
 
41
45
  def skip?
@@ -74,13 +78,13 @@ module Overcommit
74
78
  @arguments[0]
75
79
  end
76
80
 
77
- def commit_message
78
- @commit_message ||= ::IO.readlines(commit_message_file)
81
+ def raw_commit_message
82
+ @raw_commit_message ||= ::IO.readlines(commit_message_file)
79
83
  end
80
84
 
81
85
  # Strip comments and diff (from git-commit --verbose)
82
- def user_commit_message
83
- @user_commit_message ||= commit_message.
86
+ def commit_message
87
+ @commit_message ||= raw_commit_message.
84
88
  reject { |line| line =~ /^#/ }.
85
89
  take_while { |line| !line.start_with?('diff --git') }
86
90
  end
@@ -5,32 +5,44 @@ module Overcommit
5
5
  class Logger
6
6
  include Singleton
7
7
 
8
+ attr_accessor :output
9
+
8
10
  def partial(*args)
9
- print *args
11
+ out.print *args
10
12
  end
11
13
 
12
14
  def log(*args)
13
- puts *args
15
+ out.puts *args
14
16
  end
15
17
 
16
18
  def bold(str)
17
- log "\033[1;37m#{str}\033[0m"
19
+ color('1;37', str)
18
20
  end
19
21
 
20
22
  def error(str)
21
- log "\033[31m#{str}\033[0m"
23
+ color(31, str)
22
24
  end
23
25
 
24
26
  def success(str)
25
- log "\033[32m#{str}\033[0m"
27
+ color(32, str)
26
28
  end
27
29
 
28
30
  def warning(str)
29
- log "\033[33m#{str}\033[0m"
31
+ color(33, str)
30
32
  end
31
33
 
32
34
  def notice(str)
33
- log "\033[1;33m#{str}\033[0m"
35
+ color('1;33', str)
36
+ end
37
+
38
+ def out
39
+ self.output ||= $stdout
40
+ end
41
+
42
+ private
43
+
44
+ def color(code, str)
45
+ log(out.isatty ? "\033[#{code}m#{str}\033[0m" : str)
34
46
  end
35
47
  end
36
48
  end
@@ -0,0 +1,14 @@
1
+ module Overcommit::GitHook
2
+ class HardTabs < HookSpecificCheck
3
+ include HookRegistry
4
+
5
+ def run_check
6
+ # Catches hard tabs entered by the user (not auto-generated)
7
+ if commit_message.join.index /\t/
8
+ return :warn, "Don't use hard tabs in commit messages"
9
+ end
10
+
11
+ :good
12
+ end
13
+ end
14
+ end
@@ -4,7 +4,7 @@ module Overcommit::GitHook
4
4
 
5
5
  EMPTY_RELEASE_NOTE = /^release notes?\s*[:.]?\n{2,}/im
6
6
  def run_check
7
- if user_commit_message.join =~ EMPTY_RELEASE_NOTE
7
+ if commit_message.join =~ EMPTY_RELEASE_NOTE
8
8
  strip_release_note
9
9
  return :warn, 'Empty release note found, automatically removed'
10
10
  end
@@ -15,7 +15,7 @@ module Overcommit::GitHook
15
15
  private
16
16
 
17
17
  def strip_release_note
18
- stripped_message = user_commit_message.join.sub(EMPTY_RELEASE_NOTE, '')
18
+ stripped_message = commit_message.join.sub(EMPTY_RELEASE_NOTE, '')
19
19
 
20
20
  ::File.open(commit_message_file, 'w') do |file|
21
21
  file.write(stripped_message)
@@ -6,7 +6,7 @@ module Overcommit::GitHook
6
6
 
7
7
  RUSSIAN_NOVEL_LENGTH = 30
8
8
  def run_check
9
- if user_commit_message.length > RUSSIAN_NOVEL_LENGTH
9
+ if commit_message.length > RUSSIAN_NOVEL_LENGTH
10
10
  return :warn, 'You seem to have authored a Russian novel; congratulations!'
11
11
  end
12
12
 
@@ -0,0 +1,13 @@
1
+ module Overcommit::GitHook
2
+ class SingleLineSubject < HookSpecificCheck
3
+ include HookRegistry
4
+
5
+ def run_check
6
+ unless commit_message[1].to_s.strip.empty?
7
+ return :warn, 'Subject should be a single line'
8
+ end
9
+
10
+ :good
11
+ end
12
+ end
13
+ end
@@ -3,11 +3,11 @@ module Overcommit::GitHook
3
3
  include HookRegistry
4
4
 
5
5
  def run_check
6
- if user_commit_message.first.size > 60
6
+ if commit_message.first.size > 60
7
7
  return :warn, 'Please keep the subject < ~60 characters'
8
8
  end
9
9
 
10
- user_commit_message.each do |line|
10
+ commit_message.each do |line|
11
11
  chomped = line.chomp
12
12
  if chomped.size > 72
13
13
  return :warn, "> 72 characters, please hard wrap: '#{chomped}'"
@@ -4,7 +4,7 @@ module Overcommit::GitHook
4
4
 
5
5
  def run_check
6
6
  if commit_message[0].rstrip.end_with?('.')
7
- return :warn, 'Please omit trailing period from commit message subject.'
7
+ return :warn, 'Please omit trailing period from commit message subject'
8
8
  end
9
9
 
10
10
  :good
@@ -3,12 +3,12 @@ module Overcommit
3
3
  def initialize(name, checks)
4
4
  @name = name
5
5
  @checks = checks
6
- @width = 70 - (@checks.map { |s| s.name.length }.max || 0)
6
+ @width = 60 - (@checks.map { |s| s.friendly_name.length }.max || 0)
7
7
  @results = []
8
8
  end
9
9
 
10
10
  def with_status(check, &block)
11
- title = " Checking #{check.name}..."
11
+ title = " Checking #{check.name}"
12
12
  log.partial title unless check.stealth?
13
13
 
14
14
  status, output = yield
@@ -1,3 +1,3 @@
1
1
  module Overcommit
2
- VERSION = '0.1.6'
2
+ VERSION = '0.1.7'
3
3
  end
metadata CHANGED
@@ -1,27 +1,30 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Causes Engineering
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-06-04 00:00:00.000000000 Z
12
+ date: 2013-06-10 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: '0'
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: '0'
27
30
  description: Overcommit is a utility to install and extend Git hooks
@@ -31,74 +34,77 @@ executables:
31
34
  extensions: []
32
35
  extra_rdoc_files: []
33
36
  files:
34
- - lib/overcommit/cli.rb
35
- - lib/overcommit/configuration.rb
36
- - lib/overcommit/errors.rb
37
- - lib/overcommit/git_hook.rb
38
- - lib/overcommit/hook_specific_check.rb
39
- - lib/overcommit/hooks/commit_msg.rb
40
- - lib/overcommit/hooks/pre_commit.rb
41
- - lib/overcommit/installer.rb
42
37
  - lib/overcommit/logger.rb
43
- - lib/overcommit/plugins/commit_msg/change_id.rb
44
- - lib/overcommit/plugins/commit_msg/release_note.rb
38
+ - lib/overcommit/installer.rb
39
+ - lib/overcommit/hook_specific_check.rb
40
+ - lib/overcommit/reporter.rb
41
+ - lib/overcommit/plugins/commit_msg/hard_tabs.rb
45
42
  - lib/overcommit/plugins/commit_msg/russian_novel.rb
43
+ - lib/overcommit/plugins/commit_msg/release_note.rb
44
+ - lib/overcommit/plugins/commit_msg/single_line_subject.rb
45
+ - lib/overcommit/plugins/commit_msg/change_id.rb
46
46
  - lib/overcommit/plugins/commit_msg/text_width.rb
47
47
  - lib/overcommit/plugins/commit_msg/trailing_period.rb
48
- - lib/overcommit/plugins/pre_commit/author_name.rb
48
+ - lib/overcommit/plugins/pre_commit/js_syntax.rb
49
+ - lib/overcommit/plugins/pre_commit/test_history.rb
50
+ - lib/overcommit/plugins/pre_commit/yaml_syntax.rb
51
+ - lib/overcommit/plugins/pre_commit/python_flake8.rb
49
52
  - lib/overcommit/plugins/pre_commit/causes_email.rb
50
- - lib/overcommit/plugins/pre_commit/coffee_lint.rb
51
- - lib/overcommit/plugins/pre_commit/css_linter.rb
53
+ - lib/overcommit/plugins/pre_commit/js_console_log.rb
54
+ - lib/overcommit/plugins/pre_commit/author_name.rb
52
55
  - lib/overcommit/plugins/pre_commit/erb_syntax.rb
56
+ - lib/overcommit/plugins/pre_commit/scss_lint.rb
57
+ - lib/overcommit/plugins/pre_commit/coffee_lint.rb
53
58
  - lib/overcommit/plugins/pre_commit/haml_syntax.rb
54
- - lib/overcommit/plugins/pre_commit/js_console_log.rb
55
- - lib/overcommit/plugins/pre_commit/js_syntax.rb
56
- - lib/overcommit/plugins/pre_commit/python_flake8.rb
59
+ - lib/overcommit/plugins/pre_commit/whitespace.rb
57
60
  - lib/overcommit/plugins/pre_commit/restricted_paths.rb
58
61
  - lib/overcommit/plugins/pre_commit/ruby_syntax.rb
59
- - lib/overcommit/plugins/pre_commit/scss_lint.rb
60
- - lib/overcommit/plugins/pre_commit/test_history.rb
61
- - lib/overcommit/plugins/pre_commit/whitespace.rb
62
- - lib/overcommit/plugins/pre_commit/yaml_syntax.rb
63
- - lib/overcommit/reporter.rb
64
- - lib/overcommit/utils.rb
62
+ - lib/overcommit/plugins/pre_commit/css_linter.rb
63
+ - lib/overcommit/git_hook.rb
64
+ - lib/overcommit/errors.rb
65
+ - lib/overcommit/cli.rb
66
+ - lib/overcommit/configuration.rb
65
67
  - lib/overcommit/version.rb
68
+ - lib/overcommit/hooks/pre_commit.rb
69
+ - lib/overcommit/hooks/commit_msg.rb
70
+ - lib/overcommit/utils.rb
66
71
  - lib/overcommit.rb
67
- - bin/hooks/commit-msg
68
- - bin/hooks/post-checkout
69
- - bin/hooks/post-merge
70
- - bin/hooks/pre-commit
71
- - bin/hooks/prepare-commit-msg
72
72
  - bin/overcommit
73
73
  - bin/run-hook
74
+ - bin/scripts/jshint.js
75
+ - bin/scripts/index-tags
74
76
  - bin/scripts/csslint-rhino.js
75
77
  - bin/scripts/gerrit-change-id
76
- - bin/scripts/index-tags
77
- - bin/scripts/jshint.js
78
78
  - bin/scripts/jshint_runner.js
79
+ - bin/hooks/commit-msg
80
+ - bin/hooks/pre-commit
81
+ - bin/hooks/post-merge
82
+ - bin/hooks/post-checkout
83
+ - bin/hooks/prepare-commit-msg
79
84
  - config/templates.yml
80
85
  homepage: http://github.com/causes/overcommit
81
86
  licenses:
82
87
  - MIT
83
- metadata: {}
84
88
  post_install_message:
85
89
  rdoc_options: []
86
90
  require_paths:
87
91
  - lib
88
92
  required_ruby_version: !ruby/object:Gem::Requirement
93
+ none: false
89
94
  requirements:
90
- - - '>='
95
+ - - ! '>='
91
96
  - !ruby/object:Gem::Version
92
97
  version: '0'
93
98
  required_rubygems_version: !ruby/object:Gem::Requirement
99
+ none: false
94
100
  requirements:
95
- - - '>='
101
+ - - ! '>='
96
102
  - !ruby/object:Gem::Version
97
103
  version: '0'
98
104
  requirements: []
99
105
  rubyforge_project:
100
- rubygems_version: 2.0.2
106
+ rubygems_version: 1.8.23
101
107
  signing_key:
102
- specification_version: 4
108
+ specification_version: 3
103
109
  summary: Opinionated Git hook manager
104
110
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 8705a9603730e08028af8ed52da1d89b34701870
4
- data.tar.gz: 36da43665b7fc82ac9e527a5bed18fe26343d072
5
- SHA512:
6
- metadata.gz: 02a1281d19da82fa562078b4c783f652b95e3eaa082cd938aa4507ff347e88206df91a892695084d78902340d6fed1ef71191a7c8635a415466bbf7d807ea785
7
- data.tar.gz: 69850c03a18dd3831710074f0985c236f50b570f10a866fcae16314570a9b35594c5153df165078c731548292b98197616809a17f7740160695a7e7f7fc2f872