Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix test output #57

Merged
merged 2 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions git_fleximod/git_fleximod.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,19 @@ def submodules_status(gitmodules, root_dir, toplevel=False, depth=0):
submod = init_submodule_from_gitmodules(gitmodules, name, root_dir, logger)

result,n,l,t = submod.status()
testfails += t
localmods += l
needsupdate += n
if toplevel or not submod.toplevel():
print(wrapper.fill(result))
subdir = os.path.join(root_dir, submod.path)
if os.path.exists(os.path.join(subdir, ".gitmodules")):
submod = GitModules(logger, confpath=subdir)
t,l,n = submodules_status(submod, subdir, depth=depth+1)
testfails += t
localmods += l
needsupdate += n
subdir = os.path.join(root_dir, submod.path)
if os.path.exists(os.path.join(subdir, ".gitmodules")):
gsubmod = GitModules(logger, confpath=subdir)
t,l,n = submodules_status(gsubmod, subdir, depth=depth+1)
if toplevel or not submod.toplevel():
testfails += t
localmods += l
needsupdate += n

return testfails, localmods, needsupdate

Expand Down
25 changes: 18 additions & 7 deletions git_fleximod/submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def status(self):
needsupdate = True
else:
result = f"e {self.name:>20} has no fxtag defined in .gitmodules{optional}"
testfails = True
testfails = False
else:
with utils.pushd(smpath):
git = GitInterface(smpath, self.logger)
Expand All @@ -106,10 +106,16 @@ def status(self):
line = git.git_operation("log", "--pretty=format:\"%h %d").partition('\n')[0]
parts = line.split()
ahash = parts[0][1:]
atag = None
if len(parts) > 3:
atag = parts[3][:-1]
else:
atag = None
idx = 0
while idx < len(parts)-1:
idx = idx+1
if parts[idx] == 'tag:':
atag = parts[idx+1][:-1]
if atag == self.fxtag:
break


#print(f"line is {line} ahash is {ahash} atag is {atag}")
# atag = git.git_operation("describe", "--tags", "--always").rstrip()
Expand All @@ -122,9 +128,11 @@ def status(self):
if self.fxtag and atag == self.fxtag:
result = f" {self.name:>20} at tag {self.fxtag}"
recurse = True
testfails = False
elif self.fxtag and ahash[: len(self.fxtag)] == self.fxtag:
result = f" {self.name:>20} at hash {ahash}"
recurse = True
testfails = False
elif atag == ahash:
result = f" {self.name:>20} at hash {ahash}"
recurse = True
Expand All @@ -133,14 +141,17 @@ def status(self):
testfails = True
needsupdate = True
else:
result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {atag}"
testfails = True
if atag:
result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {atag}"
else:
result = f"e {self.name:>20} has no fxtag defined in .gitmodules, module at {ahash}"
testfails = False

status = git.git_operation("status", "--ignore-submodules", "-uno")
if "nothing to commit" not in status:
localmods = True
result = "M" + textwrap.indent(status, " ")

# print(f"result {result} needsupdate {needsupdate} localmods {localmods} testfails {testfails}")
return result, needsupdate, localmods, testfails


Expand Down