overcommit 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 71918eba0365e808f93d99e998125bde65250068
4
- data.tar.gz: 1f44c67193e451b99db6297ae759a7b1bc6fa871
3
+ metadata.gz: 7d64fbba103905649d8924761929dd8de6ed8dda
4
+ data.tar.gz: 7e60a0e86700b84e2c0e20f31d9725e3d20e17b5
5
5
  SHA512:
6
- metadata.gz: 3ffd93a8720739d8acbb86f9e0df55c314fe706f0be649c3d66bac58cc3bcf45690db70a48862eb4297bafc99d8fd2c702be9991082107d446beb211ac3f95ae
7
- data.tar.gz: cc535627eb8fec824ddc27358e33ff29b78e0ff3e3d53c2aa79b7a251b3272d41f6c0270404f8ccd0aff0916c22c8355fe955a02d6e7b30d2ebdcb79826e0c41
6
+ metadata.gz: 6287bda409ccdcb0b42760bae088929caec13d9a09ab9dd8355374e889cae1fb33ebc2450bc2a725ec8901f2d0df3185ec7f604694ca2631c43449f4ef371d82
7
+ data.tar.gz: 4c8de904dcf1b65ef3854e43e8a313baacef309e999d38448f106941284a246fe3cdcc933c7e9e96efe749627771cf9b4b3207a221b413c3006ea78b2ebdef7e
data/config/default.yml CHANGED
@@ -134,6 +134,8 @@ CommitMsg:
134
134
 
135
135
  TextWidth:
136
136
  description: 'Checking text width'
137
+ max_subject_width: 60
138
+ max_body_width: 72
137
139
 
138
140
  TrailingPeriod:
139
141
  description: 'Checking for trailing periods in subject'
@@ -3,17 +3,28 @@ module Overcommit::Hook::CommitMsg
3
3
  # under the preferred limits.
4
4
  class TextWidth < Base
5
5
  def run
6
- if commit_message_lines.first.size > 60
7
- return :warn, 'Please keep the subject < ~60 characters'
6
+ errors = []
7
+
8
+ max_subject_width = @config['max_subject_width']
9
+ max_body_width = @config['max_body_width']
10
+
11
+ if commit_message_lines.first.size > max_subject_width
12
+ errors << "Please keep the subject <= #{max_subject_width} characters"
8
13
  end
9
14
 
10
- commit_message_lines.each do |line|
11
- chomped = line.chomp
12
- if chomped.size > 72
13
- return :warn, "> 72 characters, please hard wrap: '#{chomped}'"
15
+ if commit_message_lines.size > 2
16
+ commit_message_lines[2..-1].each_with_index do |line, index|
17
+ chomped = line.chomp
18
+ if chomped.size > max_body_width
19
+ error = "Line #{index + 3} of commit message has > " <<
20
+ "#{max_body_width} characters"
21
+ errors << error
22
+ end
14
23
  end
15
24
  end
16
25
 
26
+ return :warn, errors.join("\n") if errors.any?
27
+
17
28
  :good
18
29
  end
19
30
  end
@@ -7,7 +7,7 @@ module Overcommit::Hook::PostCheckout
7
7
  return :warn, 'bundler not installed -- run `gem install bundler`'
8
8
  end
9
9
 
10
- return :bad if dependencies_changed? && !dependencies_satisfied?
10
+ return :warn if dependencies_changed? && !dependencies_satisfied?
11
11
 
12
12
  :good
13
13
  end
@@ -11,7 +11,8 @@ module Overcommit::HookContext
11
11
  def setup_environment
12
12
  store_modified_times
13
13
 
14
- if modified_files.any?
14
+ if any_changes?
15
+ @changes_stashed = true
15
16
  `git stash save --keep-index --quiet #{<<-MSG}`
16
17
  "Overcommit: Stash of repo state before hook run at #{Time.now}"
17
18
  MSG
@@ -24,8 +25,11 @@ module Overcommit::HookContext
24
25
  # Restore unstaged changes and reset file modification times so it appears
25
26
  # as if nothing ever changed.
26
27
  def cleanup_environment
27
- `git reset --hard`
28
- `git stash pop --index --quiet` if modified_files.any?
28
+ `git reset --hard` # Ensure working tree is clean before popping stash
29
+
30
+ if @changes_stashed
31
+ `git stash pop --index --quiet`
32
+ end
29
33
 
30
34
  restore_modified_times
31
35
  end
@@ -48,6 +52,12 @@ module Overcommit::HookContext
48
52
 
49
53
  private
50
54
 
55
+ # Returns whether there are any changes between the working tree or index
56
+ # and HEAD.
57
+ def any_changes?
58
+ !`git diff --name-only --ignore-submodules=all HEAD`.strip.empty?
59
+ end
60
+
51
61
  DIFF_HUNK_REGEX = /
52
62
  ^@@\s
53
63
  [^\s]+\s # Ignore old file range
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.6.2'
3
+ VERSION = '0.6.3'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overcommit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Causes Engineering
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-21 00:00:00.000000000 Z
12
+ date: 2014-03-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: wopen3
@@ -45,14 +45,14 @@ dependencies:
45
45
  requirements:
46
46
  - - '='
47
47
  - !ruby/object:Gem::Version
48
- version: 0.10.2
48
+ version: 0.11.1
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - '='
54
54
  - !ruby/object:Gem::Version
55
- version: 0.10.2
55
+ version: 0.11.1
56
56
  description: Utility to install, configure, and extend Git hooks
57
57
  email:
58
58
  - eng@causes.com