@@ -86,19 +86,23 @@ def page(fp, repo):
8686class PathProcessor (argparse .Action ):
8787
8888 def __init__ (self , option_strings , dest , repo = None , ** kwargs ):
89- self .root = repo . root if repo else ''
89+ self .repo = repo
9090 super (PathProcessor , self ).__init__ (option_strings , dest , ** kwargs )
9191
9292 def __call__ (self , parser , namespace , paths , option_string = None ):
93+ root = self .repo .root if self .repo else ''
94+ repo_dir = self .repo .path [:- 1 ] if self .repo else '' # strip trailing /
9395 def process_paths ():
9496 for path in paths :
9597 path = os .path .normpath (path )
9698 if os .path .isdir (path ):
9799 for curr_dir , _ , fps in os .walk (path ):
98- for fp in fps :
99- yield os .path .relpath (os .path .join (curr_dir , fp ), self .root )
100+ if not os .path .abspath (curr_dir ).startswith (repo_dir ):
101+ for fp in fps :
102+ yield os .path .relpath (os .path .join (curr_dir , fp ), root )
100103 else :
101- yield os .path .relpath (path , self .root )
104+ if not os .path .abspath (path ).startswith (repo_dir ):
105+ yield os .path .relpath (path , root )
102106
103107 setattr (namespace , self .dest , process_paths ())
104108
0 commit comments