Skip to content

Commit

Permalink
Add flag to skip printing summary header
Browse files Browse the repository at this point in the history
We're using the release tool to generate new markdown docs files and
want insert our own header and then append the output of release to
generate the release changelog, so add an option to skip printing the
"Summary of Changes" header at the top.

Signed-off-by: Chance Zibolski <[email protected]>
  • Loading branch information
chancez authored and joestringer committed Jul 19, 2024
1 parent 96371d6 commit b3c084e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions cmd/changelog/changelog.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ type ChangeLogConfig struct {
StateFile string
LabelFilters []string
ExcludePRReferences bool
SkipHeader bool
}

func (cfg *ChangeLogConfig) Sanitize() error {
Expand Down Expand Up @@ -67,6 +68,7 @@ func Command(ctx context.Context, logger *log.Logger) *cobra.Command {
cmd.Flags().StringVar(&cfg.RepoName, "repo", "cilium/cilium", "GitHub organization and repository names separated by a slash")
cmd.Flags().StringArrayVar(&cfg.LabelFilters, "label-filter", []string{}, "Filter pull requests by labels. This also defines the order of the release notes.")
cmd.Flags().BoolVar(&cfg.ExcludePRReferences, "exclude-pr-references", false, "If true, do not include references to the PR or PR author")
cmd.Flags().BoolVar(&cfg.SkipHeader, "skip-header", false, "If true, do not print 'Summary of of changes' header")

for _, flag := range []string{"base", "head", "repo"} {
cobra.MarkFlagRequired(cmd.Flags(), flag)
Expand Down
6 changes: 4 additions & 2 deletions cmd/changelog/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ func GenerateReleaseNotes(globalCtx context.Context, ghClient *gh.Client, logger
}

func (cl *ChangeLog) PrintReleaseNotesForWriter(w io.Writer) {
fmt.Fprintln(w, "Summary of Changes")
fmt.Fprintln(w, "------------------")
if !cl.SkipHeader {
fmt.Fprintln(w, "Summary of Changes")
fmt.Fprintln(w, "------------------")
}

listOfPRs := cl.listOfPrs.DeepCopy()
prsWithUpstream := cl.prsWithUpstream.DeepCopy()
Expand Down
1 change: 1 addition & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ func addFlags(cmd *cobra.Command) {
cmd.Flags().BoolVar(&cfg.ForceMovePending, "force-move-pending-backports", false, "Force move pending backports to the next version's project")
cmd.Flags().StringArrayVar(&cfg.LabelFilters, "label-filter", []string{}, "Filter pull requests by labels")
cmd.Flags().BoolVar(&cfg.ExcludePRReferences, "exclude-pr-references", false, "If true, do not include references to the PR or PR author")
cmd.Flags().BoolVar(&cfg.SkipHeader, "skip-header", false, "If true, do not print 'Summary of of changes' header")
}

func signals() {
Expand Down

0 comments on commit b3c084e

Please sign in to comment.