diff options
author | Matthijs Kooijman <matthijs@stdin.nl> | 2012-04-17 22:17:20 +0200 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2012-04-19 00:23:28 +0200 |
commit | b72702fdd4adbdebdbe8c5aed080079196563969 (patch) | |
tree | c1e35b2a85a6a87f557f5edd4679883d50e768c4 | |
parent | 5826e9c2f5ae4fad2954ba02a43849ce237050a2 (diff) |
Bug#669145: [PATCH] Add git-dch --commit and --commit-msg options
Closes: #669145
Signed-off-by: Guido Günther <agx@sigxcpu.org>
-rw-r--r-- | docs/manpages/git-dch.sgml | 20 | ||||
-rw-r--r-- | gbp/config.py | 5 | ||||
-rw-r--r-- | 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 @@ <arg><option>--[no-]git-author</option></arg> <arg><option>--[no-]multimaint-merge</option></arg> <arg><option>--spawn-editor=[always|snapshot|release]</option></arg> + <arg><option>--commit-msg=</option><replaceable>msg-format</replaceable></arg> + <arg><option>--commit</option></arg> <arg choice="plain"><replaceable>[path1 path2]</replaceable></arg> </cmdsynopsis> </refsynopsisdiv> @@ -221,6 +223,24 @@ when doing a release.</para> </listitem> </varlistentry> + <varlistentry> + <term><option>--commit-msg=</option><replaceable>msg-format</replaceable> + </term> + <listitem> + <para>use this format string for the commit message when + committing the generated changelog file (when + <option>--commit</option> is given). Default is + <replaceable>Update changelog for %(version)s + release</replaceable></para> + </listitem> + </varlistentry> + <varlistentry> + <term><option>--commit</option> + </term> + <listitem> + <para>Commit the generated changelog.</para> + </listitem> + </varlistentry> </variablelist> </refsect1> <refsect1> 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) |