Add --description option to branch
authorCatalin Marinas <catalin.marinas@gmail.com>
Tue, 10 Apr 2007 21:47:10 +0000 (22:47 +0100)
committerCatalin Marinas <catalin.marinas@gmail.com>
Tue, 10 Apr 2007 21:47:10 +0000 (22:47 +0100)
This options allows one to set the description text of a branch.

Signed-off-by: Catalin Marinas <catalin.marinas@gmail.com>
stgit/commands/branch.py

index 5f79f7e..b043c69 100644 (file)
@@ -51,6 +51,8 @@ options = [make_option('-c', '--create',
            make_option('--delete',
                        help = 'delete an existing development branch',
                        action = 'store_true'),
+           make_option('-d', '--description',
+                       help = 'set the branch description'),
            make_option('--force',
                        help = 'force a delete when the series is not empty',
                        action = 'store_true'),
@@ -275,6 +277,24 @@ def func(parser, options, args):
 
         return
 
+    elif options.description is not None:
+
+        if len(args) == 0:
+            branch_name = crt_series.get_branch()
+        elif len(args) == 1:
+            branch_name = args[0]
+        else:
+            parser.error('incorrect number of arguments')
+        branch = stack.Series(branch_name)
+
+        if not branch.is_initialised():
+            raise CmdException, 'Branch "%s" is not controlled by StGIT' \
+                  % branch_name
+
+        branch.set_description(options.description)
+
+        return
+
     elif len(args) == 1:
 
         if __is_current_branch(args[0]):