Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: files from stdin only null separated #615

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func newRunCmd(opts *lefthook.Options) *cobra.Command {

runCmd.Flags().BoolVar(
&runArgs.FilesFromStdin, "files-from-stdin", false,
"get files from standard input, null- or \\n-separated",
"get files from standard input, null-separated",
)

runCmd.Flags().StringSliceVar(
Expand Down
4 changes: 2 additions & 2 deletions internal/lefthook/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -294,12 +294,12 @@ func (l *Lefthook) configHookCommandCompletions(hookName string) []string {
}
}

// parseFilesFromString parses both `\0`- and `\n`-separated files.
// parseFilesFromString parses both `\0`-separated files.
func parseFilesFromString(paths string) []string {
var result []string
start := 0
for i, c := range paths {
if c == 0 || c == '\n' {
if c == 0 {
result = append(result, paths[start:i])
start = i + 1
}
Expand Down
9 changes: 0 additions & 9 deletions testdata/files_override.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@ stdout 'a-file\.js b_file\.go c,file\.rb'
exec lefthook run echo --file a-file.js --file ghost.file
stdout 'a-file\.js ghost\.file'

stdin b_file.go
exec lefthook run echo --files-from-stdin
stdout 'b_file\.go c,file\.rb'

stdin b_file.go
exec lefthook run echo --files-from-stdin --file ghost.file
stdout 'ghost\.file b_file\.go c,file\.rb'

-- lefthook.yml --
skip_output:
- meta
Expand All @@ -36,7 +28,6 @@ a-file.js

-- b_file.go --
b_file.go
c,file.rb

-- c,file.rb --
c,file.rb
Loading