Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var GitCheck = func(cCtx *cli.Context) error { _, err := os.Stat(".git") if err != nil { if os.IsNotExist(err) { return cli.Exit("Must run in Git repository", 1) } else { return cli.Exit("Could not detect Git repository", 1) } } return nil }
View Source
var SetTemplateCommand = &cli.Command{ Name: "set", Usage: "Set up template for commit message", Flags: []cli.Flag{ &cli.BoolFlag{Name: "dry-run", Aliases: []string{"d"}, Usage: "Print template to stdout", Value: false}, &cli.StringFlag{Name: "issue", Aliases: []string{"i"}, Usage: "Issue reference to add to template", Value: ""}, &cli.StringSliceFlag{Name: "pair", Aliases: []string{"p"}, Usage: "Co-author(s) to add to template", Value: cli.NewStringSlice()}, }, Before: GitCheck, Action: func(c *cli.Context) error { var cfg Config err := envconfig.Process("GIT_COMMIT_TEMPLATE", &cfg) if err != nil { return cli.Exit("Reading environment variables failed", 1) } var f *os.File if c.Bool("dry-run") { f = os.Stdout } else { var err error f, err = os.Create(".git/.gitmessage.txt") if err != nil { return cli.Exit("Saving template file failed", 1) } defer f.Close() } _ = message.Execute(f, struct { Issue string CoAuthors []string }{issueRef(c.String("issue"), cfg.IssuePrefix), findCoAuthors(c.StringSlice("pair"), cfg.AuthorFile)}) if !c.Bool("dry-run") { err := exec.Command("git", "config", "--local", "commit.template", ".git/.gitmessage.txt").Run() if err != nil { return cli.Exit("Updating Git config failed", 1) } } return nil }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.