From b72702fdd4adbdebdbe8c5aed080079196563969 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 17 Apr 2012 22:17:20 +0200 Subject: Bug#669145: [PATCH] Add git-dch --commit and --commit-msg options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes: #669145 Signed-off-by: Guido Günther --- docs/manpages/git-dch.sgml | 20 ++++++++++++++++++++ gbp/config.py | 5 ++++- gbp/scripts/dch.py | 19 ++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/docs/manpages/git-dch.sgml b/docs/manpages/git-dch.sgml index 6dfe7bb9..bf67d500 100644 --- a/docs/manpages/git-dch.sgml +++ b/docs/manpages/git-dch.sgml @@ -37,6 +37,8 @@ + msg-format + [path1 path2] @@ -221,6 +223,24 @@ when doing a release. + + msg-format + + + use this format string for the commit message when + committing the generated changelog file (when + is given). Default is + Update changelog for %(version)s + release + + + + + + + Commit the generated changelog. + + diff --git a/gbp/config.py b/gbp/config.py index 35c78b40..d406d1ec 100644 --- a/gbp/config.py +++ b/gbp/config.py @@ -86,6 +86,7 @@ class GbpOptionParser(OptionParser): 'debian-tag' : 'debian/%(version)s', 'upstream-tag' : 'upstream/%(version)s', 'import-msg' : 'Imported Upstream version %(version)s', + 'commit-msg' : 'Update changelog for %(version)s release', 'filter' : [], 'snapshot-number' : 'snapshot + 1', 'git-log' : '--no-merges', @@ -144,7 +145,9 @@ class GbpOptionParser(OptionParser): 'keyid': "GPG keyid to sign tags with, default is '%(keyid)s'", 'import-msg': - "format string for commit message, default is '%(import-msg)s'", + "format string for git-import-orig commit message, default is '%(import-msg)s'", + 'commit-msg': + "format string for git-dch commit message, default is '%(commit-msg)s'", 'pristine-tar': "use pristine-tar to create orig tarball, default is '%(pristine-tar)s'", 'pristine-tar-commit': diff --git a/gbp/scripts/dch.py b/gbp/scripts/dch.py index 3a4a02ad..14dff295 100644 --- a/gbp/scripts/dch.py +++ b/gbp/scripts/dch.py @@ -246,7 +246,6 @@ def do_snapshot(changelog, repo, next_snapshot): mangle_changelog(changelog, cp, commit) return snapshot, commit - def parse_commit(repo, commitid, opts, last_commit=False): """Parse a commit and return message, author, and author email""" commit_info = repo.get_commit_info(commitid) @@ -324,6 +323,10 @@ def process_editor_option(options): return None +def changelog_commit_msg(options, version): + return options.commit_msg % dict(version=version) + + def main(argv): ret = 0 changelog = 'debian/changelog' @@ -392,6 +395,10 @@ def main(argv): commit_group.add_boolean_config_file_option(option_name="multimaint", dest="multimaint") commit_group.add_boolean_config_file_option(option_name="multimaint-merge", dest="multimaint_merge") commit_group.add_config_file_option(option_name="spawn-editor", dest="spawn_editor") + parser.add_config_file_option(option_name="commit-msg", + dest="commit_msg") + parser.add_option("-c", "--commit", action="store_true", dest="commit", default=False, + help="commit changelog file after generating") help_msg = ('Load Python code from CUSTOMIZATION_FILE. At the moment,' ' the only useful thing the code can do is define a custom' @@ -516,6 +523,16 @@ def main(argv): if editor_cmd: gbpc.Command(editor_cmd, ["debian/changelog"])() + if options.commit: + # Get the version from the changelog file (since dch might + # have incremented it, there's no way we can already know + # the version). + version = ChangeLog(filename=changelog).version + # Commit the changes to the changelog file + msg = changelog_commit_msg(options, version) + repo.commit_files([changelog], msg) + gbp.log.info("Changelog has been committed for version %s" % version) + except (GbpError, GitRepositoryError, NoChangeLogError), err: if len(err.__str__()): gbp.log.err(err) -- cgit v1.2.3