overcommit 0.50.0 → 0.51.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/overcommit/hook_context/commit_msg.rb +3 -1
- data/lib/overcommit/hook_context/pre_commit.rb +34 -35
- data/lib/overcommit/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be2c25e83a10d44e88ecee58e5b2638e31e13562b0b272aa68e47656b095c582
|
4
|
+
data.tar.gz: 2b568ff85f265e88387b05b88e41146f2a341b3d22f571c461910c1833a76359
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ae077600ff211f4bbc13a6dd97e1fe8ab4a625fb8918751f1238ee7b9d832f686cdaa42e9e2f1be5f2da0a150fd008532e45a3c45b48f23a3bb118a1d190597
|
7
|
+
data.tar.gz: 4db41972b13aa4c47c230fca0828f4a1d8d7491a09e8e753f0db27bd9f8cf1906b618ad0612e7dbfc84aa3e532529e4d2b41092f85e7bad91b303cd7f7e01017
|
@@ -34,7 +34,9 @@ module Overcommit::HookContext
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def post_fail_message
|
37
|
-
"Failed commit message:\n
|
37
|
+
"Failed commit message:\n#{commit_message_lines.join.chomp}\n\n" \
|
38
|
+
"Try again with your existing commit message by running:\n" \
|
39
|
+
"git commit --edit --file=#{commit_message_file}"
|
38
40
|
end
|
39
41
|
|
40
42
|
private
|
@@ -49,29 +49,15 @@ module Overcommit::HookContext
|
|
49
49
|
Overcommit::GitRepo.store_merge_state
|
50
50
|
Overcommit::GitRepo.store_cherry_pick_state
|
51
51
|
|
52
|
-
if
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
Overcommit::Utils.execute(
|
58
|
-
%w[git -c commit.gpgsign=false stash save --keep-index --quiet] + [stash_message]
|
59
|
-
)
|
60
|
-
end
|
61
|
-
|
62
|
-
unless result.success?
|
63
|
-
# Failure to stash in this case is likely due to a configuration
|
64
|
-
# issue (e.g. author/email not set or GPG signing key incorrect)
|
65
|
-
raise Overcommit::Exceptions::HookSetupFailed,
|
66
|
-
"Unable to setup environment for #{hook_script_name} hook run:" \
|
67
|
-
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
|
68
|
-
end
|
52
|
+
# Don't attempt to stash changes if all changes are staged, as this
|
53
|
+
# prevents us from modifying files at all, which plays better with
|
54
|
+
# editors/tools which watch for file changes.
|
55
|
+
if !initial_commit? && unstaged_changes?
|
56
|
+
stash_changes
|
69
57
|
|
70
|
-
|
58
|
+
# While running hooks make it appear as if nothing changed
|
59
|
+
restore_modified_times
|
71
60
|
end
|
72
|
-
|
73
|
-
# While running the hooks make it appear as if nothing changed
|
74
|
-
restore_modified_times
|
75
61
|
end
|
76
62
|
|
77
63
|
# Restore unstaged changes and reset file modification times so it appears
|
@@ -82,19 +68,14 @@ module Overcommit::HookContext
|
|
82
68
|
# modification time on the file was newer. This helps us play more nicely
|
83
69
|
# with file watchers.
|
84
70
|
def cleanup_environment
|
85
|
-
unless initial_commit? || (@stash_attempted && !@changes_stashed)
|
86
|
-
clear_working_tree # Ensure working tree is clean before restoring it
|
87
|
-
restore_modified_times
|
88
|
-
end
|
89
|
-
|
90
71
|
if @changes_stashed
|
72
|
+
clear_working_tree
|
91
73
|
restore_working_tree
|
92
74
|
restore_modified_times
|
93
75
|
end
|
94
76
|
|
95
77
|
Overcommit::GitRepo.restore_merge_state
|
96
78
|
Overcommit::GitRepo.restore_cherry_pick_state
|
97
|
-
restore_modified_times
|
98
79
|
end
|
99
80
|
|
100
81
|
# Get a list of added, copied, or modified files that have been staged.
|
@@ -140,6 +121,27 @@ module Overcommit::HookContext
|
|
140
121
|
|
141
122
|
private
|
142
123
|
|
124
|
+
def stash_changes
|
125
|
+
@stash_attempted = true
|
126
|
+
|
127
|
+
stash_message = "Overcommit: Stash of repo state before hook run at #{Time.now}"
|
128
|
+
result = Overcommit::Utils.with_environment('GIT_LITERAL_PATHSPECS' => '0') do
|
129
|
+
Overcommit::Utils.execute(
|
130
|
+
%w[git -c commit.gpgsign=false stash save --keep-index --quiet] + [stash_message]
|
131
|
+
)
|
132
|
+
end
|
133
|
+
|
134
|
+
unless result.success?
|
135
|
+
# Failure to stash in this case is likely due to a configuration
|
136
|
+
# issue (e.g. author/email not set or GPG signing key incorrect)
|
137
|
+
raise Overcommit::Exceptions::HookSetupFailed,
|
138
|
+
"Unable to setup environment for #{hook_script_name} hook run:" \
|
139
|
+
"\nSTDOUT:#{result.stdout}\nSTDERR:#{result.stderr}"
|
140
|
+
end
|
141
|
+
|
142
|
+
@changes_stashed = `git stash list -1`.include?(stash_message)
|
143
|
+
end
|
144
|
+
|
143
145
|
# Clears the working tree so that the stash can be applied.
|
144
146
|
def clear_working_tree
|
145
147
|
removed_submodules = Overcommit::GitRepo.staged_submodule_removals
|
@@ -172,14 +174,11 @@ module Overcommit::HookContext
|
|
172
174
|
end
|
173
175
|
end
|
174
176
|
|
175
|
-
# Returns whether there are any changes to
|
176
|
-
#
|
177
|
-
def
|
178
|
-
|
179
|
-
|
180
|
-
map { |line| line.gsub(/[^\s]+\s+(.+)/, '\\1') }
|
181
|
-
|
182
|
-
modified_files.any?
|
177
|
+
# Returns whether there are any changes to tracked files which have not yet
|
178
|
+
# been staged.
|
179
|
+
def unstaged_changes?
|
180
|
+
result = Overcommit::Utils.execute(%w[git --no-pager diff --quiet])
|
181
|
+
!result.success?
|
183
182
|
end
|
184
183
|
|
185
184
|
# Stores the modification times for all modified files to make it appear like
|
data/lib/overcommit/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: overcommit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.51.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: childprocess
|