overcommit 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -75,7 +75,8 @@ insert_submodule_changes() {
75
75
  $done = false
76
76
 
77
77
  def insert
78
- puts "#{ARGV.first}\n\n" unless $done
78
+ ref = ARGV.first
79
+ puts `git submodule summary --cached #{ref}` unless $done
79
80
  $done = true
80
81
  end
81
82
 
@@ -96,7 +97,7 @@ insert_submodule_changes() {
96
97
  ensure
97
98
  insert # just in case no lines matched
98
99
  end
99
- ' "$SUBMODULE_CHANGES" > $TMP_FILE && cp $TMP_FILE "$FILE"
100
+ ' "$OTHER" > $TMP_FILE && cp $TMP_FILE "$FILE"
100
101
  }
101
102
 
102
103
  strip_submodule_changes() {
@@ -152,8 +153,6 @@ case "$SOURCE" in
152
153
  # do nothing else if there are no submodule changes staged
153
154
  git diff-index --cached $OTHER | grep -q -e '^:160000' || exit 0
154
155
 
155
- SUBMODULE_CHANGES=$(git submodule summary --cached $OTHER)
156
-
157
156
  strip_submodule_changes
158
157
  insert_submodule_changes
159
158
  ;;
@@ -70,7 +70,14 @@ module Overcommit
70
70
  end
71
71
 
72
72
  def in_path?(cmd)
73
- system("which #{cmd} &> /dev/null")
73
+ exts = ENV['PATHEXT'] ? ENV['PATHEXT'].split(';') : ['']
74
+ ENV['PATH'].split(File::PATH_SEPARATOR).each do |path|
75
+ exts.each do |ext|
76
+ exe = File.join(path, "#{cmd}#{ext}")
77
+ return true if File.executable? exe
78
+ end
79
+ end
80
+ false
74
81
  end
75
82
 
76
83
  def commit_message_file
@@ -8,7 +8,8 @@ module Overcommit::GitHook
8
8
  return :warn, 'Run `npm install -g coffeelint`'
9
9
  end
10
10
 
11
- output = `coffeelint --quiet #{(staged.join(' '))}`.split("\n")
11
+ paths = staged.collect(&:path).join(' ')
12
+ output = `coffeelint --quiet #{paths}`.split("\n")
12
13
  return ($?.success? ? :good : :bad), output
13
14
  end
14
15
  end
@@ -9,9 +9,8 @@ module Overcommit
9
9
  attr_reader :contents
10
10
 
11
11
  def initialize(path)
12
- @original_path = path
13
- @tempfile = Tempfile.new([path.gsub('/', '_'), File.extname(path)])
14
- self.contents = `git show :#{@original_path}`
12
+ @original_path = path
13
+ @contents = `git show :#{@original_path}`
15
14
  end
16
15
 
17
16
  # Given error output from a syntax checker, replace references to the
@@ -23,7 +22,7 @@ module Overcommit
23
22
  # The path of the temporary file on disk, suitable for feeding in to a
24
23
  # syntax checker.
25
24
  def path
26
- @tempfile.path
25
+ tempfile.path
27
26
  end
28
27
 
29
28
  # Set or overwrite the temporary file's contents.
@@ -32,9 +31,7 @@ module Overcommit
32
31
  # the template before checking.
33
32
  def contents=(contents)
34
33
  @contents = contents
35
- @tempfile.seek 0
36
- @tempfile.write @contents
37
- @tempfile.flush
34
+ write_tempfile
38
35
  end
39
36
 
40
37
  # Returns the set of line numbers corresponding to the lines that were
@@ -69,5 +66,21 @@ module Overcommit
69
66
 
70
67
  lines
71
68
  end
69
+
70
+ def tempfile
71
+ unless @tempfile
72
+ basename = [@original_path.gsub('/', '_'), File.extname(@original_path)]
73
+ @tempfile = Tempfile.new(basename)
74
+ write_tempfile
75
+ end
76
+ @tempfile
77
+ end
78
+
79
+ def write_tempfile
80
+ tempfile.open if tempfile.closed?
81
+ tempfile.truncate 0
82
+ tempfile.write @contents
83
+ tempfile.close
84
+ end
72
85
  end
73
86
  end
@@ -1,3 +1,3 @@
1
1
  module Overcommit
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,112 +1,129 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
- version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 3
10
+ version: 0.2.3
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Causes Engineering
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-07-25 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-08-21 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
15
22
  name: rspec
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
23
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :development
34
+ version_requirements: *id001
30
35
  description: Overcommit is a utility to install and extend Git hooks
31
36
  email: eng@causes.com
32
- executables:
37
+ executables:
33
38
  - overcommit
34
39
  extensions: []
40
+
35
41
  extra_rdoc_files: []
36
- files:
37
- - lib/overcommit.rb
38
- - lib/overcommit/version.rb
39
- - lib/overcommit/utils.rb
40
- - lib/overcommit/plugins/commit_msg/trailing_period.rb
41
- - lib/overcommit/plugins/commit_msg/change_id.rb
42
+
43
+ files:
44
+ - lib/overcommit/logger.rb
45
+ - lib/overcommit/installer.rb
46
+ - lib/overcommit/hook_specific_check.rb
47
+ - lib/overcommit/reporter.rb
48
+ - lib/overcommit/staged_file.rb
49
+ - lib/overcommit/plugins/commit_msg/hard_tabs.rb
50
+ - lib/overcommit/plugins/commit_msg/russian_novel.rb
42
51
  - lib/overcommit/plugins/commit_msg/release_note.rb
43
52
  - lib/overcommit/plugins/commit_msg/single_line_subject.rb
44
- - lib/overcommit/plugins/commit_msg/russian_novel.rb
45
- - lib/overcommit/plugins/commit_msg/hard_tabs.rb
53
+ - lib/overcommit/plugins/commit_msg/change_id.rb
46
54
  - lib/overcommit/plugins/commit_msg/text_width.rb
47
- - lib/overcommit/plugins/pre_commit/erb_syntax.rb
48
- - lib/overcommit/plugins/pre_commit/js_console_log.rb
49
- - lib/overcommit/plugins/pre_commit/ruby_syntax.rb
55
+ - lib/overcommit/plugins/commit_msg/trailing_period.rb
56
+ - lib/overcommit/plugins/pre_commit/ruby_style.rb
50
57
  - lib/overcommit/plugins/pre_commit/js_syntax.rb
58
+ - lib/overcommit/plugins/pre_commit/test_history.rb
51
59
  - lib/overcommit/plugins/pre_commit/yaml_syntax.rb
52
- - lib/overcommit/plugins/pre_commit/haml_syntax.rb
60
+ - lib/overcommit/plugins/pre_commit/python_flake8.rb
53
61
  - lib/overcommit/plugins/pre_commit/causes_email.rb
62
+ - lib/overcommit/plugins/pre_commit/js_console_log.rb
54
63
  - lib/overcommit/plugins/pre_commit/author_name.rb
55
- - lib/overcommit/plugins/pre_commit/whitespace.rb
56
- - lib/overcommit/plugins/pre_commit/python_flake8.rb
64
+ - lib/overcommit/plugins/pre_commit/erb_syntax.rb
65
+ - lib/overcommit/plugins/pre_commit/scss_lint.rb
57
66
  - lib/overcommit/plugins/pre_commit/coffee_lint.rb
58
- - lib/overcommit/plugins/pre_commit/test_history.rb
67
+ - lib/overcommit/plugins/pre_commit/haml_syntax.rb
68
+ - lib/overcommit/plugins/pre_commit/whitespace.rb
59
69
  - lib/overcommit/plugins/pre_commit/restricted_paths.rb
60
- - lib/overcommit/plugins/pre_commit/ruby_style.rb
61
- - lib/overcommit/plugins/pre_commit/scss_lint.rb
70
+ - lib/overcommit/plugins/pre_commit/ruby_syntax.rb
62
71
  - lib/overcommit/plugins/pre_commit/css_linter.rb
63
- - lib/overcommit/staged_file.rb
64
- - lib/overcommit/reporter.rb
65
- - lib/overcommit/hook_specific_check.rb
66
- - lib/overcommit/installer.rb
67
- - lib/overcommit/errors.rb
68
72
  - lib/overcommit/git_hook.rb
73
+ - lib/overcommit/errors.rb
74
+ - lib/overcommit/cli.rb
69
75
  - lib/overcommit/configuration.rb
76
+ - lib/overcommit/version.rb
70
77
  - lib/overcommit/hooks/pre_commit.rb
71
78
  - lib/overcommit/hooks/commit_msg.rb
72
- - lib/overcommit/logger.rb
73
- - lib/overcommit/cli.rb
79
+ - lib/overcommit/utils.rb
80
+ - lib/overcommit.rb
81
+ - bin/overcommit
74
82
  - bin/run-hook
75
- - bin/scripts/index-tags
76
- - bin/scripts/gerrit-change-id
77
83
  - bin/scripts/jshint.js
84
+ - bin/scripts/index-tags
78
85
  - bin/scripts/csslint-rhino.js
86
+ - bin/scripts/gerrit-change-id
79
87
  - bin/scripts/jshint_runner.js
80
- - bin/overcommit
81
88
  - bin/hooks/commit-msg
82
- - bin/hooks/post-checkout
83
- - bin/hooks/post-merge
84
89
  - bin/hooks/pre-commit
90
+ - bin/hooks/post-merge
91
+ - bin/hooks/post-checkout
85
92
  - bin/hooks/prepare-commit-msg
86
93
  - config/templates.yml
94
+ has_rdoc: true
87
95
  homepage: http://github.com/causes/overcommit
88
- licenses:
96
+ licenses:
89
97
  - MIT
90
98
  post_install_message:
91
99
  rdoc_options: []
92
- require_paths:
100
+
101
+ require_paths:
93
102
  - lib
94
- required_ruby_version: !ruby/object:Gem::Requirement
103
+ required_ruby_version: !ruby/object:Gem::Requirement
95
104
  none: false
96
- requirements:
97
- - - ! '>='
98
- - !ruby/object:Gem::Version
99
- version: '0'
100
- required_rubygems_version: !ruby/object:Gem::Requirement
105
+ requirements:
106
+ - - ">="
107
+ - !ruby/object:Gem::Version
108
+ hash: 3
109
+ segments:
110
+ - 0
111
+ version: "0"
112
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
113
  none: false
102
- requirements:
103
- - - ! '>='
104
- - !ruby/object:Gem::Version
105
- version: '0'
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ hash: 3
118
+ segments:
119
+ - 0
120
+ version: "0"
106
121
  requirements: []
122
+
107
123
  rubyforge_project:
108
- rubygems_version: 1.8.23
124
+ rubygems_version: 1.3.7
109
125
  signing_key:
110
126
  specification_version: 3
111
127
  summary: Opinionated Git hook manager
112
128
  test_files: []
129
+