Skip to content

Commit ba9ec41

Browse files
endothermicdevcdecker
authored andcommitted
reckless: set relative path of local git repo directories
1 parent 47c8199 commit ba9ec41

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tools/reckless

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ class InstInfo:
187187
found_entry = None
188188
for file in sub.contents:
189189
if isinstance(file, SourceDir):
190+
assert file.relative
190191
success = search_dir(self, file, True, recursion - 1)
191192
if success:
192193
return success
@@ -197,6 +198,10 @@ class InstInfo:
197198
if result != target:
198199
if result.relative:
199200
self.subdir = result.relative
201+
else:
202+
# populate() should always assign a relative path
203+
# if not in the top-level source directory
204+
assert self.subdir == result.name
200205
return True
201206
return False
202207

@@ -299,7 +304,7 @@ class SourceDir():
299304
return None
300305

301306
def __repr__(self):
302-
return f"<SourceDir: {self.name} ({self.location})>"
307+
return f"<SourceDir: {self.name}, {self.location}, {self.relative}>"
303308

304309
def __eq__(self, compared):
305310
if isinstance(compared, str):
@@ -363,7 +368,17 @@ def populate_local_repo(path: str) -> list:
363368
if child:
364369
parentdir = child
365370
else:
366-
child = SourceDir(p, srctype=Source.LOCAL_REPO)
371+
if p == revpath[-1]:
372+
relative_path = None
373+
elif parentdir.relative:
374+
relative_path = str(Path(parentdir.relative) /
375+
parentdir.name)
376+
else:
377+
relative_path = parentdir.name
378+
child = SourceDir(p, srctype=Source.LOCAL_REPO,
379+
relative=relative_path)
380+
# ls-tree lists every file in the repo with full path.
381+
# No need to populate each directory individually.
367382
child.prepopulated = True
368383
parentdir.contents.append(child)
369384
parentdir = child

0 commit comments

Comments
 (0)