@@ -5,6 +5,7 @@ package cmd
5
5
import (
6
6
"errors"
7
7
"fmt"
8
+
8
9
// "io" // win specific
9
10
"log"
10
11
"os"
@@ -20,6 +21,7 @@ import (
20
21
21
22
arrop "github.com/adam-hanna/arrayOperations"
22
23
"github.com/gobwas/glob"
24
+
23
25
// "github.com/kr/pty" //win specific
24
26
"github.com/spf13/afero"
25
27
"github.com/spf13/cobra"
@@ -53,6 +55,7 @@ const (
53
55
subFiles string = "{files}"
54
56
subAllFiles string = "{all_files}"
55
57
subStagedFiles string = "{staged_files}"
58
+ pushFiles string = "{push_files}"
56
59
runnerWrapPattern string = "{cmd}"
57
60
tagsConfigKey string = "tags"
58
61
pipedConfigKey string = "piped"
@@ -162,19 +165,28 @@ func executeCommand(hooksGroup, commandName string, wg *sync.WaitGroup) {
162
165
return
163
166
}
164
167
165
- files , _ := context . AllFiles ()
168
+ files := [] string {}
166
169
runner := getRunner (hooksGroup , commandsConfigKey , commandName )
167
170
168
171
if strings .Contains (runner , subStagedFiles ) {
169
172
files , _ = context .StagedFiles ()
170
173
} else if strings .Contains (runner , subFiles ) || getCommandFiles (hooksGroup , commandName ) != "" {
171
174
files , _ = context .ExecGitCommand (getCommandFiles (hooksGroup , commandName ))
175
+ } else if strings .Contains (runner , pushFiles ) {
176
+ files , _ = context .PushFiles ()
177
+ } else {
178
+ files , _ = context .AllFiles ()
172
179
}
173
180
181
+ VerbosePrint ("Files before filters: \n " , files )
182
+
174
183
files = FilterGlob (files , getCommandGlobRegexp (hooksGroup , commandName ))
175
184
files = FilterInclude (files , getCommandIncludeRegexp (hooksGroup , commandName )) // NOTE: confusing option, suppose delete it
176
185
files = FilterExclude (files , getCommandExcludeRegexp (hooksGroup , commandName ))
177
186
187
+ VerbosePrint ("Files after filters: \n " , files )
188
+
189
+ runner = strings .Replace (runner , pushFiles , strings .Join (files , " " ), - 1 )
178
190
runner = strings .Replace (runner , subStagedFiles , strings .Join (files , " " ), - 1 )
179
191
runner = strings .Replace (runner , subAllFiles , strings .Join (files , " " ), - 1 )
180
192
runner = strings .Replace (runner , subFiles , strings .Join (files , " " ), - 1 )
0 commit comments