githelp: don't crash when user does githelp -- git

Summary:
We didn't check for sanity when the user asked for hg githelp -- git -
oops. Fix the args test to catch you if you ask for help for git, as opposed to
(say) git commit.

Test Plan: Ran the new test cases.

Reviewers: #fbhgext, ikostia

Reviewed By: ikostia

Differential Revision: https://phab.mercurial-scm.org/D183
This commit is contained in:
Simon Farnsworth 2017-07-26 08:51:21 -07:00
parent d5c1c31862
commit bb9d88ea1a
2 changed files with 11 additions and 1 deletions

View File

@ -67,7 +67,7 @@ def githelp(ui, repo, *args, **kwargs):
Usage: hg githelp -- <git command>
'''
if len(args) == 0:
if len(args) == 0 or (len(args) == 1 and args[0] =='git'):
raise error.Abort(_('missing git command - '
'usage: hg githelp -- <git command>'))

View File

@ -21,6 +21,16 @@
githelp on a single command should succeed
$ hg githelp -- commit
hg commit
$ hg githelp -- git commit
hg commit
githelp should fail nicely if we don't give it arguments
$ hg githelp
abort: missing git command - usage: hg githelp -- <git command>
[255]
$ hg githelp -- git
abort: missing git command - usage: hg githelp -- <git command>
[255]
githelp on a command with options should succeed
$ hg githelp -- commit -pm "abc"