Add -x/--exclude parameter to allow to exclude some commits from generated changelog
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 15:05:09 +01:00
parent d7ff1fd03f
commit f659811be5

27
gitdch
View file

@ -175,6 +175,20 @@ parser.add_argument(
default=[] default=[]
) )
parser.add_argument(
'-x', '--exclude',
action='append',
type=re.compile,
dest='exclude',
help=(
'Commit exclusion regex: you could specify regex to exclude some '
'commits from generated changelog entries. For instance, to exclude '
'commits with message starting with "CI: ", specify -x "^CI: " '
'(optional, multiple regex allowed)'
),
default=[]
)
options = parser.parse_args() options = parser.parse_args()
if not options.package_name: if not options.package_name:
@ -256,7 +270,16 @@ messages = []
for commit in repo.iter_commits(rev=options.revision): for commit in repo.iter_commits(rev=options.revision):
if version_commit is None: if version_commit is None:
version_commit = commit version_commit = commit
log.debug('Commit %s', commit) 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)
@ -267,7 +290,7 @@ for commit in repo.iter_commits(rev=options.revision):
version = clean_deb_version(tag.name) version = clean_deb_version(tag.name)
version_commit = commit version_commit = commit
messages = [] messages = []
log.debug('Iter commits for version %s') log.debug('Iter commits for version %s', version)
messages.append(commit.summary) messages.append(commit.summary)
add_version() add_version()
log.info('%d versions found', len(versions)) log.info('%d versions found', len(versions))