diff options
author | Tommi Virtanen <tv@eagain.net> | 2007-09-03 17:06:49 -0700 |
---|---|---|
committer | Tommi Virtanen <tv@eagain.net> | 2007-09-03 17:09:19 -0700 |
commit | 82f5857759e0262e43ec11f4319395b6a373872d (patch) | |
tree | 75702d7fa3041d092754728637c32bdc6db166cc /gitosis | |
parent | Refactor command line utilities to share setup. (diff) | |
download | gitosis-dakkar-82f5857759e0262e43ec11f4319395b6a373872d.tar.gz gitosis-dakkar-82f5857759e0262e43ec11f4319395b6a373872d.tar.bz2 gitosis-dakkar-82f5857759e0262e43ec11f4319395b6a373872d.zip |
Make gitosis-serve not fail with commands without arguments.
Diffstat (limited to 'gitosis')
-rw-r--r-- | gitosis/serve.py | 6 | ||||
-rw-r--r-- | gitosis/test/test_serve.py | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/gitosis/serve.py b/gitosis/serve.py index 4b7c6a7..551ac46 100644 --- a/gitosis/serve.py +++ b/gitosis/serve.py @@ -54,7 +54,11 @@ def serve( if '\n' in command: raise CommandMayNotContainNewlineError() - verb, args = command.split(None, 1) + try: + verb, args = command.split(None, 1) + except ValueError: + # all known commands take one argument; improve if/when needed + raise UnknownCommandError() if (verb not in COMMANDS_WRITE and verb not in COMMANDS_READONLY): diff --git a/gitosis/test/test_serve.py b/gitosis/test/test_serve.py index a79dbaf..416587a 100644 --- a/gitosis/test/test_serve.py +++ b/gitosis/test/test_serve.py @@ -21,6 +21,18 @@ def test_bad_newLine(): eq(str(e), 'Command may not contain newline') assert isinstance(e, serve.ServingError) +def test_bad_nospace(): + cfg = RawConfigParser() + e = assert_raises( + serve.UnknownCommandError, + serve.serve, + cfg=cfg, + user='jdoe', + command='git-upload-pack', + ) + eq(str(e), 'Unknown command denied') + assert isinstance(e, serve.ServingError) + def test_bad_command(): cfg = RawConfigParser() e = assert_raises( |