Fix handling tag on excluded commits and even if there is no message for this version
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
Benjamin Renard 2022-12-12 19:15:55 +01:00
parent f659811be5
commit 70381153b9

43
gitdch
View file

@ -248,14 +248,18 @@ def clean_deb_version(version_name):
def add_version(): def add_version():
""" Add version info """ """ Add version info """
if messages: global messages # pylint: disable=global-statement
log.info('Add version %s:\n - %s', version, '\n - '.join(messages)) if not version_commit:
versions.append({ return
'name': version, if not messages:
'tag': tag, messages = ['Release version {0}'.format(version)]
'commit': version_commit, log.info('Add version %s:\n - %s', version, '\n - '.join(messages))
'messages': messages, versions.append({
}) 'name': version,
'tag': tag,
'commit': version_commit,
'messages': messages
})
tag = None tag = None
@ -268,18 +272,7 @@ version = (
) )
messages = [] messages = []
for commit in repo.iter_commits(rev=options.revision): for commit in repo.iter_commits(rev=options.revision):
if version_commit is None:
version_commit = commit
log.debug('Commit %s (%s)', commit, commit.summary) log.debug('Commit %s (%s)', commit, commit.summary)
excluded = False
for regex in options.exclude:
if regex.search(commit.summary):
excluded = True
log.debug(
'Exclude commit %s ("%s", match with "%s")',
commit, commit.summary, regex.pattern)
if excluded:
continue
if commit.binsha in tag_commits: if commit.binsha in tag_commits:
new_tag = tag_commits[commit.binsha] new_tag = tag_commits[commit.binsha]
log.debug('Reach new tag %s', new_tag) log.debug('Reach new tag %s', new_tag)
@ -291,7 +284,17 @@ for commit in repo.iter_commits(rev=options.revision):
version_commit = commit version_commit = commit
messages = [] messages = []
log.debug('Iter commits for version %s', version) log.debug('Iter commits for version %s', version)
messages.append(commit.summary) if version_commit is None:
version_commit = commit
excluded = False
for regex in options.exclude:
if regex.search(commit.summary):
excluded = True
log.debug(
'Exclude commit %s ("%s", match with "%s")',
commit, commit.summary, regex.pattern)
if not excluded:
messages.append(commit.summary)
add_version() add_version()
log.info('%d versions found', len(versions)) log.info('%d versions found', len(versions))