File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -7,21 +7,16 @@ import argparse
77sys .path .append (os .path .join (os .path .dirname (__file__ ), '..' ))
88
99from gitbrowse .browser import GitBrowser
10- from gitbrowse import git
1110
1211
1312parser = argparse .ArgumentParser (add_help = False )
1413parser .add_argument ('rev' , nargs = '?' , default = 'HEAD' )
1514parser .add_argument ('file' )
1615args = parser .parse_args ()
1716
18- if not git .verify_revision (args .rev ):
19- sys .exit (1 )
17+ try :
18+ browser = GitBrowser (args .file , args .rev )
19+ except ValueError as err :
20+ sys .exit (str (err ))
2021
21- if not git .verify_file (args .file ):
22- sys .exit ("'%s' either does not exist, or is not tracked by git" % (
23- args .file
24- ))
25-
26- browser = GitBrowser (args .file , args .rev )
2722browser .run ()
Original file line number Diff line number Diff line change @@ -35,8 +35,13 @@ class GitFileHistory(object):
3535 """
3636
3737 def __init__ (self , path , start_commit ):
38- #TODO Validate path
39- #TODO Validate commit
38+ if not verify_revision (start_commit ):
39+ raise ValueError ('%s is not a valid commit, branch, tag, etc.' % (
40+ start_commit ,
41+ ))
42+
43+ if not verify_file (path ):
44+ raise ValueError ('"%s" is not tracked by git' % (path , ))
4045
4146 self .path = path
4247
You can’t perform that action at this time.
0 commit comments