Skip to content

Commit

Permalink
feat(history): allow customizing changelog_sections (#207)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Amorim committed Apr 1, 2020
1 parent 0f57662 commit d5803d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
19 changes: 19 additions & 0 deletions docs/configuration.rst
Expand Up @@ -97,6 +97,25 @@ Default: ``semantic-release <semantic-release>``
If you are using the built-in GitHub Action, this is always set to
``github-actions <actions@github.com>``.

Changelog
=========

``changelog_sections``
-----------------------
Comma-separated list of sections to display in the changelog.
They will be displayed in the order they are given.

The available options are:

* ``feature``
* ``fix``
* ``documentation``
* ``refactor``
* ``performance``
* ``breaking``

Default: `feature, fix, breaking, documentation, performance`

Distributions
=============

Expand Down
1 change: 1 addition & 0 deletions semantic_release/defaults.cfg
Expand Up @@ -14,3 +14,4 @@ dist_path=dist
remove_dist=true
build_command=python setup.py sdist bdist_wheel
branch=master
changelog_sections=feature,fix,breaking,documentation,performance
19 changes: 7 additions & 12 deletions semantic_release/history/logs.py
Expand Up @@ -17,16 +17,6 @@
3: 'major',
}

# Sections which will be shown in the Markdown changelog.
# This is NOT related to supported commit types.
CHANGELOG_SECTIONS = [
'feature',
'fix',
'breaking',
'documentation',
'performance',
]


def evaluate_version_bump(current_version: str, force: str = None) -> Optional[str]:
"""
Expand Down Expand Up @@ -173,8 +163,13 @@ def markdown_changelog(version: str, changelog: dict, header: bool = False) -> s
# Add a heading with the version number
output += '## v{0}\n'.format(version)

for section in CHANGELOG_SECTIONS:
if not changelog[section]:
# Sections which will be shown in the Markdown changelog.
# This is NOT related to supported commit types.
changelog_sections = config.get("semantic_release", "changelog_sections")
changelog_sections = [s.strip() for s in changelog_sections.split(',')]

for section in changelog_sections:
if section not in changelog or not changelog[section]:
# This section does not have any commits
continue

Expand Down

0 comments on commit d5803d5

Please sign in to comment.