Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var RootCmd = &cobra.Command{ Use: "changelog", Short: "Generate a Clog changelog", Run: func(cmd *cobra.Command, args []string) { if err := validateProvider(viper.GetString("provider")); err != nil { exitOnError(err) } var style linkStyle.Style var querier changelog.Querier switch viper.GetString("provider") { case "github": style = linkStyle.Github querier = changelog.NewGithubQuerier(viper.GetString("repo"), viper.GetString("token")) default: querier = changelog.NewLocalQuerier(viper.GetString("git-dir"), viper.GetString("work-tree")) repo := viper.GetString("repo") if len(repo) == 0 { repo, err := querier.GetOrigin() if err != nil { exitOnError(err) } viper.Set("repo", repo) } style = linkStyle.InferStyle(repo) } if config, err := querier.GetConfig(); err == nil { err := viper.ReadConfig(config) if err != nil { exitOnError(err) } } c := changelog.ChangeLog{ Repo: viper.GetString("repo"), Version: viper.GetString("version"), Subtitle: viper.GetString("subtitle"), } sectionAliasMap := changelog.MergeSectionAliasMaps( changelog.NewSectionAliasMap(), viper.GetStringMapStringSlice("sections"), ) var commits changelog.Commits if len(viper.GetString("since")) > 0 || len(viper.GetString("until")) > 0 { if viper.GetString("until") == "" { viper.Set("until", time.Now().Format(time.RFC3339)) } if viper.GetString("since") == "" { viper.Set("since", time.Unix(1, 0).Format(time.RFC3339)) } until, err := time.Parse(time.RFC3339, viper.GetString("until")) if err != nil { exitOnError(err) } since, err := time.Parse(time.RFC3339, viper.GetString("since")) if err != nil { exitOnError(err) } commits, err = querier.GetCommitRange(since, until) if err != nil { exitOnError(errors.Wrap(err, "Could not get list of commits")) } } else { if viper.GetBool("from-latest-tag") { version, err := querier.GetLatestTag() if err != nil { exitOnError(errors.Wrap(err, "Could not get latest tag revision")) } viper.Set("from", version) } var err error commits, err = querier.GetCommits(viper.GetString("from"), viper.GetString("to")) if err != nil { exitOnError(errors.Wrap(err, "Could not get list of commits")) } } if !viper.GetBool("include-all") { commits = changelog.FilterCommits( commits, sectionAliasMap.Grep(), viper.GetBool("include-all"), ) commits = changelog.FormatCommits(commits, sectionAliasMap) } else { commits = changelog.TitleCommitType(commits, sectionAliasMap) } sectionMap := changelog.NewSectionMap(commits) if order := viper.GetStringSlice("order"); len(order) > 0 { sectionMap.SetOrder(order) } w := writer.MarkdownWriter{Writer: os.Stdout} err := w.Generate(c, style, sectionMap) if err != nil { panic(err) } }, }
RootCmd represents the base command when called without any subcommands
Functions ¶
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.