Hello, One draw back I just fixed, unset options without default values are None, so I do not change the ChangeLog field in that case too.
My branch is now public[1]. Regards. diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index a82c1bd..acf11eb 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -195,6 +195,24 @@ def mangle_changelog(changelog, cp, snapshot=''): raise GbpError, "Error mangling changelog %s" % e +def apply_options_to_changelog_entry(cp, options): + """ + Modify the changelog entry accordingly with user options. + Actual options is 'distributions' and 'urgency'. + """ + used_options = {'distribution':'UNRELEASED', 'urgency':'low'} + for opt, default in used_options.items(): + if hasattr(options, opt) and getattr(options, opt) not in [ cp[ opt.capitalize() ], None ]: + gbp.log.debug("Replace changelog '%s' from '%s' to '%s'" \ + % (opt.capitalize(), cp[opt.capitalize()], getattr(options, opt))) + del(cp[ opt.capitalize() ]) + cp[ opt.capitalize() ] = getattr(options, opt) + elif hasattr(options, opt) and getattr(options, opt) == None: + setattr(options, opt, default) + + return cp + + def do_release(changelog, repo, cp, git_author, dch_options): "remove the snapshot header and set the distribution" author, email = get_author_email(repo, git_author) @@ -205,7 +223,7 @@ def do_release(changelog, repo, cp, git_author, dch_options): spawn_dch(release=True, author=author, email=email, dch_options=dch_options) -def do_snapshot(changelog, repo, next_snapshot): +def do_snapshot(changelog, repo, options): """ Add new snapshot banner to most recent changelog section. The next snapshot number is calculated by eval()'ing next_snapshot @@ -213,8 +231,10 @@ def do_snapshot(changelog, repo, next_snapshot): commit = repo.head cp = parse_changelog(filename=changelog) + cp = apply_options_to_changelog_entry(cp, options) + (release, snapshot) = snapshot_version(cp['Version']) - snapshot = int(eval(next_snapshot)) + snapshot = int(eval(options.snapshot_number)) suffix = "%d.gbp%s" % (snapshot, "".join(commit[0:6])) cp['MangledVersion'] = "%s~%s" % (release, suffix) @@ -281,6 +301,9 @@ def process_options(options, parser): else: dch_options += " --nomultimaint" + if options.force_distribution: + dch_options += " --force-distribution" + get_customizations(options.customization_file) return dch_options @@ -342,8 +365,12 @@ 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("-U", "--urgency", dest="urgency", help="Set urgency level") version_group.add_option("--bpo", dest="bpo", action="store_true", default=False, help="Increment the Debian release number for an upload to lenny-backports, and add a backport upload changelog comment.") version_group.add_option("--nmu", dest="nmu", action="store_true", default=False, @@ -433,6 +460,9 @@ def main(argv): else: add_section = False + # Apply user option here to avoid clash with add_section test above + cp = apply_options_to_changelog_entry(cp, options) + i = 0 for c in commits: i += 1 @@ -446,7 +476,7 @@ def main(argv): 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, + add_changelog_section(distribution=options.distribution, msg=commit_msg, version=version_change, author=commit_author, email=commit_email, @@ -468,7 +498,7 @@ def main(argv): 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. - add_changelog_section(distribution="UNRELEASED", msg=["UNRELEASED"], + add_changelog_section(distribution=options.distribution, msg=["UNRELEASED"], version=version_change, dch_options=dch_options, repo=repo, @@ -482,7 +512,7 @@ def main(argv): do_release(changelog, repo, cp, git_author=options.git_author, dch_options=dch_options) elif options.snapshot: - (snap, version) = do_snapshot(changelog, repo, options.snapshot_number) + (snap, version) = do_snapshot(changelog, repo, options) gbp.log.info("Changelog has been prepared for snapshot #%d at %s" % (snap, version)) if editor_cmd: Footnotes: [1] git pull git://git.baby-gnu.org/git-buildpackage dad/dch-configurable-changelog-entry -- Daniel Dehennin Récupérer ma clef GPG: gpg --keyserver pgp.mit.edu --recv-keys 0x6A2540D1
pgp6spzwGgyl5.pgp
Description: PGP signature