From 8b8c1372ec7564a6e603dcf54554f246671a422c Mon Sep 17 00:00:00 2001 From: Guido Günther Date: Fri, 14 Nov 2008 13:40:02 +0100 Subject: gather all invocations of dch in one function fixes dch failures due to missing quotes introduced by [7f24b98] --- git-dch | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/git-dch b/git-dch index 3c1667c5..6133a3cf 100755 --- a/git-dch +++ b/git-dch @@ -44,33 +44,48 @@ def escape_commit(msg): return msg.replace('"','\\\"').replace("$","\$").replace("`","\`") -def add_changelog_entry(msg, author, email): - "add aa single changelog entry" - cmd = """DEBFULLNAME="%s" DEBEMAIL="%s" dch --no-auto-nmu --append -- "%s" """ % (author, email, escape_commit(msg)) - system(cmd) +def spawn_dch(msg='', author=None, email=None, newversion=False, version=None, release=False, distribution=None): + distopt = "" + versionopt = "" + env = "" -def add_changelog_section(msg, distribution, newversion=None, author=None, email=None): - "add a new changelog section" if newversion: - versionopt = '--newversion=%s' % newversion - else: - versionopt = '-i' + if version: + versionopt = '--newversion=%s' % version + else: + versionopt = '-i' + elif release: + versionopt = "--release" + msg = None if author and email: env = """DEBFULLNAME="%s" DEBEMAIL="%s" """ % (author, email) - else: - env = "" - cmd = "%s dch --no-auto-nmu --distribution=%s %s %s" % (env, distribution, versionopt, escape_commit(msg)) + + if distribution: + distopt = "--distribution=%s" % distribution + + cmd = '%(env)s dch --no-auto-nmu %(distopt)s %(versionopt)s ' % locals() + if type(msg) == type(''): + cmd += '"%s"' % escape_commit(msg) system(cmd) +def add_changelog_entry(msg, author, email): + "add aa single changelog entry" + spawn_dch(msg=msg, author=author, email=email) + + +def add_changelog_section(msg, distribution, author=None, email=None, version=None): + "add a new changelog section" + spawn_dch(msg=msg, newversion= True, version=version, author=author, email=email, distribution=distribution) + + def fixup_trailer(): """fixup the changelog trailer's comitter and email address - it might otherwise point to the last git committer instead of the person creating the changelog""" - cmd = "dch \"\"" - system(cmd) + spawn_dch(msg='') def head_commit(): @@ -139,8 +154,7 @@ def do_release(changelog, cp): if snapshot: cp['MangledVersion'] = release mangle_changelog(changelog, cp) - cmd = "dch --release" - system(cmd) + spawn_dch(release=True) def do_snapshot(changelog, next_snapshot): @@ -339,7 +353,7 @@ def main(argv): commit_author = None commit_email = None add_changelog_section(distribution="UNRELEASED", msg=commit_msg, - newversion=options.new_version, author=commit_author, + version=options.new_version, author=commit_author, email=commit_email) if commits: -- cgit v1.2.3