From 6f823204992f999796529ef59605bf08ab75ee86 Mon Sep 17 00:00:00 2001
From: dam1n19 <dam1n19@soton.ac.uk>
Date: Thu, 27 Apr 2023 16:55:04 +0100
Subject: [PATCH] SOC1-124: Added method to determine branch for each subrepo

---
 proj-branch | 19 +++++++++++++++++++
 set_env.sh  |  2 ++
 2 files changed, 21 insertions(+)
 create mode 100644 proj-branch

diff --git a/proj-branch b/proj-branch
new file mode 100644
index 0000000..901f523
--- /dev/null
+++ b/proj-branch
@@ -0,0 +1,19 @@
+#-----------------------------------------------------------------------------
+# 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
+# Project Repository Subrepository Branch Index
+nanosoc: feat_accel_decouple
+CHIPKIT: main
+accelerator-wrapper: main
+fpga-lib: main
+generic-lib: main
+secworks-sha256: main
+socsim: main
\ No newline at end of file
diff --git a/set_env.sh b/set_env.sh
index 65400a5..d54fb37 100755
--- a/set_env.sh
+++ b/set_env.sh
@@ -72,6 +72,8 @@ if [ ! -f $PROJECT_DIR/.socinit ]; then
     done
     git submodule update --remote --recursive
     git submodule foreach --recursive git checkout main
+    # Read proj-branch file to find out which branch each subrepo needs to be on
+    git config --file .gitmodules --get-regexp path | awk '{ print $2 }' | while read line; do cd $PROJECT_DIR/$line && git checkout `grep $line $PROJECT_DIR/project-branch | awk '{ print $2 }'`; done
     git restore $DESIGN_ROOT/.gitmodules
     touch $PROJECT_DIR/.socinit
 fi
\ No newline at end of file
-- 
GitLab