diff --git a/bin/subrepo_checkout.py b/bin/subrepo_checkout.py index a689d9bc3fcc409d81aa5f27edb31fd5c112cc2c..a2cb19a542816ae7f84fab6ae78e1e8f7ffa3ae8 100755 --- a/bin/subrepo_checkout.py +++ b/bin/subrepo_checkout.py @@ -11,6 +11,8 @@ import argparse import os +from os.path import exists + class git_repo(): def __init__(self, directory, branch): self.directory = directory @@ -28,10 +30,19 @@ def read_branchfile(branchfile): sub_repos.append(git_repo(repo[0],repo[1])) return sub_repos + +def find_branchfile(directory, branchfile): + if exists(f"{directory}/{branchfile}"): + print(f"Found Branchfile in {directory}") + sub_repos = read_branchfile(f"{directory}/{branchfile}") + for repo in sub_repos: + print(f"Subrepo found: {repo.directory}") + repo_checkout(f"{directory}/{repo.directory}", repo.branch, branchfile) -def repo_checkout(directory, branch): +def repo_checkout(directory, branch, branchfile): print(f"Checking out {directory} to branch {branch}") os.system(f"cd {directory}; git checkout {branch}") + find_branchfile(directory, branchfile) if __name__ == "__main__": # Capture Arguments from Command Line @@ -41,4 +52,4 @@ if __name__ == "__main__": args = parser.parse_args() sub_repos = read_branchfile(args.branchfile) for repo in sub_repos: - repo_checkout(repo.directory, repo.branch) + repo_checkout(repo.directory, repo.branch, args.branchfile) diff --git a/projbranch b/projbranch new file mode 100644 index 0000000000000000000000000000000000000000..cf874476883109693578502787a6d8c417f6797e --- /dev/null +++ b/projbranch @@ -0,0 +1,13 @@ +#----------------------------------------------------------------------------- +# SoC Labs Sub repository branch setup +# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license. +# +# Contributors +# +# David Mapstone (d.a.mapstone@soton.ac.uk) +# +# Copyright 2023, SoC Labs (www.soclabs.org) +#----------------------------------------------------------------------------- +# Each Repo needs to have its branch set manually in here - they will defaultly be checked out to main + +tools/chipkit_flow: main \ No newline at end of file