From f659811be5ebc80531bf916f9c8bab36b86fbf56 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 12 Dec 2022 15:05:09 +0100 Subject: [PATCH] Add -x/--exclude parameter to allow to exclude some commits from generated changelog --- gitdch | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/gitdch b/gitdch index e856523..a7f0e93 100755 --- a/gitdch +++ b/gitdch @@ -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))