Skip to content

Commit

Permalink
Merge commit '87640adf43cdd3c30acd258185f128e638cb41ac' into rme/cam6…
Browse files Browse the repository at this point in the history
…_3_161
  • Loading branch information
jedwards4b committed Jun 6, 2024
2 parents 8ca8b13 + 87640ad commit 6536011
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .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.7.6"
__version__ = "0.7.7"

def find_root_dir(filename=".gitmodules"):
""" finds the highest directory in tree
Expand All @@ -21,7 +21,7 @@ def find_root_dir(filename=".gitmodules"):
attempt = dl / filename
if attempt.is_file():
return str(dl)
utils.fatal_error("No .gitmodules found in directory tree")
return None


def get_parser():
Expand Down
22 changes: 17 additions & 5 deletions .lib/git-fleximod/git_fleximod/git_fleximod.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,25 @@ def submodules_status(gitmodules, root_dir, toplevel=False):
# submodule commands use path, not name
url = url.replace("[email protected]:", "https://github.com/")
tags = rootgit.git_operation("ls-remote", "--tags", url)
result = rootgit.git_operation("submodule","status",newpath).split()
ahash = None
if result:
ahash = result[0][1:]
hhash = None
atag = None
needsupdate += 1
if not toplevel and level:
continue
for htag in tags.split("\n"):
if tag and tag in htag:
if htag.endswith('^{}'):
htag = htag[:-3]
if ahash and not atag and ahash in htag:
atag = (htag.split()[1])[10:]
if tag and not hhash and htag.endswith(tag):
hhash = htag.split()[0]
if hhash and atag:
break
if tag and tag == atag:
if tag and (ahash == hhash or atag == tag):
print(f"e {name:>20} not checked out, aligned at tag {tag}")
elif tag:
ahash = rootgit.git_operation(
Expand Down Expand Up @@ -565,10 +575,12 @@ def main():

logger.info("action is {} root_dir={} file_name={}".format(action, root_dir, file_name))

if not os.path.isfile(os.path.join(root_dir, file_name)):
file_path = utils.find_upwards(root_dir, file_name)
if not root_dir or not os.path.isfile(os.path.join(root_dir, file_name)):
if root_dir:
file_path = utils.find_upwards(root_dir, file_name)

if file_path is None:
if root_dir is None or file_path is None:
root_dir = "."
utils.fatal_error(
"No {} found in {} or any of it's parents".format(file_name, root_dir)
)
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.7.6"
version = "0.7.7"
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.7.6"
current = "0.7.7"

# Example of a semver regexp.
# Make sure this matches current_version before
Expand Down
4 changes: 2 additions & 2 deletions .lib/git-fleximod/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def logger():
"submodule_name": "test_optional",
"status1" : "test_optional MPIserial_2.5.0-3-gd82ce7c is out of sync with .gitmodules MPIserial_2.4.0",
"status2" : "test_optional at tag MPIserial_2.4.0",
"status3" : "test_optional not checked out, aligned at tag MPIserial_2.4.0",
"status3" : "test_optional not checked out, out of sync at tag None, expected tag is MPIserial_2.4.0",
"status4" : "test_optional at tag MPIserial_2.4.0",
"gitmodules_content": """
[submodule "test_optional"]
Expand All @@ -46,7 +46,7 @@ def logger():
"submodule_name": "test_alwaysoptional",
"status1" : "test_alwaysoptional MPIserial_2.3.0 is out of sync with .gitmodules e5cf35c",
"status2" : "test_alwaysoptional at hash e5cf35c",
"status3" : "test_alwaysoptional not checked out, out of sync at tag MPIserial_2.3.0",
"status3" : "out of sync at tag None, expected tag is e5cf35c",
"status4" : "test_alwaysoptional at hash e5cf35c",
"gitmodules_content": """
[submodule "test_alwaysoptional"]
Expand Down
13 changes: 6 additions & 7 deletions .lib/git-fleximod/tests/test_d_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def test_complex_checkout(git_fleximod, complex_repo, logger):
assert("ToplevelOptional not checked out, aligned at tag v5.3.2" in status.stdout)
assert("ToplevelRequired not checked out, aligned at tag MPIserial_2.5.0" in status.stdout)
assert("AlwaysRequired not checked out, aligned at tag MPIserial_2.4.0" in status.stdout)
assert("Complex not checked out, aligned at tag testtag01" in status.stdout)
assert("AlwaysOptional not checked out, aligned at tag MPIserial_2.3.0" in status.stdout)
assert("Complex not checked out, aligned at tag testtag02" in status.stdout)
assert("AlwaysOptional not checked out, out of sync at tag None, expected tag is MPIserial_2.3.0" in status.stdout)

# This should checkout and update test_submodule and complex_sub
result = git_fleximod(complex_repo, "update")
Expand All @@ -18,7 +18,7 @@ def test_complex_checkout(git_fleximod, complex_repo, logger):
assert("ToplevelOptional not checked out, aligned at tag v5.3.2" in status.stdout)
assert("ToplevelRequired at tag MPIserial_2.5.0" in status.stdout)
assert("AlwaysRequired at tag MPIserial_2.4.0" in status.stdout)
assert("Complex at tag testtag01" in status.stdout)
assert("Complex at tag testtag02" in status.stdout)

# now check the complex_sub
root = (complex_repo / "modules" / "complex")
Expand All @@ -39,9 +39,8 @@ def test_complex_checkout(git_fleximod, complex_repo, logger):
assert("ToplevelOptional at tag v5.3.2" in status.stdout)
assert("ToplevelRequired at tag MPIserial_2.5.0" in status.stdout)
assert("AlwaysRequired at tag MPIserial_2.4.0" in status.stdout)
assert("Complex at tag testtag01" in status.stdout)
assert("AlwaysOptional not checked out, aligned at tag MPIserial_2.3.0" in status.stdout)

assert("Complex at tag testtag02" in status.stdout)
assert("AlwaysOptional not checked out, out of sync at tag None, expected tag is MPIserial_2.3.0" in status.stdout)

# Finally update optional
result = git_fleximod(complex_repo, "update --optional")
Expand All @@ -51,7 +50,7 @@ def test_complex_checkout(git_fleximod, complex_repo, logger):
assert("ToplevelOptional at tag v5.3.2" in status.stdout)
assert("ToplevelRequired at tag MPIserial_2.5.0" in status.stdout)
assert("AlwaysRequired at tag MPIserial_2.4.0" in status.stdout)
assert("Complex at tag testtag01" in status.stdout)
assert("Complex at tag testtag02" in status.stdout)
assert("AlwaysOptional at tag MPIserial_2.3.0" in status.stdout)

# now check the complex_sub
Expand Down

0 comments on commit 6536011

Please sign in to comment.