Skip to content

Commit

Permalink
feat(cmd/activate_commit_validator.go): Adding cmd/activate_commit_va…
Browse files Browse the repository at this point in the history
…lidator.go
  • Loading branch information
plvhx committed Jul 15, 2022
1 parent 4d2129b commit e269994
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions cmd/activate_commit_validator.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright 2022 Paulus Gandung Prakosa <[email protected]>
// All rights reserved.

package cmd

import (
"github.com/plvhx/polar/src"
"github.com/spf13/cobra"
)

var (
hookName = "prepare-commit-msg"
hookCommand = "polar validate-commit"
)

var activateFunc = func(cmd *cobra.Command, args []string) {
if err := src.CreateHook(hookName, hookCommand); err != nil {
panic(err)
}
}

var activateCmd = &cobra.Command{
Use: "activate-commit-validator",
Short: "Activate prepare-commit-msg hook",
Long: "Activate prepare-commit-msg hook for validating commit message.",
Example: "polar activate-commit-validator",
Run: activateFunc,
}

func init() {
rootCmd.AddCommand(activateCmd)
}

0 comments on commit e269994

Please sign in to comment.