-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
144 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
package cmd | ||
|
||
import ( | ||
"os" | ||
import "github.com/evilmartians/lefthook/internal/log" | ||
|
||
"github.com/evilmartians/lefthook/internal/log" | ||
) | ||
|
||
func Lefthook() { | ||
func Lefthook() int { | ||
rootCmd := newRootCmd() | ||
|
||
if err := rootCmd.Execute(); err != nil { | ||
if err.Error() != "" { | ||
log.Errorf("Error: %s", err) | ||
} | ||
os.Exit(1) | ||
return 1 | ||
} | ||
|
||
return 0 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//go:build integrity | ||
// +build integrity | ||
|
||
package main_test | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
|
||
"github.com/rogpeppe/go-internal/testscript" | ||
) | ||
|
||
func TestLefthookIntegrity(t *testing.T) { | ||
testscript.Run(t, testscript.Params{ | ||
Dir: "testdata", | ||
Setup: func(env *testscript.Env) error { | ||
env.Vars = append(env.Vars, fmt.Sprintf("GOCOVERDIR=%s", os.Getenv("GOCOVERDIR"))) | ||
return nil | ||
}, | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
package main | ||
|
||
import "github.com/evilmartians/lefthook/cmd" | ||
import ( | ||
"os" | ||
|
||
"github.com/evilmartians/lefthook/cmd" | ||
) | ||
|
||
func main() { | ||
cmd.Lefthook() | ||
os.Exit(cmd.Lefthook()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exec git init | ||
exec lefthook add pre-commit | ||
exists .git/hooks/pre-commit | ||
! stderr . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
exec git init | ||
exec lefthook dump | ||
cmp stdout lefthook-dumped.yml | ||
! stderr . | ||
|
||
exec lefthook dump --json | ||
cmp stdout lefthook-dumped.json | ||
! stderr . | ||
|
||
exec lefthook dump --toml | ||
cmp stdout lefthook-dumped.toml | ||
! stderr . | ||
|
||
-- lefthook.yml -- | ||
colors: false | ||
pre-commit: | ||
follow: true | ||
commands: | ||
lint: | ||
interactive: true | ||
skip: | ||
- merge | ||
- rebase | ||
- ref: main | ||
run: yarn lint {staged_files} | ||
test: | ||
skip: merge | ||
glob: "*.js" | ||
run: yarn test | ||
-- lefthook-dumped.yml -- | ||
colors: false | ||
pre-commit: | ||
commands: | ||
lint: | ||
run: yarn lint {staged_files} | ||
skip: | ||
- merge | ||
- rebase | ||
- ref: main | ||
interactive: true | ||
test: | ||
run: yarn test | ||
skip: merge | ||
glob: '*.js' | ||
follow: true | ||
-- lefthook-dumped.json -- | ||
{ | ||
"colors": false, | ||
"pre-commit": { | ||
"commands": { | ||
"lint": { | ||
"run": "yarn lint {staged_files}", | ||
"skip": [ | ||
"merge", | ||
"rebase", | ||
{ | ||
"ref": "main" | ||
} | ||
], | ||
"interactive": true | ||
}, | ||
"test": { | ||
"run": "yarn test", | ||
"skip": "merge", | ||
"glob": "*.js" | ||
} | ||
}, | ||
"follow": true | ||
} | ||
} | ||
-- lefthook-dumped.toml -- | ||
colors = false | ||
|
||
[pre-commit] | ||
follow = true | ||
|
||
[pre-commit.commands] | ||
[pre-commit.commands.lint] | ||
run = 'yarn lint {staged_files}' | ||
skip = ['merge', 'rebase', {ref = 'main'}] | ||
interactive = true | ||
|
||
[pre-commit.commands.test] | ||
run = 'yarn test' | ||
skip = 'merge' | ||
glob = '*.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
exec git init | ||
exec lefthook install | ||
exists lefthook.yml | ||
! stderr . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
exec lefthook version | ||
stdout \d\.\d\.\d | ||
! stderr . |