@@ -110,7 +110,7 @@ func init() {
110
110
changelogCmd .PersistentFlags ().StringVar (& changelogOpts .replayDir , "replay" , "" , "Replay a previously recorded API from a directory" )
111
111
112
112
if err := changelogCmd .MarkPersistentFlagRequired ("tag" ); err != nil {
113
- logrus .Fatal ( err )
113
+ logrus .Fatalf ( "unable to %v" , err )
114
114
}
115
115
116
116
rootCmd .AddCommand (changelogCmd )
@@ -119,7 +119,7 @@ func init() {
119
119
func runChangelog (opts * changelogOptions , rootOpts * rootOptions ) error {
120
120
tag , err := util .TagStringToSemver (opts .tag )
121
121
if err != nil {
122
- return errors .Wrapf (err , "unable to parse tag %s" , opts .tag )
122
+ return errors .Wrapf (err , "parse tag %s" , opts .tag )
123
123
}
124
124
125
125
// Automatically set the branch to a release branch if not provided
@@ -133,7 +133,7 @@ func runChangelog(opts *changelogOptions, rootOpts *rootOptions) error {
133
133
repo , err := git .OpenRepo (rootOpts .repoPath )
134
134
if err != nil {
135
135
return errors .Wrapf (err ,
136
- "unable to open expected k/k repository %q" , rootOpts .repoPath ,
136
+ "open expected k/k repository %q" , rootOpts .repoPath ,
137
137
)
138
138
}
139
139
if currentBranch , err := repo .CurrentBranch (); err == nil {
@@ -143,7 +143,7 @@ func runChangelog(opts *changelogOptions, rootOpts *rootOptions) error {
143
143
remoteBranch := git .Remotify (branch )
144
144
head , err := repo .RevParse (remoteBranch )
145
145
if err != nil {
146
- return errors .Wrapf (err , "unable to get latest branch commit" )
146
+ return errors .Wrapf (err , "get latest branch commit" )
147
147
}
148
148
logrus .Infof ("Found latest %s commit %s" , remoteBranch , head )
149
149
@@ -158,7 +158,7 @@ func runChangelog(opts *changelogOptions, rootOpts *rootOptions) error {
158
158
if err := document .CreateDownloadsTable (
159
159
downloadsTable , opts .bucket , opts .tars , previousTag , opts .tag ,
160
160
); err != nil {
161
- return errors .Wrapf (err , "unable to create downloads table" )
161
+ return errors .Wrapf (err , "create downloads table" )
162
162
}
163
163
164
164
// New final minor versions should have remote release notes
@@ -168,7 +168,7 @@ func runChangelog(opts *changelogOptions, rootOpts *rootOptions) error {
168
168
// New minor alphas, betas and rc get generated notes
169
169
latestTags , tErr := github .New ().LatestGitHubTagsPerBranch ()
170
170
if tErr != nil {
171
- return errors .Wrap (tErr , "unable to get latest GitHub tags" )
171
+ return errors .Wrap (tErr , "get latest GitHub tags" )
172
172
}
173
173
174
174
if startTag , ok := latestTags [branch ]; ok {
@@ -205,22 +205,26 @@ func runChangelog(opts *changelogOptions, rootOpts *rootOptions) error {
205
205
}
206
206
defer func () {
207
207
if err := repo .Checkout (currentBranch ); err != nil {
208
- logrus .Errorf ("unable to restore branch %s: %v" , currentBranch , err )
208
+ logrus .Errorf ("restore branch %s: %v" , currentBranch , err )
209
209
}
210
210
}()
211
211
212
+ logrus .Infof ("Checking out %s branch" , git .Master )
212
213
if err := repo .Checkout (git .Master ); err != nil {
213
214
return errors .Wrap (err , "checking out master branch" )
214
215
}
215
216
217
+ logrus .Info ("Writing markdown" )
216
218
if err := writeMarkdown (repo , toc , markdown , tag ); err != nil {
217
219
return err
218
220
}
219
221
222
+ logrus .Info ("Writing HTML" )
220
223
if err := writeHTML (opts , tag , markdown ); err != nil {
221
224
return err
222
225
}
223
226
227
+ logrus .Info ("Committing changes" )
224
228
return commitChanges (repo , branch , tag )
225
229
}
226
230
@@ -302,7 +306,7 @@ func writeMarkdown(repo *git.Repo, toc, markdown string, tag semver.Version) err
302
306
tocEndIndex := bytes .Index (content , []byte (tocEnd ))
303
307
if tocEndIndex < 0 {
304
308
return errors .Errorf (
305
- "unable to find table of contents end marker `%s` in %q" ,
309
+ "find table of contents end marker `%s` in %q" ,
306
310
tocEnd , changelogPath ,
307
311
)
308
312
}
@@ -366,7 +370,7 @@ func writeHTML(opts *changelogOptions, tag semver.Version, markdown string) erro
366
370
md := goldmark .New (goldmark .WithExtensions (extension .GFM ))
367
371
content := & bytes.Buffer {}
368
372
if err := md .Convert ([]byte (markdown ), content ); err != nil {
369
- return errors .Wrap (err , "unable to render HTML from markdown" )
373
+ return errors .Wrap (err , "render HTML from markdown" )
370
374
}
371
375
372
376
t , err := template .New ("html" ).Parse (htmlTemplate )
@@ -385,7 +389,7 @@ func writeHTML(opts *changelogOptions, tag semver.Version, markdown string) erro
385
389
if err != nil {
386
390
return err
387
391
}
388
- logrus .Infof ("Writing single HTML to %s" , absOutputPath )
392
+ logrus .Infof ("Writing HTML file to %s" , absOutputPath )
389
393
return ioutil .WriteFile (absOutputPath , output .Bytes (), os .FileMode (0644 ))
390
394
}
391
395
@@ -431,21 +435,24 @@ func commitChanges(repo *git.Repo, branch string, tag semver.Version) error {
431
435
}
432
436
433
437
if branch != git .Master {
438
+ logrus .Infof ("Checking out %s branch" , branch )
434
439
// Release branch modifications
435
440
if err := repo .Checkout (branch ); err != nil {
436
441
return errors .Wrapf (err , "checking out release branch %s" , branch )
437
442
}
438
443
439
444
// Remove all other changelog files if we’re on the first RC
440
445
if len (tag .Pre ) > 1 && tag .Pre [0 ].String () == "rc" && tag .Pre [1 ].String () == "1" {
441
- if err := repo .Rm (true , repoChangelogDir + "/CHANGELOG-*.md" ); err != nil {
442
- return errors .Wrap (err , "unable to remove CHANGELOG-*.md files" )
446
+ pattern := filepath .Join (repoChangelogDir , "CHANGELOG-*.md" )
447
+ logrus .Infof ("Removing unnecessary %s files" , pattern )
448
+ if err := repo .Rm (true , pattern ); err != nil {
449
+ return errors .Wrapf (err , "removing %s files" , pattern )
443
450
}
444
451
}
445
452
446
453
logrus .Info ("Checking out changelog from master branch" )
447
454
if err := repo .Checkout (git .Master , releaseChangelog ); err != nil {
448
- return errors .Wrap (err , "unable to check out master branch changelog" )
455
+ return errors .Wrap (err , "check out master branch changelog" )
449
456
}
450
457
451
458
logrus .Info ("Committing changes to release branch in repository" )
@@ -463,7 +470,7 @@ func adaptChangelogReadmeFile(repo *git.Repo, tag semver.Version) error {
463
470
targetFile := filepath .Join (repo .Dir (), repoChangelogDir , "README.md" )
464
471
readme , err := ioutil .ReadFile (targetFile )
465
472
if err != nil {
466
- return errors .Wrap (err , "unable to read changelog README.md" )
473
+ return errors .Wrap (err , "read changelog README.md" )
467
474
}
468
475
469
476
cf := filepath .Base (markdownChangelogFilename (tag ))
@@ -487,7 +494,7 @@ func adaptChangelogReadmeFile(repo *git.Repo, tag semver.Version) error {
487
494
const nl = "\n "
488
495
if err := ioutil .WriteFile (
489
496
targetFile , []byte (strings .Join (res , nl )+ nl ), os .FileMode (0644 )); err != nil {
490
- return errors .Wrap (err , "unable to write changelog README.md" )
497
+ return errors .Wrap (err , "write changelog README.md" )
491
498
}
492
499
return nil
493
500
}
0 commit comments