Skip to content

Commit

Permalink
feat: make commit message configurable (#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
claymcleod committed Mar 3, 2020
1 parent 1b7f46c commit eb0762c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
8 changes: 6 additions & 2 deletions docs/configuration.rst
Expand Up @@ -43,9 +43,13 @@ Moreover, those configuration values can be overloaded with the ``-D`` option, l
If set to false, do not upload distributions to GitHub releases. If you are not using
GitHub, this will be skipped regardless.

``commit_subject``
Git commit subject line. Accepts the following variables as format fields: [``{version}``].
Default: ``{version}``

``commit_message``
Long description to append to the version number. This can be useful to skip
pipelines in your CI tool
Git commit message body. Accepts the following variables as format fields: [``{version}``].
Default: ``Automatically generated by python-semantic-release``

``commit_author``
Author used in commits in git format ``name <email>``. Default: ``semantic-release <semantic-release>``
Expand Down
4 changes: 2 additions & 2 deletions semantic_release/cli.py
Expand Up @@ -263,8 +263,8 @@ def main(**kwargs):
debug('main env:', filter_output_for_secrets(message))

obj = {}
for key in ['check_build_status', 'commit_message', 'commit_parser', 'patch_without_tag',
'upload_to_pypi', 'version_source']:
for key in ['check_build_status', 'commit_subject', 'commit_message', 'commit_parser',
'patch_without_tag', 'upload_to_pypi', 'version_source']:
val = config.get('semantic_release', key)
obj[key] = val
debug('main config:', obj)
Expand Down
1 change: 1 addition & 0 deletions semantic_release/defaults.cfg
Expand Up @@ -8,6 +8,7 @@ commit_parser=semantic_release.history.angular_parser
upload_to_pypi=true
upload_to_release=true
version_source=commit
commit_subject={version}
commit_message=Automatically generated by python-semantic-release
dist_path=dist
remove_dist=true
Expand Down
7 changes: 6 additions & 1 deletion semantic_release/vcs_helpers.py
Expand Up @@ -120,8 +120,13 @@ def commit_new_version(version: str):
"""

check_repo()
commit_subject = config.get('semantic_release', 'commit_subject')
commit_message = config.get('semantic_release', 'commit_message')
message = '{0}\n\n{1}'.format(version, commit_message)

message = commit_subject.format(version=version)
if commit_message:
message += "\n\n"
message += commit_message.format(version=version)

commit_author = config.get('semantic_release', 'commit_author',
fallback='semantic-release <semantic-release>')
Expand Down

0 comments on commit eb0762c

Please sign in to comment.