Raise UserError if summary is not given to `be commit`.
authorW. Trevor King <wking@drexel.edu>
Wed, 25 May 2011 14:39:51 +0000 (10:39 -0400)
committerW. Trevor King <wking@drexel.edu>
Wed, 25 May 2011 14:39:51 +0000 (10:39 -0400)
If the user doesn't provide the summary on the command line, through
stdin, or through editor_string, raise an error.  This will generally
happen with

  $ be commit
  (user doesn't enter any text in the editory)

libbe/command/commit.py

index 32ca3efaafbe40e933a38ae3761ee315a6cf0658..841610724bc94072d4b06e82bdb9b3833df98b35 100644 (file)
@@ -84,6 +84,9 @@ class Commit (libbe.command.Command):
             body = libbe.util.encoding.get_file_contents(
                 params['body'], decode=True)
         if summary == None:  # use the first body line as the summary
+            if body == None:
+                raise libbe.command.UserError(
+                    'cannot commit without a summary')
             lines = body.splitlines()
             summary = lines[0]
             body = '\n'.join(lines[1:]).strip() + '\n'