Skip to content

Commit

Permalink
fix: Add commit hash when generating breaking changes
Browse files Browse the repository at this point in the history
Fixes #120
  • Loading branch information
daveenguyen authored and relekang committed Aug 5, 2019
1 parent 2c5dd80 commit 0c74faf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions semantic_release/history/logs.py
Expand Up @@ -102,12 +102,12 @@ def generate_changelog(from_version: str, to_version: str = None) -> dict:
if message[3][1] and 'BREAKING CHANGE' in message[3][1]:
parts = re_breaking.match(message[3][1])
if parts:
changes['breaking'].append(parts.group(1))
changes['breaking'].append((_hash, parts.group(1)))

if message[3][2] and 'BREAKING CHANGE' in message[3][2]:
parts = re_breaking.match(message[3][2])
if parts:
changes['breaking'].append(parts.group(1))
changes['breaking'].append((_hash, parts.group(1)))

except UnknownCommitMessageStyleError as err:
debug('Ignoring', err)
Expand Down
8 changes: 8 additions & 0 deletions tests/test_history.py
Expand Up @@ -111,6 +111,14 @@ def test_should_generate_all_sections(self):
self.assertGreater(len(changelog['fix']), 0)
self.assertGreater(len(changelog['breaking']), 0)

def test_should_include_hash_in_section_contents(self):
with mock.patch('semantic_release.history.logs.get_commit_log',
lambda *a, **k: ALL_KINDS_OF_COMMIT_MESSAGES):
changelog = generate_changelog('0.0.0')
self.assertEqual(changelog['breaking'][0][0], MAJOR[0])
self.assertEqual(changelog['feature'][0][0], MINOR[0])
self.assertEqual(changelog['fix'][0][0], PATCH[0])

def test_should_only_read_until_given_version(self):
with mock.patch('semantic_release.history.logs.get_commit_log',
lambda *a, **k: MAJOR_LAST_RELEASE_MINOR_AFTER):
Expand Down

0 comments on commit 0c74faf

Please sign in to comment.