overcommit 0.9.0 → 0.10.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f85ad2d80c2da4defeec5bce808514385a27c6e6
4
- data.tar.gz: e547ff585ce285436624840c7b16e32ab79677a7
3
+ metadata.gz: c401b4037c6c90452c248dfaca8cacbd549179eb
4
+ data.tar.gz: 0dd31cd371594e594acf9a4801c35de6a86501fb
5
5
  SHA512:
6
- metadata.gz: 5e7633bf2eccb141b29a8b0bb69910ceb3810badc570a9573f3a6ce069988af8a436ee7b91f2802bf8f305be92aac98c1f603d9570690f7bad5ecae4bf6bff5c
7
- data.tar.gz: 5988d0a37ca6bf001019e94c19e11e97aeb52cc1bec66e75478d1c5bb04f231c43f77447702b579c3a468d9248c6515d62fa28337b93cd92725e33b47eec665b
6
+ metadata.gz: 87a27a2be76870493529d9f66bd518107c6bc3cfeb039801075da2d89c8d50b603c8245f871d0ceae26b9ef2b2aeb87c9b77eaad7c71548d0686e282ca17b882
7
+ data.tar.gz: b40a66a5f76dd54b234940370411f5dec3bc8061efe8a5c4c2dd85493f19ab350687605dab2a634fb72a183b8bfe6682484119ea9ba5f5bdb0430270995d0e80
@@ -70,22 +70,17 @@ module Overcommit::Hook
70
70
  def applicable_file?(file)
71
71
  includes = Array(@config['include']).map { |glob| convert_glob_to_absolute(glob) }
72
72
  included = includes.empty? ||
73
- includes.any? { |glob| File.fnmatch(glob, file) }
73
+ includes.any? { |glob| Dir[glob].include?(file) }
74
74
 
75
75
  excludes = Array(@config['exclude']).map { |glob| convert_glob_to_absolute(glob) }
76
- excluded = excludes.any? { |glob| File.fnmatch(glob, file) }
76
+ excluded = excludes.any? { |glob| Dir[glob].include?(file) }
77
77
 
78
78
  included && !excluded
79
79
  end
80
80
 
81
81
  def convert_glob_to_absolute(glob)
82
82
  repo_root = Overcommit::Utils.repo_root
83
-
84
- if glob.start_with?('**')
85
- repo_root + glob # Want ** to match items in the repo root as well
86
- else
87
- File.join(repo_root, glob)
88
- end
83
+ File.join(repo_root, glob)
89
84
  end
90
85
  end
91
86
  end
@@ -22,7 +22,7 @@ module Overcommit::Hook::PostCheckout
22
22
  result = execute(%w[git diff --exit-code --name-only] + [new_head, previous_head])
23
23
 
24
24
  result.stdout.split("\n").any? do |file|
25
- Array(@config['include']).any? { |glob| File.fnmatch(glob, file) }
25
+ Array(@config['include']).any? { |glob| Dir[glob].include?(file) }
26
26
  end
27
27
  end
28
28
 
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'set'
2
3
 
3
4
  module Overcommit::HookContext
@@ -10,6 +11,7 @@ module Overcommit::HookContext
10
11
  # about to be committed.
11
12
  def setup_environment
12
13
  store_modified_times
14
+ store_merge_state
13
15
 
14
16
  if any_changes?
15
17
  @changes_stashed = true
@@ -28,9 +30,10 @@ module Overcommit::HookContext
28
30
  `git reset --hard` # Ensure working tree is clean before popping stash
29
31
 
30
32
  if @changes_stashed
31
- `git stash pop --index --quiet`
33
+ `git stash apply --index --quiet`
32
34
  end
33
35
 
36
+ restore_merge_state
34
37
  restore_modified_times
35
38
  end
36
39
 
@@ -83,6 +86,37 @@ module Overcommit::HookContext
83
86
  lines
84
87
  end
85
88
 
89
+ def store_merge_state
90
+ merge_head = `git rev-parse MERGE_HEAD 2> /dev/null`.chomp
91
+
92
+ # Store the merge state if we're in the middle of resolving a merge
93
+ # conflict. This is necessary since stashing removes the merge state.
94
+ if merge_head != 'MERGE_HEAD'
95
+ @merge_head = merge_head
96
+
97
+ merge_msg_file = File.expand_path('.git/MERGE_MSG', Overcommit::Utils.repo_root)
98
+ @merge_msg = File.open(merge_msg_file).read if File.exist?(merge_msg_file)
99
+ end
100
+ end
101
+
102
+ def restore_merge_state
103
+ if @merge_head
104
+ FileUtils.touch(File.expand_path('.git/MERGE_MODE', Overcommit::Utils.repo_root))
105
+
106
+ File.open(File.expand_path('.git/MERGE_HEAD', Overcommit::Utils.repo_root), 'w') do |f|
107
+ f.write("#{@merge_head}\n")
108
+ end
109
+ @merge_head = nil
110
+ end
111
+
112
+ if @merge_msg
113
+ File.open(File.expand_path('.git/MERGE_MSG', Overcommit::Utils.repo_root), 'w') do |f|
114
+ f.write("#{@merge_msg}\n")
115
+ end
116
+ @merge_msg = nil
117
+ end
118
+ end
119
+
86
120
  def store_modified_times
87
121
  @modified_times = {}
88
122
 
@@ -1,4 +1,4 @@
1
1
  # Defines the gem version.
2
2
  module Overcommit
3
- VERSION = '0.9.0'
3
+ VERSION = '0.10.0'
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.9.0
4
+ version: 0.10.0
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-05-14 00:00:00.000000000 Z
12
+ date: 2014-05-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: childprocess