diff options
author | W. Trevor King <wking@drexel.edu> | 2011-05-25 08:37:03 -0400 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2011-05-25 08:37:03 -0400 |
commit | 2426c5f118b7e9c6f58e800da459554499b2950e (patch) | |
tree | c854be960f8adcd2e9fd3eb4eb006bb3523f3c3f | |
parent | 17fc2c4dbb59385ed1bf77eab10f1237b1de9871 (diff) | |
download | bugseverywhere-2426c5f118b7e9c6f58e800da459554499b2950e.tar.gz |
Rework summary handling in `be commit`.
Now you can run `be commit` with no options and have the summary split
off the body automatically. This should be more familiar to most VCS
users.
-rw-r--r-- | libbe/command/commit.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/libbe/command/commit.py b/libbe/command/commit.py index a450c4b..32ca3ef 100644 --- a/libbe/command/commit.py +++ b/libbe/command/commit.py @@ -60,16 +60,19 @@ class Commit (libbe.command.Command): ]) self.args.extend([ libbe.command.Argument( - name='comment', metavar='COMMENT', default=None), + name='summary', metavar='SUMMARY', default=None, + optional=True), ]) def _run(self, **params): - if params['comment'] == '-': # read summary from stdin + if params['summary'] == '-': # read summary from stdin assert params['body'] != 'EDITOR', \ 'Cannot spawn and editor when the summary is using stdin.' summary = sys.stdin.readline() else: - summary = params['comment'] + summary = params['summary'] + if summary == None and params['body'] == None: + params['body'] = 'EDITOR' storage = self._get_storage() if params['body'] == None: body = None @@ -80,6 +83,10 @@ class Commit (libbe.command.Command): self._check_restricted_access(storage, params['body']) body = libbe.util.encoding.get_file_contents( params['body'], decode=True) + if summary == None: # use the first body line as the summary + lines = body.splitlines() + summary = lines[0] + body = '\n'.join(lines[1:]).strip() + '\n' try: revision = storage.commit(summary, body=body, allow_empty=params['allow-empty']) @@ -90,7 +97,12 @@ class Commit (libbe.command.Command): def _long_help(self): return """ -Commit the current repository status. The summary specified on the -commandline is a string (only one line) that describes the commit -briefly or "-", in which case the string will be read from stdin. +Commit the current repository status. + +The summary specified on the commandline is a string (only one line) +that describes the commit briefly or "-", in which case the string +will be read from stdin. If no summary is given, the first line from +the body message is used instead. If no summary or body is given, we +spawn an editor without needing the special "EDITOR" value for the +"--body" option. """ |