Skip to content

Commit

Permalink
feat: Add support for commit_message config variable
Browse files Browse the repository at this point in the history
This variable can allow you to skip CI pipelines in CI tools like GitLab
CI by adding [CI skip] in the body. There are likely many uses for this
beyond that particular example...

BREAKING CHANGE: If you rely on the commit message to be the version
number only, this will break your code

re #88 #32
  • Loading branch information
cvockrodt authored and relekang committed Nov 21, 2018
1 parent 29c25d3 commit 4de5400
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/configuration.rst
Expand Up @@ -26,3 +26,6 @@ All configuration described here belongs in ``setup.cfg`` in a section:
If set to false the pypi uploading will be disabled. This can be useful to create
tag releases for non-pypi projects.

``commit_message``
Long description to append to the version number. This can be useful to skip
pipelines in your CI tool
1 change: 1 addition & 0 deletions semantic_release/defaults.cfg
Expand Up @@ -7,3 +7,4 @@ hvcs=github
commit_parser=semantic_release.history.angular_parser
upload_to_pypi=true
version_source=commit
commit_message=Automatically generated by python-semantic-release
4 changes: 3 additions & 1 deletion semantic_release/vcs_helpers.py
Expand Up @@ -80,8 +80,10 @@ def commit_new_version(version):
:param version: The version number to be used in the commit message
"""

commit_message = config.get('semantic_release', 'commit_message')
message = '{0}\n\n{1}'.format(version, commit_message)
repo.git.add(config.get('semantic_release', 'version_variable').split(':')[0])
return repo.git.commit(m=version, author="semantic-release <semantic-release>")
return repo.git.commit(m=message, author="semantic-release <semantic-release>")


def tag_new_version(version):
Expand Down
5 changes: 4 additions & 1 deletion tests/test_vcs_helpers.py
Expand Up @@ -21,7 +21,10 @@ def test_first_commit_is_not_initial_commit():
def test_add_and_commit(mock_git):
commit_new_version('1.0.0')
mock_git.add.assert_called_once_with('semantic_release/__init__.py')
mock_git.commit.assert_called_once_with(m='1.0.0', author="semantic-release <semantic-release>")
mock_git.commit.assert_called_once_with(
m='1.0.0\n\nAutomatically generated by python-semantic-release',
author="semantic-release <semantic-release>"
)


def test_tag_new_version(mock_git):
Expand Down

0 comments on commit 4de5400

Please sign in to comment.