ESMCI / git-fleximod

MIT License
2 stars 2 forks source link

Simple problem in "git-fleximod test" since name of the fx #48

Closed ekluzek closed 1 week ago

ekluzek commented 1 week ago

"git-fleximod test" is failing for me both in ctsm and CESM. This happens whether or not I first run "git-fleximod update" beforehand.

git clone git@github.com:ESCOMP/CESM.git cesm3_0_alpha01a
cd cesm3_0_alpha01a
./bin/git-fleximod test
            ccs_config at tag ccs_config_cesm0.0.109
                 share at tag share1.0.19
                  cime at tag cime6.0.246
                   mct at tag MCT_2.11.0
            mpi-serial at tag MPIserial_2.5.0
                   cam at tag cam6_3_162
                   ww3 at tag ww3i_0.0.2
                   rtm at tag rtm1_0_78
                pysect at tag 3.2.2
                mosart at tag mosart1_0_49
             mizuroute at tag cesm-coupling.n02_v2.1.2
                   fms at tag fi_240516
            parallelio at tag pio2_6_2
                 cdeps at tag cdeps1.0.37
                 cmeps at tag cmeps0.14.63
                  cice at tag cesm_cice6_5_0_9
                  cism at tag cismwrap_2_2_001
                   clm at tag ctsm5.2.007
                   mom at tag mi_240522

Traceback (most recent call last):
  File "./bin/git-fleximod", line 8, in <module>
    sys.exit(main())
  File "/glade/derecho/scratch/erik/cesm3_0_alpha01a/.lib/git-fleximod/git_fleximod/git_fleximod.py", line 617, in main
    retval = submodules_test(gitmodules, root_dir)
  File "/glade/derecho/scratch/erik/cesm3_0_alpha01a/.lib/git-fleximod/git_fleximod/git_fleximod.py", line 553, in submodules_test
    fxurl = fxurl[:-4] if fxurl.endswith(".git") else fxurl
AttributeError: 'NoneType' object has no attribute 'endswith'

The problem is that the code is looking for fxDONOTMODIFYurl rather than fxDONOTUSEurl. So there is a simple fix.

However, it also might be good to add more error checking around getting variables and making sure they are valid before doing something with them.

ekluzek commented 1 week ago

Here's the simple fix that gets it to work:

diff --git a/.lib/git-fleximod/git_fleximod/git_fleximod.py b/.lib/git-fleximod/git_fleximod/git_fleximod.py
index e1b8f48..ed24c4e 100755
--- a/.lib/git-fleximod/git_fleximod/git_fleximod.py
+++ b/.lib/git-fleximod/git_fleximod/git_fleximod.py
@@ -547,7 +547,7 @@ def submodules_test(gitmodules, root_dir):
     # and that sparse checkout files exist
     for name in gitmodules.sections():
         url = gitmodules.get(name, "url")
-        fxurl = gitmodules.get(name, "fxDONOTMODIFYurl")
+        fxurl = gitmodules.get(name, "fxDONOTUSEurl")
         fxsparse = gitmodules.get(name, "fxsparse")
         path = gitmodules.get(name, "path")
         fxurl = fxurl[:-4] if fxurl.endswith(".git") else fxurl

Beyond above it might be good to add some error checking after the gitmodules.get to make sure a value was returned, and if not to return with an error that the field wasn't found.

jedwards4b commented 1 week ago

Any contributions you would like to make to add more error checking would be gratefully accepted. Can you please issue your change as a PR?