@@ -18,7 +18,11 @@ var getGitFolder = require('./getGitFolder');
18
18
// hacky start if not run by mocha :-D
19
19
// istanbul ignore next
20
20
if ( process . argv . join ( '' ) . indexOf ( 'mocha' ) === - 1 ) {
21
- var commitMsgFileOrText = process . argv [ 2 ] || getGitFolder ( ) + '/COMMIT_EDITMSG' ;
21
+ var commitMsgFileOrText ,
22
+ gitFolder = getGitFolder ( ) + '/' ,
23
+ //GIT GUI stores commit msg @GITGUI_EDITMSG file, so user can pass file name has argument
24
+ //if it doesn't exist then we are considering "/COMMIT_EDITMSG" file
25
+ filename = ( process . argv [ 2 ] && fs . existsSync ( gitFolder + process . argv [ 2 ] ) ) ? process . argv [ 2 ] : 'COMMIT_EDITMSG' ;
22
26
23
27
var bufferToString = function ( buffer ) {
24
28
return hasToString ( buffer ) && buffer . toString ( ) ;
@@ -28,11 +32,11 @@ if (process.argv.join('').indexOf('mocha') === -1) {
28
32
return x && typeof x . toString === 'function' ;
29
33
} ;
30
34
31
- var validate = function ( msg , isFile ) {
35
+ var validate = function ( msg , isFile , filename ) {
32
36
if ( ! validateMessage ( msg ) ) {
33
37
var incorrectLogFile = (
34
38
isFile
35
- ? commitMsgFileOrText . replace ( 'COMMIT_EDITMSG' , 'logs/incorrect-commit-msgs' )
39
+ ? commitMsgFileOrText . replace ( filename , 'logs/incorrect-commit-msgs' )
36
40
: ( getGitFolder ( ) + '/logs/incorrect-commit-msgs' )
37
41
) ;
38
42
@@ -44,6 +48,8 @@ if (process.argv.join('').indexOf('mocha') === -1) {
44
48
}
45
49
} ;
46
50
51
+ commitMsgFileOrText = gitFolder + filename ;
52
+
47
53
fs . readFile ( commitMsgFileOrText , function readFile ( err , buffer ) {
48
54
if ( err && err . code !== 'ENOENT' ) {
49
55
throw err ;
@@ -56,6 +62,6 @@ if (process.argv.join('').indexOf('mocha') === -1) {
56
62
: commitMsgFileOrText
57
63
) ;
58
64
59
- validate ( msg , isFile ) ;
65
+ validate ( msg , isFile , filename ) ;
60
66
} ) ;
61
67
}
0 commit comments