Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions cmd/krel/cmd/release_notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,18 @@ permissions to your fork of k/sig-release and k-sigs/release-notes.`,
}

type releaseNotesOptions struct {
repoPath string
tag string
userFork string
createDraftPR bool
createWebsitePR bool
dependencies bool
fixNotes bool
websiteRepo string
mapProviders []string
githubOrg string
draftRepo string
repoPath string
tag string
userFork string
createDraftPR bool
createWebsitePR bool
dependencies bool
fixNotes bool
listReleaseNotesV2 bool
websiteRepo string
mapProviders []string
githubOrg string
draftRepo string
}

type releaseNotesResult struct {
Expand Down Expand Up @@ -212,6 +213,13 @@ func init() {
"the user's fork in the form org/repo. Used to submit Pull Requests for the website and draft",
)

releaseNotesCmd.PersistentFlags().BoolVar(
&releaseNotesOpts.listReleaseNotesV2,
"list-v2",
false,
"enable experimental implementation to list commits (ListReleaseNotesV2)",
)

rootCmd.AddCommand(releaseNotesCmd)
}

Expand Down Expand Up @@ -951,6 +959,7 @@ func gatherNotesFrom(repoPath, startTag string) (*notes.ReleaseNotes, error) {
notesOptions.EndRev = releaseNotesOpts.tag
notesOptions.Debug = logrus.StandardLogger().Level >= logrus.DebugLevel
notesOptions.MapProviderStrings = releaseNotesOpts.mapProviders
notesOptions.ListReleaseNotesV2 = releaseNotesOpts.listReleaseNotesV2

if err := notesOptions.ValidateAndFinish(); err != nil {
return nil, err
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ require (
github.com/GoogleCloudPlatform/testgrid v0.0.38
github.com/blang/semver v3.5.1+incompatible
github.com/cenkalti/backoff/v4 v4.1.0
github.com/cheggaaa/pb/v3 v3.0.5
github.com/containers/image/v5 v5.9.0
github.com/go-git/go-git/v5 v5.2.0
github.com/golang/protobuf v1.4.3
github.com/google/go-containerregistry v0.3.0
github.com/google/go-github/v33 v33.0.0
github.com/google/licenseclassifier/v2 v2.0.0-alpha.1
github.com/google/uuid v1.1.4
github.com/mattn/go-isatty v0.0.12
github.com/maxbrunsfeld/counterfeiter/v6 v6.3.0
github.com/mitchellh/mapstructure v1.4.1
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635
Expand Down
9 changes: 9 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdko
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d h1:G0m3OIz70MZUWq3EgK3CesDbo8upS2Vm9/P3FtgI+Jk=
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdcM=
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
github.com/acarl005/stripansi v0.0.0-20180116102854-5a71ef0e047d/go.mod h1:asat636LX7Bqt5lYEZ27JNDcqxfjdBQuJ/MM4CN/Lzo=
github.com/alcortesm/tgz v0.0.0-20161220082320-9c5fe88206d7 h1:uSoVVbwJiQipAclBbw+8quDsfcvFjOpI5iCf4p/cqCs=
Expand Down Expand Up @@ -124,6 +125,8 @@ github.com/cenkalti/backoff/v4 v4.1.0/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInq
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/checkpoint-restore/go-criu/v4 v4.0.2/go.mod h1:xUQBLp4RLc5zJtWY++yjOoMoB5lihDt7fai+75m+rGw=
github.com/cheggaaa/pb/v3 v3.0.5 h1:lmZOti7CraK9RSjzExsY53+WWfub9Qv13B5m4ptEoPE=
github.com/cheggaaa/pb/v3 v3.0.5/go.mod h1:X1L61/+36nz9bjIsrDU52qHKOQukUQe2Ge+YvGuquCw=
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
Expand Down Expand Up @@ -211,6 +214,7 @@ github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5y
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/evanphx/json-patch v0.0.0-20200808040245-162e5629780b/go.mod h1:NAJj0yf/KaRKURN6nyi7A9IZydMivZEm9oQLWNjfKDc=
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
github.com/fatih/color v1.9.0 h1:8xPHl4/q1VyqGIPif1F+1V3Y3lSmrq01EabUW3CoW5s=
github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568 h1:BHsljHzVlRcyQhjrss6TZTdY2VfCqZPbv5k3iBFa2ZQ=
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
Expand Down Expand Up @@ -488,11 +492,15 @@ github.com/manifoldco/promptui v0.8.0/go.mod h1:n4zTdgP0vr0S3w7/O/g98U+e0gwLScEX
github.com/maratori/testpackage v1.0.1/go.mod h1:ddKdw+XG0Phzhx8BFDTKgpWP4i7MpApTE5fXSKAqwDU=
github.com/matoous/godox v0.0.0-20190911065817-5d6d842e92eb/go.mod h1:1BELzlh859Sh1c6+90blK8lbYy0kwQf1bYlBhBysy1s=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.4 h1:snbPLB8fVfU9iwbbo30TPtbLRzwWu6aJS6Xh4eaaviA=
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-runewidth v0.0.2/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU=
github.com/mattn/go-runewidth v0.0.7/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI=
Expand Down Expand Up @@ -934,6 +942,7 @@ golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200124204421-9fbb57f87de9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
2 changes: 1 addition & 1 deletion pkg/notes/document/document.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func New(
note := releaseNotes.Get(pr)

if note.DoNotPublish {
logrus.Infof("skipping PR %d as (marked to not be published)", pr)
logrus.Debugf("skipping PR %d as (marked to not be published)", pr)
continue
}

Expand Down
23 changes: 17 additions & 6 deletions pkg/notes/notes.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"strconv"
"strings"
"sync"
"time"

gogithub "github.com/google/go-github/v33/github"
"github.com/nozzle/throttler"
Expand Down Expand Up @@ -245,10 +246,18 @@ func GatherReleaseNotes(opts *options.Options) (*ReleaseNotes, error) {
return nil, errors.Wrapf(err, "retrieving notes gatherer")
}

releaseNotes, err := gatherer.ListReleaseNotes()
var releaseNotes *ReleaseNotes
startTime := time.Now()
if gatherer.options.ListReleaseNotesV2 {
logrus.Warn("EXPERIMENTAL IMPLEMENTATION ListReleaseNotesV2 ENABLED")
releaseNotes, err = gatherer.ListReleaseNotesV2()
} else {
releaseNotes, err = gatherer.ListReleaseNotes()
}
if err != nil {
return nil, errors.Wrapf(err, "listing release notes")
}
logrus.Infof("finished gathering release notes in %v", time.Since(startTime))

return releaseNotes, nil
}
Expand Down Expand Up @@ -662,7 +671,7 @@ func (g *Gatherer) notesForCommit(commit *gogithub.RepositoryCommit) (*Result, e
prs, err := g.prsFromCommit(commit)
if err != nil {
if err == errNoPRIDFoundInCommitMessage || err == errNoPRFoundForCommitSHA {
logrus.Infof(
logrus.Debugf(
"No matches found when parsing PR from commit SHA %s",
commit.GetSHA(),
)
Expand All @@ -674,12 +683,12 @@ func (g *Gatherer) notesForCommit(commit *gogithub.RepositoryCommit) (*Result, e
for _, pr := range prs {
prBody := pr.GetBody()

logrus.Infof(
logrus.Debugf(
"Got PR #%d for commit: %s", pr.GetNumber(), commit.GetSHA(),
)

if MatchesExcludeFilter(prBody) {
logrus.Infof(
logrus.Debugf(
"Skipping PR #%d because it contains no release note",
pr.GetNumber(),
)
Expand Down Expand Up @@ -722,7 +731,7 @@ func (g *Gatherer) prsFromCommit(commit *gogithub.RepositoryCommit) (
) {
githubPRs, err := g.prsForCommitFromMessage(*commit.Commit.Message)
if err != nil {
logrus.Infof("No PR found for commit %s: %v", commit.GetSHA(), err)
logrus.Debugf("No PR found for commit %s: %v", commit.GetSHA(), err)
Comment on lines -725 to +734
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@puerco since we're talking about release logs -- is this intentional to be in Info level? because I found it to be noisy when running release notes locally, but I wonder if this is a desired feature?

alternatively, if it is desired, would it make sense to run with Debug level for releases?

Copy link
Member

@puerco puerco Feb 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I'm not sure when or how often this case can happen. I don't remember seeing it much scratch that, I ran a couple of tests and I see what you mean.

return g.prsForCommitFromSHA(*commit.SHA)
}
return githubPRs, err
Expand Down Expand Up @@ -973,7 +982,9 @@ func prettifySIGList(sigs []string) string {
// ApplyMap Modifies the content of the release using information from
// a ReleaseNotesMap
func (rn *ReleaseNote) ApplyMap(noteMap *ReleaseNotesMap) error {
logrus.Infof("Applying map to note from PR %d", rn.PrNumber)
logrus.WithFields(logrus.Fields{
"pr": rn.PrNumber,
}).Debugf("Applying map to note")
reRenderMarkdown := false
if noteMap.ReleaseNote.Author != nil {
rn.Author = *noteMap.ReleaseNote.Author
Expand Down
Loading