-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd/activate_commit_validator.go): Adding cmd/activate_commit_va…
…lidator.go
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 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 |
---|---|---|
@@ -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) | ||
} |