-
Notifications
You must be signed in to change notification settings - Fork 215
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
167 additions
and
139 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: go | ||
|
||
go: | ||
- 1.13.x | ||
- 1.16.x | ||
|
||
notifications: | ||
email: false | ||
|
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
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,44 @@ | ||
package cmd | ||
|
||
import ( | ||
"bytes" | ||
"embed" | ||
"text/template" | ||
|
||
"github.com/spf13/afero" | ||
) | ||
|
||
//go:embed templates/* | ||
var templatesFS embed.FS | ||
|
||
type hookTmplData struct { | ||
AutoInstall string | ||
HookName string | ||
} | ||
|
||
func hookTemplate(hookName string, fs afero.Fs) []byte { | ||
buf := &bytes.Buffer{} | ||
t := template.Must(template.ParseFS(templatesFS, "templates/hook.tmpl")) | ||
err := t.Execute(buf, hookTmplData{ | ||
AutoInstall: autoInstall(hookName, fs), | ||
HookName: hookName, | ||
}) | ||
check(err) | ||
|
||
return buf.Bytes() | ||
} | ||
|
||
func configTemplate() []byte { | ||
tmpl, err := templatesFS.ReadFile("templates/config.tmpl") | ||
check(err) | ||
|
||
return tmpl | ||
} | ||
|
||
func autoInstall(hookName string, fs afero.Fs) string { | ||
if hookName != checkSumHook { | ||
return "" | ||
} | ||
|
||
return "# lefthook_version: " + configChecksum(fs) + "\n\ncall_lefthook \"lefthook install\"" | ||
} |
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,34 @@ | ||
# EXAMPLE USAGE | ||
# Refer for explanation to following link: | ||
# https://github.com/evilmartians/lefthook/blob/master/docs/full_guide.md | ||
# | ||
# pre-push: | ||
# commands: | ||
# packages-audit: | ||
# tags: frontend security | ||
# run: yarn audit | ||
# gems-audit: | ||
# tags: backend security | ||
# run: bundle audit | ||
# | ||
# pre-commit: | ||
# parallel: true | ||
# commands: | ||
# eslint: | ||
# glob: "*.{js,ts}" | ||
# run: yarn eslint {staged_files} | ||
# rubocop: | ||
# tags: backend style | ||
# glob: "*.rb" | ||
# exclude: "application.rb|routes.rb" | ||
# run: bundle exec rubocop --force-exclusion {all_files} | ||
# govet: | ||
# tags: backend style | ||
# files: git ls-files -m | ||
# glob: "*.go" | ||
# run: go vet {files} | ||
# scripts: | ||
# "hello.js": | ||
# runner: node | ||
# "any.go": | ||
# runner: go run |
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,37 @@ | ||
#!/bin/sh | ||
|
||
if [ "$LEFTHOOK" = "0" ]; then | ||
exit 0 | ||
fi | ||
|
||
if [ -t 1 ] ; then | ||
exec < /dev/tty ; # <- enables interactive shell | ||
fi | ||
|
||
dir="$(cd "$(dirname "$(dirname "$(dirname "$0")")")" >/dev/null 2>&1 || exit ; pwd -P)" | ||
|
||
call_lefthook() | ||
{ | ||
if lefthook -h >/dev/null 2>&1 | ||
then | ||
eval $1 | ||
elif test -f "$dir/node_modules/@arkweid/lefthook/bin/lefthook" | ||
then | ||
eval $dir/node_modules/@arkweid/lefthook/bin/$1 | ||
elif bundle exec lefthook -h >/dev/null 2>&1 | ||
then | ||
bundle exec $1 | ||
elif npx lefthook -h >/dev/null 2>&1 | ||
then | ||
npx $1 | ||
elif yarn lefthook -h >/dev/null 2>&1 | ||
then | ||
yarn $1 | ||
else | ||
echo "Can't find lefthook in PATH" | ||
fi | ||
} | ||
|
||
{{.AutoInstall}} | ||
|
||
call_lefthook "lefthook run {{.HookName}} $@" |
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 |
---|---|---|
|
@@ -16,4 +16,4 @@ require ( | |
gopkg.in/alessio/shellescape.v1 v1.0.0-20170105083845-52074bc9df61 | ||
) | ||
|
||
go 1.13 | ||
go 1.16 |
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