Skip to content

Commit

Permalink
fix(history): Fix changelog generation
Browse files Browse the repository at this point in the history
This enables regeneration of a given versions changelog.
  • Loading branch information
relekang committed Aug 19, 2015
1 parent 6493a58 commit f010272
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions semantic_release/history/__init__.py
Expand Up @@ -4,6 +4,7 @@
from invoke import run

from ..settings import config
from ..vcs_helpers import get_commit_log
from .logs import evaluate_version_bump # noqa

from .parser_angular import parse_commit_message as angular_parser # noqa isort:skip
Expand Down Expand Up @@ -31,6 +32,21 @@ def get_new_version(current_version, level_bump):
return current_version
return getattr(semver, 'bump_{0}'.format(level_bump))(current_version)

def get_previous_version(version):
"""
Returns the version prior to the given version.
:param version: A string with the version number.
"""
found_version = False
for commit_message in get_commit_log():
if version in commit_message:
found_version = True
if found_version:
if re.match(r'\d+.\d+.\d+', commit_message):
return commit_message.replace('v', '')



def set_new_version(new_version):
"""
Expand Down
12 changes: 10 additions & 2 deletions semantic_release/history/logs.py
Expand Up @@ -53,7 +53,7 @@ def evaluate_version_bump(current_version, force=None):
return bump


def generate_changelog(version):
def generate_changelog(from_version, to_version=None):
"""
Generates a changelog for the given version.
Expand All @@ -63,8 +63,16 @@ def generate_changelog(version):

changes = {'feature': [], 'fix': [], 'documentation': [], 'refactor': [], 'breaking': []}

found_the_release = to_version is None

for commit_message in get_commit_log():
if version in commit_message:
if not found_the_release:
if to_version and to_version not in commit_message:
continue
else:
found_the_release = True

if from_version is not None and from_version in commit_message:
break

try:
Expand Down

0 comments on commit f010272

Please sign in to comment.