devcam test: run devcam hook pre-commit

Instead of the old ./misc/pre-commit.githook
Also fix devcam hook pre-commit so we don't show the override message in
that case.

Change-Id: I390016765056b9c4d3331d12bef8f2581e5621df
This commit is contained in:
mpl 2015-09-22 15:42:45 +02:00
parent def28fc337
commit 974ed85e2e
2 changed files with 5 additions and 3 deletions

View File

@ -112,7 +112,9 @@ func (c *hookCmd) RunCommand(args []string) error {
switch args[0] {
case "pre-commit":
if err := c.hookPreCommit(args[1:]); err != nil {
printf("You can override these checks with 'git commit --no-verify'\n")
if !(len(args) > 1 && args[1] == "test") {
printf("You can override these checks with 'git commit --no-verify'\n")
}
cmdmain.ExitWithFailure = true
return err
}

View File

@ -45,7 +45,7 @@ func init() {
cmdmain.RegisterCommand("test", func(flags *flag.FlagSet) cmdmain.CommandRunner {
cmd := new(testCmd)
flags.BoolVar(&cmd.short, "short", false, "Use '-short' with go test.")
flags.BoolVar(&cmd.precommit, "precommit", true, "Run misc/pre-commit.githook as part of tests.")
flags.BoolVar(&cmd.precommit, "precommit", true, "Run the pre-commit githook as part of tests.")
flags.BoolVar(&cmd.verbose, "v", false, "Use '-v' (for verbose) with go test.")
flags.StringVar(&cmd.run, "run", "", "Use '-run' with go test.")
return cmd
@ -158,7 +158,7 @@ func (c *testCmd) runTests(args []string) error {
}
func (c *testCmd) runPrecommitHook() error {
out, err := exec.Command(filepath.FromSlash("./misc/pre-commit.githook"), "test").CombinedOutput()
out, err := exec.Command(filepath.FromSlash("./bin/devcam"), "hook", "pre-commit", "test").CombinedOutput()
if err != nil {
fmt.Println(string(out))
}