MCPcopy Index your code
hub / github.com/conventionalcommit/commitlint / newInitCmd

Function newInitCmd

internal/cmd/cmd.go:61–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

59}
60
61func newInitCmd() *cli.Command {
62 return &cli.Command{
63 Name: "init",
64 Usage: "Set up commitlint for a git repository",
65 Description: "Creates the commit-msg hook and points git to it.\nUse --global to apply across all your repositories.",
66 Flags: []cli.Flag{
67 &cli.BoolFlag{
68 Name: "global",
69 Aliases: []string{"g"},
70 Usage: "Set up for all repositories (uses global git config)",
71 },
72 &cli.StringFlag{
73 Name: "config",
74 Aliases: []string{"c"},
75 Usage: "Pass a config `FILE` to the hook",
76 },
77 &cli.BoolFlag{
78 Name: "replace",
79 Aliases: []string{"r"},
80 Usage: "Overwrite existing hook files",
81 },
82 &cli.StringFlag{
83 Name: "hookspath",
84 Aliases: []string{"p"},
85 Usage: "Where to write hook files (default: .commitlint/hooks)",
86 },
87 },
88 Action: func(ctx *cli.Context) error {
89 confPath := ctx.String("config")
90 isGlobal := ctx.Bool("global")
91 isReplace := ctx.Bool("replace")
92 hooksPath := ctx.String("hookspath")
93
94 err := initLint(confPath, hooksPath, isGlobal, isReplace)
95 if err != nil {
96 if isHookExists(err) {
97 fmt.Println("commitlint init failed: hook files already exist")
98 fmt.Println("use --replace to overwrite them")
99 return nil
100 }
101 return err
102 }
103
104 fmt.Println("commitlint init successfully")
105 return nil
106 },
107 }
108}
109
110func newConfigCmd() *cli.Command {
111 createCmd := &cli.Command{

Callers 1

newCliAppFunction · 0.85

Calls 3

initLintFunction · 0.85
isHookExistsFunction · 0.85
StringMethod · 0.45

Tested by

no test coverage detected