Skip to content

Commit

Permalink
Merge pull request #224 from rest-for-physics/jgalan_pull_submodules
Browse files Browse the repository at this point in the history
pull-submodules.py general improvement. Added option --onlylibs
  • Loading branch information
jgalan authored May 24, 2022
2 parents b585914 + 294ba27 commit 8b722e1
Showing 1 changed file with 36 additions and 9 deletions.
45 changes: 36 additions & 9 deletions pull-submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,36 @@
dontask = False
clean = False
fbName = ""
onlylibs = False

if( len(sys.argv ) <= 1 ):
print( " " )
print( "pull-submodules.py requires arguments." )
print( " " )
print( " - clean : It will restore all submodules to the official release versions" )
print( " - latest : It will pull the master branch of each submodule" )
def print_help():
print( " pull-submodules.py is a helper script to pull REST-for-Physics related submodules" )
print( " " )
print( "Usage: " )
print( "python3 pull-submodules.py --clean" )
print( "python3 pull-submodules.py --latest" )
print( " " )
print( " --clean : It will restore all submodules to the official release versions" )
print( " --latest : It will pull the master branch of each submodule" )
print ( " ")
print( "When using --clean make sure the framework local repository is at an official release" )
print ( " " )
print ( " Other complementary options: " )
print ( " --force : It will override changes using git reset" )
print ( " --dontask : It wont ask when overriding changes" )
print ( " --lfna : It will pull LFNA Git repositories. SSH grant required" )
print ( " --sjtu : It will pull SJTU Git repositories. SSH grant required" )
print ( " --exclude:lib1,lib2 will prevent lib1,lib2 from being pulled" )
print ( " --onlylibs: It will pull only the REST library submodules" )
print ( " " )

if( len(sys.argv ) <= 1 ):
print( " " )
print( "ERROR pull-submodules.py requires arguments." )
print_help()
sys.exit(1)

exclude_elems = ""
exclude_elems = ["userguide", "data", "external"]
for x in range(len(sys.argv) - 1):
if sys.argv[x + 1] == "--lfna":
lfna = True
Expand Down Expand Up @@ -72,11 +85,19 @@
dontask = True
if sys.argv[x + 1] == "--force":
force = True
if sys.argv[x + 1] == "--onlylibs":
onlylibs = True
if sys.argv[x + 1] == "--clean":
force = True
clean = True
if sys.argv[x + 1] == "--help" or sys.argv[x + 1] == "-h":
print_help()
sys.exit(1)
if sys.argv[x + 1].find("--exclude:") >= 0:
exclude_elems = sys.argv[x + 1][10:].split(",")
elems = sys.argv[x + 1][10:].split(",")
for y in elems:
exclude_elems.append(y)



def main():
Expand Down Expand Up @@ -113,6 +134,7 @@ def main():
for line in gitmodules_file:
line = line.replace(' ', '')
if "path=" in line:
exclude = False
submodule = line.replace("path=", '').strip()
fullpath = os.path.join(root, submodule).replace(' ', '')
if fullpath.find("project") >= 0:
Expand All @@ -124,10 +146,15 @@ def main():
if fullpath.find("scripts") >= 0:
fullpath = fullpath[fullpath.find("scripts"):]

for exclude_element in exclude_elems:
if fullpath.lower().find(exclude_element.lower()) > 0:
exclude = True
if onlylibs and fullpath.lower().find("libraries") == -1:
exclude = True

if "url=" in line:
url = line.replace("url=", '').strip()

exclude = False
for exclude_element in exclude_elems:
if url.lower().find(exclude_element.lower()) > 0:
exclude = True
Expand Down

0 comments on commit 8b722e1

Please sign in to comment.