mirror of
https://github.com/vbatts/git-validation.git
synced 2024-11-25 17:45:40 +00:00
Add exclude pattern for git checks
Allows excluding of vendor directories for whitespace checks Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
parent
cf8d44cfd7
commit
742f9db7ae
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strings"
|
||||
|
@ -61,7 +62,14 @@ var FieldNames = map[string]string{
|
|||
// Check warns if changes introduce whitespace errors.
|
||||
// Returns non-zero if any issues are found.
|
||||
func Check(commit string) ([]byte, error) {
|
||||
cmd := exec.Command("git", "--no-pager", "show", "--check", commit)
|
||||
args := []string{
|
||||
"--no-pager", "log", "--check",
|
||||
fmt.Sprintf("%s^..%s", commit, commit),
|
||||
}
|
||||
if exclude := os.Getenv("GIT_CHECK_EXCLUDE"); exclude != "" {
|
||||
args = append(args, "--", ".", fmt.Sprintf(":(exclude)%s", exclude))
|
||||
}
|
||||
cmd := exec.Command("git", args...)
|
||||
if debug() {
|
||||
logrus.Infof("[git] cmd: %q", strings.Join(cmd.Args, " "))
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue