Skip to content
Snippets Groups Projects
Commit 3b989540 authored by dam1n19's avatar dam1n19
Browse files

Added subrepo checkout script

parent ddb82138
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
#------------------------------------------------------------------------------------
# SProject Subrepository Checkout Script
# A joint work commissioned on behalf of SoC Labs, under Arm Academic Access license.
#
# Contributors
#
# David Mapstone (d.a.mapstone@soton.ac.uk)
# Copyright (c) 2023, SoC Labs (www.soclabs.org)
#------------------------------------------------------------------------------------
import argparse
import os
class git_repo():
def __init__(self, directory, branch):
self.directory = directory
self.branch = branch
def read_branchfile(branchfile):
f = open(branchfile, "r")
filelines = f.readlines()
f.close()
sub_repos = []
for line in filelines:
if not line.startswith("#"):
repo = line.replace(" ","").split(":")
if len(repo) == 2:
sub_repos.append(git_repo(repo[0],repo[1]))
return sub_repos
def repo_checkout(directory, branch):
os.system(f"cd {directory}; git checkout {branch}")
if __name__ == "__main__":
# Capture Arguments from Command Line
parser = argparse.ArgumentParser(description='Checks out branches for subrepositories in a project')
parser.add_argument("-b", "--branchfile", type=str, help="File to Read in Branches from")
parser.add_argument("-t", "--topproject", type=str, help="Top-level directory of Project")
args = parser.parse_args()
sub_repos = read_branchfile(args.branchfile)
for repo in sub_repos:
repo_checkout(repo.directory, repo.branch)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment