A changelog formatter for Changesets that adds commit and issue/PR links
Atlassian Changesets is a changelog management tool. Its default changelog formatter only generates a plain list of changes.
This package adds links to the git commits, issues, and pull requests where your changesets were added.
The result is similar to the output of other common changelog managers, such as standard-version and Release Please.
If you have already set up Changesets, you only need to install the package and add it to your .changeset/config.json
.
You do not need to enable the commit
option in your config.
npm install --save-dev changesets-format-with-git-links
// .changeset/config.json
{
"changelog": [
"changesets-format-with-git-links",
{
"repoBaseUrl": "https://github.com/your-username/repo",
// This will inject issue and commit links to the end of the first line of your changeset message
"changesetTemplate": "- ${changesetTitle}${issue}${commit}${changesetBody}"
}
]
}
A base url -- including https
-- which can be used to build links in commitTemplate
and issueTemplate
.
Example: "https://github.com/spautz/changesets-changelog-format"
Content that will be added to your changelog.
With the deafult value, issue and commit links will be inserted at the end of the first line of your changeset message.
See commitTemplate
for the $commit
variable, issueTemplate
for the $issue
variable, and Template Variables
for other available values.
Content for the $commit
variable, based on the commit when the changeset was created.
See gitlogOptions
below for information on the available fields from the commit.
Content for the $commit
variable when no commit could be found. This should generally be left blank.
Regular expression (without the leading and trailing /
) used to identify issues and pull requests in the subject line
of a commit message. The default will match a number immediately followed by a closing parentheses, like #4)
.
If the commit message matches this pattern, the Regex result will be available as $issueMatch
and the text inside the
capturing group ((\d+)
in the default) will be available as $issue
in the issueTemplate
, below.
Content for the $issue
variable, based on the value matched by issuePattern
.
Content for the $issue
variable when no issue or pull request could be found. This should generally be left blank.
Default:
{
"repo": ".",
"number": 1,
"fields": ["hash", "abbrevHash", "subject"],
"includeMergeCommitFiles": true
}
Options passed to gitlog (see docs here).
This can be used to add additional fields
to the template, or to change the
behavior of the git log search.
This works by identifying the git commit when a changeset entry was added or updated, looking for an issue number, and then using templates to append the git links (commit and issue number, if present) to the changelog entry.
Inside any of the templates (changesetTemplate
, commitTemplate
, commitMissingTemplate
, issueTemplate
, or issueMissingTemplate
),
any token that starts with $
or which is wrapped within ${...}
will be treated as a variable.
Use \\$
to escape the dollar sign character if you do not want it to be treated as a variable.
Information from the changeset entry:
$changesetTitle
$changesetBody
$changesetRawBody
$versionType
-
$changesetInfo
contains all of the above, and any other information from Changesets (e.g.,${changesetInfo.changesetTitle}
,${changesetInfo.versionType}
).
Information from the git commit when the changeset was added or modified:
$hash
$abbrevHash
$summary
- Anything you requested via
gitlogOptions.fields
-
$commit
is generated fromcommitTemplate
(orcommitMissingTemplate
if the commit was not found) -
$commitInfo
contains all of the above (e.g.,${commitInfo.abbrevHash}
,${commitInfo.hash}
).
Information from the matched issue pattern, if any:
-
$issue
is generated fromissueTemplate
(orissueMissingTemplate
if no issue not found) -
$issueMatch
contains all of the results from the match againstissuePattern
(e.g.,${issueMatch[1]}
})
And also any additional values you added to the options in your .changeset/config.json
(such as $repoBaseUrl
)