File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change 15
15
var mtime = new Date ( fs . statSync ( oldMessagePath ) . mtime )
16
16
17
17
// Date.now() - mtime.getTime() is milliseconds, convert to seconds
18
- if ( ( Date . now ( ) - mtime . getTime ( ) ) / 1000 < oldMessageSeconds ) {
18
+ var fresh = ( Date . now ( ) - mtime . getTime ( ) ) / 1000 < oldMessageSeconds
19
+
20
+ // There are many scenarios that trigger the prepare-commit-msg hook
21
+ // These scenarios pass different console parameters, see here:
22
+ // https://www.kernel.org/pub/software/scm/git/docs/githooks.html
23
+ //
24
+ // A plain `git commit` is the only scenario that passes 3 entries
25
+ // For all other scenarios (like `git commit -m`, squash or merge)
26
+ // just delete oldMessagePath, do not actually suggest it to user
27
+ var plain = process . argv === 3
28
+
29
+ if ( plain && fresh ) {
19
30
fs . writeFileSync ( process . argv [ 2 ] , fs . readFileSync ( oldMessagePath ) )
20
31
}
21
32
You can’t perform that action at this time.
0 commit comments