MCPcopy Create free account
hub / github.com/TheThingsNetwork/lorawan-stack / RunHook

Method RunHook

tools/mage/git.go:267–286  ·  view source on GitHub ↗

RunHook runs the Git hook for $HOOK. - standard input contents are taken from $STDIN - arguments are taken from $ARGS

()

Source from the content-addressed store, hash-verified

265// - standard input contents are taken from $STDIN
266// - arguments are taken from $ARGS
267func (g Git) RunHook() error {
268 hook, stdin, args := os.Getenv("HOOK"), os.Getenv("STDIN"), strings.Fields(os.Getenv("ARGS"))
269 switch hook {
270 case "pre-commit":
271 return g.preCommit()
272 case "commit-msg":
273 var messageFile string
274 if len(args) > 0 {
275 messageFile = args[0]
276 }
277 return g.commitMsg(messageFile)
278 case "pre-push":
279 if mg.Verbose() {
280 fmt.Println("Running pre-push hook with", args)
281 }
282 return g.prePush(stdin, args...)
283 default:
284 return fmt.Errorf("Unknown hook %s", hook)
285 }
286}
287
288// Diff returns error if `git diff` is not empty
289func (Git) Diff() error {

Callers

nothing calls this directly

Calls 5

preCommitMethod · 0.95
commitMsgMethod · 0.95
prePushMethod · 0.95
FieldsMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected