devcam hook: correct pathspec for older gits

Older git versions (prior to 2.13 / commit
859b7f1d0e)
required a more explicit pattern.

This also reorders the gofmt one to put the positive before the negative
match for consistency.

Fixes #1191

Change-Id: Ie74e3c3d434f667d76d5ebbb76811b4f304800c8
This commit is contained in:
Euan Kemp 2018-06-18 18:17:42 -07:00
parent 887e87845b
commit feef4b6b0d
1 changed files with 2 additions and 2 deletions

View File

@ -237,7 +237,7 @@ func (c *hookCmd) hookGofmt() error {
func (c *hookCmd) hookTrailingSpace() error { func (c *hookCmd) hookTrailingSpace() error {
// see 'pathspec' for the ':!' syntax to ignore a directory. // see 'pathspec' for the ':!' syntax to ignore a directory.
out, _ := cmdOutputDirErr(".", "git", "diff-index", "--check", "--diff-filter=ACM", "--cached", "HEAD", "--", ":!/vendor/") out, _ := cmdOutputDirErr(".", "git", "diff-index", "--check", "--diff-filter=ACM", "--cached", "HEAD", "--", ".", ":!/vendor/")
if out != "" { if out != "" {
printf("\n%s", out) printf("\n%s", out)
printf("Trailing whitespace detected, you need to clean it up manually.\n") printf("Trailing whitespace detected, you need to clean it up manually.\n")
@ -257,7 +257,7 @@ func (c *hookCmd) runGofmt() (files []string, err error) {
repo += string(filepath.Separator) repo += string(filepath.Separator)
} }
out, err := cmdOutputDirErr(".", "git", "diff-index", "--name-only", "--diff-filter=ACM", "--cached", "HEAD", "--", ":!/vendor/", ":(glob)**/*.go") out, err := cmdOutputDirErr(".", "git", "diff-index", "--name-only", "--diff-filter=ACM", "--cached", "HEAD", "--", ":(glob)**/*.go", ":!/vendor/")
if err != nil { if err != nil {
return nil, err return nil, err
} }