Fix release notes generation even if no new version is detected
This commit is contained in:
parent
bbae5ea39e
commit
bc072ccf32
1 changed files with 25 additions and 18 deletions
43
gitdch
43
gitdch
|
@ -227,14 +227,6 @@ if not options.quiet or not options.logfile:
|
||||||
|
|
||||||
repo = git.Repo(options.git_path)
|
repo = git.Repo(options.git_path)
|
||||||
|
|
||||||
log.info('Generate changelog from git commits')
|
|
||||||
|
|
||||||
versions = []
|
|
||||||
tag_commits = dict(
|
|
||||||
(tag.commit.binsha, tag)
|
|
||||||
for tag in repo.tags
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def clean_deb_version(version_name):
|
def clean_deb_version(version_name):
|
||||||
""" Clean debian version name """
|
""" Clean debian version name """
|
||||||
|
@ -246,6 +238,21 @@ def clean_deb_version(version_name):
|
||||||
return version_name
|
return version_name
|
||||||
|
|
||||||
|
|
||||||
|
if not options.version:
|
||||||
|
log.info('Detect current version from git tags & commits')
|
||||||
|
options.version = clean_deb_version(
|
||||||
|
repo.git.describe('--always', '--tags')
|
||||||
|
)
|
||||||
|
log.info('Currrent version detected: %s', options.version)
|
||||||
|
log.info('Generate changelog from git commits')
|
||||||
|
|
||||||
|
versions = []
|
||||||
|
tag_commits = dict(
|
||||||
|
(tag.commit.binsha, tag)
|
||||||
|
for tag in repo.tags
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def add_version():
|
def add_version():
|
||||||
""" Add version info """
|
""" Add version info """
|
||||||
global messages # pylint: disable=global-statement
|
global messages # pylint: disable=global-statement
|
||||||
|
@ -264,12 +271,7 @@ def add_version():
|
||||||
|
|
||||||
tag = None
|
tag = None
|
||||||
version_commit = None
|
version_commit = None
|
||||||
version = (
|
version = options.version
|
||||||
options.version or
|
|
||||||
clean_deb_version(
|
|
||||||
repo.git.describe('--always', '--tags')
|
|
||||||
)
|
|
||||||
)
|
|
||||||
messages = []
|
messages = []
|
||||||
for commit in repo.iter_commits(rev=options.revision):
|
for commit in repo.iter_commits(rev=options.revision):
|
||||||
log.debug('Commit %s (%s)', commit, commit.summary)
|
log.debug('Commit %s (%s)', commit, commit.summary)
|
||||||
|
@ -350,10 +352,15 @@ else:
|
||||||
if options.release_notes:
|
if options.release_notes:
|
||||||
log.info('Generate Markdown release notes')
|
log.info('Generate Markdown release notes')
|
||||||
release_notes_lines = ['# Changelog:\n\n']
|
release_notes_lines = ['# Changelog:\n\n']
|
||||||
release_notes_lines.extend([
|
if versions:
|
||||||
'* {0}\n'.format(message)
|
release_notes_lines.extend([
|
||||||
for message in versions[0]['messages']
|
'* {0}\n'.format(message)
|
||||||
])
|
for message in versions[0]['messages']
|
||||||
|
])
|
||||||
|
else:
|
||||||
|
release_notes_lines.extend([
|
||||||
|
'* Release version {0}\n'.format(options.version)
|
||||||
|
])
|
||||||
log.info(
|
log.info(
|
||||||
'Write generated Markdown release notes in file %s',
|
'Write generated Markdown release notes in file %s',
|
||||||
options.release_notes)
|
options.release_notes)
|
||||||
|
|
Loading…
Reference in a new issue