Fixed version of this patch, I missed that parse_commit was used twice on my first try. Sorry for that.
Closes: #561346 Thanks: Matthijs Kooijman --- docs/chapters/releases.sgml | 18 +++++++++++++ docs/manpages/git-dch.sgml | 4 +- git-dch | 58 +++++++++++++++++++++++++++++------------- 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/docs/chapters/releases.sgml b/docs/chapters/releases.sgml index 95c2335..00fb76f 100644 --- a/docs/chapters/releases.sgml +++ b/docs/chapters/releases.sgml @@ -115,5 +115,23 @@ via &git-dch;'s <option>--id-length</option> option. Using </screen> This makes it much easier to see which commit actually fixed bug #1000. </para> +<para> +Finally, there is the <option>Git-Dch:</option> header that can +currently only be set to <option>Ignore</option> (or omitted). When this +header is set to <option>Ignore</option>, the commit message is +completely ignored and will not be included in the changelog at all. +This is useful for janitorial commits or other commits that really don't +need to end up in the changelog. + +</para><para> +For example, the following git commit message +<screen> +Set correct branchnames in debian/gbp.conf + +Git-Dch: Ignore +</screen> +will not show up in the generated changelog in any way. +</para> + </sect1> </chapter> diff --git a/docs/manpages/git-dch.sgml b/docs/manpages/git-dch.sgml index 890df67..4c4a6f7 100644 --- a/docs/manpages/git-dch.sgml +++ b/docs/manpages/git-dch.sgml @@ -107,8 +107,8 @@ <varlistentry> <term><option>--[no-]meta</option></term> <listitem> - <para>Parse meta tags like <option>Closes:</option> and - <option>Thanks:</option>. </para> + <para>Parse meta tags like <option>Closes:</option>, + <option>Thanks:</option> and <option>Git-Dch:</option>. </para> </listitem> </varlistentry> <varlistentry> diff --git a/git-dch b/git-dch index 1051f82..b68ea72 100755 --- a/git-dch +++ b/git-dch @@ -198,6 +198,7 @@ def parse_commit(repo, commitid, options): msg = '' thanks = '' closes = '' + git_dch = '' bugs = {} bts_closes = re.compile(r'(?P<bts>%s):\s+%s' % (options.meta_closes, bug_r), re.I) @@ -217,6 +218,8 @@ def parse_commit(repo, commitid, options): bugs[m.group('bts')] = bug_nums elif line.startswith('Thanks: '): thanks = line.split(' ', 1)[1].strip() + elif line.startswith('Git-Dch: '): + git_dch = line.split(' ', 1)[1].strip() else: # normal commit message if msg and not options.full: continue @@ -226,6 +229,8 @@ def parse_commit(repo, commitid, options): elif line.startswith('diff '): break if options.meta: + if git_dch == 'Ignore': + return None for bts in bugs: closes += '(%s: %s) ' % (bts, ', '.join(bugs[bts])) if thanks: @@ -241,8 +246,11 @@ def shortlog_to_dch(repo, commits, options): author = 'Unknown' for commit in commits: - msg, (author, email) = parse_commit(repo, commit, options) - add_changelog_entry(msg, author, email) + parsed = parse_commit(repo, commit, options) + # Allow commits to be ignored. + if parsed: + msg, (author, email) = parsed + add_changelog_entry(msg, author, email) def guess_snapshot_commit(cp, repo, options): @@ -371,25 +379,39 @@ def main(argv): else: add_section = False - if add_section: - if commits: - first_commit = commits[0] - commits = commits[1:] - commit_msg, (commit_author, commit_email) = parse_commit(repo, first_commit, options) + for c in commits: + parsed = parse_commit(repo, c, options) + if not parsed: + # Some commits can be ignored + continue + + commit_msg, (commit_author, commit_email) = parsed + if add_section: + # Add a section containing just this message (we can't + # add an empty section with dch). + add_changelog_section(distribution="UNRELEASED", msg=commit_msg, + version=options.new_version, author=commit_author, + email=commit_email) + # Adding a section only needs to happen once. + add_section = False else: - commit_msg = "UNRELEASED" - commit_author = None - commit_email = None - add_changelog_section(distribution="UNRELEASED", msg=commit_msg, - version=options.new_version, author=commit_author, - email=commit_email) - - if commits: - shortlog_to_dch(repo, commits, options) - fixup_trailer(repo, git_author=options.git_author) - elif not first_commit: + add_changelog_entry(commit_msg, commit_author, commit_email) + + + # Show a message if there were no commits (not even ignored + # commits). + if not commits: print "No changes detected from %s to %s." % (since, until) + if add_section: + # If we end up here, then there were no commits to include, + # so we put a dummy message in the new section. + commit_msg = "UNRELEASED" + add_changelog_section(distribution="UNRELEASED", msg="UNRELEASED", + version=options.new_version) + + fixup_trailer(repo, git_author=options.git_author) + if options.release: do_release(changelog, cp) elif options.snapshot: -- 1.6.5.4 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org