Skip to content

Commit

Permalink
Merge commit 'c37ca3fe32b576f9123614874328ce809a1fa1cc' into gitflexi…
Browse files Browse the repository at this point in the history
…modupdatev0.8.2
  • Loading branch information
ekluzek committed Aug 9, 2024
2 parents 49f2c6e + c37ca3f commit 8bb0934
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .lib/git-fleximod/git_fleximod/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import argparse
from git_fleximod import utils

__version__ = "0.8.2"
__version__ = "0.8.4"

def find_root_dir(filename=".gitmodules"):
""" finds the highest directory in tree
Expand Down
15 changes: 8 additions & 7 deletions .lib/git-fleximod/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
33 changes: 23 additions & 10 deletions .lib/git-fleximod/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 @@ -103,15 +103,23 @@ def status(self):
needsupdate = True
return result, needsupdate, localmods, testfails
rurl = git.git_operation("ls-remote","--get-url").rstrip()
line = git.git_operation("log", "--pretty=format:\"%h %d").partition('\n')[0]
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]
while atag.endswith(')') or atag.endswith(',') or atag.endswith("\""):
atag = atag[:-1]
if atag == self.fxtag:
break


#print(f"line is {line} ahash is {ahash} atag is {atag}")
#print(f"line is {line} ahash is {ahash} atag is {atag} {parts}")
# atag = git.git_operation("describe", "--tags", "--always").rstrip()
# ahash = git.git_operation("rev-list", "HEAD").partition("\n")[0]

Expand All @@ -122,9 +130,11 @@ def status(self):
if self.fxtag and atag == self.fxtag:
result = f" {self.name:>20} at tag {self.fxtag}"
recurse = True
elif self.fxtag and ahash[: len(self.fxtag)] == self.fxtag:
testfails = False
elif self.fxtag and (ahash[: len(self.fxtag)] == self.fxtag or (self.fxtag.find(ahash)==0)):
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 +143,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
2 changes: 1 addition & 1 deletion .lib/git-fleximod/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "git-fleximod"
version = "0.8.2"
version = "0.8.4"
description = "Extended support for git-submodule and git-sparse-checkout"
authors = ["Jim Edwards <[email protected]>"]
maintainers = ["Jim Edwards <[email protected]>"]
Expand Down
2 changes: 1 addition & 1 deletion .lib/git-fleximod/tbump.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
github_url = "https://github.com/jedwards4b/git-fleximod/"

[version]
current = "0.8.2"
current = "0.8.4"

# Example of a semver regexp.
# Make sure this matches current_version before
Expand Down

0 comments on commit 8bb0934

Please sign in to comment.