Add option to open editor
authorGuido Günther <agx@sigxcpu.org>
Mon, 20 Dec 2010 14:51:22 +0000 (15:51 +0100)
committerGuido Günther <agx@sigxcpu.org>
Mon, 20 Dec 2010 14:55:18 +0000 (15:55 +0100)
Closes: #565553

docs/manpages/git-dch.sgml
gbp/config.py
git-dch

index 5b64e19..b175d9a 100644 (file)
@@ -36,6 +36,7 @@
       <arg><option>--git-log=</option><replaceable>git-log-options</replaceable></arg>
       <arg><option>--[no-]git-author</option></arg>
       <arg><option>--[no-]multimaint-merge</option></arg>
+      <arg><option>--spawn-editor=[always|snapshot|release]</option></arg>
       <arg choice="plain"><replaceable>[path1 path2]</replaceable></arg>
     </cmdsynopsis>
   </refsynopsisdiv>
           <para>Merge commits by maintainer.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term><option>--spawn-editor=<replaceable>[always|snapshot|release]</replaceable></option>
+        </term>
+        <listitem>
+         <para>Whether to spawn an editor: always, when doing snapshots or
+         when doing a release.</para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
   <refsect1>
index b3f4c53..61862f3 100644 (file)
@@ -80,7 +80,8 @@ class GbpOptionParser(OptionParser):
                  'arch'            : '',
                  'interactive'     : 'True',
                  'color'           : 'auto',
-                 'customizations'  : ''
+                 'customizations'  : '',
+                 'spawn-editor'    : 'release',
              }
     help = {
              'debian-branch':
@@ -131,6 +132,8 @@ class GbpOptionParser(OptionParser):
                   "Run command interactive, default is '%(interactive)s'",
              'color':
                   "color output, default is '%(color)s'",
+             'spawn-editor':
+                  "Wether to spawn an editor after adding the changelog entry, default is '%(spawn-editor)s'",
            }
     config_files = [ '/etc/git-buildpackage/gbp.conf',
                      os.path.expanduser('~/.gbp.conf'),
diff --git a/git-dch b/git-dch
index 75e7bea..cb15742 100755 (executable)
--- a/git-dch
+++ b/git-dch
@@ -292,6 +292,21 @@ def process_options(options, parser):
     return dch_options
 
 
+def process_editor_option(options, parser):
+    # Determine Editor and check if we need it
+    states = ['always']
+
+    if options.snapshot:
+        states.append("snapshot")
+    elif options.release:
+        states.append("release")
+
+    if options.spawn_editor in states:
+        return "sensible-editor"
+    else:
+        return None
+
+
 def main(argv):
     ret = 0
     changelog = 'debian/changelog'
@@ -355,6 +370,7 @@ def main(argv):
                       help="Ignore commit lines matching regex, default is '%(ignore-regex)s'")
     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")
 
     help_msg = 'Load Python code from CUSTOMIZATION_FILE.  At the moment,' \
         + ' the only useful thing the code can do is define a custom' \
@@ -366,6 +382,7 @@ def main(argv):
     (options, args) = parser.parse_args(argv[1:])
     gbp.log.setup(options.color, options.verbose)
     dch_options = process_options(options, parser)
+    editor_cmd = process_editor_option(options, parser)
 
     try:
         try:
@@ -473,6 +490,9 @@ def main(argv):
             (snap, version) = do_snapshot(changelog, repo, options.snapshot_number)
             gbp.log.info("Changelog has been prepared for snapshot #%d at %s" % (snap, version))
 
+        if editor_cmd:
+            gbpc.Command(editor_cmd, ["debian/changelog"])()
+
     except (GbpError, GitRepositoryError, NoChangelogError), err:
         if len(err.__str__()):
             gbp.log.err(err)