From ae4a3683c3becac1c6dcc8efb2eececb7a630c32 Mon Sep 17 00:00:00 2001 From: Daniel Dehennin Date: Mon, 21 Nov 2011 15:44:41 +0100 Subject: Add option to manage distribution fields for non snapshot mode. The snapshot mode fails to merge two "debian/changelog" entries if the distribution is not "UNRELEASED". * tests/11_test_dch_main.py: test the new --distribution option to dch.main(). Add only meaningful tests, i.e. options alone and combined with --release and --snapshot. * git-dch (fixup_section): Rename as it's used to fix header in addition to trailer, this require a new named parameter "options". (main): Add version_group option "-D" and "--distribution" to specify the distribution name. Add version_group option "--force-distribution" to force the provided distribution to be used, used by "dch". Rename fixup_trailer() to fixup_section() and add options as parameters. * docs/manpages/git-dch.sgml: Update documentation for new options. Closes: #646684 --- gbp/scripts/dch.py | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'gbp/scripts/dch.py') diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index b31a67b..c06fb50 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -63,15 +63,30 @@ def get_author_email(repo, use_git_config): return author, email -def fixup_trailer(repo, git_author, dch_options): +def fixup_section(repo, git_author, options, dch_options): """ - Fixup the changelog trailer's comitter and email address. + Fixup the changelog header and trailer's comitter and email address It might otherwise point to the last git committer instead of the person creating the changelog + This apply --distribution and --urgency options passed to git-dch """ author, email = get_author_email(repo, git_author) - ChangeLog.spawn_dch(msg='', author=author, email=email, dch_options=dch_options) + used_options = ['distribution'] + header_opts = [] + + # This must not be done for snapshots or snapshots changelog entries + # will not be concatenated + if not options.snapshot: + for opt in used_options: + val = getattr(options, opt) + if val: + gbp.log.debug("Set header option '%s' to '%s'" % (opt, val)) + header_opts.append("--%s=%s" % (opt, val)) + else: + gbp.log.debug("Snapshot enabled: do not fixup options in header") + + ChangeLog.spawn_dch(msg='', author=author, email=email, dch_options=dch_options+header_opts) def snapshot_version(version): @@ -223,6 +238,9 @@ def process_options(options, parser): else: dch_options.append("--nomultimaint") + if options.force_distribution: + dch_options.append("--force-distribution") + get_customizations(options.customization_file) return dch_options @@ -295,6 +313,9 @@ def main(argv): help="mark as release") version_group.add_option("-S", "--snapshot", action="store_true", dest="snapshot", default=False, help="mark as snapshot build") + version_group.add_option("-D", "--distribution", dest="distribution", help="Set distribution") + version_group.add_option("--force-distribution", action="store_true", dest="force_distribution", default=False, + help="Force the provided distribution to be used, even if it doesn't match the list of known distributions") version_group.add_option("-N", "--new-version", dest="new_version", help="use this as base for the new version number") version_group.add_option("--bpo", dest="bpo", action="store_true", default=False, @@ -446,7 +467,7 @@ def main(argv): version=version_change, dch_options=dch_options) - fixup_trailer(repo, git_author=options.git_author, + fixup_section(repo, git_author=options.git_author, options=options, dch_options=dch_options) if options.release: -- cgit v1.2.3