Skip to content

Commit 549ea16

Browse files
committed
ignore .git dir when processing paths
1 parent db23034 commit 549ea16

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

gitless/cli/helpers.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,19 +86,23 @@ def page(fp, repo):
8686
class 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

Comments
 (0)