diff --git a/git_fleximod/git_fleximod.py b/git_fleximod/git_fleximod.py index b0a5a33070..ca5f90622d 100755 --- a/git_fleximod/git_fleximod.py +++ b/git_fleximod/git_fleximod.py @@ -298,7 +298,10 @@ def submodules_status(gitmodules, root_dir, toplevel=False): # submodule commands use path, not name url = url.replace("git@github.com:", "https://github.com/") tags = rootgit.git_operation("ls-remote", "--tags", url) - ahash = rootgit.git_operation("submodule","status",newpath).split()[0][1:] + result = rootgit.git_operation("submodule","status",newpath).split() + ahash = None + if result: + ahash = result[0][1:] hhash = None atag = None needsupdate += 1 @@ -307,7 +310,7 @@ def submodules_status(gitmodules, root_dir, toplevel=False): for htag in tags.split("\n"): if htag.endswith('^{}'): htag = htag[:-3] - if not atag and ahash in htag: + 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] diff --git a/tests/conftest.py b/tests/conftest.py index 942a0efb97..1cc008eb1d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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"] @@ -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"] diff --git a/tests/test_d_complex.py b/tests/test_d_complex.py index 62889f2cba..edde7d816d 100644 --- a/tests/test_d_complex.py +++ b/tests/test_d_complex.py @@ -8,7 +8,7 @@ def test_complex_checkout(git_fleximod, complex_repo, logger): 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 testtag02" in status.stdout) - assert("AlwaysOptional not checked out, aligned at tag MPIserial_2.3.0" 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") @@ -40,8 +40,7 @@ def test_complex_checkout(git_fleximod, complex_repo, logger): 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 testtag02" in status.stdout) - assert("AlwaysOptional not checked out, aligned at tag MPIserial_2.3.0" 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")