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=[]
)
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()
if not options.package_name:
@ -256,7 +270,16 @@ messages = []
for commit in repo.iter_commits(rev=options.revision):
if version_commit is None:
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:
new_tag = tag_commits[commit.binsha]
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_commit = commit
messages = []
log.debug('Iter commits for version %s')
log.debug('Iter commits for version %s', version)
messages.append(commit.summary)
add_version()
log.info('%d versions found', len(versions))