mirror of
https://github.com/vbatts/git-validation.git
synced 2025-01-30 15:17:33 +00:00
Merge pull request #21 from dmcgowan/exclude-check
Add exclude pattern for git checks
This commit is contained in:
commit
e6a550d472
1 changed files with 9 additions and 1 deletions
|
@ -1,6 +1,7 @@
|
||||||
package git
|
package git
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -61,7 +62,14 @@ var FieldNames = map[string]string{
|
||||||
// Check warns if changes introduce whitespace errors.
|
// Check warns if changes introduce whitespace errors.
|
||||||
// Returns non-zero if any issues are found.
|
// Returns non-zero if any issues are found.
|
||||||
func Check(commit string) ([]byte, error) {
|
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() {
|
if debug() {
|
||||||
logrus.Infof("[git] cmd: %q", strings.Join(cmd.Args, " "))
|
logrus.Infof("[git] cmd: %q", strings.Join(cmd.Args, " "))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue