Add option to add links to changelog

Allows creating links in changelog, similar to what Github does
for markdown but works for dependencies as well.

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
This commit is contained in:
Derek McGowan
2018-08-28 17:49:35 -07:00
parent f76a5ec83a
commit 69e7c77e6a
2 changed files with 74 additions and 0 deletions

View File

@@ -116,11 +116,16 @@ This tool should be ran from the root of the project repository for a new releas
Usage: "template filepath to use in place of the default",
Value: defaultTemplateFile,
},
cli.BoolFlag{
Name: "linkify,l",
Usage: "add links to changelog",
},
}
app.Action = func(context *cli.Context) error {
var (
releasePath = context.Args().First()
tag = context.String("tag")
linkify = context.Bool("linkify")
)
if tag == "" {
tag = parseTag(releasePath)
@@ -150,6 +155,11 @@ This tool should be ran from the root of the project repository for a new releas
if err != nil {
return err
}
if linkify {
if err := linkifyChanges(changes, githubCommitLink(r.GithubRepo), githubPRLink(r.GithubRepo)); err != nil {
return err
}
}
if err := addContributors(r.Previous, r.Commit, contributors); err != nil {
return err
}
@@ -221,6 +231,16 @@ This tool should be ran from the root of the project repository for a new releas
if err := addContributors(dep.Previous, dep.Commit, contributors); err != nil {
return errors.Wrapf(err, "failed to get authors for %s", name)
}
if linkify {
if !strings.HasPrefix(dep.Name, "github.com/") {
logrus.Debugf("linkify only supported for Github, skipping %s", dep.Name)
} else {
ghname := dep.Name[11:]
if err := linkifyChanges(changes, githubCommitLink(ghname), githubPRLink(ghname)); err != nil {
return err
}
}
}
projectChanges = append(projectChanges, projectChange{
Name: name,